Help using fmincon function
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
0 commentaires
Réponses (1)
Matt J
le 14 Jan 2015
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 commentaires
Matt J
le 14 Jan 2015
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.
Voir également
Catégories
En savoir plus sur Solver Outputs and Iterative Display dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!