这是我定义的函数:
function f=fun3_3(x);
f=58*x(1)+54*x(2)+50*x(3)+0.2*sum(x.^2)-560;
这是主程序:
A=[-1 -1 0];
b=-100;
a1=[40;0;0];
a2=100*ones(3,1);
Aeq=[1 1 1];
beq=[180];
x0=[10 10 10]';
[x,fval]=fmincon('fun3_3',x0,A,b,Aeq,beq,a1,a2,[])
运行之后就出现这个状况:
Warning: The default trust-region-reflective algorithm does not solve problems with the constraints you
have specified. FMINCON will use the active-set algorithm instead. For information on applicable
algorithms, see Choosing the Algorithm in the documentation.
> In fmincon at 500
Warning: Your current settings will run a different algorithm (interior-point) in a future release.
> In fmincon at 505
Local minimum possible. Constraints satisfied.
fmincon stopped because the predicted change in the objective function
is less than the default value of the function tolerance and constraints
are satisfied to within the default value of the constraint tolerance.
这个情况是正常的,系统有提示:Optimization completed because the objective function is non-decreasing in
feasible directions, to within the default value of the function tolerance,
and constraints are satisfied to within the default value of the constraint tolerance.
提示说你的目标函数在可行域内不是单调下降的,所以只找到了局部最优解,如果想寻找全局最优解需要修改初始值,我修改了几个初始值得到的结果都是一样的,可以大致认定它是全局最优解了,你如果对问题的全局最优解有一定的了解,也可以根据这个选择初始点再试!