作业帮 > 综合 > 作业

关于matlab里fmincon函数的问题

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/04/26 03:21:34
关于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之间来约束,结果如下: