Phase 5. Adding buses

Our model currently contains automobiles only. In the next improvement step we will add buses to our model. They will move from the South to the North along the Tapiolavagen road making a stop at the bus stop (you can see it at the roadsideafter the intersection on the layout). 

Add block that will generate buses

  1. Add another CarSource block from the Road Traffic Library. This block will generate buses. Name it busSource and connect it to the carMoveToN block.
  1. Since buses will appear more rarely than cars we need to modify the properties of the previously created block. Let us set the Arrival rate to 20 per hour for a start. 
  2. Choose roadSouth in the Road parameter.
  3. Open the Car section in the block's properties and set the Length of the bus that you are creating to 10 meters
  4. In the Initial speed field type 40 kilometers per hour.
  5. Unlike the previously created CarSource blocks, this block must generate buses.  To make it generate buses we must create another agent type. Open the Car section of the block's properties and click on create a custom type.
  6. The new agent wizard will open. Type Bus into the Agent type name and press Next.
  7. On the next page leave the 3D option selected and choose Bus 1 from the list of animation figures below. Click Finish
Make sure to compare your properties with the screenshot below to check if all the parameters are specified correctly.

Switch back to the Main flowchart and run the model. You will see that occasionally buses move from the South to the North along the road  (You might actually have to wait for a bus to appear like in real life).


On the screenshot above a bus is currently passing by the bus stop. Let us change the logic of the model to make buses stop at the bus stops.

First, we need to create a bus stop with the help of the AnyLogic Bus Stop space markup element.

Draw a bus stop

  1. Drag the Bus Stop element from the Space Markup section of the Road Traffic Library palette to the graphical editor. Place it at the roadside as shown on the picture below. 
  1. Increase the length of the bus stop. Click the bus stop to select it and then drag the rectangle marker on its edge. 

Now we shall add new blocks to the flowchart.

Adjust the flowchart

  1. Add another  CarMoveTo block to the busSource block's flowchart branch (see screenshot below). Name it busMoveToStop. It will model bus movement to the bus stop. 
  1. Switch to the Properties view of the busMoveToStop block and choose bus stop in the Moves to parameter. In the Bus stop option below specify the name of the previously created bus stop (busStop).
  2. Now we need to model the certain period of time that buses spend at the bus stop. Add the   Delay block from the Process Modeling Library. Name it stop and connect it as shown on the picture below.
  1. Go to the block's properties and specify the Delay timetriangular( 15, 30, 90 ) seconds

Run the model. You will see that buses arrive at the bus stop and wait for passengers to get on and off. Afterwards, buses continue to move according to the specified route.

Reference model: Road Traffic Tutorial - Phase 5


          Phase 4. Adding a parking lot

          Phase 6. Adding traffic lights