UseParalle in Particleswarm doesn't star

7 vues (au cours des 30 derniers jours)
Marta
Marta le 25 Fév 2025
I am performing an optimization using particleSwarm (with the function implemented in MATLAB), where the goal is to minimize the error between the experimental displacements of a model and the predicted displacements from an FE model.
In the objective function passed to particleswarm, an Abaqus simulation is launched, which on average takes about one day to complete. To speed up the process and obtain an optimal result more efficiently, I would like to try using the UseParallel option of particleswarm.
However, it seems that even when setting UseParallel = true, once the code is executed, the objective function is not assigned to the specified workers, and the execution still runs sequentially instead of in parallel.
What could be the issue?
I appreciate any help on this matter.
  2 commentaires
Raymond Norris
Raymond Norris le 25 Fév 2025
  1. Is UseVectorized set to true or false?
  2. Do you have the Parallel Computing Toolbox?
  3. Are you running the code locally or on a remote machine/cluster?
  4. If locally, how many cores do you have?
Marta
Marta le 26 Fév 2025
  1. i set UseVectorixed to false
  2. yes, i have the toolbox
  3. i'm running my code on a remote machine beacuse it is a proget for my thesis and i have to use some programs that are on their pc
  4. i don't know exactly how many cores it has

Connectez-vous pour commenter.

Réponses (1)

Abhishek
Abhishek le 27 Juin 2025
Hi @Marta,
I understand that your Abaqus-based simulation still runs sequentially, even after setting the UseParallel’ to ‘true’. To ensure that your optimization runs efficiently in parallel when each function evaluation involves an external Abaqus simulation, a few key considerations can help set things up smoothly:
  • Activate a Parallel Pool: Ensure a parallel pool is running before you start the optimization. MATLAB will not parallelize unless a pool is available. You can do this manually by running the parpool('local');’ command in the command window.
  • Enable Parallel Evaluation in Options: Set the ‘UseParallel’ option while defining your solver configuration:
options = optimoptions('particleswarm', ...
'UseParallel', true, ...
'SwarmSize', 20, ...
'Display', 'iter');
  • Prepare Objective Function for Parallel Execution: The objective function should be written in a way that each evaluation is independent and safe to execute concurrently. A common practice when launching external solvers like Abaqus is to assign a unique working directory for each particle.
  • Verify parallel behavior: You may verify that the function is running on workers by including:
task = getCurrentTask;
if isempty(task)
disp('Running on main thread');
else
disp(['Running on worker: ' num2str(task.ID)]);
end
Hope this helps.

Catégories

En savoir plus sur Problem-Based Optimization Setup 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