Use parallel computing with particleswarm

2 views (last 30 days)
Hello,
I would like to use parallel computing with particleswarm to try if I can improve the speed of the optimization. The function to optimize needs to write in a simulink model (optimization of parameters). When I am trying to use parallel computing I got an error saying that I can't write the new parameters in the simulink file because the permission is denied. Is it due to the fact that I have only 1 file and that the workers are trying to write parameters in the file at the same time? How can I use properly the parallel computing?
Thank you in advance,

Accepted Answer

arushi
arushi on 6 Aug 2024
Hi Lucas,
When using parallel computing with particleswarm in MATLAB to optimize parameters in a Simulink model, you might encounter issues related to file access permissions. This is because multiple workers (parallel processes) might try to access and modify the same Simulink model file simultaneously, leading to conflicts.The error you're encountering is likely due to concurrent access to the Simulink model file. When multiple workers attempt to write to the same file at the same time, it causes file access conflicts, resulting in permission denied errors. You can follow these steps:
  1. Create a Copy of the Simulink Model for Each Worker: Each parallel worker should have its own copy of the Simulink model to avoid conflicts. This can be done by creating temporary copies of the model in each worker's workspace.
  2. Use parfor or parfeval for Parallel Execution: Ensure that the optimization process is correctly parallelized using parfor or parfeval.
  3. Clean Up Temporary Files: After the optimization is complete, clean up any temporary files created during the process.
Hope this helps.

More Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!