lundi 5 février 2018

Python: Modelling traffic (creating an array with randomly occupied states)

The task is an extended one but I just want to get the first part so I can begin to make a model.

"Consider a long road divided into L sites each of which may be empty or contain a car. There are N total cars. Each car has a velocity and a position which can take integer values (...) it is convenient to pretend the road is a closed circle"

Thinking you do something like this

L=np.arange(0,201,1)

array[n]=array[0]

v=np.arange(0,6,1)

x=np.arange(0,201,1)

(Using two arrays to store position and velocity of car)

Unsure of how to create a position on L, randomly chose a place to put a car?

Thanks




Aucun commentaire:

Enregistrer un commentaire