TRAFFIC INTERSECTION

WHAT IS IT?
-----------
In this model the turtles are cars traveling through an 
intersection.
The user has the ability to control the number of cars
coming from each direction, the speed of the cars, and the 
timing of the light at the traffic intersection.
Once the number and speed of cars is selected, the user
should
run the simulation and adjust the timing of the traffic
light so as to minimize the amount of waiting time of cars 
traveling through the intersection.


HOW TO USE IT
-------------
Use the W-CARS slider to select how many cars will travel 
from the west to the east.
Use the S-CARS slider to select how many cars will travel 
from the south to the north.
One new car for each direction will enter every 5 ticks
until the selected number of cars is on the screen.  New
cars may be added at any time during the simulation.  
Decreasing the value of a slider will not decrease the
number of cars, however.

Use the W-SPEED slider to select how fast the cars from the 
west will travel.
Use the S-SPEED slider to select how fast the cars from the 
south will travel.

The speed slider values will be used as input for JUMP
commands.  A car will not move if there is a car in the patch
where it intends to move or if there is a car that cannot
move that is between it and its target patch.  These values
may be adjusted at any time during a simulation.

If a car from the west and a car from the south will each 
reach the intersection at the same time, the right of way is
given to the car traveling at a faster speed.  If both cars 
are traveling at the same speed, right of way is given to
cars from the west.

Use NUM-TICKS to select the number of ticks out of 100 for 
which traffic from the west gets a green light.


Monitors
--------
SUM-OF-E-W-CARS shows how many thousands of ticks of waiting
time have been logged by all cars from the west.

SUM-OF-N-S-CARS shows how many thousands of ticks of waiting
time have been logged by all cars from the south.

COUNTER shows how many ticks have elapsed.

Press STEPONCE to make the cars move once.

Press GO to make the cars move continuously.
To stop the cars, press the GO button again.


RUNNING THE MODEL
-----------------
Try starting with 20 cars with a speed of 1 coming from each
direction.

   THINGS TO NOTICE
   ----------------
   Cars start out evenly spaced but over time, they form 
   bunches.
   What kinds of patterns appear in the traffic flow?
   Under what conditions do the cars appear to be moving 
   backwards?

   Gridlock happens when cars are unable to move because cars
   from the other direction are in their path.  What settings
   cause gridlock in this model?  What settings can be
   changed to end the gridlock?  There are multiple answers
   to each of these questions.


   THINGS TO TRY
   -------------
   Try to answer the following questions before running the 
   simulations.  Record your predictions.
   Compare your predicted results with the actual results.
   - What reasoning led you to correct predictions?
   - What assumptions that you made need to be revised?


   Try different numbers of W-CARS while keeping all other
   slider values the same.
   Try different numbers of S-CARS while keeping all other
   slider values the same.
   Try different values of W-SPEED while keeping all other
   slider values the same.
   Try different values of S-SPEED while keeping all other
   slider values the same.
   Try different values of NUM-TICKS while keeping all
   other slider values the same.
   For all of the above cases, consider the following:
   - What happens to the waiting time of W-CARS?
   - What happens to the waiting time of S-CARS?
   - What happens to the overall waiting time?

   - What generalizations can you make about the impact
      of each variable on the waiting time of cars?

   - What kind of relationship exists between the number
      of cars and the waiting time they experience?
   - What kind of relationship exists between the speed of
      cars and the waiting time they experience?
   - What kind of relationship exists between the number
      of ticks of green light and the waiting time cars 
      experience?

   Use your answers to the above questions to come up
   with a strategy for minimizing the waiting time of 
   cars.

   What factor (or combination of factors) has the most 
   influence over the waiting time experienced by the cars?


The simulation will stop once the counter reaches the
StarLogo maximum value of 32766.  If you want to continue
the simulation beyond this point, use the command center to
reset the value of counter to 0 (setcounter 0) and press the
GO button to continue.


EXTENDING THE MODEL
-------------------
In this simulation, cars only try to move at the speed 
indicated by their related speed slider.  In real life, a 
driver would proceed at a slower speed if that were
possible.  Change the procedures that check to see if the 
cars have room to move forward so that cars will move
forward at the maximum speed less than or equal to their
speed value.  In other words, if the speed slider is set 
to 5 and the car cannot jump 5 but it can jump 4, allow it
to jump 4.

How does this impact the waiting time of cars?
How does this change your strategy for minimizing waiting
time of cars?

In this simulation, the right of way is given to the car 
traveling at a faster speed.  Change the model so that right
of way is given to cars traveling in the direction with the 
greater number of other cars on the same road.

How does this impact the waiting time of cars?
How does this change your strategy for minimizing waiting 
time of cars?

In an actual traffic intersection, the cars are required to
stop further from the traffic light than is the case here.
Change the model so that when cars have a red light, they
stop at the location of the amber warning bar [instead of at
the patch just before the red light].  How does this change
the patterns in the traffic?


STARLOGOT FEATURES
-----------------
The JUMP command is used instead of the FORWARD command so 
that cars really do move faster, not just further, with each
clock tick when speeds are set to values greater than one.