Closed bokae closed 5 years ago
Now, request result files are way too big. Moreover, it is not sustainable any more to leave uncompressed result files in the results folder. They should be written compressed, and then read by visualize.py compressed.
Results files are smaller now, I only output some aggregates on the requests.
I'm indexing the grid now everywhere in 1D, and the translation from 1D to 2D and vice versa is stored in dictionaries instead of being computed on the fly.
The BFS-trees that search from a certain position for the nearest locations are also stored in a dictionary, since looking up elements of a numpy.array
is incredibly slow.
Replaced multivariate random generator by two 1D ones, correlated Gausses do not interest us for now. Multivariate is much slower than simple normal distribution.
New structure for keeping track of requests: one deque for storing each single request in time order, and one other with a fixed length for storing request sets that have been generated together in one timestep. If new bunch of requests are generated, they 'push out' the old ones from this deque. Also, before loosing the oldest requests, we delete the ones from the left end of the time-ordered deque that are in the to-be-deleted set of the other deque. This is the way of dropping requests that have been waiting for a match for too long.
It is still quite slow for bigger (e.g. more realistic) sizes. Ideas for speeding up.
Done:
pip install git+https://github.com/NicoDeGiacomo/randomdict
, this contains the fix. On the benchmark config, it only speeded up the simulation by 1s/batch...python -m cProfile run.py 0608_benchmark
, and it turned out that generating requests eats up almost half of the time! There should be a better way for it. Thepoorest
algorithm is not much slower than therandom
one.Possibilities:
Maybe Python itself is an obstacle - is there any way to compile the code? (How much would it take to rewrite it in C++? Is it worth the time?) A pyc file is compiled from the city_model.py module, the question is whether there is a compiler that can optimize more.
Could we run it on GPU?
Estimate runtime based on parameters and find an optimum schedule, submit jobs in that order. That is just having a look at the slurm files.**
numba
Putting taxis into a pandas DataFrame, then moving them by
.apply()
.