Questions about Parallel Computing and Custom uneven time grid nodes

OpenSim Moco is a software toolkit to solve optimal control problems with musculoskeletal models defined in OpenSim using the direct collocation method.
POST REPLY
User avatar
Matthew Lee
Posts: 52
Joined: Sat Jun 20, 2020 7:46 pm

Questions about Parallel Computing and Custom uneven time grid nodes

Post by Matthew Lee » Sun Feb 19, 2023 7:28 am

Dear Moco development team and Moco users,

Thank you all for your contributions to the biomechanics community! I have some questions about Parallel Computing and Custom uneven time grid nodes in Moco, I would appreciate it if anyone could give me some advice.

1. If I want to run N (N>20) independent Moco predictive problems in parallel in only one Matlab or Python terminal, and each Moco predictive problem uses all the cores of the computer (the number of cores = 6) for parallel computing (ie, solver.set_parallel(1)). Under this condition,parallel computing exists inside each Moco calculation problem and in the outer loop which used to run multiple Moco calculation problems. (For example, when using parfor in Matlab to run multiple Moco cases in parallel, the setting of MocoCasADiSolver in each Moco case is solver.set_parallel(1)).My questions are:

1).Will this situation cause problems such as data confusion when different Moco calculation problems are running in parallel?
2).Is the result obtained for each Moco problem under this condition the same as running multiple Moco problems in series(Regardless of whether the outer layer used to run multiple Moco problems is parallel or serial,MocoCasADiSolver is always set to solver.set_parallel(1))?

2. When using the trapezoidal algorithm or the hermite-simpson algorithm for transcription in Moco, is it possible to customize the time grid nodes with uneven mesh intervals for discretization?

Best Wishes,
Matthew

User avatar
Nicholas Bianco
Posts: 980
Joined: Thu Oct 04, 2012 8:09 pm

Re: Questions about Parallel Computing and Custom uneven time grid nodes

Post by Nicholas Bianco » Sun Feb 19, 2023 1:03 pm

Hello (again) Matthew,

1. I wouldn't recommend this approach. The Moco problems won't interfere with each other, but since all will be accessing resources from all cores on your machine, you will probably see poor performance. With only 6 cores (12 threads), you probably don't want that many problems running simultaneously. Maybe 2-4 would be fine, and you could use all threads for each problem, or divide up the available threads across the problems. Lastly, you don't need parfor to run multiple problems simultaneously. and it won't provide you any computational benefit. Just create separate terminal instances for each problem.

2. No, this is not currently supported in Moco.

Best,
Nick

POST REPLY