why getting infeasible solutions using fmincon? (Update)

9 views (last 30 days)
Hi
I have an optimization problem with many optimization variables and constraints (~561 var). I tried to solve the problem with fmincon but it gives the exit flag -2, which means there is no feasible solution.
For this reason, I thought, maybe the constraints (linear and nonlinear) don't have any feasible solution. So, I tried to consider these constraints as a system of equations and solve it with 'fsolve' for the same initial guess that I used for fmincon. fortunately, fsolve leads to an acceptable answer which is very close to the supplied initial guess.
Then I updated the original problem(which is solved by fmincon) with this new initial guess. But still the exit flag is -2 (infeasible). Then I thought the problem must be for bounding of optimization variables (lb,ub). So, I relaxed them and got exit flag 4. I also, wrote linear constraint as A,B matrices for both fsolve and fmincon. So, Based on the above explanation, what is exit flag 4? does it means the problem is feasible and I should accept its answer?
Can I solve the constraints (as an equation system) for the given initial guess considering the bounding of variables with fsolve as well in order to really understand if it has a feasible solution within the bounding?
Your help and suggestions are much appreciated.
  5 Comments
Jamais avenir
Jamais avenir on 24 Apr 2015
hmm, I did that few minutes ago, but didn't work @Torsten
Jamais avenir
Jamais avenir on 24 Apr 2015
Dear @Torsten I edited my question and added my attempts with fmincon and fsolve function. If its convenient please check them.

Sign in to comment.

Answers (2)

Brendan Hamm
Brendan Hamm on 24 Apr 2015
fmincon is a gradient based solver and as it is a discretized version of the optimization problem these are approximated by the solver (both the gradient and the hessian). You may look into supplying these values yourself if you can analytically solve them.
You can suplpy the gradient in the objective and nonlinear constraint functions and then turn the GradObj on using optimoptions:
Furthermore the discretization allows for modest violations of the feasible region. By default this is set to 1e-6, you can change this by changing the TolCon option using optimoptions.
To really narrow in on your problem, one would need more information about the actual problem being solved. Just because there is a 0 from fsolve on your nonlinear equality constraints does not imply that this is a feasible solution given other constraints/bounds. My guess is this is likely your issue, the points you find are not satisfying bounds/equality constraints, or perhaps even return an Inf or NaN in your objective.
  5 Comments
Brendan Hamm
Brendan Hamm on 26 Apr 2015
Just looking at this real briefly, it appears you are not solving the same set of equations. In your fmincon you have 561 design variables, whereas with fsolve you have 484. Not to mention your objective function and nonlinear constraints are expecting different size inputs. If I try and call your nolconfun with your Dat.InitialGuess I get the error:
Index exceeds matrix dimensions.
Error in nolconfun (line 68) pji = X( 451:496 )';
as you try and index beyond the size of the initial guess. For this reason you will NOT have a feasible point. Your non-linear constraint function must take your vector of design variables as input and therefore they should have the same size.
Jamais avenir
Jamais avenir on 6 May 2015
Dear Brendan. I modified my question above and updated the attach file based on your comment. Now, both fmincon and fsolve use 561 variables. Please kindly check my problem.
Thanks.

Sign in to comment.


Matt J
Matt J on 7 May 2015
Edited: Matt J on 7 May 2015
Based on the above explanation, what is exit flag 4
A full table explaining all of the exit flags is in the fmincon documentation here. Exitflag=4 is one of the stopping criteria which fmincon interprets as a potential success. Basically, fmincon has decided that the size of the step taken at the last iteration was insignificant as measured by the choice of the TolX parameter, and assumes this to be a sign of convergence.. Obviously, the criterion gets more stringent as you take TolX smaller and smaller. If you think you may not have selected a stringent enough TolX, it may help to test with still smaller TolX values and see if the solution remains stable.
On the surface, it looks like the problem simply wasn't feasible until you made the lb,ub bounds large enough.
  5 Comments
Matt J
Matt J on 7 May 2015
Edited: Matt J on 7 May 2015
My previous comment was assuming you already had a solution of the problem that you trusted (from GAMS, or elsewhere). If you have a version of the problem where the solution is known, a good first test is to see whether the known solution x satisfies the constraints as you've provided them to MATLAB. Run x through your nonlcon function and apply the linear in/equalities A*x<=b etc... to see if the constraints are satisfied. Scrutinize the ones that are not.
A good second test is to see if fmincon thinks your solution is optimal. If you initialize fmincon with a correct solution, it should stop right away with that same solution.
On the other hand, if you don't have a version of the problem where the solution is known, it's not clear why are questioning the results you are now getting. The hard truth might be that a solution simply does not exist in some cases. You can't rely on intuition for everything!
Jamais avenir
Jamais avenir on 7 May 2015
Thanks again for your elaborated answer.
It is originally a multi-objective programming problem which is already solved by someone in GAMS with epsilon constraint method But I want to solve it with NBI (Non boundary intersection) method. In either method we need to calculate the Anchor points which are obtained by individually optimizing each objective function. At this point, I want to optimize these three objective functions that I have in this problem individually to obtain the anchor points. The solution is also know as it was calculated in GAMS already (calculation of Anchor point in epsilon constraint and NBI and etc is same thing). I am trying to work on it as you suggested in your comment.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!