Kevin A
Kevin A

Reputation: 71

Netlogo is working but behaviorspace is showing garbage

I am running the following code:

breed [houses house]
breed [buyers buyer]
houses-own [value visitors bought]  
buyers-own [visited wealth bought]

to setup
  clear-all
  reset-ticks

  create-houses 100 [
   move-to one-of patches with [not any? houses-here]
   set shape "house"
   set color 125
   set value (who + 100)                         
   set visitors []
  ]

  create-buyers 100 [
   move-to one-of patches with [not any? turtles-here]
   set shape "person"
   set color yellow
   set wealth who   
   set visited []
  ]
end


to go
  repeat 5 [
    ask buyers [
      move-to one-of houses with [bought = 0]
      set visited fput ([value] of houses-here) visited        
      
      ask houses-here [
        set visitors fput ([wealth] of buyers-here) visitors
      ]
      
      move-to one-of patches with [not any? turtles-here ]
    ]
  ]
  
  ask buyers [
    if length visited > 0 [
      set visited reduce sentence visited
    ]
  ]
  
  ask houses [
    if length visitors > 0 [
      set visitors reduce sentence visitors
    ]
  ]
  
  tick
end

Which compiles a list of houses that each buyer has visited (see visited) and a list for each house of who visited it (see visitors). After I run it, if I inspect the turtles on screen they all contain lists that I would expect. For example each buyer has a list of 5 houses visited and each house has approximately 5 buyers. A typical buyer looks like this: attributes of a buyer. Note the list of 5 houses visited.

However if I run BehaviorSpace and ask for the reporters

[visited] of buyers
[visitors] of houses

then I get lists running to several thousand long - this is currently with just 1 repetition and a time limit of 1000.

The output looks as follows:

spreadsheet output

table output

I have reported agent attributes before with no problem - I cannot see what is different here.

Upvotes: 0

Views: 80

Answers (1)

Matteo
Matteo

Reputation: 2926

You didn't specify any stop condition, either in-code or in your BehaviorSpace setup.

I saw from the image you originally posted about the BhaviorSpace setup, that you included a Time limit of 1000. I imagine you got there because, with the default value of 0, BehaviorSpace experiments were running forever. With experiments stopping only once they hit the specified time limit, your buyers are continuing to do what they're told for much longer than just 5 repetitions - hence the very long lists.

In your case, since you are already telling NetLogo how many times you want your go to execute (by using repeat), and based on the arrangement of your code (i.e. tick happening only after all your desired repetitions took place), either of the following stop conditions will achieve what you want:

  • In BehaviorSpace: ticks = 1;
  • In code:
to go
  repeat 5 [
    ...
  ]

  tick
  stop
end

In both cases, you can just go back to having a Time limit of 0 (i.e. no time limit).

Upvotes: 1

Related Questions