Record best solution in each GA generation running with UseParallel=true

조회 수: 20 (최근 30일)
Hello,
Is there a way to record the best solution at each generation running with parallelization? (that is, with UseParallel=1)
I used outputFcn_global (from File Exchange), but it uses a global variable to record the info. In each generation, I would like to use the output function to just record the best solution (e.g. 1x1000 array) in the population. Since my objective function is a combination of several things, I need the best solution of each generation to then calculate the value of each term in the fitness function separately, and see how the objectives evolve over the generations.
Is there a way to do that without global variables?

채택된 답변

Star Strider
Star Strider 2021년 1월 17일
See: How to save data from Genetic Algorithm in case MATLAB crashes? That will likely do what you want. Define it as the output function 'OutputFcn',@SaveOut.
  댓글 수: 2
Mitsu
Mitsu 2021년 2월 8일
Finally got back to work on this, sorry for not upvoting earlier.
Thank you! I misunderstood what the output function does, and thought it was not compatible with parallelizing the optimizer. Since the output function is called only once during each iteration, it works fine!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multiobjective Optimization에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by