How does the ga in matlab give exitflag 1 before reaching the stall generation limit ?
4 views (last 30 days)
Show older comments
How does the ga in matlab throw an exitflag 1 before reaching the stall generation limit of 50 ? It throws exitflag 1 even if I set total generations less than 50.
I would sincerely appreciate your response this question.
Thanks,
7 Comments
Geoff Hayes
on 28 Sep 2014
Do you have the documentation for 2012a with respect to the exit flag of the ga function? Perhaps it has changed in the newer releases…
For example, at Global Optimization Toolbox Release Notes, the Genetic Algorithm changes for R2014a includes the comment
ga now stops when the average relative change in best fitness value over StallGenLimit generations is less than the TolFun tolerance. Previously, the stopping criterion was a weighted average relative change, where the weighting factor was (1/2)n for the nth prior iteration. This change usually causes ga to take more iterations. The new StallTest option, with default value 'totalChange', controls the stopping criterion. Set StallTest to 'geometricWeighted' to recover the previous behavior.
Though when I look at the ga exitflag documentation for R2012a Global Optimization Toolbox and the equivalent for 2014a, the descriptions are the same.
You may want to contact The MathWorks support concerning this question.
Answers (2)
Alan Weiss
on 29 Sep 2014
I don't understand how you are seeing what you report. My reading of the GA code shows that it should give an exit flag of 0 when it hits a generation limit that is smaller than the stall generation limit.
Perhaps you can post your exact options call, your exact call to GA, and the exact exit message.
Alan Weiss
MATLAB mathematical toolbox documentation
3 Comments
Alan Weiss
on 30 Sep 2014
If you want help, please post your exact options call, your exact call to GA, and the exact exit message. And then ask a question about the exact output that you find confusing.
Alan Weiss
MATLAB mathematical toolbox documentation
Alan Weiss
on 30 Sep 2014
Thank you for posting the options, GA call, and returned info.
As you realize, having a nonlinear constraint function, even one that returns all empty, changes the GA algorithm and exit conditions. And having an all-empty return for the nonlinear constraint makes it behave in hard-to-understand ways. For example, when GA internally compares the magnitude of the constraint function, it is comparing [] to some value such as TolCon. What is the result of that comparison? Say you try
3 <= 5
ans =
1
[] <= 5
ans =
[]
So, in the end, I have to say that it is not clear to me what happens internally when GA makes these comparisons.
It seems to me that the question you are asking is "What happens if I give GA an unexpected function?" And my answer is "I guess it does unexpected things."
Sorry, I really don't know any more than that. Sorry for the long answer to a short question.
Alan Weiss
MATLAB mathematical toolbox documentation
2 Comments
Alan Weiss
on 1 Oct 2014
The subproblem is described here. In addition to the formulas, the relevant portion of the documentation is:
The genetic algorithm minimizes a sequence of subproblems, each of which is an approximation of the original problem. Each subproblem has a fixed value of λ, s, and ρ. When the subproblem is minimized to a required accuracy and satisfies feasibility conditions, the Lagrangian estimates are updated. Otherwise, the penalty parameter is increased by a penalty factor (PenaltyFactor). This results in a new subproblem formulation and minimization problem. These steps are repeated until the stopping criteria are met.
I hope that this is clear. Remember, TolFun operates as a stopping criterion for GA as follows:
Function tolerance (TolFun) — The algorithm stops if the average relative change in the best fitness function value over Stall generations is less than or equal to Function tolerance.
Alan Weiss
MATLAB mathematical toolbox documentation
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!