How to terminate GA when a criteria is reached

7 Ansichten (letzte 30 Tage)
Sam136
Sam136 am 18 Aug. 2015
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

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 18 Aug. 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 Kommentare
Sam136
Sam136 am 20 Aug. 2015
Perfect. It finally worked. You were right. The output function should have three outputs.
Mahmoud Elbeltagy
Mahmoud Elbeltagy am 10 Aug. 2021
Amazing! @Walter Roberson, thanks a lot!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by