Page 1 of 1

Change objective function in static optimization or CMC?

Posted: Thu Sep 28, 2017 7:32 pm
by schumi00
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

Re: Change objective function in static optimization or CMC?

Posted: Fri Sep 29, 2017 8:23 am
by adrianlai88
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)

Re: Change objective function in static optimization or CMC?

Posted: Fri Sep 29, 2017 11:00 am
by mitkof6
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

Re: Change objective function in static optimization or CMC?

Posted: Sun Nov 12, 2017 10:54 am
by dafarla
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