Handling large scale data for traffic simulation

Hi,

We are trying to find the most suited game engine for simulation of large scale data of traffic.

Formerly, I tried a similar simulation to update thousands of objects that belong to pollution and it didn’t work very well. The thing is, the update function would bring the frame rate to 2 fps which wasn’t really optimal.

so the question is, can we use Unity to update car movements (more than 200 cars at a time) while trying to feed around 1,000,000 float numbers to the system for calculation?

Any thoughts on this would be great.

Thank you.

1 Answer

1

The real question is do you need to do ALL that data every frame? Most games of this kind will be doing a lot of faking behind the scenes.

If even after optimising the code its still too slow (and since you say 1,000,000, I would guess unity [and any game engine] will be too slow), you’ll want to consider making the process yieldable and processing the variables over a series of frames.

If desperate for speed, you might be able to feed the data into a shader and do it on the graphics card, since this sort of computation will probably be very suited to parallelisation.

Updating the positions of 200 cars in real-time, on the other hand, should be trivial.

If you are going with a client-server model, perhaps you could do the actual simulating on the server and send the client only the pieces they need? The best strategy will depend on the type of game you're making of course. Sounds like a pretty cool project anyway :) I'd love to work on some detailed simulation stuff :(

What are you doing with the floats? Processing 1m floats per frame is pretty straightforward (4mb images are processable easily within a frame) but it totally depends on how many calculations you will do with it. If the calculations are mathematical and lend themselves to the instruction set of a GPU then you could have a shader actually do a lot of the work (not to shade the objects, but to calculate the results) - this requires Unity Pro.

We have a model and this model may be updated or be used to predict the future state of a system. It requires a lot of calculations. Now, I am familiar with CUDA and I can handle the fast calculations externally as Tarlius mentioned, perhaps on a server. The problem is exposing the result to the objects on the scene, in other words transferring the data to the scene. This is what appears to be the most time consuming task. I wondered that having 1 object (1 draw call) is better than 10,000 objects (10,000 draw calls). Thanks.

If the objects share a material they'll be batched (one draw call). Although I'm sure there will be overhead for the GameObjects, and I know just instantiating can be a pain on mobile devices. It depends what local calculations will be needed I think. If the heavy stuff is done on the server, would you need to send any more data than whats needed to update the 200 cars you mentioned? That should be pretty trivial. Just be careful of server load. The simcity comparison is very valid here :)

You won't get automatic batching on 10,000 things - no way :) Plus it's not free in performance terms... By building your own meshes you can effectively simulate multiple materials with a clever shader and a use of different reference textures/vertex data. That way you can have different coloured things etc. I promise you 10,000 draw calls is not a good idea! 200 cars - will be fine on desktop hardware. Are you running on a known platform? Memory mapped files may well work on Windows (never tried on Mac with .NET). Feeding deltas by an open TCP/UDP socket would probably be your best bet.