Calling multiple instances of OpenSim from MATLAB

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Michael Rosenberg
Posts: 6
Joined: Sat Oct 03, 2015 12:07 pm

Calling multiple instances of OpenSim from MATLAB

Post by Michael Rosenberg » Thu Jun 23, 2016 10:04 pm

I am running a batch of OpenSim Static Optimization jobs via MATLAB using eval():

Code: Select all

evalstring = sprintf('!analyze -S %s', fullPath)
        eval(evalstring);
The number of jobs is sufficiently large that I would like to run multiple jobs simultaneously. I think that I can do this using parallel processing only on MATLAB's end. Rather than dive into the OpenSim API, I want to call multiple instances of OpenSim from MATLAB. That is, run distinct jobs (unique filenames) simultaneously on separate OpenSim instances. However, I have not found a way to call multiple OpenSim instances.The link below is the best example, that I have found, of what I am hoping to do.

http://www.femm.info/wiki/MultipleInstancesInMatlab

If this is feasible can someone provide some guidance on how to call these separate instances?

Thanks!

User avatar
jimmy d
Posts: 1375
Joined: Thu Oct 04, 2007 11:51 pm

Re: Calling multiple instances of OpenSim from MATLAB

Post by jimmy d » Wed Jul 20, 2016 10:36 am

I have used Matlabs parfor to run jobs in parallel. Though, you will need the specific toolbox.

User avatar
Michael Rosenberg
Posts: 6
Joined: Sat Oct 03, 2015 12:07 pm

Re: Calling multiple instances of OpenSim from MATLAB

Post by Michael Rosenberg » Thu Aug 18, 2016 5:01 pm

Thanks for the feedback. I have the Parallel Computing toolbox, and got the 'parfor' method functioning. I want to run analyze.exe for two .osim models in parallel. Below is some pseudocode:

Code: Select all

parpool('local',2);
parfor subjects 1 & 2
	Modify .OSIM & Setup files
	
	% Run static optimization
	evalstring = sprintf('!analyze -S %s', fullPath)
        eval(evalstring);
end


I run into the problem that each simulation only gets through about 10 time points (~10% of the full simulation). I think that this is because only one instance of analyze.exe gets called, and ends the analyze.exe instance that it running just prior. Can you explain a bit more about how you got the parfor loop to work?

User avatar
Michael Rosenberg
Posts: 6
Joined: Sat Oct 03, 2015 12:07 pm

Re: Calling multiple instances of OpenSim from MATLAB

Post by Michael Rosenberg » Fri Aug 19, 2016 9:24 am

Please ignore my last reply. A night's rest was all I needed to work out the issue. Everything works fine now. Thanks again for your help!

POST REPLY