Customised output function for ga
이전 댓글 표시
I have been looking how to create my own output function in GA to get each x and fval of each iteration and generation. Although I have looked into all the answered questions for such a question, nothing has been working so far. Here is my output function and please help me with what I'm missing.
function [state,options,optchanged] = gaoutfun(options,state,flag)
persistent history_pop history_Best history_Score
history_pop = [];
history_Best = [];
history_Score = [];
optchanged = false;
switch flag
case 'init'
history_pop = [history_pop;state.Population];
assignin('base','gapopulationhistory',history_pop);
history_Best = [history_Best;state.Best];
assignin('base','gabesthistory',history_Best);
history_Score = [history_Score;state.Score];
assignin('base','gascorehistory',history_Score);
case 'iter'
history_pop = [history_pop;state.Population];
assignin('base','gapopulationhistory',history_pop);
history_Best = [history_Best;state.Best];
assignin('base','gabesthistory',history_Best);
history_Score = [history_Score;state.Score];
assignin('base','gascorehistory',history_Score);
case 'done'
history_pop = [history_pop;state.Population];
assignin('base','gapopulationhistory',history_pop);
history_Best = [history_Best;state.Best];
assignin('base','gabesthistory',history_Best);
history_Score = [history_Score;state.Score];
assignin('base','gascorehistory',history_Score);
end
채택된 답변
추가 답변 (1개)
Alan Weiss
2018년 5월 18일
0 개 추천
Alan Weiss
MATLAB mathematical toolbox documentation
댓글 수: 1
Yaser Khojah
2018년 5월 18일
편집: Walter Roberson
2018년 5월 18일
카테고리
도움말 센터 및 File Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!