Static Optimization in Matlab

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
francesca bottin
Posts: 6
Joined: Tue Mar 26, 2019 1:06 pm

Static Optimization in Matlab

Post by francesca bottin » Fri Jan 14, 2022 12:57 am

Hi everyone,
I am running Static Optimization with the Matlab API. In my simulations, I have to increase the external force to find the value at which SO fails. Is there a way to automatically get if SO failed or not as an output, without manually reading the command window at each simulation?

Thanks in advance,
Francesca

Tags:

User avatar
Thomas Uchida
Posts: 1793
Joined: Wed May 16, 2012 11:40 am

Re: Static Optimization in Matlab

Post by Thomas Uchida » Fri Jan 14, 2022 5:33 am

You should also be able to retrieve this information by checking the out.log and err.log files (renamed to opensim.log as of v4.2; see https://simtk-confluence.stanford.edu:8 ... d=48988768). To detect a certain behavior automatically, you could load this file and search for a particular string.

User avatar
John Davis
Posts: 59
Joined: Mon Aug 26, 2019 7:42 am

Re: Static Optimization in Matlab

Post by John Davis » Sun Jan 16, 2022 9:45 pm

I have a small MATLAB script that I've developed for exactly this purpose. I put together a demo repository on GitHub that uses the Rajagopal 2015 data and my log parsing function, you can check it out here.

It uses the new Logger() class so I think it will only work in OpenSim 4.3+. You can set the file name of the log to correspond to whatever file you are processing, then the function outputs a processed .csv with a column indicating which timestamps, if any, static optimization failed. It should be pretty easy to adapt for your purposes!

User avatar
francesca bottin
Posts: 6
Joined: Tue Mar 26, 2019 1:06 pm

Re: Static Optimization in Matlab

Post by francesca bottin » Mon Jan 17, 2022 10:20 am

Thanks for the replies.
@John Davis, thank you for sharing the script. I converted my code to 4.3, adapted your script to my case and it worked!

POST REPLY