How to use the Parallel Computing Toolbox of MATLAB to optimize the parameters of a Simulink model with genetic algorithm?
3 次查看(过去 30 天)
显示 更早的评论
Hello,
I am using the genetic algorithm function "ga()" in MATLAB to optimize operating parameters of a Simulink model.
The decision variables are several parameters of the Simulink model. The output of the fitness function is calculated by the Simulink model (The function "sim ()" is applied in the fitness function to simulate the model, and then the fitness function choose the output value of the model as the output for fitness evaluation).
Here is the fitness function:
And here is the Simulink model:
However, the optimization process will be very time-consuming as the model simulation of each individual in a generation is in serial. I wonder if it is possible to accelerate the process by simulating the model of each individual in parallel by the Parallel Computing Toolbox?
I am very grateful if you can answer my question or give me some suggestions!
0 个评论
回答(1 个)
Abdolkarim Mohammadi
2020-9-17
编辑:Abdolkarim Mohammadi
2020-9-17
You should set ga() to pass all of the generation members at once using UseVectorized option. Then you set the objective function to be calculated for all of the members in parallel using parsim() and SimulationInput object. The general framework is to create an array of SimulationInput object, which has one such object in each element. Each element contains the variables set from the corresponding rows of the generation passed by ga(). The objective function receives a PopulationSize-by-nvars array and returns a PopulationSize-by-1 array. https://www.mathworks.com/help/simulink/slref/parsim.html
You can also benefit from options of parsim to run even faster, including fast restart, rapid accelerator, etc.
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!