- 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 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
Raymond Norris
2025 年 2 月 25 日
回答 (1 件)
Abhishek
2025 年 6 月 27 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Problem-Based Optimization Setup についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!