Genetic algorithm, nonlinear constraints, TolFun how to get good results ?

2 views (last 30 days)
Hello, please i simulated a code for optimization of discrete and continous variables using ga function but I get a result that I do not like and in addition I have this message "Optimization terminated: average change in the penalty fitness value less than options.TolFun and constraint violation is less than options.TolCon. " . How can I improve the results? Thanks thank you

Accepted Answer

John D'Errico
John D'Errico on 4 May 2017
Edited: John D'Errico on 4 May 2017
This is not a question of options. Yes, people think, if only I knew what options to set, and to exactly what values, the answer would emerge like magic. NOT true. That only happens in the movies or on TV, where computers are all powerful, and the proper code is written in 5 keystrokes to then solve a problem that would require at least a Phd thesis in real life, IF it was solvable at all.
Not all optimization problems converge to the solution you hope to see. That may be because you
1. Coded the objective incorrectly.
2. Formulated the problem poorly (so a poor objective.)
3. Provided poor starting values.
4. The optimization got stuck in a local minimizer.
5. The solution you hoped to see really is not a minimum.
Case 4 is a variation of case 3. Both say that you get to the wrong solution, because you started in the wrong spot.
Probably a few others I forgot to list. But one reason that is only very rarely the case is you chose the wrong settings for options. I would strongly suggest you reconsider each of the possibilities I suggested above. Why cannot I be more accurate in my diagnosis of where the problem lies? Because we see NOTHING about what you actually did! All that we can tell from here is that you had a problem with an optimization. So the answer is you did something wrong.
  3 Comments
John D'Errico
John D'Errico on 4 May 2017
That is NOT a warning or error. "Terminated" is just a synonym for "done" in this case. The optimizer thinks the result is a s good as it can do, given the set of starting values provided. It sees no place better to search, and the convergence criteria were satisfied.
houda mejri
houda mejri on 4 May 2017
thanks for the response. i am just wondering if i can get this message to be sure that the result is the best.

Sign in to comment.

More Answers (1)

Alan Weiss
Alan Weiss on 4 May 2017
I believe that the best way to get better answers is to use a better algorithm. In this case, first see whether your fitness function and nonlinear constraints are both smooth. If they are, then use fmincon instead of ga, and if you are looking for a global minimum, start from a variety of initial points, such as
x0 = lb + rand(size(lb)).*(ub-lb);
If your fitness function or nonlinear constraints are not smooth, then use patternsearch, again starting from a variety of points.
Seriously, both fmincon and patternsearch are much faster, more reliable and robust, and easier to tune than ga. You will almost certainly be delighted.
Alan Weiss
MATLAB mathematical toolbox documentation
  1 Comment
houda mejri
houda mejri on 4 May 2017
Thank you very much for the answer but I work on the optimization of the discrete and continuous variables at the time so ga I think that is the most suitable. In addition, my objective function is a learning function which I call from the library in jar on matlab.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!