Using Simulink Fast Restart in a parallel computed optimization problem

Hi, I have a Simulink Model which works perfect when i turn on fast restart. I can change the Values of my parameters A1, A2 and i by hand and it does not need to recompile.
Now i want to use this model in a parameter optimization problem using parallel computing AND fast restart. It would save a lot of time to cut out the recompiling time. The Problem is parallel computing works great but the model compiles for every iteration.
I set up the optzimization like this
% Simulator set up with experiment data, multiple experiments
Simulator = createSimulator(Exp(1));
Simulator = fastRestart(Simulator,'On'); %Fast Restart ON??
% estimation function handle, sdo requires function with just one input
% argument
estFcn = @(param) ObjectiveFun(param,Simulator,Exp);
% optimization options
parpool
opt = sdo.OptimizeOptions;
opt.Method = 'surrogateopt';
opt.UseParallel = true;
opt.OptimizedModel = 'Model';
opt.ParallelFileDependencies = files;
opt.MethodOptions.PlotFcn = 'surrogateoptplot';
opt.MethodOptions.MaxFunctionEvaluations = Iterations;
% Optimization
vOpt = sdo.optimize(estFcn,param,opt);
I just tried running the same code without parallel computing (opt.UseParallel = false) and fast restart works.. but not with parallel computing

 Accepted Answer

Just if someone faces the same problem as me.
The problem was that my Simulink model was inside a Matlab Project. A part of the startup function of this project was to open the simulink model.
open('Test.slx')
When starting the optimization the startup function is called, which opens the model without fast restart, which the optimization function does not override..
I got arround adding those lines to the startup function:
open('Test.slx')
sim_obj = sdo.SimulationTest('Test');
sim_obj = fastRestart(sim_obj,'On');

More Answers (0)

Asked:

on 22 Mar 2022

Answered:

on 29 Mar 2022

Community Treasure Hunt

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

Start Hunting!