Parallel computing for genetic algorithm

1 次查看(过去 30 天)
i have an objective function that calls an external program for optimization work. Running and getting results of objective function is very time consuming since the external program works really slow.
i want to distrubute the population generation task to 4 workers. But every worker must first copy the objective function folder which has an external function files in it into a seperate folder and then run the external program in that folder. this way, external program doesnt confused since it works seperately.
im using this file:
it has this code in evaluate.m file for parallel computing;
parfor i = 1:N
fprintf('\nEvaluating the objective function... Generation: %d / %d , Individual: %d / %d \n', state.currentGen, opt.maxGen, i, N);
[pop(i), allTime(i)] = evalIndividual(pop(i), opt.objfun, varargin{:});
end
function [indi, evalTime] = evalIndividual(indi, objfun, varargin)
[y, cons] = objfun( indi.var, varargin{:} );
What should be done in parfor loop above in order to create seperate working folder that has a copied external program files in it for each worker ?
thank you
  3 个评论
Ugur Acar
Ugur Acar 2020-6-1
Alberto Mora thank you for your answer. you are right i may not explain the problem clearly.
My objective funtion calls an external program. if each worker calls the objective function at the same time,it cannot evaluate objective function. so, before the worker call the objective function in parfor loop, objective function folder must be copied and the worker should work in that seperate folder.
Ugur Acar
Ugur Acar 2020-6-1
Or,
i created 4 folders and copied necessary external program files into these folders before running optimization algorithm. Let say folder names are worker1,worker2, worker3 and worker4.
I have quadcore machine and i want 4 parallel jobs at the same time.
how sud i make sure each worker evalute the objective function in differents folders (worker1,worker2, worker3 and worker4 folders)

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surrogate Optimization 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by