Hi all,
In most simulations that most of us do in Moco, the variables that are optimized (i.e. the "design variables) all vary over a range of approximately [-1, +1], for example muscle excitations, muscle activations, CC lengths, normalized SEC forces, joint angles in radians, etc.
In a current simulation, I have one variable, stiffness of a spring, whose range is much larger in magnitude, about [10,000, 30,000].
Is this bad for convergence? Is it better to have it such that all variables in the solution space are optimized/searched for over approximately the same range?
Ross
Range of design variables
- Ross Miller
- Posts: 375
- Joined: Tue Sep 22, 2009 2:02 pm
Range of design variables
Last edited by Ross Miller on Mon Nov 06, 2023 11:39 am, edited 1 time in total.
- Ton van den Bogert
- Posts: 166
- Joined: Thu Apr 27, 2006 11:37 am
Re: Range of design variables
Ross,
In my experience, it can make a large difference. I once spent two weeks trying to find an error in my code, when an optimization problem would not solve. Turned out my code was correct after all, I just needed to change my force units to kN and it solved immediately.
I don't know if this is generally the case, but to be safe, it is a good idea to scale the problem well. Gradient-based optimization methods are all based on Newton's method, and are developed and tested by mathematicians who never think about units.
Ton van den Bogert
In my experience, it can make a large difference. I once spent two weeks trying to find an error in my code, when an optimization problem would not solve. Turned out my code was correct after all, I just needed to change my force units to kN and it solved immediately.
I don't know if this is generally the case, but to be safe, it is a good idea to scale the problem well. Gradient-based optimization methods are all based on Newton's method, and are developed and tested by mathematicians who never think about units.
Ton van den Bogert
- Nicholas Bianco
- Posts: 1041
- Joined: Thu Oct 04, 2012 8:09 pm
Re: Range of design variables
Hi Ross,
I find this blog post from the CasADi developers on the topic of NLP scaling helpful: https://web.casadi.org/blog/nlp-scaling/.
Last year we added to Moco support for automatic variable scaling when using CasADi solver via the 'scaling_variables_using_bounds' property:
Give it a try and see if it helps with convergence in your problem.
Best,
Nick
I find this blog post from the CasADi developers on the topic of NLP scaling helpful: https://web.casadi.org/blog/nlp-scaling/.
Last year we added to Moco support for automatic variable scaling when using CasADi solver via the 'scaling_variables_using_bounds' property:
Code: Select all
solver = study.initCasADiSolver();
solver.set_scale_variables_using_bounds(true);
Best,
Nick
- Ross Miller
- Posts: 375
- Joined: Tue Sep 22, 2009 2:02 pm
Re: Range of design variables
Thanks both! That is a nice new feature.