Restarting simulation

Topics: Developer Forum, User Forum
Jun 16, 2011 at 1:03 PM

I have a requirement that I be able to save the state of a physics simulation to disk, load that information back from disk, restart and get the same results (not just close) to that I would have gotten if I never saved and reloaded.  I have unit test which test for this.

My question is what information must I store (I can't use built in serialization) to make this possible.

It should be noted that I have turned off "EnableWarmstarting".

I currently save position, rotation, velocity, angular rotation, mass, size of every body in the simulation and about 50% of the time I get back the same results (after 300 time steps).  The other 50% of the time I am getting positions which are close (0.001) to the original values but they are not the same.

It looks like it's the physics simulation which is causing these differences based on the state of the bodies at time of saving.

I am using source control revision number 87480.

Any help would be appreciated.

Jim K

Jun 18, 2011 at 7:49 PM

I'm not a Farseer expert, but I have read a couple of articles that might help you.  This blog post http://blogs.msdn.com/b/shawnhar/archive/2009/03/20/motogp-replays.aspx and the one that follows it might give you some ideas.

Could you share your serialisation code?  I need to do the same thing as you, although for my purposes I dont mind if the simulations then digress later.

Thanks.

Jun 18, 2011 at 11:20 PM

I understood and using something similar to the blog post to store my simulation and I am sorry, but my serialisation code is spread amoug many classes and levels of abstraction.

However is short I set EnableWarmstarting to false and the save x,y position, rotation angle and same for velocity. (In world coordinates) 

I know this work because it works about 50% of the time and gives me back the exact same path.  In my unit tests run the simulation for about 600 time steps. After 300 times steps I save the simulation and start new metrics. I then reload simulation and start a new set of metrics for 300 times steps.

I have eliminated everything on my side, but still can't get reproducible 100% of the time.

I can only think of 2 things which could cause the results to be different.

1. I am missing something small which needs to be serialized

2. There is information in the physics simulation which is bleeding from one time step to the next which can't be serialized.  I hope this is not the case and what I though turning off warm staring was to address.  Without turning off warm starting I could never get the same results when restarting.

 

Jim K.