Hi my objective function is nonlinear, and my only constraints are:
x(1)<0.00125x(1)>0x(2)>0
And I wanna solve it with interior point optimzation method I get error for this code :
x0=[1.1;3]; % Starting guess
B = [1.25;20.0]; A = [1,0;0,1]; lb=[0.5;0.4]; up=[1.25;20.0];Aeq=[];beq=[];options=optimset('outputfcn',@outfun,'Largescale','off','Algorithm','interior-point','Display','iter','Tolx',1e-15,'Tolfun',1e-16,'MaxFunEvals',60000,'MaxIter',1000); [x,fval,exitflag,output]=fmincon(@optim,x0,A,B,Aeq,beq,lb,ub,options);
it said I need a nonlcons in my Fmincon function So I add this function
function [c,ceq]=const(x)c(1)=x(1)-0.00125;c(2)=-x(1);c(3)=-x(2);ceq=[];endand add these to my code:nonlcon=@const[x,fval,exitflag,output]=fmincon(@optim,x0,A,B,Aeq,beq,lb,ub,'nonlcon',options);
But I still get error for this nonlcon 🙁
Best Answer