Help in understanding optimization problems and solving them in Matlab (choise of appropriate solver)
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hello
Maybe a classical phrase: I have been trying to understand this since several days but not succeed - really about me!
Lets take a simple constrained optimization problem from here maximazing revenu with bubget constraints. So the problem is
We can solve it in Matlab with 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
OR we can use Lagrangian cost function and rewrite these to unconstrained optimization problem (Am I right at this stage?)
Then solving this objective function with fminsearch or fminunc (even tried with 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
gives different results and even not close to constrained solution with fmincon. I tried to change the sign, put lambda = 1....
So why its like this, where I am wrong or I dont understand something?
0 Commenti
Risposta accettata
Matt J
il 17 Mag 2019
Modificato: Matt J
il 17 Mag 2019
You have to reformulate the problem with a convex objective to be certain that the Lagrangian minimization will behave as you're expecting (see Sufficient Conditions for Strong Duality). You can do this as follows:
objective = @(x) -2/3*log(x(1))-1/3*log(x(2));
[Xcon,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] = fmincon(objective,[1,1],[],[],[20, 170],20000,[],[],[])
objectiveUC = @(x) -2/3*log(x(1))-1/3*log(x(2))+LAMBDA.eqlin*(20*x(1) + 170*x(2) - 20000);
Xunc = fminunc(objectiveUC,[1, 1])
This leads to
Xcon =
666.6664 39.2157
Xunc =
666.6533 39.2154
3 Commenti
Matt J
il 20 Mag 2019
All 3 objectives differ by monotonic transformations, e.g.,
objective_2=-log(-objective_1/200)
is a monotonic function of objective_1. Therefore if one increases or decreases, so does the other, and they therefore have minima at the same locations.
Più risposte (0)
Vedere anche
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!