AnyLogic
Expand
Font size

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 roadside after 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.

  2. 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.
  3. Choose  roadSouth in the Road parameter.
  4. Open the Car section in the block’s properties and set the Length of the bus that you are creating to 10 meters.
  5. In the Initial speed field type 40 kilometers per hour.
  6. 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.
  7. The new agent wizard will open. Type Bus into the Agent type name and press Next.
  8. 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.

  2. 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.

  2. 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).
  3. Now we need to model the certain period of time that buses spend at the bus stop. Add a  Delay block from the  Process Modeling Library palette. Name it stop and connect it as shown on the picture below.

  4. 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.

Demo model: Road Traffic Tutorial - Phase 5 Open the model page in AnyLogic Cloud. There you can run the model or download it (by clicking Model source files).
How can we improve this article?