Page 1 of 1

Saving and loading complete state of predictive simulation

Posted: Tue Nov 24, 2015 3:34 pm
by jakobwelner
I am trying to save the complete state of my system based on PredictiveSim by Dorn et al. in order to use the state as a start-condition in new simulations.

I have saved out all inner variables in the controller, each muscle as well as the position and velocity of each limb and I can load them all into place again but I cannot seem to recreate the exact state that I saved out. Position, velocity and muscle activation at load point match initially but diverge at the first time step.
I guess I am missing something somewhere but I don't know where and I have spent a week now trying to solve the issue.

I am currently going through all the values one by one making sure that they match between save-point and load-point but if anyone here by any chance has a suggestion then I am all ears. I may even be doing it in a completely silly way but if that's the case then I'll be more than happy to hear a better approach!

I am setting the muscle state by overwriting their local MuscVars struct (My actuators are 'SimpleMuscles' defined by Dorn and Wang)
Controller state is set by overwriting all inner variables as well, including the lists containing accumulated data points for delayed retrieval.
Position and velocity is handled by updating an .sto file used to initiate the simulation

Cheers and thanks in advance
- Jakob

Re: Saving and loading complete state of predictive simulati

Posted: Mon Nov 30, 2015 2:46 pm
by jimmy
Hi Jakob,

One thing may be the precision. To exactly preserve a double precision value (16 digits of accuracy) you have to write out about 20 digits so that every last bit gets preserved.

Others that have used PredictiveSim have had issues with recreating their results from the same state. The differences were so small that they discounted them since all the solutions would be as legitimate as each other. They did find that you would at least get the same simulation every time you read in the same .sto file, so at least that is stable.

I would reach out to the Authors, since it sounds like this issue may be with how the code works.

-j

Re: Saving and loading complete state of predictive simulati

Posted: Wed Dec 09, 2015 10:30 am
by jmwang
Hope you've had some luck on this issue. The main thing I can think of is to make sure you preserve enough digits when you write them out to file. You could also try the same thing on a simple simulation using a standard OpenSim muscle model, just to see if the issue is indeed in the SimpleMuscle class we wrote.

Re: Saving and loading complete state of predictive simulati

Posted: Sat Dec 19, 2015 9:08 am
by jakobwelner
Hi and thank you very much for your replies, and sorry for my slow response. I can't seem to get the notification e-mails to work for this forum.

I have sadly had to postpone this issue as I couldn't afford to spend more time on it. However, following your comments I double checked the precision and I was saving out way too few digits so this may very well be the issue. Thanks a lot for pointing it out!
Furthermore I have a hunch that it could also be concerned with when and how I read the values back in as there seem to be some initiation of different parts that has to happen in a certain order, which I am not quite confident that I am getting right.
I hope to be able to fix this eventually and will let you know if it worked.

@Jack, a little side note. I have tried writing you but your e-mail at Hong Kong University bounced. I guess you are no longer affiliated with them, given your profile here.
However, can you tell me if PredictiveSim can run?

Cheers and thank you both for the suggestions.
-Jakob Welner

Re: Saving and loading complete state of predictive simulati

Posted: Tue Dec 29, 2015 12:56 pm
by jmwang
Hi Jakob,

We've never gotten this model to run, I believe it has to do with the 3-state control formulation instead of the 4-state one I used in my previous work (see SIGGRAPH 2012). The walking simulations using 4 states weren't as good as the 3-state ones using this model, that's why we dropped it.

Jack