Hi
I am trying to maximize an function(x,y) over (x,y)
x^2+y^2+b, subject to 0<x<1 and 0<y<1. and b is between 0 and 20.
Now, I want to run fmincon on this function 20 times (for b=0, b=1, b=2..... and so on). I also want to save the optimal (x,y) with the coresponding b so that I can plot this function later.
I have looked up ( http://www.mathworks.com/help/optim/ug/nonlinear-equality-and-inequality-constraints.html ), How should I modify the code so that it will do the above?

댓글 수: 5

Matt J
Matt J 2014년 8월 24일
편집: Matt J 2014년 8월 24일
Your problem is a quadratic program. It is therefore better to use quadprog as opposed to fmincon.
Aside from that, there is no point in repeating the optimization for multiple b, as you describe. The value of b doesn't affect the maximizing coordinates (x,y), which will always be x=y=1.
Aniruddha Phatak
Aniruddha Phatak 2014년 8월 24일
You are trying to maximize the function (which anyway has a straightforward answer x=y=1), but the function fmincon finds the (x,y) values that minimizes the function . Also, the value of b makes no difference to the maximized or minimized value. Perhaps you meant x^2-y^2 with perhaps b as a multiplying factor rather than just an additive factor? (Or perhaps I didn't read your question right in the first place?)
JJ
JJ 2014년 8월 24일
yes, but I will apply this process to a more complicate function, subject to more complicate constraint, what I am looking for is the process that will solve this problem.
Matt J
Matt J 2014년 8월 24일
편집: Matt J 2014년 8월 24일
But because your example isn't similar enough to your true problem, you are unlikely to get a response that is meaningful to your true problem.

댓글을 달려면 로그인하십시오.

 채택된 답변

Matt J
Matt J 2014년 8월 24일
편집: Matt J 2014년 8월 24일

0 개 추천

Your example is a straightforward application of QUADPROG
[xy, fval]=quadprog(-eye(2),[0;0],[],[],[],[],[0;0],[1;1])
b=0:20;
fval=fval+b;

댓글 수: 2

Matt J
Matt J 2014년 8월 25일
편집: Matt J 2014년 8월 25일
I have the vague impression that this is what you're looking for
It will tell you how to pass 'b' to the objective function as fixed data.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Surrogate Optimization에 대해 자세히 알아보기

질문:

JJ
2014년 8월 24일

편집:

2014년 8월 25일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by