Ivana Pecuchova Ivana Vaŀová

Simulation models for economics

Project work on

"Traffic-jam externalities."

 

The applet requires Java 5 or higher. Java must be enabled in your browser settings. Mac users must have Mac OS X 10.4 or higher. Windows and Linux users may obtain the latest Java from Oracle's Java site.


Here you can find an introduction to the Traffic-jam externalities application.


powered by NetLogo

view/download model file: Traffic-jam_externalities.nlogo

WHAT IS IT?

The program can be understood as model showing how following agent's decision can be affected by observation of current situation. Generally thinking this model shows also the externalities that car drivers impose on each other. The program is showing behavior of agents who are facing to a question what kind of vehicle (a car or a train) should they use following day with respect to their total today's experience with travelling . According to previous experiences agents decide whether to travel by car or train.

HOW IT WORKS

The model's agent will face a decision problem between using a car or a train with respect to his total today's experience with travelling (which is meant as total experience dated to yesterday adjusted by experience of the current day). So if too many agents decide to travel by car, it causes traffic jam. And the occurrence of traffic jam has an effect on agent's following decision. According to previous experiences agent decides whether to travel by car or train.

The decision comes up for the first time in SETUP process (which is capturing building the world and executing the first decision of agents) and his choice will be based on his random income classification and value of experience given him also randomly.

According to his first decision the total number of ‘traffic-members’ will be adjusted and also his current experience will be adjusted (as his current feeling about the traffic on the road).

Further GO process will follow, in which based on this new computed current experience an agent will decide between vehicles again. His current experience and “traffic-members” will be adjusted again. And so again and again tick by tick.

HOW TO USE IT

To use the model, set the Number-of-agents, Traffic-jam-threshold and Preffer-car?-threshold by sliders, press SETUP, and then GO.

Plots show the mean experience and its standard deviation and the number of the traffic memebers on the road.

THINGS TO NOTICE

General principle of the model observed on the screen:

In an ordinary case, e.g. when we set up the total number of agents over 200, the value of traffic jam threshold setted approximately by 3/4 of its max. and the value of prefer-car?-threshold less than 0,5.

In this case when the number of ‘traffic-members’ exceeds ‘Traffic-jam-threshold’ the traffic jam is observed. Traffic jam will affect the current agent's experience. This fact will imply that in next round of decision some of middle-income agents who are using a car in the current tick will change their opinion. They will join the train in the following tick.

In the case when traffic jam does not appear more time, it will have positive effect on agent's experience and agent will decide for using car again.

THINGS TO TRY

The model has 3 variables regulable by sliders in interface and it is :

- the total Number-of-agents,
- Traffic-jam-threshold which shows how many car users cause traffic jam and
- Preffer-car?-threshold which is the ratio of accumulated experience which have to be exceeded in order to make agents to choose car journey.

The ‘Traffic-jam-threshold’ and ‘Preffer-car?-threshold’ become mainly important In order to see some noticalbe things.

By different settings of these sliders it could be observed interesting changes on plots of ‘Mean experience and standard deviation’ and ‘Traffic Members’ as well as on the screen representing the world of agents.

The most interesting are extreme cases which appear in differences in ‘Prefer-car?-threshold’ and ‘Traffic-jam-threshold’.

EXTENDING THE MODEL

It would be quite interesting to put to each agent's mind instead of just random starting experience some kind of decision strategy, e.g. one part of agents will be altruistic and they will consider joining the traffic on road as negative for the others, in some certain circumstances, and so they will take the train even if they could use the car.

Or what if the whole day would be divided into the smaller day's parts and the agents would be able to remember the certain time when usually the traffic jam appears on the road. Would they take it into the consideration?

NETLOGO FEATURES

move-to one-of patches (we used groups of patches as train or road defined in the beginning)
;; turtle moves to the center of a random patch

Plots show both, global value in and the number of the traffic memebers on the road, and also the mean value of experience of all single agent, which give user a chance to watch overal patterns and individual behavior at the same time.

RELATED MODELS

From the Netlogo Models Library > El Farol and Traffic Basic.

CODE

globals [traffic-members                        ; a number of agents currently on the road (using a car)
         homes                                  ; an agentset of green patches 
         road                                   ; an agentset of gray patches
         railway                                ; an agentset of light gray patches
         train                                  ; an agentset of gray patches on railway
         traffic-jam-indicator]                 ; a patch which indicates traffic jam by label "TRAFFIC JAM" 
                      

turtles-own [income                             ; an income of each agent choosed randomly in range 0 - 1500
             experience                         ; total traffic experience of each agent after meeting or not a traffic jam during a day (tick)) - first setted up randomly then always adjusted by +/- 0.1 according to previous experience of jam or not 
             prefer-car?]                       ; true if experience of agent is > 0.5


TO SETUP
  clear-all
  setup-world                                   ; a procedure creating the world
  create-indicators                             ; a procedure creating the indicator of traffic jam
  create-turtles-all                            ; a procedure creating the agents
  reset-ticks
  
  ; GO-FirstDecision
  
  do-decision-first-time                        ; a procedure separating the agents to using a train or a car for the first time (it means if an agent using a car decides to use a train this fact does not affect the number of traffic-members) 
  indicate-traffic-jam                          ; a procedure activating the traffic jam indicator
  remember-experience                           ; a procedure noting and adjusting a current experience of each agent according to the previous one
  tick
END



TO GO
  do-decision-any-other-time                    ; a procedure separating the agents to using a train or a car
  indicate-traffic-jam                          ; a procedure activating the traffic jam indicator
  remember-experience                           ; a procedure noting and adjusting a current experience of each agent according to the previous one
  tick 
END  




; SETUP PROCEDURES

; a procedure creating the world's enviroment by differentiating color and placement of patches 

to setup-world
  ask patches [set pcolor 74]
  set homes patches with [pycor < 8 and pycor > 2]
  
  set road patches with [(pycor < 15) and (pycor > 8)]
  ask road [set pcolor grey]
  
  set railway patches with [(pycor > -5) and (pycor < 2)]
  ask railway [ set pcolor 8 ]
  set train patches with [(pycor > -3) and (pycor < 0)]
  ask train [ set pcolor gray ]
end



; a procedure creating traffic jam indicator which will be activated in case of traffic jam

to create-indicators
ask patch (0.17 * max-pxcor) (0.97 * max-pycor)
          [ set traffic-jam-indicator self
            set plabel-color white ]
end



; a procedure creating all agents of the world and separating them in 3 different visual groups according to a randomly assigned income

to create-turtles-all
  crt Number-of-agents
  [separate-agents-on homes
   set income random 2000
   set experience random-float 1]
  ask turtles with [income <= 500] 
  [set shape "face neutral"
   set color yellow]
  ask turtles with [income > 500]
  [ifelse income <= 1200
  [set shape "car"
   set color red]
  [set shape "car"
   set color white]]
  
end



; a procedure used in step of creating all agents to separate them in space for better visualisation

to separate-agents-on [locations]            
  move-to one-of locations                 
  if any? other turtles-here
  [move-to one-of locations]
end





; GO PROCEDURES


; a procedure moving agents to a prefered vehicle according to an assigned income and in case of middle-income
;; agents also according to their previous experience with traffic (jam or not) for the first time

; this procedure is also according to the choice of agents adding agents to total number of traffic members 
;; (meaning agents on the road using a car) but it is not substracting them in the opposite case

to do-decision-first-time
set traffic-members 0

ask turtles
[set prefer-car? (experience > Preffer-car?-threshold)]

ask turtles with [income <= 500] 
     [ move-to one-of train
     separate-agents-on train]
     
ask turtles with [income > 1200]
  [ move-to one-of road
    separate-agents-on road
    set traffic-members traffic-members + 1]
     
ask turtles with [income > 500 and income <= 1200]
 [ifelse prefer-car?
     [ set shape "car"
       move-to one-of road
       separate-agents-on road
       set traffic-members traffic-members + 1]
     [ set shape "face neutral"
       move-to one-of train
       separate-agents-on train]]
     
end



; a procedure moving agents to a prefered vehicle according to an assigned income and in case of middle-income 
;; agents also according to their previous experience with traffic (jam or not)

; this procedure is also according to the choice of agents adding or substracting agents to total number 
;; of traffic members (meaning agents on the road using a car)

to do-decision-any-other-time

ask turtles
[set prefer-car? (experience > Preffer-car?-threshold)]

ask turtles with [income <= 500] 
     [ move-to one-of train
     separate-agents-on train]
     
ask turtles with [income > 1200]
  [ move-to one-of road
    separate-agents-on road
    set traffic-members traffic-members + 1]
     
ask turtles with [income > 500 and income <= 1200]
[ifelse traffic-members >= traffic-jam-threshold
 [ifelse prefer-car?
     [ set shape "car"
       move-to one-of road
       separate-agents-on road]
     [ set shape "face neutral"
       move-to one-of train
       separate-agents-on train
       set traffic-members traffic-members - 1]]
 [ifelse prefer-car?
     [ set shape "car"
       move-to one-of road
       separate-agents-on road
       set traffic-members traffic-members + 1]
     [ set shape "face neutral"
       move-to one-of train
       separate-agents-on train]]]
     
end



; a procedure activating a traffic jam indicator in case that sum of agents on the road is greater than 
;; a predetermined value of traffic jam threshold

to indicate-traffic-jam
set traffic-members count turtles-on road
  ifelse traffic-members >= Traffic-jam-threshold 
        [ ask traffic-jam-indicator [ set plabel "TRAFFIC JAM" ]]
        [ ask traffic-jam-indicator [ set plabel "" ]]
end

 
 
; a procedure adjusting experience (of each agent) which will be used as a base for decision in next tick 
;; - a previous experience is adjusted by value 0.1 according to a current one (meeting a traffic jam on 
;; the road or not)to previous 

to remember-experience
ask turtles
 [ifelse traffic-members >= Traffic-jam-threshold
    [set experience experience - random-float 0.4]
    [set experience experience + random-float 0.4]]
end