Cetarius
Cetarius

Reputation: 69

Netlogo BehaviorSpace Optmization - Delete Aborted Runs - Final Command

I am working with quite a lot of runs and most of them will be aborted. Can I write a Final Command that deletes aborted runs in order to speed up the process and/or make my csv files smaller?

Upvotes: 1

Views: 31

Answers (1)

Nicolas Payette
Nicolas Payette

Reputation: 14972

There is nothing allowing you to do that in a straightforward way. And it wouldn't really speed things up anyway.

Unless the size of your csv files is really a problem, the easiest thing is just to filter out aborted runs in whichever data analysis program you use.

The only alternative I can think of is to write your own experiment code. Assuming you have a stop-condition? reporter and you set aborted? true when a run is aborted, you could do something along the lines of:

extensions [ csv ]
globals [ aborted? ]

to experiment
  let run-number 1
  let file-name "experiment.csv"
  if file-exists? file-name [ file-delete file-name ]
  file-open file-name
  foreach [ 1 2 3 ] [ ; vary x
    set x ?
    foreach [ "a" "b" "c" ] [ ; vary y
      set y ?
      set run-number run-number + 1
      setup
      while [ not stop-condition? ] [ go ]
      if not aborted? [
        file-print csv:to-row (list
          run-number
          x
          y
          (count turtles)
          ; whatever else you want to measure...
        )
      ]
      if run-number mod 10 = 0 [ file-flush ]
    ]
  ]
  file-close-all
end

This assumes that x and y are, respectively, a slider and a chooser widget. If you want to vary global variables, you'll have to be careful not to override them with a call to clear-all in setup.

As you can see, all of this is far from ideal and probably error-prone.

Upvotes: 2

Related Questions