What's allowed during setup might not be allowed afterwards

In the discussion on constants in code we had the question whether it should be allowed to change the value of a constant or parameter afterwards.
It should be possible to control parameters (and measured constants) from BehaviorSpace. There are possibly more use cases where one would want to change the value of a parameter.

While thinking about this question, it occurred to me that the distinction should be between setting up the model and running the model after setup.
It can make sense to change a parameter (early) during setup, but changing a parameter (even a slider) after the simulation has really started should be considered bad practice.

This is related to a discussion (https://github.com/NetLogo/NetLogo/issues/2636) in NetLogo’s github issues list.
Should resize-world reset the tick counter or not?
If we turn it around, we could argue that it does make sense changing world dimensions (and topology) during setup, but not afterwards.

So, it would be nice if NetLogo allows some operations only during setup.
As far as I see, there is only one reasonable way to make the distinction: check whether the tick counter has started or not; like the corresponding option for button widgets.
This is not waterthight, but good enough for the vast majority of models.

Actions that would fall in this category would be:

  • resize-world and set-topology
  • maybe set-default-shape
  • maybe set-current-directory
  • assigning a value to a constant or parameter
  • hubnet-reset (but this is special anyway)
  • … anything I missed …

This sounds like a somewhat slippery slope to go down. Which things you can and cannot do in setup is a very arbitrary decision, and I imagine that we would have many unhappy users if we suddenly introduced this kind of restriction. I think it’s more a problem of model design and construction than a problem to be solved by NetLogo. That said, users could certainly benefit from some documentation or tutorials explaining this type of logic and how to structure a NetLogo model; if that doesn’t exist yet we can consider creating something like it for a future release of NetLogo.

Isaac B.

1 Like