Hi,
If I script in Matlab and want to change the objective function in static optimization or CMC for a gait simulation, what would be the best way to do it?
Thanks!
Xiao
Change objective function in static optimization or CMC?
- Adrian Lai
- Posts: 46
- Joined: Tue Mar 13, 2012 11:33 am
Re: Change objective function in static optimization or CMC?
Hi Xiao,
I also wanted to change the cost function in OpenSim but unfortunately, it is embedded in source code.
A possible alternative method, which I have got to work in Matlab, is to use an optimal control approach such as direct collocation to run the optimisation outside of the OpenSim framework. See Freidl De Groote's simTK project (https://simtk.org/frs/?group_id=1096)
I also wanted to change the cost function in OpenSim but unfortunately, it is embedded in source code.
A possible alternative method, which I have got to work in Matlab, is to use an optimal control approach such as direct collocation to run the optimisation outside of the OpenSim framework. See Freidl De Groote's simTK project (https://simtk.org/frs/?group_id=1096)
- Dimitar Stanev
- Posts: 1096
- Joined: Fri Jan 31, 2014 5:14 am
Re: Change objective function in static optimization or CMC?
Hi Xiao,
Another approach would be to implement you own ActuatorForceTarget (see the available target classes):
https://github.com/opensim-org/opensim- ... nSim/Tools
Then you can use the CMC class and provide it with you optimization target:
https://github.com/opensim-org/opensim- ... C.cpp#L258
Probably you will have to change a couple of things in CMC.cpp and CMCTool.cpp so that the new target will be exposed. Then you build OpenSim and link it to your application.
Best
Another approach would be to implement you own ActuatorForceTarget (see the available target classes):
https://github.com/opensim-org/opensim- ... nSim/Tools
Then you can use the CMC class and provide it with you optimization target:
https://github.com/opensim-org/opensim- ... C.cpp#L258
Probably you will have to change a couple of things in CMC.cpp and CMCTool.cpp so that the new target will be exposed. Then you build OpenSim and link it to your application.
Best
- Daniel McFarland
- Posts: 3
- Joined: Mon Aug 25, 2014 5:57 pm
Re: Change objective function in static optimization or CMC?
Hi,
I'm implementing my own ActuatorForceTarget like Dimitar suggests. My goal is to add a penalty term to the optimization to force the JRF within the glenoid. The code compiles and runs with my OpenSim build, but I'm having convergence issues within the optimization.
The original ActuatorForceTarget is set up as a linear least sqaures problem with precomputed preformance matrices in the prepareToOptimize function. I've found a penalty term that will converge with this, but the term has to be pretty small and doesn't guarantee the JRF is within the glenoid. And I'm not sure if adding a penalty term in the objective function after the preformance matrices are already calculated is the best idea?
On the other hand if performance is calculated explicitly in the objective function, the optimization does not converge even without adding a penalty term. I've tried different convergence tolerances from .0001 to .1,but I still am running into this issue. Any ideas why this might be happening?
Thanks!
Daniel
I'm implementing my own ActuatorForceTarget like Dimitar suggests. My goal is to add a penalty term to the optimization to force the JRF within the glenoid. The code compiles and runs with my OpenSim build, but I'm having convergence issues within the optimization.
The original ActuatorForceTarget is set up as a linear least sqaures problem with precomputed preformance matrices in the prepareToOptimize function. I've found a penalty term that will converge with this, but the term has to be pretty small and doesn't guarantee the JRF is within the glenoid. And I'm not sure if adding a penalty term in the objective function after the preformance matrices are already calculated is the best idea?
On the other hand if performance is calculated explicitly in the objective function, the optimization does not converge even without adding a penalty term. I've tried different convergence tolerances from .0001 to .1,but I still am running into this issue. Any ideas why this might be happening?
Thanks!
Daniel