필터 지우기
필터 지우기

Deriving Max with fmincon when contraints differ

조회 수: 2 (최근 30일)
Joon Jeon
Joon Jeon 2011년 2월 28일
I am about to derive maximum values under linear contraint. Exactly describing
Target function is
function f = utility(x) f = (0.7*x(1)^2 + 0.3*x(2)^2)^0.5
And then
Aeq = [1 1]
beq = 100
So, using fmincon
[x, fval] = fmincon(@utility, x0, [], [], Aeq, beq);
I actually derived the result.
HOWEVER, what I REALLY want to do is to change Aeq = [i 1] (i=1~10) and finally get a 10*3 matrix with i and x. Thru this, I could get a plot of x(:,2) against x(:,3).
So, I used FOR such as below. (I also changed initial guessing values X()
=======================
Aeq = zeros(10,2);
Aeq(:,1) = 1:1:10;Aeq(:,2)=1;
X = zeros(10,2);
X(:,1) = 100:-8:28;X(:,2)=100:-8:28;
for i=1:10 beq = 100;
[x] = fmincon(@utility, X(i,:), [], [], Aeq(i,:), beq);
S = [Aeq(i) x];
end
==========================
Result doesn't give me what i WANT. What is wrong with these lines?
Please, help me.
Thanks in advance.

채택된 답변

Andrew Newell
Andrew Newell 2011년 3월 4일
If I understand your request, you want the matrix S to have two columns containing the values of Aeq and two columns containing the values of x(2) and x(3) for each case. This should do it:
f = @(x) (0.7*x(1)^2 + 0.3*x(2)^2)^0.5;
Aeq = ones(10,2); Aeq(:,1) = 1:10;
X = [100:-8:28; 100:-8:28]';
beq = 100;
options = optimset('fmincon');
options = optimset(options,'Algorithm','sqp');
S = [Aeq zeros(10,2)];
for i=1:10
S(i,3:4) = fmincon(f, X(i,:), [], [], Aeq(i,:), beq, [], [], [], options);
end
The options settings eliminated some warnings.
  댓글 수: 2
Joon Jeon
Joon Jeon 2011년 3월 4일
It results some error such as followings.
??? Error using ==> optimset at 242
Invalid value for OPTIONS parameter Algorithm:
must be 'active-set', 'trust-region-reflective', 'interior-point',
'levenberg-marquardt', 'trust-region-dogleg', or 'lm-line-search'.
Error in ==> minmin at 7
options = optimset(options,'Algorithm','sqp');
I thought that 'Algorithm' should be substituted to one of the options in the warning message such as 'active-set'. So I tried but it still gives a error message
Andrew Newell
Andrew Newell 2011년 3월 4일
What version of MATLAB do you have? Try getting rid of the options.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by