Non linear optimisation using solver based approach
显示 更早的评论
I have been assigned to minimize x(1)^2+x(2)^2+x(3)^2 subject to 1-x(2)^-1*x(3)>=0,x(1)-x(3)>=0,x(1)-x(2)^2+x(2)*x(3)-4=0,0<=x(1)<=5,0<=x(2)<=3,0<=x(3)<=3.
I have written the following script for the above optimization problem:
% Solver based approach for non linear problem
%define the objective function
f=@(x) (x(1)^2+x(2)^2+x(3)^2);
%initial feasible solution
x0=[0 0 0];
A=[0 -1 1;-1 0 1];b=[0;0];%linear inequality constraints
Aeq=[];beq=[];
lb=[0;0;0];ub=[5;3;3];%define the bounds
c=[];%there is no non linear inequality
ceq=@(x) (x(1)-x(2)^2+x(2)*x(3)-4);%non linear equality constraint
nlcon=@(x) deal(c,ceq(x));
[x,fval]=fmincon(f,x0,A,b,Aeq,beq,lb,ub,nlcon)
I am getting the values 4,0.0003,0.0002 and these values meet all the conditions except one which is x(1)-x(2)^2+x(2)*x(3)-4=0. With the above values, this expression becomes -0.00000003 which is not 0 obviously
Kindly check and give feedback and suggest corrections
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!