关于matlab里fmincon函数的问题

算一个很简单的三元函数的约束极值,要求得到最大值,我把原函数取了下负号,然后看着help写了下但是结果有问题。求指正
要最大值的函数是y=(1+(1.2*x(1)-860)/6485)*(1.5*x(2)+0.75*x(3)+0.7375),约束条件是x(1)+4500x(2)+3375x(3)=4570
三个变量取值分别是[1000,3000],[0,0.8],[0,0.25]
我是这么写的:
function y = fun1(x)
y = -(1+(1.2*x(1)-860)/6485)*(1.5*x(2)+0.75*x(3)+0.7375);
x=fmincon('fun1',[0 0 0],[],[],[1 4500 3375],[4570],[1000 0 0],[3000 0.8 0.25]);

然后说
fmincon stopped because the size of the current search direction is less than
twice the default value of the step size tolerance and constraints are
satisfied to within the default value of the constraint tolerance.
这是什么原因呢?怎么修改呢?

一定要使用matlab吗?我使用mathematica计算了一下,由于mathematica中x(1)+4500x(2)+3375x(3)=4570条件报错,所以我修改了一下条件,近似采用x(1)+4500x(2)+3375x(3)介于4569.9与4570.1之间来约束,结果如下:

温馨提示:内容为网友见解,仅供参考
第1个回答  2013-11-12
这不是错误,不管做什么最优,它都会出现这条提示,这条提示是告诉你,寻优结束的原因——步差小于设定精度值。因为程序一种循环迭代寻优过程,必须要有一个停住的条件的。我帮你看了,和楼上结果差不多,lingo也可以求解,不妨试试,结果应该一样。
相似回答