MATLAB: PCT and GA optimizer

genetic algorithmParallel Computing Toolbox

Hi, I try to use parallel computing toolbox to decrease genetic algorithm optimizer run time. all of workers will call an external solver using one premade input file.(call MSC Nastran bdf is made in MATLAB). the thing is each time external solver is called some files are created.to avoid conflict between workers three options came to my mind. 1) use of resource lock to avoid conflict but this will bring problems since other workers solver dont wait and will fail. 2) tell PCT to create directory for each worker and copy necessary files into each directory. 3) in objective function get process id of each worker and put an extension in input file made by objective function for external solver therefore each workers will have different output and input file name.
the last option looks like the easiest one. what do you guys think ? and btw I dont know method 2 and 3. need some help 🙂 thanks in advance

Best Answer

If you use the Vectorize option, you can have GA pass the entire population to your objective function in each iteration. Within your objective function, you can then implement your own parallel splitting of the computation using Parallel Computing Toolbox functions.
For example, you can evaluate different population chunks in parallel in an SPMD...END block and use the labindex() command to create a worker-dependent name for your files,
spmd
...
filename=[filename numstr(labindex)];
end