How to use the Parallel Computing Toolbox of MATLAB to optimize the parameters of a Simulink model with genetic algorithm?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Abdolkarim Mohammadi
el 17 de Sept. de 2020
Editada: Abdolkarim Mohammadi
el 17 de Sept. de 2020
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 comentarios
Ver también
Categorías
Más información sobre Genetic Algorithm en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!