How to save each result of objective function solved by genetic algorithm for each iteration?
조회 수: 3 (최근 30일)
이전 댓글 표시
Hello!
- I have solved my optimization problem using genetic algorithm.My objective function is related to a random matrix that's why it is changed in each execution of my program.I want to put a specific number of iterations and store the result of my objective function of each one.It is possible to do that?
- any suggestion is appreciated
댓글 수: 0
답변 (1개)
Walter Roberson
2023년 2월 24일
Yes, of course.
numiter = 50;
results = zeros(nvars, numiter);
fvals = zeros(1, numiter);
for iter = 1 : numiter
[results(:, iter), fvals(iter)] = ga(...);
end
[bestfval, bestidx] = min(fvals);
bestx = results(:,bestidx).';
댓글 수: 2
Walter Roberson
2023년 2월 25일
Your code is already running Num iterations, each with a different qm and N value . However, you do not use qm or N so all of the iterations are running the same problem.
참고 항목
카테고리
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!