Running Static Optimization in Matlab?

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
User avatar
Dennis Anderson
Posts: 6
Joined: Fri Aug 01, 2008 5:12 am

Running Static Optimization in Matlab?

Post by Dennis Anderson » Mon Jan 13, 2014 1:49 pm

Hi all,

I am trying to set up and run static optimization from Matlab, but I am having trouble figuring out how to do so: using and editing a static optimization settings file, specifying external loads on the model, running the analysis, etc. I'm assuming this is actually possible, perhaps someone can confirm? It doesn't seem to work in the same way as other analyses, e.g. the InverseKinematicsTool, nor can I find an example where it has been done.

If anyone can post some example code showing how to do this, that would be fantastic!

Thanks,
Dennis

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

Re: Running Static Optimization in Matlab?

Post by jimmy d » Wed Jan 29, 2014 11:01 am

Hi Dennis,

Static Optimization isn't run as a 'tool', which I agree can be confusing. Static Opt is done by running an analysis. You will need to create an analysis object and attach static optimization. The doxygen page for analysis can be found here;
https://simtk.org/api_docs/opensim/api_ ... lysis.html

Hope that helps,
-james

User avatar
Alexander Bruno
Posts: 7
Joined: Mon Mar 07, 2011 5:03 pm

Re: Running Static Optimization in Matlab?

Post by Alexander Bruno » Thu Jan 30, 2014 5:49 pm

Hi James,

I'm also trying to run a Static Optimization Analysis via MatLab scripting. In particular, I'm not sure how to get the 'states' argument that needs to be passed through begin(), step(), and end(). For instance, if I was to run a static optimization analysis using a .mot file, I know how to turn this file into a Storage object, but then I'm confused about how to turn the Storage object into a set of states. I tried passing the Storage object into StaticOptimization.set_statesStore(), but this doesn't seem to provide an output I can use in begin() step() end(). I can get a states argument from model.initSystem(), but this only provides an optimization result for that one state.

I would greatly appreciate any advice you might have on this.

Thanks,
Alex

User avatar
Míriam Febrer-Nafría
Posts: 26
Joined: Thu Apr 18, 2013 4:14 am

Re: Running Static Optimization in Matlab?

Post by Míriam Febrer-Nafría » Fri Jan 31, 2014 4:56 am

Hi,
I'm trying also to run Static Optimization in Matlab, and I have two questions:

1. I don't know how to "attach" an Static Optimization analyses to an Analysis. And when I try to create an Analysis object, I get an error message, the same with different trials:
analisi=Analysis();
analisi=Analysis(model);
analisi=Analysis('C:\OpenSim 3.0\Models\Cirugia articulacio humer\proves matlab\Setup_Analysis.xml');
Error message:
??? No constructor 'org.opensim.modeling.Analysis' with matching signature found.

2. I don't undersatnd the difference between StateVector and State, and I get an error message when I try to declare a variable from class "State"
Error message:
??? Undefined function or variable 'State'.

Thanks,

Miriam Febrer

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

Re: Running Static Optimization in Matlab?

Post by jimmy d » Fri Jan 31, 2014 9:44 am

To run an analysis you will use the AnalyzeTool(). I have attached a Analyze tool setup file to this reply. You will be able to see the different levels of the tool and how to change the properties of it. You can build the tool doing something like;

staticOpt = AnalyzeTool([path 'staticOpt_setup.xml'])

Along with having a static optimization object attached, MuscleAnalysis() is attached to output the muscle states.

Your comments have been helpful and we will try and build some confluence info that will help with this particular tool/analysis.

Let us know how it goes,
-james
Attachments
staticOpt_Setup.xml
Creates an AnalyzeTool() object with a static opt attached
(6.21 KiB) Downloaded 437 times

User avatar
Alexander Bruno
Posts: 7
Joined: Mon Mar 07, 2011 5:03 pm

Re: Running Static Optimization in Matlab?

Post by Alexander Bruno » Fri Jan 31, 2014 10:32 am

Thanks James, that did the trick. It seems to be working for me now.

-Alex

User avatar
Dennis Anderson
Posts: 6
Joined: Fri Aug 01, 2008 5:12 am

Re: Running Static Optimization in Matlab?

Post by Dennis Anderson » Fri Jan 31, 2014 2:15 pm

Thank you James, this is exactly what we were trying to figure out. I really appreciate the help!

User avatar
John Rogers
Posts: 45
Joined: Fri Feb 24, 2012 11:47 am

Re: Running Static Optimization in Matlab?

Post by John Rogers » Sun Mar 29, 2015 12:56 pm

James and all,
This post is helpful, but I still have a question:
I have a metabolic probe set to integrate.
I want to attach an analysis (ProbeReporter) when I run CMC tool.
Do I copy-paste the XML code for the analysis into the CMC setup file?
Thanks,
John

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

Re: Running Static Optimization in Matlab?

Post by jimmy d » Tue Mar 31, 2015 2:55 pm

Hi John-

Yes, you will have to paste the the ProbeReporter into your CMC setup file through xml editing (no GUI method).

The analyzeTool works step by step and therefore can't integrate.

Cheers,
-James

User avatar
William Edwards
Posts: 3
Joined: Sun Dec 02, 2007 12:29 am

Re: Running Static Optimization in Matlab?

Post by William Edwards » Fri Nov 18, 2016 5:13 pm

When attemping static optimization from matlab using the AnalyzeTool approach described above I get the following error message:

analyzeTool.verifyControlsStates: ERROR- a storage object containing the time histories of states was not specified. at org.opensim.modeling.opensimModelJNI.AnalyzeTool_run__SWIG_0(Native Method) at org.opensim.modeling.AnalyzeTool.run(AnalyzeTool.java:154Error using AleenBatch_IK_ID_Opensim (line 127) Java exception occurred: java.io.IOException: analyzeTool.verifyControlsStates: ERROR- a storage object containing the time histories of states was not specified

Any ideas how to deal with this error?

Thanks,

Brent

POST REPLY