SFI CXC Winner Model

SFI CXC Winner Model preview image

1 collaborator

Tags

Visible to everyone | Changeable by the author
Model was written in NetLogo 6.2.0 • Viewed 70 times • Downloaded 5 times • Run 0 times
Download the 'SFI CXC Winner Model' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


WHAT IS IT?

This is an agent based model developed for Santa Fe Institute 2018 Complexity Chalenge. The startegy used by a rational agent from this model wound up generating the best strategy in the Code Tournament.

HOW IT WORKS

The rules used by the agents are described in the write-up which is a response to the Santa Fe Institute 2018 Spring Complexity Challenge.The write up as well as the winning code is avalable at: https://www.complexityexplorer.org/challenges/pages/solution-gallery

HOW TO USE IT

  1. Select scenario (one out of five). For the write-up the core scenarion is "Irrational-I"

  2. Set the number of agents (by the sliders "num-random-agents" (for Random scenario), "num-masters", "num-i-s-agents", "num-i-l-agents", "num-i-h-agents", "num-r1-agents" (for Meta scenarios)

  3. Timer for a standard run should be "off"

  4. Replication switch should be "off" except "Merta" scenarios.

  5. Press "Setup" and "Go" buttons. This will run the selected scenario with the set number of agents.

  6. Plot areas show the payoff in low and high pools (left) and mean cumulative wealth of diffrent classes of agents during the run (right).

  7. Monitors show the numeric values of parameters.

NB: The standard scenario manly takled in the write-up is "Irrational-I" with 18 "i-s-agents", 16 "i-l-agents", 16 "i-h-agents" and 3 masters.

THINGS TO NOTICE

Observe the dinamics of the wealth of master-agents with the above scenario. The write-up provides much more possibilities to focus on and try.

CREDITS AND REFERENCES

This model was developed by Victor Iapascurta, MD. At time of development he was in the Department of Anesthesia and Intensive Care at University of Medicine and Pharmacy in Chisinau, Moldova / ICU at City Emergency Hospital in Chisinau. Please email any questions or comments to viapascurta@yahoo.com

The model was created in NetLogo 6.0.3 and updated to 6.2.0 version, Wilensky, U. (1999). NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL as a responce to SFI 2018 Complexity Challenge.

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

globals [
  s-pull-patches
  h-pull-patches
  l-pull-patches

  low-payoff
  high-payoff
  stable-payoff
  low-number
  high-number
  stable-number

  lpay
  hpay

  tau
  tau-list
  ; replication?

]

breed [masters master]
breed [i-s-agents i-s-agent]
breed [i-l-agents i-l-agent]
breed [i-h-agents i-h-agent]
breed [r1-agents r1-agent]
breed [r2-agents r2-agent]
breed [r3-agents r3-agent]
breed [random-agents random-agent]

turtles-own [
   my-choices
   my-payoff
   my-wealth
   current-choice
   current-payoff
   commission
   wealth
   ; my-data
]

to setup

  ca

  set s-pull-patches patches with [ pxcor <= 5 and pxcor >= -5]
  ask s-pull-patches
  [set pcolor 87]

  set h-pull-patches patches with [  pxcor > 5 ]
  ask h-pull-patches
  [set pcolor 47]

  set l-pull-patches patches with [pxcor < -5]
  ask l-pull-patches
  [ set pcolor 137]

  if scenario = "Random" [
   set replication? false
  create-random-agents num-random-agents[
   set shape "face happy"
   set color yellow
   set size 2
  ]

    create-masters num-masters
  [
  set size 5
  set color green]

    set num-i-s-agents 0
    set num-i-l-agents 0
    set num-i-h-agents 0

  ]

  if scenario = "Irrational-I" [
    set replication? false
  set num-random-agents 0

    create-masters num-masters
  [
  set size 5
  set color green]

    create-i-s-agents num-i-s-agents
    [
      set size 3
      set color sky]

     create-i-l-agents num-i-l-agents
     [
      set size 3
      set color brown]

     create-i-h-agents num-i-h-agents
     [
        set size 3
      set color red]

  ]

   if scenario = "Meta-2" [
     set replication? false

  set num-random-agents 0

    create-masters num-masters
  [
  set size 5
  set color green]

    create-i-s-agents 18
    [
      set size 3
      set color sky]

     create-i-l-agents 16
     [
      set size 3
      set color brown]

     create-i-h-agents 16
     [
        set size 3
      set color red]
  ]

   if scenario = "Meta-1" [

  set num-random-agents 0

    create-masters num-masters
  [
  set size 5
  set color green]

    create-i-s-agents 48
    [
      set size 3
      set color sky]

     create-i-l-agents 1
     [
      set size 3
      set color brown]

     create-i-h-agents 1
     [
        set size 3
      set color red]

    if replication? = true [

    create-r1-agents num-r1-agents
     [
        set size 3
      set color orange]

      create-r2-agents 1
     [
        set size 3
      set color black]

      create-r3-agents 1
     [
        set size 3
      set color 44]
    ]

  ]

  if scenario = "Meta-3" [
     set replication? false

  set num-random-agents 0

    create-masters num-masters
  [
  set size 5
  set color green]

    create-i-s-agents 4
    [
      set size 3
      set color sky]

     create-i-l-agents 23
     [
      set size 3
      set color brown]

     create-i-h-agents 23
     [
        set size 3
      set color red]
  ]


   ask turtles [
   set my-choices []
   ]

  set low-number []
  set high-number []
  set stable-number []
  set low-payoff []
  set high-payoff []
  set stable-payoff []

   ask turtles [
   set my-payoff []
  ]

  set tau-list []
  set tau 0

  ask turtles [
    set my-wealth []
  ]


  ask turtles [
    set wealth []
  ]

  reset-ticks
end 

to go

   if ticks >= 100 [stop]

  ifelse ticks != 0
   [ask turtles [choose]];[
   [ask turtles [setxy random-xcor random-ycor]]

   ask turtles [update-choice]
   ask turtles [set my-choices fput current-choice my-choices]

   generate-low-number
   generate-high-number
   generate-stable-number

   generate-low-payoff
   generate-high-payoff
   generate-stable-payoff

   ask turtles [update-payoff]
   ask turtles [set my-payoff fput current-payoff my-payoff]

  ifelse ticks != 0
   [set tau random-float max-tau]
   [set tau 0]
   set tau-list fput tau tau-list

   ask turtles [pay-commission]

   ask turtles [update-wealth]

  ask turtles [set wealth fput (sum my-wealth) wealth]

  tick
end 

to choose
  let choice strategy
  if choice = 0
  [ move-to one-of s-pull-patches ]

  if choice = 1
  [ move-to one-of l-pull-patches]

  if choice = 2
  [move-to one-of h-pull-patches]
end 

to-report strategy

  if scenario = "Random" [

    if breed = random-agents
     [report random 3]

    if (breed = masters)
  [ifelse ticks > t-threshold
    [ifelse (2500 - (sum ( map * (low-payoff) (low-number)))) > (2500 - (sum ( map * (high-payoff) (high-number))))
     [report 1]
     [report 2]]
    [report random 3]

  ]
  ]
   if scenario = "Irrational-I" [

    if breed = random-agents
     [report random 3]

    if (breed = masters)
  [ifelse ticks > t-threshold
    [ifelse (2500 - (sum ( map * (low-payoff) (low-number)))) > (2500 - (sum ( map * (high-payoff) (high-number))))
     [report 1]
     [report 2]]
    [report random 3]

  ]

  if ( breed = i-s-agents )
      [report 0]

     ifelse (breed = i-l-agents and (first low-payoff > first high-payoff))
     [report 1]
     [report 2]

    ifelse (breed = i-h-agents and (first high-payoff > first low-payoff))
       [report 1]
       [report 2]
]
  if scenario = "Meta-1" [

  if (breed = masters)
  [ifelse ticks > t-threshold
    [ifelse (2500 - (sum ( map * (low-payoff) (low-number)))) > (2500 - (sum ( map * (high-payoff) (high-number))))
     [report 1]
     [report 2]]
    [report random 3]
    ]

     if ( breed = i-s-agents )
      [report 0]

     if (breed = i-l-agents)
     [report 1]


    if  (breed = i-h-agents)
       [report 2]

  ]
  if scenario = "Meta-1" and replication? = true
  [
  if ( breed = r1-agents)
    [report 0]
     if ( breed = r2-agents)
    [report 1]
     if ( breed = r3-agents)
    [report 2]
  ]

   if scenario = "Meta-2" [

  if (breed = masters)
  [ifelse ticks > t-threshold
    [ifelse (2500 - (sum ( map * (low-payoff) (low-number)))) > (2500 - (sum ( map * (high-payoff) (high-number))))
     [report 1]
     [report 2]]
    [report random 3]
    ]

     if ( breed = i-s-agents )
      [report 0]

     if (breed = i-l-agents)
     [report 1]


    if  (breed = i-h-agents)
       [report 2]

  ]

  if scenario = "Meta-3" [

  if (breed = masters)
  [ifelse ticks > t-threshold
    [ifelse (2500 - (sum ( map * (low-payoff) (low-number)))) > (2500 - (sum ( map * (high-payoff) (high-number))))
     [report 1]
     [report 2]]
    [report random 3]
    ]

     if ( breed = i-s-agents )
      [report 0]

     if (breed = i-l-agents)
     [report 1]


    if  (breed = i-h-agents)
       [report 2]

  ]
end 

to generate-low-number
  if ticks >= 0
  [set low-number fput (count turtles-on l-pull-patches) low-number]
end 

to generate-high-number
  if ticks >= 0
  [set high-number fput (count turtles-on h-pull-patches) high-number]
end 

to generate-stable-number
  if ticks >= 0
  [set stable-number fput (count turtles-on s-pull-patches) stable-number]
end 

to generate-low-payoff
  ifelse first low-number > 0
  [
  ifelse random-float 1 < 0.5
  [set lpay 40]
  [set lpay 0]

  set low-payoff fput (lpay / first low-number) low-payoff
  ]
  [
    ifelse random-float 1 < 0.5
  [set lpay 40]
  [set lpay 0]
    set low-payoff fput lpay low-payoff
  ]
end 

to generate-high-payoff
  ifelse first high-number > 0
  [
   ifelse random-float 1 < 0.25
  [set hpay 80]
  [set hpay 0]

  set high-payoff fput (hpay / first high-number) high-payoff
  ]
  [
    ifelse random-float 1 < 0.25
  [set hpay 80]
  [set hpay 0]

  set high-payoff fput hpay high-payoff
  ]
end 

to generate-stable-payoff
   set stable-payoff fput 1 stable-payoff
end 

to update-choice

  ask turtles-on patches with [pcolor =  87]
  [set current-choice  0]

  ask turtles-on patches with [pcolor = 137]
  [set current-choice  1]

  ask turtles-on patches with [pcolor = 47]
  [set current-choice  2]
end 

to update-payoff

  ask turtles-on patches with [pcolor =  87]
  [set current-payoff 1]

  ask turtles-on patches with [pcolor = 137]
  [set current-payoff first low-payoff]

  ask turtles-on patches with [pcolor = 47]
  [set current-payoff first high-payoff]
end 

to pay-commission
  ifelse ticks > 0 [
    ifelse  item 0 my-choices = item 1 my-choices
    [set commission 0]
    [set commission tau]
  ]
  [ set commission 0]
end 

to update-wealth
   let earning (current-payoff - commission)
   set my-wealth fput earning my-wealth
end 

to-report f-wealth
 report sum my-wealth
end 


There is only one version of this model, created almost 2 years ago by Victor Iapascurta.

Attached files

File Type Description Last updated
SFI CXC Winner Model.png preview Preview for 'SFI CXC Winner Model' almost 2 years ago, by Victor Iapascurta Download

This model does not have any ancestors.

This model does not have any descendants.