# fmincon and exitflag = -2 or 2 / non respect of constrained conditions

22 vues (au cours des 30 derniers jours)
Helen le 1 Juin 2012
Commenté : Walter Roberson le 6 Juil 2018
Hello everyone,
I'm creating a model on Matlab for optimization with inequality constraints, especially the minimization of a function with several variables (at least 4). I'm trying to run the optimization for many times to get a list of solutions, gotten by a parameter varying at each simulation.
However, I cannot solve problems I met: - exitflag = -2 most of the time and 2 for the other simulations. I don't know where I can correct or change to get exitflag = 1. - among constrained conditions I set, some of them aren't respected after minimizations.
If someone could advice me what method I could follow?
General description of the model: *------ objective : minimize a section ( I shape) submitted to a tension force *------ variables : thicknesses, height, wide *------- constraints : - section > 0 - variables >0 + linear inequality relation between two of them - tension stress < certain value in MPa : non respected condition
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

Sargondjani le 1 Juin 2012
Modifié(e) : John Kelly le 2 Mar 2015
getting exit message 2 is not bad but if you insist on having 1, you could try to use smaller values for TolX (ie.. 1e-10 or even 1e-14)
as for exit message -2: there could be many causes.
if you choose a feasible starting point, fmincon should be able to find a solution i guess...
but maybe you could also post the output of the last couple of iterations and the exit message? and the fmincon command + options? otherwise it is very hard to guess what's going on
##### 1 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
Helen le 4 Juin 2012
Modifié(e) : John Kelly le 2 Mar 2015
Hello,
Thank you very much for your answer. I've tried to check non linear constraints. Even i found a feasible point, the problem is that I'd like to do the optimization with random values of the variables, so I could obtain a list of solutions. How to make sure that the initial values are all feasible points?
Thank you.

Connectez-vous pour commenter.

### Plus de réponses (2)

Alan Weiss le 6 Juin 2012
Modifié(e) : John Kelly le 2 Mar 2015
If you have a Global Optimization Toolbox license, you could try MultiStart. If you like, you can filter the initial points so the local solver uses only feasible starting points, although I am not sure this is really necessary. See this link for general information about how to use MultiStart, and this link to see the effect of using only feasible start points.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
##### 4 commentairesAfficher 2 commentaires plus anciensMasquer 2 commentaires plus anciens
Sargondjani le 8 Juin 2012
you have three input variables so you could make a 3D grid and solve for all points in the grid.
you could start with a wide grid with not so many points and then make a finer grid around the points that give feasible solutions, or something like that
Helen le 12 Juil 2012
sorry for the late answer, thank you very much.

Connectez-vous pour commenter.

Ahmed Rageh le 4 Juil 2018
Where could I find TolX? the code has TolFun and TolCon only.
options = optimset('Display','iter','TolFun',1e-10,'TolCon',1e-10)
##### 1 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
Walter Roberson le 6 Juil 2018
TolX is still the name to use with optimset() .
If you were updating to the newer option routines, you would use StepTolerance, or XTolerance for GlobalSearch and MultiStart

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Solver Outputs and Iterative Display dans Help Center et File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by