How to terminate GA when a criteria is reached

7 次查看(过去 30 天)
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

采纳的回答

Walter Roberson
Walter Roberson 2015-8-18
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 个评论
Sam136
Sam136 2015-8-20
Perfect. It finally worked. You were right. The output function should have three outputs.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Genetic Algorithm 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by