也许是一句经典的话:几天以来我一直试图理解这一点,但没有成功——真的是关于我!让我们从这里开始一个简单的约束优化问题,在预算约束下最大化收入。所以问题是
我们可以在 Matlab 中用fmincon解决它
objective = @(x) -200*x(1)^(2/3)*x(2)^(1/3);
[X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] = fmincon(objective,[1,1],[],[],[20, 170],20000,[],[],[])
>> X =
666.6669 39.2157
LAMBDA =
struct with fields:
eqlin: 2.5927
或者我们可以使用拉格朗日成本函数并将它们重写为无约束优化问题(我在这个阶段是对的吗?)
然后用fminsearch或fminunc求解这个目标函数(甚至用ga尝试过)
lambda = 2.5927;
>> objective = @(x) -200*x(1)^(2/3)*x(2)^(1/3)-lambda*(20*x(1) + 170*x(2) - 20000);
x = fminuncfminunc(objective,[1, 1])
>> Problem appears unbounded.
fminunc stopped because the objective function value is less than
or equal to the value of the objective function limit.
<stopping criteria details>
x =
1.0e+19 *
0.2504 6.4423
>> x = fminsearch(objective,[1, 1])
Exiting: Maximum number of function evaluations has been exceeded
- increase MaxFunEvals option.
Current function value: -51855.290146
x =
0.1088 1.7458
给出不同的结果,甚至不接近fmincon的约束解。我试图改变符号,把 lambda = 1....
那么为什么会这样,我错在哪里或者我不明白什么?
提前致谢!