How to output and save x1 and x2 after each run / generation?

조회 수: 1 (최근 30일)
Emily Senay
Emily Senay 2015년 6월 25일
댓글: Alan Weiss 2015년 6월 29일
I am using the genetic algorithm with a two variable function. I am running gaoptimeset and ga in a loop of a specified number. I want to get the value of x1 and x2 for each generation that the program is ran in one loop. How do I do this? I want to see how the values of x1 and x2 converge to the solution.
Thanks

답변 (1개)

Alan Weiss
Alan Weiss 2015년 6월 25일
Use an Output Function. For an example (using different solver and syntax, be careful!), see Output Functions in the Optimization Toolbox documentation.
Alan Weiss
MATLAB mathematical toolbox documentation
  댓글 수: 2
Emily Senay
Emily Senay 2015년 6월 26일
okay but if I want to output the best fitness function value for the first generation and the last, how do I do that? I would like to call them best1 and best2 so that at the end i can take the difference.
Alan Weiss
Alan Weiss 2015년 6월 29일
You can get the population at each generation in the state.Population field. See The State Structure. ga passes the state structure to your output function.
Alan Weiss
MATLAB mathematical toolbox documentation

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

카테고리

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