johan14
johan14

Reputation: 11

How to extract variables from Behaviour Space in NetLogo

I'm using a model that returns a series of variables at the end of the simulation. I'm trying to analyze this set of variables for 100 times with Behaviour Space but I'm not able to get the same variables that I can easily find with a single simulation. In particular, launching the experiment the output is just a repetition for 100 times of the parameters of the model. This is what I see when I create a new experiment

I've also tried to write on "Measure runs using these reporters" the code count individuals-own because i've seen on the code of the model this individuals-own [talent success n-lucky-events n-unlucky-events] but I'im not sure of what it is, and with this command it returns an error "END expected".

Upvotes: 1

Views: 278

Answers (1)

Wade Schuette
Wade Schuette

Reputation: 1473

(1) I am trying to get all the variables values of this model for every run made in behaviour space. (2) I almost managed to get what I need writing in "Final commands" export-world "file-name" but it returns only one world instead of the 10 runs made in behaviour space. How can I get export-world for each run? – Davide Cacozza 12 hours ago

(1) If you simply list the variables you want, one per row in the Behavior Space Experiment section "Measure runs using these reporters" they should all be exported.

(2) I suspect you are putting export-world in BehaviorSpace as a "final command" which is only run once at the end of all the runs, as you noticed.

If you want to export everything each run, you need to export as the last step in your actual CODE section. To avoid over-writing conflicts a unique name should be used. I had trouble with timestamps ( which at least would be sequential ) and Windows doesn't like colons ( so raw date-and-time is out ) so here's an example just using random numbers to get uniqueness ( well, 99.9999% of the time )

    
globals [  x y z  ]
to setup
  clear-all   
  set state random 5
  reset-ticks
end
to go
  if ticks > 10 [ print ( word state " " x " " y " " z)  wrap stop]
  set x   state * ticks
  set y   x * x + random 3333
  set z   sqrt x + random 2222
  tick
end

to wrap  
   let cmd (word " export-world \"myfilenumber" random 8000 ".txt\"")
   run cmd
   print (word "exported world via : " cmd )
end

I checked, it works.

Upvotes: 2

Related Questions