netlogo

How to get import world to work with behaviour space?


My NetLogo setup is a procedure to import a world:

to setup
import-world "world"
end

I then need to change a parameter value.

And then run a procedure.

Then I want to repeat all of this automatically.

What I would like is to run it in behaviour space:

run setup   
get the next parameter value from behaviour space    
run go

but I don't think I can do this in behaviour space?

I'm looking at the R extension but can't figure out what I need. Does anyone have any suggestions?


Solution

  • You might decide that R is the way to go, as @ThomasC describes, but it is possible to use Behavior Space, with a slight modification. As you surmise, import-world overwrites the values of all the globals in your model, including those being manipulated by Behavior Space. However, there are two ways around that.

    The first is to edit the file created by export-world. It is a simple text file that can be edited with Notepad or your text editor of choice. In that file there is a section labeled "GLOBALS", with two lists. The first is a list of the global variables in the model, the second a corresponding list of their values. If you delete the name(s) of the variable(s) that you wand Behavior Space to manipulate in the first list and the corresponding value(s) in the second list, then import-world will not overwrite their values. They will remain as Behavior Space sets them.

    The second approach is to modify the model AFTER it has created the export-world file. Add a "dummy" global to the interface for each "real" global that you want to have Behavior Space manipulate. Since the dummies are not in the exported world, they will not be overwritten by import-world. Then, in your setup, simply set the "real" global variables to the values of the dummy ones.

    The first approach seems a bit more straightforward to me, but both should work.