필터 지우기
필터 지우기

Help using fmincon function

조회 수: 3 (최근 30일)
Joey
Joey 2015년 1월 14일
댓글: Matt J 2015년 1월 14일
I attached a picture of the problem I'm working on.
objecfun is:
function f = objecfun(x)
f = (x(1)-x(2))^2 + (x(2)+x(3)-2)^2 + (x(4)-1)^2 + (x(5)-1)^2;
end
optscript is:
x0 = [2;2;2;2;2];
A = [ ];
b = [ ];
Aeq = [1 3 0 0 0; 0 0 1 1 -2; 0 1 0 0 -1];
beq = [0;0;0];
lb = [-10;-10;-10;-10;-10];
ub = [10;10;10;10;10];
[x,fval] = fmincon('objecfun',x0,A,b,Aeq,beq,lb,ub);
When I run optscript, I keep getting this error:
>> optscript
Warning: The default trust-region-reflective algorithm does not solve problems
with the constraints you have specified. FMINCON will use the active-set
algorithm instead. For information on applicable algorithms, see Choosing the
Algorithm in the documentation.
> In fmincon at 501
In optscript at 8
Warning: Your current settings will run a different algorithm (interior-point)
in a future release.
> In fmincon at 506
In optscript at 8
Local minimum possible. Constraints satisfied.
fmincon stopped because the predicted change in the objective function
is less than the default value of the function tolerance and constraints
are satisfied to within the default value of the constraint tolerance.
<stopping criteria details>
No active inequalities.

답변 (1개)

Matt J
Matt J 2015년 1월 14일
It's not an error. It's a warning. There's no evidence of anything wrong. However, your problem is more appropriate to LSQLIN than to FMINCON, so you might consider using that instead.
  댓글 수: 2
Joey
Joey 2015년 1월 14일
problem says we have to use fmincon. how come i don't get any results?
Matt J
Matt J 2015년 1월 14일
Try this instead
[x,fval] = fmincon(@objecfun,x0,A,b,Aeq,beq,lb,ub);
When I run it this way, I get
x =
-0.7674
0.2558
0.6279
-0.1163
0.2558
fval =
4.0930
which is also what LSQLIN gives me.

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

카테고리

Help CenterFile Exchange에서 Linear Least Squares에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by