Opensim vs Moco optimization algorithm
- Radhakrishnan Vignesh
- Posts: 104
- Joined: Tue Jun 01, 2021 8:09 am
Opensim vs Moco optimization algorithm
Hello,
Hope you are doing well. I have a question regarding the optimization algorithm applied in moco vs opensim.
1) Is there a difference and if yes, what are the key differences?
2) Would the differences affect the residual error being calculated?
Additionally, in the documentation, it was mentioned that moco uses two models (one without constraints and one with constraints ) to calculate multipliers for forces and muscle activations. If my focus is just on residual error, what is the difference between OpenSim's IK and moco's track?
Thanks
Hope you are doing well. I have a question regarding the optimization algorithm applied in moco vs opensim.
1) Is there a difference and if yes, what are the key differences?
2) Would the differences affect the residual error being calculated?
Additionally, in the documentation, it was mentioned that moco uses two models (one without constraints and one with constraints ) to calculate multipliers for forces and muscle activations. If my focus is just on residual error, what is the difference between OpenSim's IK and moco's track?
Thanks
- Nicholas Bianco
- Posts: 1040
- Joined: Thu Oct 04, 2012 8:09 pm
Re: Opensim vs Moco optimization algorithm
Hello Radhakrishnan,
Moco uses direct collocation to solve optimal control problems. This method takes an optimal control problem and converts it to a non-linear program, which can be solved with off-the-shelf solvers like IPOPT.
OpenSim's inverse kinematics solver is also a non-linear optimization problem, but it does not use direct collocation. In the IK problem, the joint angles are the optimization varibles and the cost function is the error between model and experimental markers. IK does not include the model dynamics, so there are no residual forces.
-Nick
Moco uses direct collocation to solve optimal control problems. This method takes an optimal control problem and converts it to a non-linear program, which can be solved with off-the-shelf solvers like IPOPT.
OpenSim's inverse kinematics solver is also a non-linear optimization problem, but it does not use direct collocation. In the IK problem, the joint angles are the optimization varibles and the cost function is the error between model and experimental markers. IK does not include the model dynamics, so there are no residual forces.
-Nick
- Radhakrishnan Vignesh
- Posts: 104
- Joined: Tue Jun 01, 2021 8:09 am
Re: Opensim vs Moco optimization algorithm
Hello Nicholas,
Thanks for your response.
If my focus is just on marker residual errors, would there be a difference between IK and MOCO results? For example, if I do not provide grf data.
Thanks
Vignesh
Thanks for your response.
If my focus is just on marker residual errors, would there be a difference between IK and MOCO results? For example, if I do not provide grf data.
Thanks
Vignesh
- Nicholas Bianco
- Posts: 1040
- Joined: Thu Oct 04, 2012 8:09 pm
Re: Opensim vs Moco optimization algorithm
Hi Radhakrishnan,
Thanks for the clarification. In that case, you can just use inverse kinematics. It will be faster than Moco for just minimize marker errors.
-Nick
Thanks for the clarification. In that case, you can just use inverse kinematics. It will be faster than Moco for just minimize marker errors.
-Nick
- Radhakrishnan Vignesh
- Posts: 104
- Joined: Tue Jun 01, 2021 8:09 am
Re: Opensim vs Moco optimization algorithm
Hi Nick,
Thank yoi. I shall do that. Out of curiosity:
1) Would there be a difference in residual errors calculated using MOCO and IK? From another post, IK uses different solvers based on the constraints and coordinates such as LBFGS, LBFGSB method and IPOPT. There hasnt been any information on how this changes the residual error, so I am curious
Thanks,
vignesh
Thank yoi. I shall do that. Out of curiosity:
1) Would there be a difference in residual errors calculated using MOCO and IK? From another post, IK uses different solvers based on the constraints and coordinates such as LBFGS, LBFGSB method and IPOPT. There hasnt been any information on how this changes the residual error, so I am curious
Thanks,
vignesh
- Nicholas Bianco
- Posts: 1040
- Joined: Thu Oct 04, 2012 8:09 pm
Re: Opensim vs Moco optimization algorithm
You could probably achieve similar marker errors, but would likely get different solutions since the methods are fundamentally different.
With Moco, you would get a "dynamically-consistent" inverse kinematics solutions since Moco will enforce dynamic consistency as part of the optimization problem. Whereas with IK, the solver is just posing the model in different configurations to minimize marker errors.
IPOPT settings (e.g., LBFGS) are less important than the differences in the two methods here.
With Moco, you would get a "dynamically-consistent" inverse kinematics solutions since Moco will enforce dynamic consistency as part of the optimization problem. Whereas with IK, the solver is just posing the model in different configurations to minimize marker errors.
IPOPT settings (e.g., LBFGS) are less important than the differences in the two methods here.
- Radhakrishnan Vignesh
- Posts: 104
- Joined: Tue Jun 01, 2021 8:09 am
Re: Opensim vs Moco optimization algorithm
Thanks a lot for the clarification.
Regards,
Vignesh
Regards,
Vignesh
- Radhakrishnan Vignesh
- Posts: 104
- Joined: Tue Jun 01, 2021 8:09 am
Re: Opensim vs Moco optimization algorithm
Hi Nicholas,
I have two additional questions sorry:
1) When you mention 'dynamically-consistent', what exactly do you mean by that? What are the optimisation variables in MOCO? And if my model had just a pelvis and femur, would the angles between IK and MOCO differ?
2) Is there any influence of scaling in MOCO? None of the examples, mention scaling or a scaled model. So does scaling not influence the results of MOCO ?
Thanks
I have two additional questions sorry:
1) When you mention 'dynamically-consistent', what exactly do you mean by that? What are the optimisation variables in MOCO? And if my model had just a pelvis and femur, would the angles between IK and MOCO differ?
2) Is there any influence of scaling in MOCO? None of the examples, mention scaling or a scaled model. So does scaling not influence the results of MOCO ?
Thanks
- Nicholas Bianco
- Posts: 1040
- Joined: Thu Oct 04, 2012 8:09 pm
Re: Opensim vs Moco optimization algorithm
Hi Vignesh,
1) "Dynamically-consistent" means that the joint angles and speeds produced by Moco are consistent with the forces acting at the model joints. Inverse kinematics just finds a set of joint angles that minimizes marker error and doesn't consider model forces. As long as the model has forces acting at the pelvis and hip joint, Moco should produce similar results.
2) Moco uses the model that you provide to solve an optimization problem. If you want to study the motion of a specific subject, then you should use a model scaled to that subject. Whether or not a model is scaled will not change how a problem is solved, but it will certainly affect results.
Best,
Nick
1) "Dynamically-consistent" means that the joint angles and speeds produced by Moco are consistent with the forces acting at the model joints. Inverse kinematics just finds a set of joint angles that minimizes marker error and doesn't consider model forces. As long as the model has forces acting at the pelvis and hip joint, Moco should produce similar results.
2) Moco uses the model that you provide to solve an optimization problem. If you want to study the motion of a specific subject, then you should use a model scaled to that subject. Whether or not a model is scaled will not change how a problem is solved, but it will certainly affect results.
Best,
Nick
- Radhakrishnan Vignesh
- Posts: 104
- Joined: Tue Jun 01, 2021 8:09 am
Re: Opensim vs Moco optimization algorithm
Hi Nicholas,
Thanks a lot for your reply. Sorry, I have one additional question. I understand that the algorithm used between OpenSim IK and Moco differ, I would like to know, how the optimisation function works in detail. Specifically,
1) What is the optimisation function for marker tracking or track? How are the mobilizers integrated in them? I think, that reduction of marker error is still he cost function, so are the mobilizers used as conditions to be matched.
2) Are there any rigid body constraints? For example, ensuring segment length is fixed, joint centre location etc? How is this accounted for and where in the code can this be studied? Does scaling of the model play into rigid body constraints?
3) I understand that the free joint is currently not supported in MOCO but if I use a custom joint with 6DoF, I would expect really small residual errors? Is my understanding wrong? If the residual errors are large, which part of the optimisation function prevents the reduction in marker error in a 6DoF joint.
I have asked a similar question in OpenSim's forum. But would like to understand Moco;s too
Thanks
Vignesh
Thanks a lot for your reply. Sorry, I have one additional question. I understand that the algorithm used between OpenSim IK and Moco differ, I would like to know, how the optimisation function works in detail. Specifically,
1) What is the optimisation function for marker tracking or track? How are the mobilizers integrated in them? I think, that reduction of marker error is still he cost function, so are the mobilizers used as conditions to be matched.
2) Are there any rigid body constraints? For example, ensuring segment length is fixed, joint centre location etc? How is this accounted for and where in the code can this be studied? Does scaling of the model play into rigid body constraints?
3) I understand that the free joint is currently not supported in MOCO but if I use a custom joint with 6DoF, I would expect really small residual errors? Is my understanding wrong? If the residual errors are large, which part of the optimisation function prevents the reduction in marker error in a 6DoF joint.
I have asked a similar question in OpenSim's forum. But would like to understand Moco;s too
Thanks
Vignesh