Using Objective Function with .mat File I/O for Parallel Computing
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 :)
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Manual Performance Optimization finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!