I am using a the constrained solver fmincon with 2 constrains: all values of x >= 0 and the sum of x is equal to y.
I know the analytic solution for some low y values and I use those as a guess. When look at what fmincon puts into my function, I see that it doesn't put my guess value in to it. And it does not reach my guess values, so it reaches some kind of local minimum. Why is fmincon being stubborn and why doesn't it use my guess values?

4 commentaires

Matt J
Matt J le 13 Juin 2014
Modifié(e) : Matt J le 13 Juin 2014
We will know (maybe) when you show us your code.
Tim
Tim le 13 Juin 2014
It is quite a large script so I don't want to bore you with that. But basically my initial guess is:
x0 = [50 0 0 0 0 0]
and fmincon puts this in the function:
x0 = [50 1 1 1 1 1]
It might be possible that it is because of the boundary condition (x>=0), but since 0 should be an allowed value, my guess should be okay. The guess of fmincon is also not a valid guess according to my secondary constraint. In this case y = 50, so the sum of my x0 is 50 which fits my constraint. And the sum of the guess of fmincon is 55 which does not fit the constraint.
Mahdi
Mahdi le 13 Juin 2014
Have you tried using a value slight bigger than zero? Like 0.00000001, does the same problem happen?
Matt J
Matt J le 13 Juin 2014
Modifié(e) : Matt J le 13 Juin 2014
What is the the value of y? 50?
What is the final value of x that fmincon returns?
What is the value of the 3rd output argument "exitflag"?
What options are you passing to fmincon (TolCon, TolFun, Algorithm, etc...)?

Connectez-vous pour commenter.

 Réponse acceptée

Matt J
Matt J le 13 Juin 2014
Modifié(e) : Matt J le 13 Juin 2014

0 votes

The 'interior point' algorithm would ignore your initial guess when AlwaysHonorConstraints='bounds', which is the default. Then, it needs to find a starting point in the interior of your bound constraints. Hence,
x0 = [50 1 1 1 1 1]
is a valid candidate.

1 commentaire

Tim
Tim le 13 Juin 2014
Thanks for your help! At the end, I changed a lot of the tolerance options which resulted in a final solution that was acceptably close to my initial guess.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by