ropensci / nlrx

nlrx NetLogo R
https://docs.ropensci.org/nlrx
GNU General Public License v3.0
77 stars 12 forks source link

Improve performance: Run many simulations on a single NetLogo instance #60

Open bitbacchus opened 2 years ago

bitbacchus commented 2 years ago

See #57 , to solve this use NetLogo's Controlling API instead of experiment xml files.

nldoc commented 1 year ago

Hi @bitbacchus, I was following up on the discussion in the issue linked above. I saw your proposal to run multiple simulations in the same NetLogo instance. However, I am not convinced that this is a "better" solution. There were reasons we decided to implement nlrx that way, let me explain.

When I started running NetLogo from R, I always used RNetLogo. When running projects with many simulations, we always encountered a lot of problems with NetLogo and ever increasing memory consumption. It turned out that it is just not possible to re-use the same NetLogo instance over and over again. At some point it will break. For me that was a quite frustrating experience, and actually led to the basic idea around nlrx: having independent sessions with a fresh start for every single simulation. This was actually a game changer for me and the reason why nlrx is alive :)

While I do in general agree that this creates a lot of overhead, it also brings a lot of stability. For sure there is a trade-off. However, I would strongly advise against changing the approach of how nlrx calls NetLogo.

One thing we could think about is kind of a hybrid-approach, which leaves the decision to the user. However, I will anyway not have the time to implement/test such a feature.