Why getting different solutions by suppying same constraint to fmincon in two similar way (linear and nonlinear))?
Afficher commentaires plus anciens
I am using `fmincon` to solve a problem. The problem has some linear inequality constraints that are written in Matrix A and B. I can write these constraints in 2 way and I should get analogous results. But, weirdly I am getting different solutions. why is that?
1) In the first way, I can feed the constraint to 'fmincon' function as follows:
`[Xsqp, FUN ,FLAG ,Options] = fmincon(@(X)SQP(X,Dat),X,A,B,[],[],lb,ub,@(X)SQPnolcon(X,Dat,A,B),options);
% I comment the line 'C=A*X'-B;'
in the function 'SQPnolcon' and put C=[] instead, because A and B are defined already in fmincon function`
2) As the second way I can write it like this:
`[Xsqp, FUN ,FLAG ,Options] = fmincon(@(X)SQP(X,Dat),X,[],[],[],[],lb,ub,@(X)SQPnolcon(X,Dat,A,B),options);`
and also the constraint function as follows:
function [C,Ceq] = SQPnolcon(X,Dat,A,B)
C=A*X'-B;
Ceq = [];
end
Note: In the first, you're supplying A and B as both linear inequality constraints and as nonlinear inequality constraints, but in the second you're only supplying them as nonlinear inequality constraints. What option should I set for fmincon here to get same results?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Nonlinear Optimization dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!