I'm wondering if anyone knows of a good way to scale the states controls (and bonus points for kinematic constraint lagrange multipliers) in a MocoProblem? I am working in a branch of the source code but I can't figure out the best place to add in scaling to improve the problem formulation I am working with.
For a few rare parts of OpenSim the answer is not too difficult. Muscles activations and excitations are already scaled [0 1] and many actuators can be scaled by an arbitrary scale factor ("optimal_force") so one can conceivably scale them to the range [-1 1] or [-0.5 0.5] with just that property. However, I do not know of any way to scale coordinate values and most significantly, coordinate speeds and kinematic constraint lagrange multipliers. Meaning you can have a problem with a speed on the order of 1e2 with a position on the scale of 1e-2 and have a seemingly poorly scaled problem.
Is there any way to specify a simple linear scale for variables -- perhaps something hidden in a CasADi class? It would be nice to be able to specify this scaling along with setting the bounds for a state or control i.e.: setStateInfo/setControlInfo/setMultiplierBounds etc.
Optimally, I feel it would be nice for all of the variables (states, controls, lagrange multipliers, etc.) in the NLP to be scaled [1 2] or something like that.
Problem Scaling
- Nicholas Bianco
- Posts: 1057
- Joined: Thu Oct 04, 2012 8:09 pm
Re: Problem Scaling
Hi Tyler,
Problem scaling is a feature that I'd love to have that we haven't fully gotten around to yet. We've played around with it on development branches but never fully implemented it or created examples that showed it's benefit (even though it should certainly improve performance for badly scaled problems).
If you're already in the source code, you can check out the branch "scaling" in the old Moco repo, opensim-moco: https://github.com/opensim-org/opensim- ... ...scaling.
If you want to take a shot at properly implementing scaling, that would be fantastic. I would start by creating a test or example with badly scaled problem and then turning problem scaling on to see the performance improvement. There's a nice example from the CasADi creator that would be a good starting point: https://web.casadi.org/blog/nlp-scaling/.
-Nick
Problem scaling is a feature that I'd love to have that we haven't fully gotten around to yet. We've played around with it on development branches but never fully implemented it or created examples that showed it's benefit (even though it should certainly improve performance for badly scaled problems).
If you're already in the source code, you can check out the branch "scaling" in the old Moco repo, opensim-moco: https://github.com/opensim-org/opensim- ... ...scaling.
If you want to take a shot at properly implementing scaling, that would be fantastic. I would start by creating a test or example with badly scaled problem and then turning problem scaling on to see the performance improvement. There's a nice example from the CasADi creator that would be a good starting point: https://web.casadi.org/blog/nlp-scaling/.
-Nick
- Tyler Morrison
- Posts: 9
- Joined: Wed Nov 06, 2019 7:00 am
Re: Problem Scaling
Nick,
Thank you so much for your reply! That is exceedingly helpful. I was not aware of that branch, but it's the perfect starting place. If I do end up implementing scaling properly to solve one or more of our problems, I will definitely try to contribute it to the project along with the example.
On a related note, if I have contributions, or issues to report or ask about (intermediate trajectory output comes to mind) should I post those here first, to the opensim-moco github, or to the opensim-core github where I see things are starting to get merged?
-Tyler
Thank you so much for your reply! That is exceedingly helpful. I was not aware of that branch, but it's the perfect starting place. If I do end up implementing scaling properly to solve one or more of our problems, I will definitely try to contribute it to the project along with the example.
On a related note, if I have contributions, or issues to report or ask about (intermediate trajectory output comes to mind) should I post those here first, to the opensim-moco github, or to the opensim-core github where I see things are starting to get merged?
-Tyler
- Nicholas Bianco
- Posts: 1057
- Joined: Thu Oct 04, 2012 8:09 pm
Re: Problem Scaling
Sounds good Tyler!
Moco-related forum posts belong on this SimTK forum, but all Moco development now will happen on the opensim-core GitHub. So if you want to submit an issue or PR related to Moco, please to it on that repository. We merged the codebase into opensim-core recently to ease code maintenance and development, but are still keeping the forums separate since the Moco project warrants it's own discussion board.
Moco-related forum posts belong on this SimTK forum, but all Moco development now will happen on the opensim-core GitHub. So if you want to submit an issue or PR related to Moco, please to it on that repository. We merged the codebase into opensim-core recently to ease code maintenance and development, but are still keeping the forums separate since the Moco project warrants it's own discussion board.