Change objective function in static optimization or CMC?

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Xiao Hu
Posts: 21
Joined: Fri Jun 26, 2009 9:25 am

Change objective function in static optimization or CMC?

Post by Xiao Hu » Thu Sep 28, 2017 7:32 pm

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

User avatar
Adrian Lai
Posts: 46
Joined: Tue Mar 13, 2012 11:33 am

Re: Change objective function in static optimization or CMC?

Post by Adrian Lai » Fri Sep 29, 2017 8:23 am

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)

User avatar
Dimitar Stanev
Posts: 1096
Joined: Fri Jan 31, 2014 5:14 am

Re: Change objective function in static optimization or CMC?

Post by Dimitar Stanev » Fri Sep 29, 2017 11:00 am

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

User avatar
Daniel McFarland
Posts: 3
Joined: Mon Aug 25, 2014 5:57 pm

Re: Change objective function in static optimization or CMC?

Post by Daniel McFarland » Sun Nov 12, 2017 10:54 am

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

POST REPLY