How to run parallel optimization when fitness function uses input/output files for [X] and [F].

2 次查看(过去 30 天)
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 个)

类别

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