フィルターのクリア

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 Center および File ExchangeProblem-Based Optimization Setup についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by