Determinism and time step

Hi all,

I'm fairly new to JBox2d so please excuse any nativity in my post.

Background:

I am working on an AI project using JBox2D as a physics engine.

I have created a top-down simulation consisting of a two-wheeled "robot" with a simple differential drive. The robot has a number of sensors (not JBox2D sensors) which use ray casting to gather information from the world - e.g closeness of other objects, the edge of the ground etc ..... I have wired up a neural network with inputs to the network coming from these sensors and 2 output neurons which affect the speed and direction of the left and right wheels. I am using genetic algorithms to train my robot to solve a problem. (In this case the problem is for the robot to locate an object - this object is modeled as a JBox2d sensor) and to keep hold of it for as long as possible. My fitness function for now is simply the length of time that that robot "holds" this object.

The problem:

I want training cycles to be as fast as possible as I have a large population trained over a number of epochs. I then want to be able to replay the winning network (robot controller) in a GUI. My question is what is best way to reliably speed up training.

My approach has been to train using a time-step of 1/600 - Training has been successful at this speed with a network that has learned how to locate an object in the world however when I replay this in the UI with a slower time step of 1/60 the results appear to be different.

I have read a number of forum post on determinism but none on determinism with a different time step.

The question:

Should I expect this to work ? - I.e should a simulation run at 1/600 run the same way as a simulation run at 1/60 (albeit at a faster rate) ? I may be smoking my socks on this but if anyone can offer any advice on how I might approach such a problem it would be greatly appreciated.

Massive thanks to everyone involved in this excellent project by the way.

Si
No, the simulation is not deterministic between different fixed time step lengths.

The main reason is that the acceleration of stuff is applied on a per time step basis. This is of course an obvious thing, but most people usually do not understand that the break down of acceleration in different time step lengths affects the outcome of the positions. Check out this tutorial: http://www.iforce2d.net/b2dtut/projected-trajectory . The explanation is just above the first table (and the table shows the effects of using different time step lengths with the same acceleration).

Box2D simulations are only deterministic if everything is the same, including time step length.
Thanks very much for taking the time to reply and pointing me to the useful article. - Back to the drawing board 🙂

Original thread: https://box2d.org/forum/viewtopic.php?t=8585