changing the mesh intervals form 25 to 50 changes the prediction outpur of cycling, cannto understand why?

OpenSim Moco is a software toolkit to solve optimal control problems with musculoskeletal models defined in OpenSim using the direct collocation method.
POST REPLY
User avatar
Muhammad Mughees Ahmed
Posts: 17
Joined: Mon Sep 18, 2023 3:22 am

changing the mesh intervals form 25 to 50 changes the prediction outpur of cycling, cannto understand why?

Post by Muhammad Mughees Ahmed » Tue May 21, 2024 3:06 am

Hello Everyone,

I am facing a problem in prediction simulation of cycling gait in moco. the problem is that if i use 25 mesh intervals then the predicted simulation works fine and give the desired results but if i increase the mesh intervals to 50 then the output result is not correct i.e. the predicted gait is not how it should be.

any idea why is it happening or what should i change to eliminate the effect of changing the mesh intervals.

best regards
Mughees

User avatar
Nicholas Bianco
Posts: 947
Joined: Thu Oct 04, 2012 8:09 pm

Re: changing the mesh intervals form 25 to 50 changes the prediction outpur of cycling, cannto understand why?

Post by Nicholas Bianco » Tue May 21, 2024 11:48 am

Hi Mughees,

Could you elaborate on the differences between the 25 and 50 mesh interval solutions? It is likely that your current problem formulation is sensitive to the number of mesh intervals.

-Nick

User avatar
Muhammad Mughees Ahmed
Posts: 17
Joined: Mon Sep 18, 2023 3:22 am

Re: changing the mesh intervals form 25 to 50 changes the prediction outpur of cycling, cannto understand why?

Post by Muhammad Mughees Ahmed » Wed May 22, 2024 5:09 am

Hi Nick,

Thanks for the reply,

I am trying to predict cycling motion. in my model i have used a crank fixed with the feet that allow the motion to operate in cyclic way.

now the problem is that if i use 50 mesh intervals for the motion prediction, the motion is not at all smooth and after half cycle it disrupts, whereas if i use 25 mesh intervals the motion is smooth and completes one rotation as it should work.

i am not sure why is this happening for my simulation because as per my understanding if i increase mesh intervals it will give more resolution to the simulation and should be giving a smoother motion output but the complete opposite is happening .

i am sorry if my question might sound stupid, i am just trying to learn moco and simulation prediction so my questions might be very basic for everyone here.

best regards
Mughees

User avatar
Nicholas Bianco
Posts: 947
Joined: Thu Oct 04, 2012 8:09 pm

Re: changing the mesh intervals form 25 to 50 changes the prediction outpur of cycling, cannto understand why?

Post by Nicholas Bianco » Wed May 22, 2024 9:03 pm

Hi Mughees,

The problem might be sensitive to the initial guess: the optimizer might be taking a different "starting path" when using 50 mesh intervals compared to 25. If you have a decent result with 25 mesh intervals, I recommend using that solution as an initial guess for the problem using 50 mesh intervals.

-Nick

User avatar
Muhammad Mughees Ahmed
Posts: 17
Joined: Mon Sep 18, 2023 3:22 am

Re: changing the mesh intervals form 25 to 50 changes the prediction outpur of cycling, cannto understand why?

Post by Muhammad Mughees Ahmed » Thu May 23, 2024 5:04 am

Thank you Nick,

I will try doing this and use the output of one simulation for the next simulation. and see if it helps


for now what i am trying to do is to predict cycling motion
if i use 25 mesh points to simulate 1 second of motion the output is fine and smooth but if i try to use 50 mesh intervals for 1 second motion prediction then the output gets disrupted.

on the other hand if i try to simulate the cycling motion for half second (i.e. time bound (1, [0.5, 0.6])) then the output is fine with 50 mesh intervals also.

i am fine with 25 mesh intervals for now because it solves my problem, but i want to understand why this is happening. so that maybe in future if i have to work on something difficult or change the parameters then i could know it better

regards
Mughees

User avatar
Nicholas Bianco
Posts: 947
Joined: Thu Oct 04, 2012 8:09 pm

Re: changing the mesh intervals form 25 to 50 changes the prediction outpur of cycling, cannto understand why?

Post by Nicholas Bianco » Tue May 28, 2024 10:41 pm

any idea why is it happening or what should i change to eliminate the effect of changing the mesh intervals.
As I said, your problem is most likely just needs better initial guesses to converge reliable. Direct collocation is powerful, but problem formulation and good initial guesses are key. Changing the number of mesh intervals with a random initial guess can change the initial search direction that the optimizer takes; one direction may converge as you expect, another may not.

To get started, I recommend simplifying your problem as much as possible to generate intermediate solutions, and then using those solutions as initial guesses for more complex problems until you reach the problem you actually want to solve.

User avatar
Muhammad Mughees Ahmed
Posts: 17
Joined: Mon Sep 18, 2023 3:22 am

Re: changing the mesh intervals form 25 to 50 changes the prediction outpur of cycling, cannto understand why?

Post by Muhammad Mughees Ahmed » Tue Jun 04, 2024 3:54 am

Hi Nick,

Thank you for the explanation, I understood and actually what you said about simplifying and then using the result for initial guess and solving it again actually helped me to converge more quickly. so i guess it sort of solved what i was looking by using the first result as initial guess for second results.

now having said that i want to clarify one more thing about working of moco i.e. while giving the boundary conditions to the path in moco, can we give a mid point where the path should pass during our optimization.

what i want to say is that currently what my understanding is that we tell the solver/optimizer that our path start from "Point A" and ends at "Point B" and give the state conditions at both the points, it find out an optimal solution for that.
What if i want to tell the solver/optimizer that my solution should start from "Point A" then should go through a specific "Point X" and then reach at "Point B" . I know the state conditions at all three points but can i do that in moco?

regards
mughees

User avatar
Nicholas Bianco
Posts: 947
Joined: Thu Oct 04, 2012 8:09 pm

Re: changing the mesh intervals form 25 to 50 changes the prediction outpur of cycling, cannto understand why?

Post by Nicholas Bianco » Tue Jun 04, 2024 10:44 am

Hi Mughees,

Glad that your problem is converging more reliably now. As for your other question:
What if i want to tell the solver/optimizer that my solution should start from "Point A" then should go through a specific "Point X" and then reach at "Point B" . I know the state conditions at all three points but can i do that in moco?
Unfortunately, no, that is not currently possible in Moco. To solve that problem, we would need to implement support for multiple phase problems. This is on our TODO list, but not currently a high priority.

Best,
Nick

POST REPLY