我后来按照X=FMINCON(FUN,X0,A,B,Aeq,Beq,LB,UB,NONLCON)试过了,可是警告说我设置的非线性约束只有一个,我不知道怎么通过options设置。
function y=myfun(x)
y=0.5*70^2*x(2)+0.5*(70-x(3))^2*x(1);
function [c,ceq]=mycon(x)
c(1)=-1584/1225*x(2)-7352575626214095/18446744073709551616*x(1)*(70-x(3))^2-11/49000*x(1)*(70-x(3))*x(3)+11/7000*(70-x(3))*x(1)+11/10;
c(2)=(-56448*x(2)-87/5*x(1)*(70-x(3))^2-49/5*x(1)*(70-x(3))*x(3)+343/5*(70-x(3))*x(1))/((70-x(3))*x(1)+70*x(2))-(2058*x(1)*(70-x(3))*x(3)*x(2)+147/5*x(1)*(70-x(3))^2*((35/3-1/6*x(3))*x(1)+35*x(2))+367500.0*x(2)*((-35+1/2*x(3))*x(1)+35/3*x(2))+75.0*x(1)*(70-x(3))^2*((-35/3+1/6*x(3))*x(1)+35*x(2))-6*(343/30*(70-x(3))*x(1)+2401/3*x(2))*((70-x(3))*x(1)+70*x(2))-3361400.0000000000000000000000000)/((70-x(3))*x(1)+70*x(2))^2;
c(3)=(-288/25*x(2)*x(3)^2-49/5*x(1)*(70-x(3))*x(3))/x(3)/x(2)-(11.520000000000000000000000000000*x(2)^2*x(3)^3+294/5*x(1)*(70-x(3))*x(3)*(1/2*x(3)*x(2)+(35-1/2*x(3))*x(1))-9.7999999999999999999999999999998*x(3)^3)/x(3)^2/x(2)^2;
ceq=[];
end
x0=[0.15,0.65,40];
>> vlb=[0,0.6,0];
>> vub=[0.2,0.8,70];
>> x=fmincon('myfun',x0,[],[],[],[],vlb,vub,'mycon');
Warning: Divide by zero.
(Type "warning off MATLAB:divideByZero" to suppress this warning.)
> In D:\MATLAB6.5\work\mycon.m at line 4
In D:\MATLAB6.5\toolbox\optim\private\nlconst.m at line 275
In D:\MATLAB6.5\toolbox\optim\fmincon.m at line 458
Maximum number of function evaluations exceeded;
increase OPTIONS.MaxFunEvals |