Running Static Optimization in Matlab?
- Dennis Anderson
- Posts: 6
- Joined: Fri Aug 01, 2008 5:12 am
Running Static Optimization in Matlab?
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
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?
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
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
- Alexander Bruno
- Posts: 7
- Joined: Mon Mar 07, 2011 5:03 pm
Re: Running Static Optimization in Matlab?
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
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
- Míriam Febrer-Nafría
- Posts: 26
- Joined: Thu Apr 18, 2013 4:14 am
Re: Running Static Optimization in Matlab?
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
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?
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
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
- Alexander Bruno
- Posts: 7
- Joined: Mon Mar 07, 2011 5:03 pm
Re: Running Static Optimization in Matlab?
Thanks James, that did the trick. It seems to be working for me now.
-Alex
-Alex
- Dennis Anderson
- Posts: 6
- Joined: Fri Aug 01, 2008 5:12 am
Re: Running Static Optimization in Matlab?
Thank you James, this is exactly what we were trying to figure out. I really appreciate the help!
- John Rogers
- Posts: 45
- Joined: Fri Feb 24, 2012 11:47 am
Re: Running Static Optimization in Matlab?
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
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?
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
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
- William Edwards
- Posts: 3
- Joined: Sun Dec 02, 2007 12:29 am
Re: Running Static Optimization in Matlab?
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
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