How to run parallel optimization when fitness function uses input/output files for [X] and [F].
2 views (last 30 days)
Show older comments
Hi, I am "gamultiobj" for multiobjective optimization. my fitness function is as below. It calls a Fortran compiled file (CNEW.exe) to calculate the objective functions. Input variables [X] from the optimiser are written to a file "xinput" which is read by CNEW.exe and it write the function values in "fout.txt". All works fine when fitness function evaluation setting is on "in serial". I tried to use paralell computation in MATLAB to reduce the time. It seems that parallel processing works fine as I can see in the task manager each core runs an individual CNEW.exe task. But since all of them communicate with the same in/out files on the hard drive, the oucome is terribly mixed and optimization goes wrong. Can someone please tell me what should I do?
function y = mymgt(x)
%write the x data
xh = fopen('xinput.txt', 'w');
fprintf(xh, '%f %f %f\n', x);
fclose(xh);
%run the program
system('CNEW.exe');
%read the f data
fh = fopen('fout.txt');
y = fscanf(fh, '%f %f');
fclose(fh);
end
0 Comments
Answers (0)
See Also
Categories
Find more on Surrogate Optimization in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!