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?
Best Answer