Multiple behavior spaces

≡放荡痞女 提交于 2019-12-11 03:58:50

问题


I have a simulation with no global values. Instead the two things that are changed between experiments are the breeds being used, and the number of ticks in the setup (how many turns before the behavior space starts recording results)

Currently I'm duplicating each behaviour space and making the minor changes, is there a better way to do this so that I can program all the behavior spaces runs at once?


回答1:


There are many different ways to do this, but since you don't give us a lot of information about what you're trying to do, I'm going to propose something very general. You should be able to adapt it to your needs.

Here is a simplistic model with two breeds (alphas and betas):

breed [ alphas alpha ]
breed [ betas beta ]

globals [
  experiment-id ; this could be a chooser in your interface
  breed-to-use
  num-steps-after-setup
]

to setup
  clear-all
  ifelse experiment-id = 0 [
    set breed-to-use alphas
    set num-steps-after-setup 25
  ] [
    set breed-to-use betas
    set num-steps-after-setup 50
  ]
  create-turtles 10 [
    set breed breed-to-use
  ]
  reset-ticks
  repeat num-steps-after-setup [ some-step-procedure-that-does-not-tick ]
end

You can make experiment-id vary in your BehaviorSpace experiment definition:

["experiment-id" 0 1]

The ifelse experiment-id = 0 statement in setup takes care of setting the other parameters according to which experiment you're running.


By the way, having a procedure run at the end of setup to delay the recording of steps by BehaviorSpace is probably not a good idea, but it's hard to suggest an alternative without knowing why you want to do that.



来源:https://stackoverflow.com/questions/30401826/multiple-behavior-spaces

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!