MATLAB: Fmincon and exitflag = -2 or 2 / non respect of constrained conditions

exitflagfminconinequality constraintsMATLABnon respect

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?
Thank you for the answer.
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

Best Answer

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
Related Question