Grid convergence study
Posted: Thu May 14, 2020 6:26 pm
Update in Post 7
I wanted to share some results from a grid sensitivity test I've been working on lately.
Using a 3D model (31 DoF, 84 muscles), I did a tracking simulation of a stride of walking, tracking mean human experimental kinematics and GRF for walking at average speed 1.45 m/s. The cost function was the weighted sum of the state tracking error, contact (GRF) tracking error, control effort (u^2), deviation of the torso from the global axes, and the auxiliary derivatives. The latter term is the tendon force "yanks" and is in there only because it has to be to use the implicit muscle formulation (I guess it could also be considered a "smoothness" criterion of sorts) and has a very light weight. The multibody dynamics are explicit. I haven't found an advantage to using the implicit multibody dynamics in Moco yet.
I ran the simulation several times with different grid densities. The "grid" here ("mesh" in Moco solver settings) is the discretization of the movement time, defining the timestep separating the nodal values at which the problem is evaluated. In Moco you set the grid density in the solver: solver.set_num_mesh_intervals(N), where N = number of intervals. The problem (to my understanding) is actually evaluated at nodal values on the ends of these intervals, and the number of nodes depends on the transcription scheme. With the default Hermite-Simpson scheme, the problem is evaluated at 2*N+1 nodes because it creates nodes also in the middle of the intervals. So for example if your simulation is for a time of 1.0 seconds and you use N=50 and Hermite-Simpson transcription, there are 101 nodes and the timestep between nodes is 10 milliseconds.
I started with N=5, which was the coarsest grid I could get convergence on with a reasonable constraint tolerance (1e-4). The initial guess for this simulation was generated using solver.createGuess(). I then took this solution and used it as the initial guess for N=10, then repeated that process for N=25, N=50, N=100, and N=200, each time using the previous solution as the initial guess. Results are in the attached figures.
You can see that there is a massive difference in the solution quality (minimization of cost function) between N=5 and N=10, but beyond N=10 there are only small changes in the cost function score. For this problem, changes in the cost function score on the order of 0.1 are pretty trivial, you would be hard-pressed to look at the videos or time series data of two solutions that differ by 0.1 and tell which is which. The bar graph figure breaks down the scores by the terms in the cost function.
My summary/interpretation: at least for tracking problems of walking data, N=10 or so is sufficient for getting grid-independent results. For publication-quality final results you will probably want to use a finer grid (e.g. at least for cosmetic purposes in figures) but the coarser grid can save a lot of time for evaluating the model, cost function, etc. For comparison, N=10 took a little under two hours to converge on my laptop, while N=50 took over six hours.
I would like to still try some predictive simulations, both of walking and of a much faster movement (running/sprinting). I would expect a faster movement would need a finer grid for grid-independence.
Ross
I wanted to share some results from a grid sensitivity test I've been working on lately.
Using a 3D model (31 DoF, 84 muscles), I did a tracking simulation of a stride of walking, tracking mean human experimental kinematics and GRF for walking at average speed 1.45 m/s. The cost function was the weighted sum of the state tracking error, contact (GRF) tracking error, control effort (u^2), deviation of the torso from the global axes, and the auxiliary derivatives. The latter term is the tendon force "yanks" and is in there only because it has to be to use the implicit muscle formulation (I guess it could also be considered a "smoothness" criterion of sorts) and has a very light weight. The multibody dynamics are explicit. I haven't found an advantage to using the implicit multibody dynamics in Moco yet.
I ran the simulation several times with different grid densities. The "grid" here ("mesh" in Moco solver settings) is the discretization of the movement time, defining the timestep separating the nodal values at which the problem is evaluated. In Moco you set the grid density in the solver: solver.set_num_mesh_intervals(N), where N = number of intervals. The problem (to my understanding) is actually evaluated at nodal values on the ends of these intervals, and the number of nodes depends on the transcription scheme. With the default Hermite-Simpson scheme, the problem is evaluated at 2*N+1 nodes because it creates nodes also in the middle of the intervals. So for example if your simulation is for a time of 1.0 seconds and you use N=50 and Hermite-Simpson transcription, there are 101 nodes and the timestep between nodes is 10 milliseconds.
I started with N=5, which was the coarsest grid I could get convergence on with a reasonable constraint tolerance (1e-4). The initial guess for this simulation was generated using solver.createGuess(). I then took this solution and used it as the initial guess for N=10, then repeated that process for N=25, N=50, N=100, and N=200, each time using the previous solution as the initial guess. Results are in the attached figures.
You can see that there is a massive difference in the solution quality (minimization of cost function) between N=5 and N=10, but beyond N=10 there are only small changes in the cost function score. For this problem, changes in the cost function score on the order of 0.1 are pretty trivial, you would be hard-pressed to look at the videos or time series data of two solutions that differ by 0.1 and tell which is which. The bar graph figure breaks down the scores by the terms in the cost function.
My summary/interpretation: at least for tracking problems of walking data, N=10 or so is sufficient for getting grid-independent results. For publication-quality final results you will probably want to use a finer grid (e.g. at least for cosmetic purposes in figures) but the coarser grid can save a lot of time for evaluating the model, cost function, etc. For comparison, N=10 took a little under two hours to converge on my laptop, while N=50 took over six hours.
I would like to still try some predictive simulations, both of walking and of a much faster movement (running/sprinting). I would expect a faster movement would need a finer grid for grid-independence.
Ross