georgenakashyan / PrisonerDilemmaSimulation

GNU General Public License v3.0
2 stars 0 forks source link

Runs too slow when simulating high node count and high game count together #1

Closed georgenakashyan closed 7 months ago

georgenakashyan commented 1 year ago

It's currently coded very inefficiently, where every game depends on the last one finishing when they shouldn't. I'm thinking of implementing some form of parallelism to fix the issue (multiprocessing in python).

If this does not fix the issue, I will attempt to make the current code more efficient in time complexity.

georgenakashyan commented 1 year ago

Most of the problem comes from how it doesn't run multiple games simultaneously. I believe multiprocessing can fix this, but I need to do more research into other methods.

georgenakashyan commented 1 year ago

After researching more, multithreading is a better solution than multiprocessing. Although multiprocessing may make each step run faster, most of the bottleneck comes from having each game depend on the last one finishing for no reason. Threading each game separately from one another will make the only thing that takes time the time step. The time complexity will go from step x games to just steps.

georgenakashyan commented 7 months ago

MatPlotLib doesn't run properly if it's on anything but the main thread, so this is not possible to fully fix. Instead, the route I opted for was limiting the step image generation to only a few images per game, such as the first, the last, and every quarter.