I need to globally optimize the parameter inputs to a fortran program in matlab. The function accepts inputs in the following manner:
z= fort_fun(X,str)
Where X is a vector of decimal numbers and str is a string. I need to identify the minimal z corresponding to the optimal X for each of 1020 str's. I can perform the process in serial by declaring str as a global variable with the function defined locally at the end of the parent script. However, in order to execute my code in a more timely manner (< 1 month) I would like to run this process in parallel with parfor as follows :
parfor i=1:n
%code to setupt global optomization problem....
z(i)=optimal output of --- fort_fun(X,str(i)) ---
end
...storing each final optimized value of z. If I declare str as a global variable, each thread of the parfor command will simultaneously optimize the same str(i).
Does anyone know of a way that I can configure each thread of the parfor command to optimize"" fort_fun(X,str(i)) "" ? I believe the OMP analog would be to use the "private" modifier applied to the str input.
Thanks!