Hi all,
I am using surrogateopt to optimize an expensive objective function. One evaluation takes approx. 6 minutes.
I run it on a Win 10 PC with 28 cores and 128GB RAM and Matlab 2023a with the Global Optimization Toolbox and the Parallel Computing Toolbox.
Each evaluation of the objective function calls a legacy fortran executable twice. The function value is an average of the two fortran outputs. (see pseudo code below)
The fortran executable is 32 bit and needs ca. 1.5GB of RAM. By my math, the PC should be good for 27 parallel executions of that fortran file.
Each time surrogateopt starts, it does indeed start Poolsize number of parallel fortrans, however, it reverts to serial execution afterwards. At the same time, Matlab uses all available 128GB of RAM. See screenshot attached.
Does anyone have an idea of how to make surrogateopt work "more parallel?" Does surrogateopt have such a high overhead in terms of RAM?
As a sidenote: if I use patternsearch in parallel, I am able to execute 10 (2*length(x)) instances consuming approx. 15 GB of RAM. However, many cores sit idle and I hoped surrogate could help.
Thank you very much!
Florian
opts = optimoptions('surrogateopt',UseParallel=true,UseVectorized=false,Display='iter',PlotFcn='surrogateoptplot',...
InitialPoints=x0,MaxFunctionEvaluations=1e9,MaxTime=3*24*60^2,ObjectiveLimit=1e-4);
xopt = patternsearch(@(x) objective(x),lb,ub,opts);
function val = objective(x)
paraset = [fixed_para(i) , x];
folder = [num2str(wrkr.ID),"_",num2str(i)];
copyfile('PricingRevisedDown.exe',folder)
fid = fopen([folder,'\input.txt'], 'wt');
fprintf(fid,'%s', paraset);
system(['pushd ',folder,' && START /high /wait PricingRevisedDown.exe && popd']);
valtemp(i) = load([folder,'\fortranout.txt']);
val = 2.\(valtemp(1) + valtemp(2));