global optimization in parallel in combination with external pde solver

6 visualizzazioni (ultimi 30 giorni)
I use MultiStart from the global optimization toolbox to run lsqnonlin solver for a bunch of start
vectors. I want to run the local run indices in parallel since one forward solve is quite expensive.
function [fval, Jacob] = myObj(x)
% write params to file
...
% invoke pde solver with system call
system(path_to_pde_solver);
% read fval and Jacob from files
...
end
As you can see, the objective function writes the current point in parameter space to a file,
invokes the pde solver (Abaqus,...) which reads the parameter file and writes fval and Jacob in a
file. Finally, the objective function reads fval and Jacob from files which were generated by the
pde solver.
This, of course, does not work if multiple run indices operate on the same files since things get
mixed up.
However, it is safe if there are as many file exchange directories as there are run indices running
in parallel. For instance, say I call MultiStart in parallel with six cores on my local machine. Then,
six directories are created and the indices running successively on core 1 ,write their data always in directory 1,
and the indices running on core 2 write their data always in directory_2,...
I have full control on the pde solver, so I can pass whatever arguments to the pde solver in the
system call.
Does that sound reasonable and can this be realized with MultiStart and parallel computing toolbox?
Any starting points or alternatives are greatly appreciated!
Best regards
  13 Commenti
SA-W
SA-W il 20 Nov 2023
Just out of curiosity: Don't you have a valid licence or what's the reason ?
I have one. But, to be honest, I found it more realistic to get an answer here than from the technical support.
Torsten
Torsten il 20 Nov 2023
I don't think so - at least not for such a technical question. But you are of course free to do what you like.

Accedi per commentare.

Risposta accettata

Jasvin
Jasvin il 22 Gen 2024
Modificato: Jasvin il 22 Gen 2024
So as per the current discussion, it looks like your key requirement is to figure out how Parallel solving works with "MultiStart" and I believe the below documentation page describes exactly that:
Also to add to the point about "getCurrentTask", you can through all the properties available to you on this page: https://www.mathworks.com/help/parallel-computing/parallel.task.html
Among these properties, the "Worker" property seemed to be of most relevance, the "ID" property is associated with each task and "Worker" property would fetch you the worker that's running this task.
These are the properties you can fetch from a "Worker" object:
You can use this data (worker name and task ID) and pass it to your objective function to generate a unique directory that data should be read from/written to.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by