djgroen / facs

FACS: Flu And Coronavirus Simulator
https://facs.readthedocs.io
BSD 3-Clause "New" or "Revised" License
10 stars 7 forks source link

Modified nearest location algorithm #48

Closed arindamsaha1507 closed 12 months ago

arindamsaha1507 commented 12 months ago

Modified according to #8

arindamsaha1507 commented 12 months ago

Hi @djgroen and @mzrghorbani,

Just to let you know, incorporating weighted probabilities leads to a significant slowing down of the code. In my test with Calarasi for 10 days, the simulation takes 17 min instead of 6 min.

Please have a look at commit 0ccc4c1 if it can be more efficient.

djgroen commented 12 months ago

Hi Arindam,

Perhaps you could put an unweighted np.random.choice as part of the "else:" branch in your modified code, and move the weighted one to your main if branch?

That should save at least some initialisation time.

Weighted random choice operations are hard to optimize, but this could be a way to reduce the number of their occurrences :).

arindamsaha1507 commented 12 months ago

Hi @djgroen,

I tested with your suggestion... doesn't seem to work... still 17 mins.

I think the if statement is causing the delay?