Phase 1. Simulating a simple
In the first phase, we will create a simple model
simulating a pedestrian flow: how people move inside our
Creating a new model
a new model
- Click the New toolbar button. The New
Model wizard appears.
- Specify the name of the new project. In the Model name
type: Subway Entrance Hall.
- Specify the location where you want to store
your model files. Browse
for the existing folder using the Browse
button, or type the name of the folder you want to create in the Location edit box.
- Select minutes as the Model time units.
- Click Finish
complete the process.
New model is created. It already has one agent type
and experiment called Simulation.
Agents are the main building blocks of AnyLogic model. In our case the Main agent
will serve as the place where will define all the logic of the
here we will put the drawing of the entrance hall, and define the
flowchart describing the
pedestrian flow process.
center of the
workspace you will see the graphical editor. It shows the
of the Main type.
To the left of the graphical editor
you can see the Projects view
and the Palette
view sharing the same area.
access to AnyLogic models currently opened in the workspace. The
workspace tree provides easy navigation throughout the
view contains all graphical elements you can add onto the graphical
editor of your agent just by drag'n'drop. Model elements are grouped by
categories in a number of palettes.
On the right side of the workspace you can see the Properties view. The
view is used
to view and modify the properties of a currently selected model
element(s). When you select something – e.g., in the Projects view or in
graphical editor – the Properties
view displays the properties of the selection.
Adding a drawing of the simulated building
When creating a pedestrian dynamics simulation model, you
always start with adding a layout image (drawing) of the simulated space (building). Then you
draw the walls on top of this image and define the process logic: how
the pedestrians move inside this building.
We will use the following layout:
Save the subway
hall layout to your computer
Now we can add this image on our model's canvas.
- Right-click the image above, click Save image as and select the location for the image file.
Add the subway
First, open the Presentation
palette of the Palette
view. This palette contains shapes you can add on your
To open a palette, just click on the corresponding icon in
the vertical ribbon
docked to the left part of the palette. While you are not
accustomed to the palette icons, you may hover the mouse over the
ribbon and wait for the popup window to appear. It will show you the
names of all palettes.
- Select the Presentation
to open it:
Drag the Image element
from the Presentation palette
on the graphical diagram.
Choose the image file to be displayed by
this shape. The file browser will open automatically. Browse to the folder
where you just saved the layout image file, select it, and then click Open in the dialog box.
- You will see the drawing displayed in the graphical editor:
- In the Properties
view, select the Lock
checkbox to lock the image. Locked
shapes do not react to mouse clicks - it is impossible to select them
in the graphical editor until you unlock them. We need this since we
will draw other shapes on top of this image and thus want to prevent
editing the drawing while drawing shapes over it.
Just few zones are marked on this drawing. We want to
experiment with different layouts and do not know right now where the
ticket offices and ticket vending machines area will be located. That
is the reason these areas are not marked on the drawing.
Drawing the walls
Now we will mark up the space of our model. Usually we start
with drawing the building walls.
- Open the Pedestrian
palette to draw the wall like in the figure shown below:
- You draw the wall this way. First, double-click
the Space Markup
section of the Pedestrian
palette. The icon of the
element should turn into . It means that the drawing mode
is activated and now
you can draw the wall in the graphical editor point by point.
- Subsequently click at the points where you want to place
wall corners. Every click appends a linear segment to the wall you are
- To append a curved segment, press the left mouse button at
the point where the curved segment ends and then move the mouse with
the button being pressed. While moving you will see how the curving
radius changes. To draw the circular segment, move the mouse exactly
along the grid line. When done, release the mouse button.
If it is hard for you to draw a wall of exactly the same shape,once,
you can draw the wall with several Wall
- Finally double-click to place the last
point and finish drawing the wall.
Drawing entry and target lines for a
Now you should define entry and exit points for the pedestrian
Draw an entry line first. Entry is a
place where pedestrians appear in
simulated environment. You define the start line for the pedestrian
flow with a special markup element Target
We want to draw the entry line right where we have the
ENTRANCE text on our drawing.
Draw the line where
- Drag the Target
the Space Markup
section of the Pedestrian
Library palette onto the graphical editor.
- Resize it and place it exactly as shown in the
- Name the line entryLine.
Now let's add one more target line that will define the place
where the passengers will move when entering the subway entrance hall.
We want them to move to subway trains, so let's place this
target line just over the text TO TRAINS.
Draw the target line
- Draw one more target line and place it as shown in
below. Entered the subway station, passengers will move here to get to
all markup elements (target lines, etc.) should lie inside the walls
Creating a flowchart defining the pedestrian flow
Now we will finish creating the simple model simulating
flow. We will define the pedestrian flow process with a flowchart
composed from Pedestrian
We will start with a very simple process: passengers enter the
subway station (just where we put the entryLine)
and then move to the trains (to our targetLine).
AnyLogic you create flowcharts by adding the blocks from the
library palette to the graphical diagram, setting custom
the blocks, and connecting blocks together.
Create the model
Library blocks on the diagram and connect them as shown
in the figure
below. To add a flowchart block on the diagram, open the Pedestrian Library
palette, and drag
the required block from the palette into the graphical editor.
- While dragging the blocks, and placing them close to each
other, you may see the lines connecting the blocks
appear. Please note that these connectors should connect only the ports
lying on right and left borders of the block icons. This is critical,
e.g. connecting the pedSink
port to the lower port of pedGoTo
block will raise the error.
- Rename the blocks. Name them inflowSource,
goToTrains, inflowSink. (You
can do this in the blocks' properties.)
Let's say a pair of words about these flowchart blocks.
block generates pedestrians. It is usually used as a starting point of
the pedestrian flow. In our
example, it models passenger arrival.
pedestrians from the current location to a new
one. We add this block
to model how passengers move from the entry to subway trains.
block disposes incoming
pedestrians. It is usually used as an end point of the pedestrian flow.
Please refer to Pedestrian
Library Reference Guide
for the detailed information about all Pedestrian
Configure the flowchart
- Select inflowSource
block. In the Properties
view, define the place where the passengers will
appear. Choose entryLine
(the name of our target line drawn earlier at the entrance) from the Target line
drop-down list. Another way to choose a markup element in the parameter
is to click the selection button
and select this element in the graphical editor.
- Set passengers Arrival rate
to 4000 per hour.
- Now modify the properties of goToTrains. Specify destination for
passengers. When entered
pedestrians will go to the target you specify here. At
this point we
assume that all passengers move directly to subway
trains. Specify targetLine
name of the target line we have drawn second) in the Target line field.
OK, we've finished! Let's run our model.
- Leave all properties of PedSink
block by default.
- Click the Run
toolbar button and choose the experiment you want to run from
drop-down list. Your simulation experiment is called Subway Entrance
Having started the model, you will see the model window. It
displays the presentation designed for your simulation experiment. By
default it is blank, with just the model name .
Later on you can add here graphics, put here the model description,
- Click the Run button in the control panel displayed at the window bottom. You can
see passengers entering
the subway entrance hall and passing through the corridor to the subway
OK, great! We have created a simple model just in minutes.
Note that there are several reference models available representing
milestones of the editing. You can
use them if you experience any difficulties creating a model
like to compare your model with the reference file. Below you
can see the link opening the reference model corresponding to this
If everything is OK, we can continue further. Follow the link at the
very end of this page to open the document describing the next phase of
the model development.
Phase 2. Adding fare