Beginner question on execution time
Hi there,
I want my Netlogo model to run for a certain number of ticks with pyNetlogo but I didn't find any method that can help me do this (please let me know if I missed anything useful). So I put these lines in my python code:
while(netlogo.report('ticks') <= max_run_time):
netlogo.command('go')
As I tried to call and run the Netlogo model through pycharm I noticed that the execution time of 1 replication is much longer than directly running the model in Netlogo, like more than 2hrs vs. 2mins. May I know if there is more efficient way of doing this?
Thanks in advance:)
any netlogo command, or string of commands, can be sent from pynetlogo. So, rather than doing the while loop in python, you can do repeat 10 go in order to run the model for 10 ticks. The more you push a set of commands in one go into NetLogo, the faster the run will become. Hope this helps
Hi quaquel,
Thanks for the prompt reply! Actually I'm doing discrete event simulation in Netlogo. For each go the advanced ticks can be different, depending on when the next event will occur.
to update-usage-stats [event-time]
tick-advance (event-time - ticks)
end
I tried repeat 10 go in python and it returned more than 10 ticks. But it really helps in speed up running. Can this repeat method be interrupted when ticks exceed the run length(max_run_time)?
There is a repeat while option available that might do what you want.