How to terminate GA when a criteria is reached

12 vues (au cours des 30 derniers jours)
Sam136
Sam136 le 18 Août 2015
Commenté : Mahmoud Elbeltagy le 10 Août 2021
I am using GA to find a local min of a function. I want to terminate iterations when fitness functions reaches a preset value.
x = ga(@AECMS,nvars,[],[],[],[],LB,UB,[],options);
function socf=AECMS(s)
sim HYB_VEH
socf=(soc_sim-soc_des)^2
It should stop when socf<A. BTW, this is different from TolFun or TolX

Réponse acceptée

Walter Roberson
Walter Roberson le 18 Août 2015
Use an options structure with an output function and set the state StopFlag to a non-empty string http://www.mathworks.com/help/gads/genetic-algorithm-options.html#f17837
  7 commentaires
Sam136
Sam136 le 20 Août 2015
Perfect. It finally worked. You were right. The output function should have three outputs.
Mahmoud Elbeltagy
Mahmoud Elbeltagy le 10 Août 2021
Amazing! @Walter Roberson, thanks a lot!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by