Page 1 of 1

Inverse Kinematics...implementation

Posted: Thu Dec 13, 2012 3:03 pm
by ambaus
Hello,

I am comparing hip kinematics calculated from the inverse kinematics tool of OpenSim and using custom C code with the SIMM dynamics pipeline. Both are solving the same optimization problem (sum of weighted errors squared). However, I get slightly different results. I think this may be in how the optimization problem is solved. How does OpenSim numerically solve the minimization problem?

Thanks,

Anne Schmitz

Re: Inverse Kinematics...implementation

Posted: Tue Dec 18, 2012 2:27 pm
by aseth
You are likely correct that our optimization algorithms are not the same. In OpenSim/Simbody the inverse kinematics solver uses different optimization algorithms depending on the problem. If the solver has an unconstrained problem with unbounded coordinates it uses the LBFGS [1] method. If the problem is unconstrained but bounded (most common case, where the coordinate is limited to predefined range) then the solver uses the LBFGSB method [2]. Finally, if there are kinematic constraints that must be enforced, those constraints are included and the system is solved using an Interior Point algorithm, IPOPT [3].

It would be interesting to know whether or not the marker errors are the same. Have you compared marker errors?

[1] D. Liu and J. Nocedal, "On the limited memory BFGS method for large scale optimization", Mathematical Programming B 45 (1989) 503-528.

[2] R. H. Byrd, P. Lu, J. Nocedal and C. Zhu, "A limited memory algorithm for bound constrained optimization'', SIAM J. Scientific Computing 16 (1995), no. 5, pp. 1190--1208.

[3] Wächter and L. T. Biegler, "On the Implementation of a Primal-Dual Interior Point Filter Line Search Algorithm for Large-Scale Nonlinear Programming", Mathematical Programming 106(1), pp. 25-57, 2006

Re: Inverse Kinematics...implementation

Posted: Tue Dec 18, 2012 3:25 pm
by bogert
As far as I know, SIMM's inverse kinematic solver uses a Levenberg-Marquardt algorithm (http://www.netlib.org/minpack/lmdif.f) so it could solve fast enough for real time applications.

If you use the exact same model, the same marker placements, and the same least-squares criterion in Opensim, without constraints or bounds, its LBFGS solver should find exactly the same answer as SIMM's LM solver. It may be take more (or fewer) iterations because the Hessian matrix is estimated differently. The Hessian matrix does not affect the answer, it only affects the speed of convergence of the optimization algorithm. A small difference between results could still happen if the minimum is shallow (i.e. the fit is poor) and/or the stopping criterion is not very strict.

When you have active constraints or bounds, a different model, different marker set, or different weighting of markers in the least-squares function, it would not be surprising to get different results between SIMM and Opensim. If the results are still similar enough, this would reassure you that the results are not sensitive to the model setup and to the details of the inverse kinematic analysis.

Ton van den Bogert

Re: Inverse Kinematics...implementation

Posted: Sat Apr 09, 2016 8:34 pm
by iman_n63
aseth wrote:You are likely correct that our optimization algorithms are not the same. In OpenSim/Simbody the inverse kinematics solver uses different optimization algorithms depending on the problem. If the solver has an unconstrained problem with unbounded coordinates it uses the LBFGS [1] method. If the problem is unconstrained but bounded (most common case, where the coordinate is limited to predefined range) then the solver uses the LBFGSB method [2]. Finally, if there are kinematic constraints that must be enforced, those constraints are included and the system is solved using an Interior Point algorithm, IPOPT [3].

It would be interesting to know whether or not the marker errors are the same. Have you compared marker errors?

[1] D. Liu and J. Nocedal, "On the limited memory BFGS method for large scale optimization", Mathematical Programming B 45 (1989) 503-528.

[2] R. H. Byrd, P. Lu, J. Nocedal and C. Zhu, "A limited memory algorithm for bound constrained optimization'', SIAM J. Scientific Computing 16 (1995), no. 5, pp. 1190--1208.

[3] Wächter and L. T. Biegler, "On the Implementation of a Primal-Dual Interior Point Filter Line Search Algorithm for Large-Scale Nonlinear Programming", Mathematical Programming 106(1), pp. 25-57, 2006

Hello,
I could not use LBFGS, PARAMOPT, IMDIF and LAPACK optimizers in CMC part of Opensim 3.1,
The software made an error like this one: "CMCTool: ERROR- Unrecognized optimizer algorithm: 'LBFGS'"
If there is any necessary dll files for these optimizers please help me to find them.
Thanks

Re: Inverse Kinematics...implementation

Posted: Thu Sep 07, 2017 7:05 am
by antoinefalisse
Hi,

I would like to know which optimizer is used when solving inverse kinematics in OpenSim 3.3. I found this post on the forum but I would like to make sure it is still up to date.

"In OpenSim/Simbody the inverse kinematics solver uses different optimization algorithms depending on the problem. If the solver has an unconstrained problem with unbounded coordinates it uses the LBFGS [1] method. If the problem is unconstrained but bounded (most common case, where the coordinate is limited to predefined range) then the solver uses the LBFGSB method [2]. Finally, if there are kinematic constraints that must be enforced, those constraints are included and the system is solved using an Interior Point algorithm, IPOPT [3]."

If I am right, this means that when using the gait2392 model (predefined ranges for coordinates) and without specifying any kinematic constraints then LBFGSB is selected.

Many thanks!

Re: Inverse Kinematics...implementation

Posted: Thu Sep 07, 2017 10:07 am
by chrisdembia
Here's a comment in the Simbody source code for the Assembler that might be helpful:
// Optimizer will choose LBFGS for unconstrained (or just bounds-constrained)
// problems, InteriorPoint for constrained problems.
https://github.com/simbody/simbody/blob ... r.cpp#L754

It still might be the case that LBFGSB is used if there are bounds constraints, and that the comment was using "LBFGS" to mean either "LBFGS" or "LBFGSB." (see https://github.com/simbody/simbody/blob ... r.cpp#L133).

Re: Inverse Kinematics...implementation

Posted: Fri Sep 08, 2017 6:21 am
by antoinefalisse
Thanks Chris!

Re: Inverse Kinematics...implementation

Posted: Sun Jun 25, 2023 2:47 pm
by vigneshrk
Hi,

I am sorry to reopen this issue but I am looking into residual errors and would like to understand the optimisation algortihms further. Specifically the comments made by Ajay: "It would be interesting to know whether or not the marker errors are the same. Have you compared marker errors?"

1) Has anyone analysed whether marker errors remain the same?
2) If I use a free joint with bounds compared to a ball joint, I am assuming the algorithm shifts from LBFGSB to IPOPT. Does this mean comparing residual errors between the two should not be done? How does the algorithm used change marker residuals?
3) Building on the second question, how would the marker residuals in Moco track vary?

Thanks
Vignesh