Accelerate time / timelapse

Post Reply
alberto2000
Posts: 2
Joined: Thu Mar 31, 2016 10:59 am

Accelerate time / timelapse

Post by alberto2000 »

I'm working with an Evolutionary Algorithm to evolve creatures - they are assessed by how far they move - so to determine and assess their fitness I need to measure the distance they have moved after around 10 seconds - but how can I speed this up so I don't have to wait 10 seconds for each candidate to assess? Is there a way to speed up the simulation so I can get more assessment results in less time? Without losing physics accuracy? I was looking at "Stepping the world" Wiki entry: http://bulletphysics.org/mediawiki-1.5. ... _The_World but not sure if that's the way... Thanks
Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: Accelerate time / timelapse

Post by Basroil »

On a 4-core machine I manage ~ 200 simulation seconds per second of real world time (in a very small simulation), so it's definitely possible :wink:

The easiest way is to just throw out the GUI entirely and manually step the simulation as fast as possible in your update loop. If you MUST have the GUI, simply update multiple times per graphics frame.
alberto2000
Posts: 2
Joined: Thu Mar 31, 2016 10:59 am

Re: Accelerate time / timelapse

Post by alberto2000 »

Thanks for the advice!

I'm actually using a Javascript rewrite of Bullet (cannon.js - which is a complete rewrite instead of the direct JS port called ammo.js) and am planning on running it with node.js so there won't be any browser / GUI involved.

Can you please point out how to "step manually"? You mean, basically running a loop as fast as the machine can and step the simulation in it each time it iterates? Is there a way to make this controllable? I mean, like setting the time lapse acceleration factor? Like 2x, 4x, 10x, 100x ... etc?
Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: Accelerate time / timelapse

Post by Basroil »

Just call stepSimulation(duration,max_sub_step, simulation_step_size) as many times per second as you need, and do whatever control you need to between steps. Remember that the default simulation step size is 1/60s, so if you want a 1:1 simulation you'll need duration at 1/60 and need to call stepSimulation 60 times a second. If you want a 10x speedup, just call it 600 times a second. Just remember that your simulation can be too complex to finish within the desired time, so you'll need to know the limits of speedup and also how to compensate for occasional speed dips.
benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland
Contact:

Re: Accelerate time / timelapse

Post by benelot »

You can look at how I implemented it in my simulator. The main part is in this file:
https://github.com/benelot/minemonics/b ... anager.cpp

You can set the speed with 1-9, 9 being the mode where it runs as fast as possible with GUI and 0 being as fast as possible without GUI. I will soon write an example for it. Just ask me if you need help.
Post Reply