필터 지우기
필터 지우기

How to restart a script for optimization after shutting down

조회 수: 5 (최근 30일)
Jean Boyer
Jean Boyer 2023년 6월 15일
편집: Govind KM 2023년 6월 15일
I would like to run a genetic algorithm to adjust certain parameters in a simulation that takes a very long time to converge.
Given a population of 50 6-uplets and 100 iterations, I estimate the time needed to converge at just over a week.
The problem is that I can't leave the computer running over the weekend. So my question is, how can I resume the calculation where I left off before switching off the computer?

채택된 답변

Govind KM
Govind KM 2023년 6월 15일
편집: Govind KM 2023년 6월 15일
Hi Jean,
It looks like you basicallly need a way to save the state of the GA before switching off the computer. One way to do this would be to run the algorithm for a specific number of generations (say N) each time. Once the execution of the first N generations is complete, you can get the final population as an output from the ga function, which can then be used for the next set of generations as the initial population. You can run the algorithm in parts in this way, only running it when you are sure that you have the required time to run the specified number of generations. You can reduce N as per the availability of your computer. I assume all other parameters such as fitness function would remain the same between the execution of these generations.
% Create the GA options structure
options = optimoptions('ga');
% Set the population size and the initial population matrix
% Let p be the final population after the execution of the previous set of
% generations
populationSize = size(p, 1);
options.PopulationSize = populationSize;
options.PopulationType = 'custom';
options.InitialPopulationMatrix = p;
You can refer to the following documentation site for detailed information about passing the initial population to the function and getting final population as output :
https://in.mathworks.com/help/gads/ga.html (Input arguments -> Options -> InitialPopulationMatrix, Outputs -> Population)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Problem-Based Optimization Setup에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by