- Is UseVectorized set to true or false?
- Do you have the Parallel Computing Toolbox?
- Are you running the code locally or on a remote machine/cluster?
- If locally, how many cores do you have?
UseParalle in Particleswarm doesn't star
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Raymond Norris
el 25 de Feb. de 2025
Respuestas (1)
Abhishek
el 27 de Jun. de 2025
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.
0 comentarios
Ver también
Categorías
Más información sobre Problem-Based Optimization Setup en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!