Is there a way to save additional information in a custom crossover function for the ga and then pass it to the output function?
조회 수: 1 (최근 30일)
이전 댓글 표시
I have custom crossover, mutation, and output functions for my implementation of the ga (genetic algorithm).
I would like to be able to save certain information when calling the crossover function (namely I want to know which parents produced which offspring and what the parents' scores were). Then when the output function is called, I want to refer to that information if a better solution was generated.
I have tried passing a struct to the crossover and output functions and have them both refer to it, but that doesn't seem to work out of the box.
(The scores seem to be passed to the crossover function in the field the documentation refers to as 'unused', by the way.)
댓글 수: 0
채택된 답변
Walter Roberson
2021년 3월 27일
There is no provided mechanism for this.
You can use strategies such as shared variables. http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F
댓글 수: 3
Walter Roberson
2021년 3월 31일
I would not have advised using global variables. Shared variables maybe.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Genetic Algorithm에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!