How to terminate GA when a criteria is reached

조회 수: 7 (최근 30일)
Sam136
Sam136 2015년 8월 18일
댓글: Mahmoud Elbeltagy 2021년 8월 10일
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.
Mahmoud Elbeltagy
Mahmoud Elbeltagy 2021년 8월 10일
Amazing! @Walter Roberson, thanks a lot!

댓글을 달려면 로그인하십시오.

추가 답변 (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