フィルターのクリア

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 Center および File ExchangeLinear Least Squares についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by