simulation based optimization using parallel computing, which one to be added to workers folders?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi everyone, im using GA and surrogate optimization to optimize a model created by external software (Finite element analysis). To speed up my optimization i also use parallel computing toolbox. After studying these two examples below i realize i needed to load my external software model into four woker folders in the beginning (because im using 4-core computer). After done this step, my questions are:
1) How to open the specific model based on the specific worker in my objective function? For example model 1 is located in folder 'worker 1' so in my objective function do i need to obtain the number of worker first and then open the related model? (spmd not working in my objective function, dont know why)
2)The model simulation results are automatically generated in the same folder where the relevant model located by the time the simulation is finished, and i need to read the results to calculate my optimization output and constraints. Same problem ouucr: how to obtain the number of worker and read the related model's results?
3)Except for my external software model, is there any other .m files i should add to the workers folders?
Thank you!
0 commentaires
Réponses (1)
Edric Ellis
le 1 Mai 2019
You haven't really given enough detail for me to give you particularly concrete suggestions, but here are a few thoughts anyway...
Firstly, if you're using "local" workers (i.e. parpool('local',4)) then you shouldn't normally have to add any MATLAB code to the workers - they will generally pick everything up automatically.
Secondly, I would suggest trying something like this:
workerBaseFolder = 'path/to/base';
parfor simIdx = 1:4
workerFolder = fullfile(workerBaseFolder, sprintf('worker %d', simIdx));
% Remember original working directory
oldWd = pwd;
% Change to the "worker" directory for this loop iteration
cd(workerFolder);
% Run the simulation
runSimulation(. . .);
% Restore the working directory
cd(oldWd);
end
0 commentaires
Voir également
Catégories
En savoir plus sur Surrogate Optimization 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!