simulation based optimization using parallel computing, which one to be added to workers folders?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Edric Ellis
2019-5-1
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surrogate Optimization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!