Using Objective Function with .mat File I/O for Parallel Computing

1 vue (au cours des 30 derniers jours)
Rajmohan
Rajmohan le 12 Déc 2019
Hey Everyone!
I am working on an optimization problem which uses a complied Simulink model. The output of a simulink model is a .mat file that needs to be read and processed to create the output of the objective function. See code:
function y=costfunction(x,rtpstruct,mdlname,Tend)
% Change the tunable variable
rtpstruct=rsimsetrtpparam(rtpstruct,'ini',x);
save Rsim_Params rtpstruct
% Run Model
runname = ['.',filesep,mdlname,' -p Rsim_Params.mat -i Rsim_Input.mat -tf ',num2str(Tend),' -v '];
[~,~] = system(runname);
% Extract Simulation Parameters
simout = RsimOut(mdlname); % RsimOut load the .mat file and creates a more readable output.
% Output to minimize
y=sum(diff(simout.OutSig1));
end
This code generates an error when 'UseParallel' is set to 'true' in fmincon. I believe there is caused due to the fact that all the works are storing the data at the same location. Is there a way to fix this issue?
Thanks :)

Réponses (0)

Catégories

En savoir plus sur Problem-Based Optimization Setup dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by