Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow interactive abmplot to initialize new starting models #1056

Open
amynang opened this issue Jul 7, 2024 · 3 comments
Open

Allow interactive abmplot to initialize new starting models #1056

amynang opened this issue Jul 7, 2024 · 3 comments
Labels
enhancement New feature or request plotting

Comments

@amynang
Copy link
Contributor

amynang commented Jul 7, 2024

This issue has been discussed here

In short, it would be great if agent number could be controlled with a slider. I realize that this change could not be dynamic.

Describe the solution you'd like
This is possible in NetLogo (e.g. here). Changing the density of the agents does not affect a started run, but it does take effect once you press setup.
The same is not possible in the Agents version of the model (here, see lines 65-86).

@Datseris
Copy link
Member

Datseris commented Jul 7, 2024

Hi, I can't run NetLogo. Are you able to provide a video of how what you want looks like?

Ideally what we would like to achieve is for the user to provide a "model generating function", that takes various keywords and generates a new model, which is then used to reset the current model to. My conceptual difficulty with this is that typically the inputs to this argument would be different to the formal model parameters. This means you would need two sets of sliders: one for the formal interactive parameters, and one for the "re-initialization" parameters. It may make the interface ugly. We are already rather tight on space... But the way I outlined above is at least easy to do in code, as all the infrastructure is already there and used for other parts: the current model resetting and the current model updating from parameter sliders.

@Datseris Datseris changed the title Enable changes in agent number on interactive plots Allow interactive abmplot to initialize new starting models Jul 7, 2024
@Datseris Datseris added plotting enhancement New feature or request labels Jul 7, 2024
@amynang
Copy link
Contributor Author

amynang commented Jul 8, 2024

Sure here it is. There is no difference between sliders that control setup conditions like agent density and parameters like "similarity threshold" that can be modified while the model runs. What is different in Netlogo is that on pressing setup you re-initialize the model so that n agents (according to density) are redeployed to random positions. Similarity on the other hand is a step related parameter so it can be manipulated on the fly (between steps).

to setup
  clear-all
  make-turtles
  update-turtles
  update-globals
  reset-ticks
end

to make-turtles
  ask patches [
    if random-float 1 < density [            ;;here
      sprout 1 [ ;;create an agent here
        set shape "square"
        set color one-of [14 35]
      ]
    ]
  ]
end

Screencast from 08 07 2024 08_01_55

@Datseris
Copy link
Member

Datseris commented Jul 8, 2024

There is no difference between sliders that control setup conditions like agent density and parameters like "similarity threshold" that can be modified while the model runs.

There is a difference. How NetLogo conveys this difference may be obscure to you. Or it may even not attempt to convey the difference because it uses global scoping for everything. But, think about it: at least in Agents.jl everything is a self contained function that doesn't use the global scope. One needs to be able to convey the information of what slider is for re-initializing the model and what slider is for adjusting a model parameter. Model parameters are stored in model.properties while re-initializing the model is given as a one-time input argument to a function that outputs a new model. To know which of these two aspects to update means that you need to know whether you slider is for "parameters" or for "re-init".

How we do this separation I don't know yet. Perhaps it makes sense to vertically concatenate both sets of parameters into one overarching set of sliders. But it would make it difficult to separate which is which I guess. I am open to PRs proposing a GUI design.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request plotting
Projects
None yet
Development

No branches or pull requests

2 participants