function hhaX0=[2 515370]A=[];b=[];Aeq=[1 1 1 1];Beq=400;LB=[0 0 0 0];UB=[];[X,FVAL,EXITFLAG]=FMINCON(@FUN,X0,A,b,Aeq,Beq,LB,UB)max=-FVALfunction yhat=FUN(x)yhat=-(sqrt(x(1))+sqrt(x(2))+sqrt(x(3))+sqrt(x(4))+(400-x(1))*0.1+(400-x(1)-x(2))*0.1+(400-x(1)-x(2)-x(3))*0.1);结果:X =
2.3559
4.9053 15.8087376.9301FVAL = -143.8717EXITFLAG =
1max =143.8717 |