回复:(vikeezhou)[求助]这个程序每一步是什么意思
%这个函数的主要作用是求min y subject to: A*X <= b (linear constraints)
% X C(X) <= 0, Ceq(X) = 0 (nonlinear constraints)
% LB <= X <= UB
%首先编写目标函数的﹒m文件:
function f=myfun(y);
f=exp(y(1)+y(2))*3*exp(-y(4)); %这个应该明白就是定义一个函数下面调用,其实可以直接在下面写出来
%调用函数fmincon:
>> y0=[1.79,2.99,-0.22,-0.0622]; %起始点
>> A=[-1.5,-1.5,2,-0.5;-3.0,-2,2,-1]; %上面的系数矩阵
>> b=[-5.2779;-7.0346]; %
>> lb=[0.693,2.833,-0.51,-0.0622];
>> ub=[3.0,3.912,0.18,-0.00549]; %LB <= X <= UB
>>[y,fval,exitflag,output]=fmincon(@myfun,y0,A,b,[],[],lb,ub)
y =
0.6930 2.8330 -0.2200 -0.0055
fval =
102.5246
exitflag =
1
output =
iterations: 2
funcCount: 17
stepsize: 1
algorithm: 'medium-scale: SQP, Quasi-Newton, line-search'
firstorderopt: 2.8422e-014
cgiterations: []
message: [1x144 char]