Function based parameter optimization (for musculotendon parameters)
- Pasha van Bijlert
- Posts: 234
- Joined: Sun May 10, 2020 3:15 am
Function based parameter optimization (for musculotendon parameters)
Hi all,
I was inspired by Oliver's thread about mocoParameters, but decided to start this separate thread because I don't think they're fully related.
I've been interested in doing parameter optimizations for the musculotendon parameters for a while now. However, as I understand it, it is currently not possible to couple parameters to each other. E.g., you could optimize F_max and L0 for each muscle, but you can't keep F_max * L0 = constant. The logical conclusion will be that the optimal solution maximizes both F_max and L0, adding free mass muscle mass to the model (possibly limited by some arbitrary weighting).
Nick - I was wondering how best to submit this as a feature request? Should I add it onto the Github issue for parameter regulization? Or should I add this separately? In my head, it would work something like a constraint on the parameters (perhaps "mocoParameterProductConstraint" or "mocoParameterProductFunction"?). In this case, I'd like to be able to define two parameters whose product must always remain constant - this would enable the user to optimize force-generating parameters without adding muscle mass (e.g., MocoParameterProductConstraint(par1, par2)). If it would help this cause, I can try to workshop something in Matlab. I think this is also somewhat related to Oliver's request, e.g., in his example he could use this to try coupling the contact sphere radius to the plain strain modulus (since in the contact model, these are both combined to get an effective stiffness, although they aren't both linearly proportional in the same way that F_max & L0 are to muscle mass).
I saw a Github issue that combined functions of outputs are being tested as a goal in Moco (which is very exciting, I can think of at least one project where I'd like to try this out). This seems to be somewhat related to function-based parameter optimizations.
Cheers,
Pasha
I was inspired by Oliver's thread about mocoParameters, but decided to start this separate thread because I don't think they're fully related.
I've been interested in doing parameter optimizations for the musculotendon parameters for a while now. However, as I understand it, it is currently not possible to couple parameters to each other. E.g., you could optimize F_max and L0 for each muscle, but you can't keep F_max * L0 = constant. The logical conclusion will be that the optimal solution maximizes both F_max and L0, adding free mass muscle mass to the model (possibly limited by some arbitrary weighting).
Nick - I was wondering how best to submit this as a feature request? Should I add it onto the Github issue for parameter regulization? Or should I add this separately? In my head, it would work something like a constraint on the parameters (perhaps "mocoParameterProductConstraint" or "mocoParameterProductFunction"?). In this case, I'd like to be able to define two parameters whose product must always remain constant - this would enable the user to optimize force-generating parameters without adding muscle mass (e.g., MocoParameterProductConstraint(par1, par2)). If it would help this cause, I can try to workshop something in Matlab. I think this is also somewhat related to Oliver's request, e.g., in his example he could use this to try coupling the contact sphere radius to the plain strain modulus (since in the contact model, these are both combined to get an effective stiffness, although they aren't both linearly proportional in the same way that F_max & L0 are to muscle mass).
I saw a Github issue that combined functions of outputs are being tested as a goal in Moco (which is very exciting, I can think of at least one project where I'd like to try this out). This seems to be somewhat related to function-based parameter optimizations.
Cheers,
Pasha
- Nicholas Bianco
- Posts: 1078
- Joined: Thu Oct 04, 2012 8:09 pm
Re: Function based parameter optimization (for musculotendon parameters)
Hi Pasha,
I think it's possible to have one solution for both use cases. I'm wondering if something like a "MocoExpressionBasedParameterGoal" would make sense here. You could point to a parameter in the model/problem, and write an expression (similar to classes like ExpressionBasedCoordinateForce) to dictate how it's minimized or constrained.
-Nick
I think it's possible to have one solution for both use cases. I'm wondering if something like a "MocoExpressionBasedParameterGoal" would make sense here. You could point to a parameter in the model/problem, and write an expression (similar to classes like ExpressionBasedCoordinateForce) to dictate how it's minimized or constrained.
-Nick
- Pasha van Bijlert
- Posts: 234
- Joined: Sun May 10, 2020 3:15 am
Re: Function based parameter optimization (for musculotendon parameters)
Hi Nick
That type of implementation would be super useful, I think! I guess for it to work for a musculotendon parameter optimization, it would have to be possible to write an expression using 2 (or more) parameters, although I don't know how challenging that would be to implement.
Best wishes,
Pasha
That type of implementation would be super useful, I think! I guess for it to work for a musculotendon parameter optimization, it would have to be possible to write an expression using 2 (or more) parameters, although I don't know how challenging that would be to implement.
Best wishes,
Pasha
- Nicholas Bianco
- Posts: 1078
- Joined: Thu Oct 04, 2012 8:09 pm
Re: Function based parameter optimization (for musculotendon parameters)
We've created the following issue to track this feature request: https://github.com/opensim-org/opensim-core/issues/3860.
It shouldn't be too difficult to implement.
It shouldn't be too difficult to implement.
- Pasha van Bijlert
- Posts: 234
- Joined: Sun May 10, 2020 3:15 am
Re: Function based parameter optimization (for musculotendon parameters)
Hi Nick,
Cool, thank you! I'll keep an eye on that GH issue! Presumably even though the Issue title says "minimizing" of parameter values, it also includes constraining them instead of minimizing them?
Cheers,
Pasha
Cool, thank you! I'll keep an eye on that GH issue! Presumably even though the Issue title says "minimizing" of parameter values, it also includes constraining them instead of minimizing them?
Cheers,
Pasha
- Nicholas Bianco
- Posts: 1078
- Joined: Thu Oct 04, 2012 8:09 pm
Re: Function based parameter optimization (for musculotendon parameters)
Hi Pasha,
Yes, we will make it a MocoGoal, with options to use it as a cost term or endpoint constraint.
Best,
Nick
Yes, we will make it a MocoGoal, with options to use it as a cost term or endpoint constraint.
Best,
Nick
- Pasha van Bijlert
- Posts: 234
- Joined: Sun May 10, 2020 3:15 am
Re: Function based parameter optimization (for musculotendon parameters)
Hi Nick,
I'll be excited to try it out! I think in situations where we're not too sure about the muscle architecture (but are confident about the muscle mass), this would be a cool feature to have. There are also many other applications of such a customizable goal.
Best wishes,
Pasha
I'll be excited to try it out! I think in situations where we're not too sure about the muscle architecture (but are confident about the muscle mass), this would be a cool feature to have. There are also many other applications of such a customizable goal.
Best wishes,
Pasha
- Pasha van Bijlert
- Posts: 234
- Joined: Sun May 10, 2020 3:15 am
Re: Function based parameter optimization (for musculotendon parameters)
Hi Nick,
I think my current project could make use of parameter optimizations, so I'm trying to familiarize myself with the syntax. The documentation of MocoParameter says "By specifying multiple component paths, you can optimize the same property in multiple components (each property will have the same value, as determined by this parameter)." Just so I'm not getting confused, does this mean that if I define my parameter, and then define both the left and right sides of a component in the component path, and then the property name, both left and right sides get the same optimized value?
i.e.:
enforces a symmetric parameter optimization of soleus TSL?
I also think there might be a typo in the example on the documentation page, I think "p0.setParameterName("mass");" should be "p0.setPropertyName("mass")", but I'm not sure.
I'm working on a project where using a MocoExpressionBasedParameterGoal might be interesting to try, and going by this github issue, it exists somewhere in one of the experimental builds, is that correct?
Cheers,
Pasha
I think my current project could make use of parameter optimizations, so I'm trying to familiarize myself with the syntax. The documentation of MocoParameter says "By specifying multiple component paths, you can optimize the same property in multiple components (each property will have the same value, as determined by this parameter)." Just so I'm not getting confused, does this mean that if I define my parameter, and then define both the left and right sides of a component in the component path, and then the property name, both left and right sides get the same optimized value?
i.e.:
Code: Select all
param = MocoParameter
param.setName('soleus_TSL')
param.appendComponentPath('/forceset/soleus_r')
param.appendComponentPath('/forceset/soleus_l')
param.setPropertyName('tendon_slack_length')
param.setBounds(MocoBounds(0.4, 0.5))
problem.addParameter(param)
I also think there might be a typo in the example on the documentation page, I think "p0.setParameterName("mass");" should be "p0.setPropertyName("mass")", but I'm not sure.
I'm working on a project where using a MocoExpressionBasedParameterGoal might be interesting to try, and going by this github issue, it exists somewhere in one of the experimental builds, is that correct?
Cheers,
Pasha
- Nicholas Bianco
- Posts: 1078
- Joined: Thu Oct 04, 2012 8:09 pm
Re: Function based parameter optimization (for musculotendon parameters)
Hi Pasha,
Best,
Nick
That is correct!enforces a symmetric parameter optimization of soleus TSL?
Good catch! I will file an issue.I also think there might be a typo in the example on the documentation page, I think "p0.setParameterName("mass");" should be "p0.setPropertyName("mass")", but I'm not sure.
MocoExpressionBasedParameterGoal has been merged, so if you can create a build from source, you will have access to it.I'm working on a project where using a MocoExpressionBasedParameterGoal might be interesting to try, and going by this github issue, it exists somewhere in one of the experimental builds, is that correct?
Best,
Nick
- Pasha van Bijlert
- Posts: 234
- Joined: Sun May 10, 2020 3:15 am
Re: Function based parameter optimization (for musculotendon parameters)
Hi Nick,
Thank you! I've tried adding two MocoParameters (for two pairs of muscles) using a version of the code I posted, trying to optimize tendon_slack_length while tracking kinematic data. The iteration time is 60x slower (from 8s/iteration to 8 minutes per iteration). Is this expected, or is there a change I've done something wrong and should I terminate the optimization? For reference: the model is a version of my emu model, and it's tuned well enough for pure predictive simulations.
Cheers,
Pasha
Thank you! I've tried adding two MocoParameters (for two pairs of muscles) using a version of the code I posted, trying to optimize tendon_slack_length while tracking kinematic data. The iteration time is 60x slower (from 8s/iteration to 8 minutes per iteration). Is this expected, or is there a change I've done something wrong and should I terminate the optimization? For reference: the model is a version of my emu model, and it's tuned well enough for pure predictive simulations.
In the past I've downloaded an experimental build as a zip from github, is that creating a build from source?MocoExpressionBasedParameterGoal has been merged, so if you can create a build from source, you will have access to it.
Cheers,
Pasha