Page 1 of 2
Running Static Optimization in Matlab?
Posted: Mon Jan 13, 2014 1:49 pm
by dennisa
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
Re: Running Static Optimization in Matlab?
Posted: Wed Jan 29, 2014 11:01 am
by jimmy
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
Re: Running Static Optimization in Matlab?
Posted: Thu Jan 30, 2014 5:49 pm
by agbruno
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
Re: Running Static Optimization in Matlab?
Posted: Fri Jan 31, 2014 4:56 am
by miriamfebrer
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
Re: Running Static Optimization in Matlab?
Posted: Fri Jan 31, 2014 9:44 am
by jimmy
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
Re: Running Static Optimization in Matlab?
Posted: Fri Jan 31, 2014 10:32 am
by agbruno
Thanks James, that did the trick. It seems to be working for me now.
-Alex
Re: Running Static Optimization in Matlab?
Posted: Fri Jan 31, 2014 2:15 pm
by dennisa
Thank you James, this is exactly what we were trying to figure out. I really appreciate the help!
Re: Running Static Optimization in Matlab?
Posted: Sun Mar 29, 2015 12:56 pm
by resodad
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
Re: Running Static Optimization in Matlab?
Posted: Tue Mar 31, 2015 2:55 pm
by jimmy
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
Re: Running Static Optimization in Matlab?
Posted: Fri Nov 18, 2016 5:13 pm
by edwards9
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