Effacer les filtres
Effacer les filtres

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

2 vues (au cours des 30 derniers jours)
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

Réponses (0)

Catégories

En savoir plus sur Surrogate Optimization dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by