Parallel computing for genetic algorithm

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 件のコメント

Alberto Mora
Alberto Mora 2020 年 6 月 1 日
編集済み: Alberto Mora 2020 年 6 月 1 日
Honesty I don't know to do what you want, but one possible solution to speed-up genetic algorithm optimization, is to use "vectorized" population.
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 件)

カテゴリ

質問済み:

2020 年 6 月 1 日

コメント済み:

2020 年 6 月 1 日

Community Treasure Hunt

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

Start Hunting!

Translated by