AnyLogic Training Materials

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 214

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.

Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Multi-Method
Simulation
Modeling with
Thispresentationisapartof
AnyLogic
AnyLogicStandardTrainingProgram

© The AnyLogic Company | www.anylogic.com

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Modeling
The model The solution at the model level

RISK-FREE SPACE
The world of models
The real world

?
The problem The solution

© The AnyLogic Company | www.anylogic.com 2


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Types ofmodels

Mental models Boxes connected with lines Physical models

Formulas on a sheet of paper


Simulation models
Excel spreadsheets

© The AnyLogic Company | www.anylogic.com 3

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

The most popular modeling tool is:

MS Excel
Input Output

X1 Y1
X2 Y2
X3 Y = f(X) Y3
X4 Y4

Analytical solution
(formulas and scripts)
© The AnyLogic Company | www.anylogic.com 4
Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

However…

• You canfindan analyticalsolution if:


о The number of parameters is ‘manageable’
о Behavior is linear
о Dependencies are clear, easy to build a
mental model

?
• But whatif:
о Too many parameters
о Non-linear, non-obvious influences
о Time and causal dependencies
о Counter-intuitive behavior
о Uncertainty (stochastic system)

© The AnyLogic Company | www.anylogic.com 5

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Example:Bank

• Asimplistic case:
о On average 10 clients per hour
о Only one teller at the counter
о Mean service time is 5 minutes
• We wantto find out:
о Mean waiting time in the queue
о [Other metrics can be derived from that one]

• It’ll take you a few seconds to find the analytical solution:


Ob2 O - arrival rate
Mean waiting time* w , where
1 Ob b - mean service time
* This holds only for a Poisson stream of clients (independent arrivals with constant rate)
and exponentially distributed service time.

© The AnyLogic Company | www.anylogic.com 6


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Bank. Assumptions of the analytic approach

• Whatdo these assumptionsmean?


о Independent arrivals of clients – this should be an OK assumption
for the bank
о Exponentially distributed This is far from reality. The distribution
service time: is more likely of this shape:
mean mean
Probability

Probability
Check cashing, depositing
More complex
transactions

Service time Service time


• Then the Internet search will suggest another formula:

 Obb2 (1 C,2where


)
w Cb - coefficient of variation of service time
2(1 Ob)
© The AnyLogic Company | www.anylogic.com 7

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Bank. What if a bit less simplistic case?

• Letthere be several(K) tellers


о This is so-called “multi-server queue model”. The analytic solution*:
Pb
w U Ob
K 1 U
, where - system utilization,
K
KU K ª KU K K 1
KU i º
1
P P , where P0 « ¦ »
K!(1 U ) 0
¬ K!(1 U ) i 0 i! ¼
- probability of all - probability of
tellers being busy “no clients in the bank”
* This, however, is valid only for Poisson stream of clients and
exponentially distributed service time.

• And what if service time has a different distribution?


о Even for such a simple system there is no analytic solution

© The AnyLogic Company | www.anylogic.com 8


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Bank example.Summary
• In the realbank the processis far morecomplex:
о Some transactions can be done only by some particular employees
о The client can be redirected to other employees
о The tellers may share resources, such as a printer or a copier
о Different employees may have different skills and performance
о Etc.

• The analytic solution probably does not exist


о Even if it exists, who will find it for you?
о Almost any change in the process makes the previous analytic solution
void
• The onlyanalysismethodfor suchsystemsthathas
foreseeable complexity and guaranteesthe resultis:
simulationmodeling

© The AnyLogic Company | www.anylogic.com 9

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Simulation modeling Y1
Measure outputs
as the model runs X1
Identify input Identify
parameters outputs (key
Animate the system
(decision variables) metrics, KPIs)
behavior
X Y

Build the model - describe the


Perform what-if
experiments X2 ?
system dynamic behavior

X1 ? X2 Compare scenarios

Measure risk
time
Run the model – obtain a trajectory
Optimize
of the system state in time

• Dynamicsimulation enablesmuchmoredetailedanalysisand can


solve problemsthatspreadsheet-basedor LP-based analyticscan’t
© The AnyLogic Company | www.anylogic.com 10
Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.

Simulation modeling methods & application areas


Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Aggregates, global feedback loops, influences,trends…


High abstraction level Strategic level: Market, Competition, Product portfolio, etc.
minimum details

System Dynamics
macro-level

Large scale logistics, Supply Chains: GIS-based models

Agent Based
Medium abstractionlevel
medium details On-site (small scale) logistics: Trucks, Trains, Pipelines, Tanks

Discrete Event
“Physical” level: Material handling, Factory floor, Pedestrian

Low abstraction level


maximum details
micro-level
Individual objects, exact sizes, velocities, distances,timing…
© The AnyLogic Company | www.anylogic.com 11

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

System Dynamics Jay Forrester’50s

• Stocks,flows
о Interacting feedback loops

Sales
Potential
Clients
clients
+ +
B R
Sales +
+ Sales from from Word of
Advertizing B Mouth Adoption
+ +
Advertizing + + Fraction
effectiveness Contact
Rate
Bass Diffusion Model

© The AnyLogic Company | www.anylogic.com 12


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

System Dynamics Jay Forrester’50s

• Stocks,flows
о Interacting feedback loops

The equivalent mathematical model:

( Potential clients )/dt = - Sales

d( Clients )/dt= Sales


+ Всё
Sales = Sales from Advertizing + Sales from Word of Mouth населе
е ние
население

Sales from Advertizing = Potential clients * Advertizing effectiveness


-
Sales from Word of Mouth =
+ Эффективность
Clients * Contact Rate * +
( Potential clients / (Potential clients + Clients )) * Adoption Fraction тной рекламы
рекламы контактов

Bass Diffusion Model

© The AnyLogic Company | www.anylogic.com 13

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Discrete event modeling. G. Gordon’60s

• Agentsand resources.Flowchartdiagram
о Queues and delays

[source] [decision] [queue+service] [sink]

yes
no

[agents]
[resources]

yes

no

[queue] [delay] [decision]


Bank

© The AnyLogic Company | www.anylogic.com 14


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Agent basedmodeling

• We focuson individual objectsanddescribetheirlocal behavior,


localrules
о Sometimes, we also model the dynamics of the environment

Agent’s behavior
Environment

Child

Junior

Adult

Senior

© The AnyLogic Company | www.anylogic.com 15

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Simulation modelingsoftware

• Traditional toolsare designed to support one particular modeling


approach
System Discrete event Agent based
dynamics modeling modeling

VenSim Arena [Academic


PowerSim ExtendSim tools:]
iThink SimProcess Swarm
AutoMod RePast
PROMODEL NetLogo
Enterprise ASCAPE
Dynamics
FlexSim

© The AnyLogic Company | www.anylogic.com 16


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

AnyLogic – multi-method simulation tool

• Easy to choose
and adjust the
“Vertical“ abstraction level
solutions
(Pedestrian, Rail, …) System • Can switch
dynamics between
Agent based different
modeling methods
• Can mix
Discrete event
(process based)
methods in one
modeling model
• Modern and
flexible OO
platform
© The AnyLogic Company | www.anylogic.com 17

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Everybody uses AnyLogic for simulation

technology automotive
pharma aerospace
healthcare

energy
global consulting
railroads

finance consumer goods


defense
mining fundamental research
supply chains
oil & gas
logistics

© The AnyLogic Company | www.anylogic.com 18


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

The AnyLogic
Model
Development
Thispresentationisapartof
Environment
AnyLogicStandardTrainingProgram

© The AnyLogic Company | www.anylogic.com

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

AnyLogic GUI
Menu and Toolbars. Shortcuts to Most Commands

Double
Project view. click Properties of
Easy the currently
Navigation selected item

Palette view.
Model items Graphical
grouped in Editor
stencils Diagram

Problems view. Displays and helps to locate Errors

© The AnyLogic Company | www.anylogic.com 20


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Menu andToolbars

• Shortcuts to mostcommands
• Automatically adjust to current view
Standard (New Model, Open Model, Save Model, Save All Models)

Edit (Undo, Redo, Cut, Copy, Paste, Delete)

Build (Build Model, Run, Debug)

Draw (Zoom to 100%, Zoom In, Zoom, Zoom Out, View Areas, Show/Hide Grid, …)

© The AnyLogic Company | www.anylogic.com 21

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Model Structure – All Elements as a Tree

Double-Click
Models with unsaved
to open editor
changes are marked
and/or properties of
with asterisks
an element

All model items are


organized hierarchically

Right-Click
(Mac OS: Ctrl+click) Use Copy/Cut and
for context menu Paste to copy within
the tree

© The AnyLogic Company | www.anylogic.com 22


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Navigation betweenpalettes

1. Hover the mouse


over the vertical
navigation bar

2. You will see the popup list


with the palette names.
Just choose the palette
name from the list.

© The AnyLogic Company | www.anylogic.com 23

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Adding Palette Items on Diagram


1. Common way 2. Rectangular objects 3. Multipoint objects
(State, Rectangle, Oval (Path, GIS Route, Transition, Connector)
Rounded Rectangle)
1A: Drag the
element from
2A: Double-clickthe
Palette… element in Palette
3A: Double-click
the element in
Palette

2B: Drag to create a new


rectangular object

3B: Click at each


point of the
multipoint line

1B: … and drop it in


the desired place 3C: Double-Click to
of the diagram 2C: Release mouse finish multipoint
button to finish object creation

© The AnyLogic Company | www.anylogic.com 24


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Graphical Editor – Selecting & Copying

Switch between
editor windows Zoom control

Maximize/restore
graphical editors
Shift+Click object to
add it to the
selection
Ctrl+drag (Mac OS:
Cmd+drag) to copy
the selected objects
in the same window

Right-Drag to move
the canvas in the Drag rectangle to
window select multiple
objects

© The AnyLogic Company | www.anylogic.com 25

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Properties view
• The Properties viewallows
Name of the
element
youto viewandmodifythe Type of the
element
selected item’s properties
(you select an item by
clicking it in the graphical
editor,or inProjectsview).
Legend:
Static value

Dynamically evaluated expression

Small triangle indicates that you can


switch between design-time (static)
and run-time (dynamic) values

© The AnyLogic Company | www.anylogic.com 26


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Running theModel

2. Choose the experiment to run


1. Click Run button

3. You will see the model window


showing presentation designed for
the experiment

4. Click the Run control to run the model


and switch to Main agent type

© The AnyLogic Company | www.anylogic.com 27

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Model Window

Animation

Developer panel
Logic
Right-Drag to move the
canvas in the window

Control panel

© The AnyLogic Company | www.anylogic.com 28


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

AnyLogic Help

Help system supports


search mechanism

Help also includes:


• Self-paced tutorials,
•Reference Guides on AnyLogic
Libraries (Process Modeling,
Pedestrian, Rail, ...)
•Java Documentation on all AnyLogic
classes and functions

© The AnyLogic Company | www.anylogic.com 29

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

AnyLogic Support
• Use the built-inGetSupportfeature

This is modeling support – not just


technical support. You can ask “how
should I model this thing” andimprove
your modeling knowledge, not simply
solve your debug problems.

© The AnyLogic Company | www.anylogic.com 30


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Discrete Event
Modeling in
AnyLogic
Thispresentationisapartof
AnyLogicStandardTrainingProgram

© The AnyLogic Company | www.anylogic.com

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Event

• We consider only “important moments” in the


system’s lifetime, which are called events.
– Any change in the model may happen only as a result of
an event
• Examples:
– Customer arrives at the bank office
– Bill finishes processing
– Amount of raw material reaches the minimum level
• Event:
– Takes zero model time
– Causes changes in the model
– May schedule or cancel other events in the future

© The AnyLogic Company | www.anylogic.com 32


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Time as event order – Discrete Time


• We consider only a
sequence of instant
“discrete” events,
while nothing happens 1 7 12 16 time
in between

• No “continuous-time” 1 7 12 16 time
processes

• Model time “jumps” 1 7 12 16 time


from one event to
another
This is Discrete Event Modeling

© The AnyLogic Company | www.anylogic.com 33

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Discrete event modeling. G. Gordon’60s

• Agentsand resources.Flowchartdiagram
о Queues and delays
[source] [decision] [queue+service]] [sink]

yes

no

[agents] [resources]

yes

no

[queue] [delay] [decision]


Bank Office

© The AnyLogic Company | www.anylogic.com 34


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

The simple process based model


• Define the processwithProcessModelingLibraryblockswitha
simpledraganddrop

Arrivals defined by: Rate Capacity: 100 Delay time: triangular( 0.5, 1, 1.5 ) On enter:
Arrival rate: 1 On enter: Capacity: 1
Limited number of arrivals: On at exit: On enter:
New agent: Agent On exit: On exit:
Location of arrival: Enable exit on timeout: Agent location:
On exit: Agent location:

© The AnyLogic Company | www.anylogic.com 35

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Parameters of Process Modeling Library blocks

• Simple staticparameters:
Evaluated once, but may be changed during Capacity 100
the model execution
• Dynamically evaluatedexpressions
Delay time exponential( 1 )
(dynamicparameters):
Condition agent.type == VIP
Evaluated each time they are needed, e.g.
each time the delay time, the speed or Speed agent.cruiseSpeed
other property of an agent needs to be
obtained
The corresponding agent is accessible as
“agent”, etc. Actions
• Dynamicallyexecuted code pieces On exit agent.setColor( red );

(codeparameters): On enter if( agent.airline == “AF”)


Evaluated each time a certain event occurs agent.destination =
gate17;
at the block: the agent enters/exits it,
conveyor stops, etc.

© The AnyLogic Company | www.anylogic.com 36


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Parameters.Examples
Delay

On enter On exit

capacity (static)
V 2serviced

Capacity: 5 Delay time: uniform( 2, 10 )

On enter: agent.setColor(blue ); On exit: serviced++;

• To change a value of the static capacity parameter, call: delay.set_capacity(20);


• You add a semicolon at the end of each line of Java code in code parameter
• You do not add a semicolon to the end of static/dynamic parameter expression

© The AnyLogic Company | www.anylogic.com 37

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Resources

© The AnyLogic Company | www.anylogic.com 38


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Resourcetypes
• Static(can’tmove and can’tbe moved):a room, a non-portable
equipment, a passage, etc.
• Portable (can’tmove on their own, but canbe moved):a wheelchair,
portable x-ray,etc.
• Moving(canmove, carryportable resources):a doctor, a nurse, a
forklift truck,etc.

• Pleasegive the examplesof resources we requireto deliver this


trainingcourse

© The AnyLogic Company | www.anylogic.com 39

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Network-based modeling
• The ProcessModeling Libraryprovides bettersupport for certain
typesof problemswhere layoutis important
• There is a network of locations and paths between them
• Agents and resources move along the paths, route lengths matter

Warehouse

Hospitaldepartment

© The AnyLogic Company | www.anylogic.com 40


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Animation of Process Modeling Library models

You can associateany block that contains agents with a


space markup shape (path or node) defining the
location ofagent animations.
Name: path
Queue

Agent location: path

© The AnyLogic Company | www.anylogic.com 41

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Agent flow at N:1 and 1:N connections

… Fairness not
guaranteed!

Round Robin SelectOutput


The “competing”
T
outputs are served in
round robin manner
to ensure fairness F

Agents are sent to one


of the two output ports depending on
(probabilistic or deterministic) condition

© The AnyLogic Company | www.anylogic.com 42


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Call Center
Model
Thispresentationisapartof
AnyLogicStandardTrainingProgram

© The AnyLogic Company | www.anylogic.com

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Call CenterModel
• Builda simulation model of the callcenter
• The callsare receivedwiththe arrivalrateof 1 callper second
• 100 agentsanswerthe incomingcalls
• Callershangup if theywaitfor too for the agentto reply
• Calculatethe percentof abandoned and answeredcalls
• Addabilityto vary the numberof agentson-the-fly and observe
how thisaffectsthe qualityof service

© The AnyLogic Company | www.anylogic.com 44


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Call Center. Phase 1. Step 1

AnyLogic Welcome Page

n Start AnyLogic

o Click to create a new model

© The AnyLogic Company | www.anylogic.com 45

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

n After you start AnyLogic, you will see the Welcome page.

Whenever you need, you can


open the list of Example
Models via AnyLogic menu:
Help > Example Models

Welcomepage
• ThepurposeoftheWelcomepageistointroduceyoutotheproduct.Thewelcome
pageprovidesaccesstotheexamplemodels,tutorials,books,andotherresources
thathelpyoutolearnmoreaboutsimulationmodelingandAnyLogic.
© The AnyLogic Company | www.anylogic.com 46
Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Call Center. Phase 1. Step 2

n Type CallCenter

o Set the model time units

p Click Finish

© The AnyLogic Company | www.anylogic.com 47

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

The New Model wizardwillappear.


n Enter the name of a new model: Call Center.
o Choose minutes as the model time units.
p Click Finish to start creating new model from scratch.

Another way to create a new model is to click the New button


located in the toolbar:

© The AnyLogic Company | www.anylogic.com 48


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

AnyLogic Graphical UserInterface

Graphical editor

Properties view

Projects + Palette views

© The AnyLogic Company | www.anylogic.com 49

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Graphical editor
• The place to graphically edit the diagram of the agent type.

Projects view
• Provides access to AnyLogic models currently opened in the workspace. The
workspace tree provides easy navigation throughout the models.

Palette view
• Provides the list of model elements grouped by categories in a number of stencils
(palettes).

Properties view
• Allows to view and modify the properties of currently selected model item(s).

Problems view
• Displays errors found during model development and compilation.

© The AnyLogic Company | www.anylogic.com 50


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Call Center. Phase 1. Step 3

n You will see the


Process Modeling Library
palette opened

To open a palette, click its


icon on the vertical tab

© The AnyLogic Company | www.anylogic.com 51

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

We will model our factory using AnyLogic Process Modeling Library.


n The Process Modeling Library palette opens by default. The palette
contains library blocks. Now we can add library blocks from this
palette onto the graphical diagram of the Main agent type.

AnyLogicProcessModelingLibrary
• Process Modeling Library is the standard AnyLogic library for discrete-event, or, to be
moreprecise,process-centricmodeling.UsingtheProcessModelingLibraryblocksyou
can model real-world systems in terms of agents (customers, products, parts,
documents, vehicles, etc.), processes (sequences of operations typically involving
queues,delays,resourceutilization),andresources.
• Theprocessesarespecifiedintheformofflowcharts- a widelyadoptedgraphical
representationusedinmanyareas:manufacturing,callcenters,businessprocesses,
logistics,healthcare,etc. FlowchartsareconstructedfromProcessModelingLibrary
blocks.

© The AnyLogic Company | www.anylogic.com 52


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Call Center. Phase 1. Step 4


•Study the most essential blocks of the AnyLogic Process Modeling
Library below and suggest your flowchart for the simplest call center
model.

? ? ? ?

© The AnyLogic Company | www.anylogic.com 53

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Process Modeling Library. Essential blocks. Part 1


Block Icon in
Description
name graphical editor

Generates agents. Is usually a starting point of a process


Source
model.

Disposes incoming agents. Is usually an end point of a


Sink
flowchart.

Stores agents in a buffer (queue) in the specified order. Here


Queue agents wait to be accepted by the next block in the process
flow.

Delay Delays agents by the specified delay time.

Forwards the agent to one of the output ports depending on


SelectOutput
the condition.

Routes the incoming agents to one of the five output ports


SelectOutput5
depending on (probabilistic or deterministic) conditions.

© The AnyLogic Company | www.anylogic.com 54


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Call Center. Phase 1. Step 5

o Name the blocksourceCalls

n Drag Source onto the diagram

© The AnyLogic Company | www.anylogic.com 55

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

AddSource block.In our modelit willgeneratecalls.


n Drag the Source element from the Palette onto the graphical
diagram. Drag’n’drop is the common way of adding palette
elements onto your diagram.
o Right after dragging an element onto the graphical editor, you can
see that its name is selected in the in-place editor.

Type here a new name of this block: sourceCalls.

Name model elements exactly as we do since later on you will refer to


these elements by their names.

© The AnyLogic Company | www.anylogic.com 56


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Call Center. Phase 1. Step 6

p Sink

n Add Queue blockhere o Delay

© The AnyLogic Company | www.anylogic.com 57

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

ContinueconstructingtheflowchartbyaddingmoreblocksfromtheProcessModeling
Library.Whenaddingflowchartblocks,you willsee thatthe portsare automatically
connectediftheblocksarebroughtclosetoeachother.
n Add Queue block. The queue will store the calls until they are handled by
the operators.
o Add Delay block. The delay will represent operators answering incoming
calls.
p Add Sink block to dispose calls.

Defininga routeforanagentflow
• A routeforagentsisdefinedbyconnectingtheportsofflowchartblocks.Youmaynoticethattheright
portisconnectedtotheleftportoftheprecedingblock.ThereasonforthisisthatProcessModeling
Libraryblockshaveinputandoutputports.Inputportsarelocatedontheleftsideoftheicon,while
outputsarelocatedontherightside.Youmayonlyconnectoutputportstoinputports.
• Byconnectingtheflowchartblocksyoudefinethepathforagentspassingthroughthisflowchart.Once
theagententerstheSourceblock,itispassedontotheflowchartblockconnectedtotheSource’soutput
port,andsoon.

© The AnyLogic Company | www.anylogic.com 58


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Call Center. Phase 1. Step 7


n Click the triangle to the right of the Run button

o Choose Call Center / Simulation

Model window

p Click the button to


start the model simulation

© The AnyLogic Company | www.anylogic.com 59

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

We have finished building this simple model. Run the model and observe
its behavior.
n - o Several models can be opened in the workspace, each one having
a number of experiments. You need to tell AnyLogic, what particular
experiment you want to run.
Having started the model, you will see the model window. It displays the
presentation of the launched experiment (Simulation).
p Clicking the Run control you start running the model. The
presentation of the top-level agent Main will be displayed.

Delay
• TheDelayblocknamemay confuseyou.Theblockhasnorelationtothestateorthemeaningof“being
late”.
• A moreappropriatenameforitcouldbeProcessingorOperation.

© The AnyLogic Company | www.anylogic.com 60


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Call Center. Phase 1. Step 8


n You will see the animated flowchart
o Click the block.
You will see its inspect
window opened.

p Move the window


by dragging its title

© The AnyLogic Company | www.anylogic.com 61

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Examine the current states of flowchart blocks using the animated


flowchart and inspect widgets.

Animatedflowchart Number of agents being processed

The total number of agents that


Delay is currently
passed through this block
processing agent(s)
Inspectwidgets

Block parameters

Information on agents that Statistics


are in the block

© The AnyLogic Company | www.anylogic.com 62


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Call Center. Phase 1. Step 9

o Close the window by


clicking the “cross” button

n Control the model


simulation using Run,
Pause and Stop controls

© The AnyLogic Company | www.anylogic.com 63

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Controlling the modelexecution


Youcancontrolthemodelexecutionusingthecontrolpanel,displayedat the
bottomofthemodelwindow.

Run
Runsthesimulation. Startstheexecution,orifthesimulationwas
paused,resumesthesimulation fromthecurrentstate.

Pause
Pausesthesimulation.Youcanresumethepausedsimulationanytime.

Stop
Terminatesthecurrentmodelexecution.

© The AnyLogic Company | www.anylogic.com 64


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Call Center. Phase 1. Step 10

n Switch to
virtual time mode

© The AnyLogic Company | www.anylogic.com 65

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Adjustingthemodelexecutionspeed
• AnyLogic model can be run either in real time or virtual time mode.
• In real time mode, the mapping of AnyLogic model time to the real time is made, i.e. you
specify how many model time units one second takes. It is frequently needed when you
want your animation to appear life-like.
• In virtual time mode, the model runs at its maximum speed and no mapping is made
between model time units and seconds of astronomical time. This time mode is useful
when you need to simulate your model for a long period of time.
• In real time mode, you can increase or decrease model simulation speed by changing the
model simulation speed scale. x2 means that model is run twice as fast as the specified
model speed, etc.
• Control the model execution speed using the Time scale controls:

Slow down Run as fast as possible


(virtual time mode)
Model time units per real second Speed up

© The AnyLogic Company | www.anylogic.com 66


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Call Center. Phase 1. Step 11

n Runtime error message

© The AnyLogic Company | www.anylogic.com 67

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Reading errormessages
• We are lucky to have a comprehensive error description with the detailed
information on fixing the problem. However, sometimes the AnyLogic engine
can get no idea of the error origin. In this case the most valuable thing in the
message is the name of the model element that caused the error.
• Always start analyzing the error message with reading the error originator`s
name. Our element is root.sourceCalls, where root is the predefined name of
the model’s top-level agent (it is Main in our case), and the element is the block
sourceCalls located on the Main diagram. The problem is that the agent is
unable to leave the block, since the next block (queue) is full and cannot
currently accept agents.

© The AnyLogic Company | www.anylogic.com 68


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Call Center. Phase 1. Step 12

n Select the queue block

o Select the Maximum capacity


checkbox

© The AnyLogic Company | www.anylogic.com 69

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Definetheparameters oftheselibraryblockswehaveaddedtotheagent’sdiagram.
n Select the block queue in the graphical editor to change its parameters in the
Properties view.
o Remove any restrictions to the number of calls in the queue by selecting a
checkbox next to the option Maximum capacity.

Properties view
• The Properties view is a context-sensitive view that
displays the properties of the currently selected
model element(s).
• To modify properties of some element, first select it
(by clicking it in the graphical editor or in the
Projects view) and then modify the required
properties in the Properties view.
• The name and the type of the currently selected
element are shown at the top of the view.
• The Properties view contains several sections. To
expand/collapse a section, just click on its name.

© The AnyLogic Company | www.anylogic.com 70


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Call Center. Phase 1. Step 13

n Select the delay block and adjust its


properties. Set its Capacity to 100 (it
corresponds to the number of operators in
the center)

o Run the model. You will not


see the error message.

© The AnyLogic Company | www.anylogic.com 71

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Call Center. Phase 1. Questions


1. How canyou accessAnyLogic examplemodels?
2. Whatis the difference betweenleft andrightportsof Process
Modeling Libraryblocks?

© The AnyLogic Company | www.anylogic.com 72


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Call Center. Phase2


• We have createda classicqueueing systemmodel.
• We have simulated operator assistance with a Delay block.
However, we canbenefita lot fromintroducingresourcesin the
model.
• Pleasestudy the libraryblocksrelatedto resources on the slide
below andtell:
о What do resources represent in this model?
о Which blocks can we use to improve the model further?

© The AnyLogic Company | www.anylogic.com 73

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Process Modeling Library. Essential blocks. Part 2


Block Icon in
Description
name graphical editor
Defines a set of resources of the specified type: how many
ResourcePool resources of this type exist in the system, what are their
attributes.
Seizes the number of units of the specified resource required
Seize
by the agent.

Release Releases resource units previously seized by the agent.

Seizes resource(s) for the agent’s operation, delays them, and


then releases the seized resources and lets the agent go
Service
further. The block itself is a Seize – Delay – Release sequence
of blocks.

Assembles a certain number of agents from several sources


Assembler
(5 or less) into a single agent.

Sends a set of portable and/or moving resources to a specified


ResourceSendTo
location.

© The AnyLogic Company | www.anylogic.com 74


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Call Center. Phase 2. Step 1

n ResourcePool
Name: operators
Capacity: 100

© The AnyLogic Company | www.anylogic.com 75

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

n Add a ResourcePool block to simulate a set of resource units


(operators). Name it operators. We do not need to consider resource
movementin this model, so you canleavethe defaultresourcetype:static.

ResourcePool
• ResourcePoolblockdefinesa setof resources.Resourcesareobjectsthatareneededby
agents to perform operations. Resourcesare seized and released by agents using Seize,
Release,ServiceandAssemblerblocks.

© The AnyLogic Company | www.anylogic.com 76


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Call Center. Phase 2. Step 2

n Service
Resource sets (alternatives): operators
Maximum queue capacity:
Delay time: triangular( 0.5, 1, 5 ) minutes

© The AnyLogic Company | www.anylogic.com 77

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Modifytheflowchartbysubstitutingthequeueanddelaybockswiththeserviceblock.
n Select the queue and delay blocks, delete them and add the Service block
instead. The Service block seizes the given number of resources to perform certain
operation over agent, delays the agent (this models the operation itself), and
releases the seized resources.
This Service block models how call center operators answer incomingcalls.
• We assume that the number of customers waiting in the line isunlimited.
• We assume that the minimum call duration is 30 seconds, the most typical call
duration is 1 minute, and the maximum call duration is 5 minutes. Considering
these three metrics, we choose the triangular distribution to define the service
time.

Triangular probability distribution


triangular( min, mode, max )
• Triangular distribution is used when we have limited
mode
knowledge about the stochastic variable, namely we
know the minimum, the maximum, and the modal
value.
min max
• Example: service time.

© The AnyLogic Company | www.anylogic.com 78


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Understandingthe blockicons

Queue Delay

built-in Queue

Seize Release
Takes resources Releases resources
for an operation

Queue 5 built-in Queues


(inside built-in Seize) built-in Delay
built-in Delay

Service Assembler

Uses resources Uses resources

© The AnyLogic Company | www.anylogic.com 79

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Model creationprocess
start
• The model creationis an iterative process
(trial anderror)
• Do not be afraid of deletingsomepartof
a modeland reconstructingit againusing
a differenttoolset
о Follow this way if your task cannot be
handled well (and eye-catchingly of
course) within the set limits
• Whatshouldbe done?
о Get one level “higher”
о Think of other means to use for simple
and convenient designing of the modeled
object behavior
result
© The AnyLogic Company | www.anylogic.com 80
Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Call Center. Phase 2. Step 3

n Save your model

o Run the model and


analyze the operators
utilization

© The AnyLogic Company | www.anylogic.com 81

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

n You may notice an asterisk near the model item in the Projects tree:
It means that you have unsaved changes in this model. Save your model
by clicking the Save toolbar button.

© The AnyLogic Company | www.anylogic.com 82


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Resources. Failures/repairs, maintenance,breaks


ResourcePool

© The AnyLogic Company | www.anylogic.com 83

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Call Center. Phase 2. Questions


1. Why do the Seize and Releaseblocksstillexistin the librarywhile
there is Serviceblock,whichcomprisesboth of them?

© The AnyLogic Company | www.anylogic.com 84


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Call Center. Phase3


• In thisphase we willsimulatethe customersleaving(hangingup) if
they’vebeen waitingfor the operator to reply for too long.
о The time a customer will wait for a reply is exponentially distributed,
the mean time is 100 seconds

© The AnyLogic Company | www.anylogic.com 85

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

TimeoutintheQueueandServiceblocks
• You can set up the Queue block to let the agents leave after they have waited for the
given amount of time. To do so you need to select the Enable exit on timeout option and
specify the timeout, which is evaluated dynamically for each agent, so it may depend on
the agent and it may be stochastic. The leaving agents will exit via the upper right port.
• The same applies to the Service block which exposes the outTimeout port of the
embedded Queue block.

Queue Service
© The AnyLogic Company | www.anylogic.com 86
Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Call Center. Phase 3. Step 1

You can add and remove the


editing points on a connector
with a double-click

o Add one more Sink


block, connect it to
the Service’s upper
right port and rename
both Sink blocks

n Advanced
Queue: exit on timeout:
Timeout: exponential( 1.0/100 ) seconds

© The AnyLogic Company | www.anylogic.com 87

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Call Center. Phase 3. Step 2

n Run the model and observe


the number of answered and
abandoned calls

© The AnyLogic Company | www.anylogic.com 88


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Call Center. Phase 3. Step 3

n Drag the Pie Chart item


from the Analysis palette

o In the Data section of the chart


properties, add two data items

© The AnyLogic Company | www.anylogic.com 89

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

n The Analysis palette contains the elements that you can use to collect and
analyze the simulation results (data set, statistics … ), and charts (bar chart,
stack chart, time plot, histogram … ) that help you visualize that collected
data.
o The Sink block has a function count() that returns the number of agents ever
exited the system via that block.

Obtainingthenumberofagentsthathavepassedthrougha port
• In general, you can obtain the number of agents that have passed through any port of any
Process Modeling Library block by calling <block name>.<port name>.count(). For
example, you can call service.outTimeout.count().
• The blocks themselves also provide count() functions. For example, the count() function of
the Sink block returns the number of agents that have entered this block. So you can
simply call: sinkAnswered.count() instead of sinkAnswered.in.count()

© The AnyLogic Company | www.anylogic.com 90


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Code CompletionMaster
• When referring to some other AnyLogic model element do not type
the element name completely, but use the built-in intelli-sense
mechanism instead.
• The wizard looks as a list, containing variables, parameters, and
functions. You can simply select the name in the list to
automatically insert it into the expression.
1.Start typingthe
element’s name
2.Press Ctrl+space
(Mac OS: Alt-space)
The wizard will list all model variables
and predefined functions

4. Double-click the name or hit


Enter to insert it into the equation
expression

© The AnyLogic Company | www.anylogic.com 91

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Call Center. Phase 3. Step 4

n Run the model. Using the pie chart, observe


the percentage of abandoned and answered calls.

© The AnyLogic Company | www.anylogic.com 92


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Call Center. Phase4


• Now we wantto developour model further.
о Say, the call center has improved their process by implementing the
automated attendant. The system prompts callers to choose the
required options (e.g., press one for this, two for that) when they call
the center, which allows them to listen to the prerecorded answer,
rather than wait for the operator to reply.
о Some customers may not find the required option and as the result
switch to waiting for the operator.

© The AnyLogic Company | www.anylogic.com 93

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

• How should we modifyour flowchart to reflectthischange?

? ? ? ?

© The AnyLogic Company | www.anylogic.com 94


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Call Center. Phase 4. Step 1

n The modified flowchart


may look like this one

© The AnyLogic Company | www.anylogic.com 95

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Suggestparameter valuesfor the new flowchart blocks.

© The AnyLogic Company | www.anylogic.com 96


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Call Center. Phase5


• In thisphase we willobtainthe distributionof timein systemfor
answeredcalls.
• We willcollectthe statisticsand build the histogram displaying time-
in-system for our callcenter.

• It is timeto study a few morelibraryblocks.

© The AnyLogic Company | www.anylogic.com 97

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Process Modeling Library. Essential blocks. Part 3


Block Icon in
Description
name graphical editor

RestrictedAreaStart
Using these blocks you can limit the number of agents in a
part of flowchart between corresponding
RestrictedAreaStart and RestrictedAreaEnd blocks.
RestrictedAreaEnd

TimeMeasureStart
TimeMeasureEnd and TimeMeasureStart compose a pair of
blocks measuring the time the agents spend between them.
TimeMeasureEnd

Takes the incoming agents out of the process flow and lets
Exit
the user to specify what to do with them.

Inserts the (already existing) agents into a particular point


Enter
of the process model.

© The AnyLogic Company | www.anylogic.com 98


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Call Center. Phase 5. Step 1

n Insert TimeMeasureStart
block here

o Insert two
TimeMeasureEnd blocks.
For both of them set:
TimeMeasureStart blocks:
timeMeasureStart

© The AnyLogic Company | www.anylogic.com 99

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Measuringtimeinprocessmodels
• In the process models we often need to know the time agents spend in a particular part
of the process, for example, length of stay in a hospital or emergency department, or
waiting time in a service system. The easiest way to measure time is to use a pair of
Process Modeling Library blocks: TimeMeasureStart and TimeMeasureEnd.
TimeMeasureStart blocks should be placed on each entry to the flowchart part where the
time is measured, and TimeMeasureEnd – on each exit. Each TimeMeasureEnd needs to
know all corresponding TimeMeasureStart blocks.
• The TimeMeasureEnd block collects statistics and distribution of time spent in the
selected part of the process.
• It is important not to let the agents that have passed the TimeMeasureStart block exit the
model without passing the TimeMeasureEnd: the latter keeps the agents in a list and the
former removes them. In our model we only need to collect statistics on answered calls,
but we need to put TimeMeasureEnd on each exit.

© The AnyLogic Company | www.anylogic.com 100


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Call Center. Phase 5. Step 2

n Drag the Histogram from


the Analysis palette.
In the histogram properties
add a data item as shown.

© The AnyLogic Company | www.anylogic.com 101

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

n Remember that TimeMeasureEnd block collects the distribution of the time


spent by the agents in the selected part of the process, i.e. the histogram of
frequencies. The distribution is available as <block name>.distribution and can
be displayed by the Histogram chart.

© The AnyLogic Company | www.anylogic.com 102


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Call Center. Phase 5. Step 3

n Run the model. Observe the distribution


of “time in system” for answered calls.

© The AnyLogic Company | www.anylogic.com 103

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Call Center. Phase 5. Questions

n Study the screenshot and say


what is wrong with this model

© The AnyLogic Company | www.anylogic.com 104


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Call Center. Phase6


• In this phase we will add a tool allowingus to vary the
number of call center operators on-the-fly and observe
how this affects the service quality

© The AnyLogic Company | www.anylogic.com 105

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Call center. Phase 6. Step 1

n Drag the Slider item


from the Controls palette.

o In the slider properties, click the


Add labels button. Link the slider to
the capacity parameter of the
operators block with minimum
value 1 and maximum value 200.

© The AnyLogic Company | www.anylogic.com 106


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

To refer to a parameter in the controlelement(slider,here), first


select the checkbox for the Link to option and then select a
parameterfroma drop-down listnextto it.
Nextyou needto define the minimumand maximumparameter’s
valuesthatthissliderwillcontrol.
Clickthe Add labelsbuttonto add textelementsthatdisplaythese
valuesas wellas the currentchosenvalue.

© The AnyLogic Company | www.anylogic.com 107

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Call center. Phase 6. Step 2

n Run the model and vary the number of


operators. Find the minimum number of operators
required to answer 100% of incoming calls.

© The AnyLogic Company | www.anylogic.com 108


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Call Center. Bonusphase


• You can choose what else you want us to demonstrate:
оHow to skip warm-up period using the model snapshots
оHow to save simulation results to model log files in the
built-in AnyLogic database
оHow to implement daily pattern for calls rate

© The AnyLogic Company | www.anylogic.com 109

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

© The AnyLogic Company | www.anylogic.com 110


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Agent Based Modeling


in AnyLogic

Thispresentationisapartof
AnyLogicStandardTrainingProgram

© The AnyLogic Company | www.anylogic.com

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Agent basedmodeling

• We focuson individual objectsanddescribetheirlocal behavior,


localrules
о Sometimes, we also model the dynamics of the environment

Agent’s behavior
Environment

Child

Junior

Adult

Senior

© The AnyLogic Company | www.anylogic.com 112


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Agents canbe:
People: Vehicles, equipment:
consumers, habitants, employees, trucks, cars, cranes, aircrafts, rail cars, machines, …
patients, doctors, clients, soldiers, …

Organizations:
Non-material things: companies, political parties, countries, …
projects, products, innovations, ideas, investments …

© The AnyLogic Company | www.anylogic.com 113

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Which approach touse?


• If the problem requirements fit well into the DE or SD
modeling paradigms – you can safelyuse thesetraditional
approaches
• In cases where your system contains active objects (people,
businessunits, animals,vehicles, or projects, stocks,products,
etc.) with timing, event ordering or other kind of individual,
autonomous behavior – You will benefit from applyingthe AB
approach
• Sometimes theserequirementsare at the sub-model level.
Thenyou can consider mixingdifferent approaches in one
model and applying most appropriate technique where
needed

© The AnyLogic Company | www.anylogic.com 114


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Multi-paradigm modelarchitectures

Agents (e.g. customers) interact with other agents


(staff) in a Discrete Event flowchart

Agents live in an Environment modeled in


System Dynamics way

© The AnyLogic Company | www.anylogic.com 115

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Typical architecture of AnyLogic AB model

Person

Name: people
Type: Person
Replication: 100000

Main
people Adding/removing people:
add_people();
remove_people( p );

Iterating through all people:


for( Person p : people ) {

}

© The AnyLogic Company | www.anylogic.com 116


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Statecharts

A
• The most powerful and
naturally visual construct
• Statecharts can be used to
Normal
A define:
Showing Date
– object states / modes of
timeout: 5 sec
A operation
Showing Time – response to the external or
A timeout: 5 sec internal signals and conditions
Setting Alarm – event and time ordering

power < 0.5 power > 1


Suspended

© The AnyLogic Company | www.anylogic.com 117

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Space: Discrete

• 2D array of cells Rows by Columns


At most one agent per cell; to retrieve location: getR(), getC()
Movement: jumpToCell(), jumpToRandomCell(), etc.
Neighborhood models: Euclidean, Moore; getNeighbors()
columns

rows
{N,S,E,W] {N,NE,E,SE,S,
SW,W,NW]

returns

© The AnyLogic Company | www.anylogic.com 118


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Space: Continuous
• Agent has (x, y, z) coordinates in 3D space
• Use agent API:
getX(); getY();
distanceTo( agent );
moveTo( x, y, z );
jumpTo( x, y ); stop();
moveTo( 20, 30 ) moveTo( 15, 50 ) stop()
isMoving();
timeToArrival();
setSpeed ( speed );
• Define action:
getX() getY()
On arrival return the current position at anytime

© The AnyLogic Company | www.anylogic.com 119

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Space: GIS

• Agentsin a geospatial environmentdefinedby GIS map


• Agenthas real (latitude, longitude) coordinates in space
• Use agentfunctions:
getLatitude();
getLongitude();
distanceTo( agent );
jumpTo( x, y );
moveTo( x, y );
stop();
isMoving();
timeToArrival();
setSpeed ( speed );
• Defineaction:
On arrival

© The AnyLogic Company | www.anylogic.com 120


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Network: connections andcommunication


• Every agenthas a listof connections– other agents
о Use standard network types or define your own using API:
connectTo( agent ); disconnectFrom( agent );
о Access the collection of connected agents:
getConnections(); getConnectedAgent( i );
о Communication in network:
Send messages:
sendToAll(msg); sendToRandom(msg); sendToAllConnected(msg);
sendToRandomConnected(msg); send(msg, agent)
Define reaction in connections element: On message received

Connections = {1,2,3,4} 5
0 4
1

2 Connections = {0,3,5}
3

© The AnyLogic Company | www.anylogic.com 121

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Network: Standardtypes

• Standard networktypes:
Random, Ring lattice, Small world, Scale free,

Distance based (layout dependent)

• You can
– combine standard and custom networks
– re-apply standard network during run, etc.

© The AnyLogic Company | www.anylogic.com 122


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

How many agents to simulate?

• If I need to model the US population do I need to


simulate 300,000,000 agents? Fortunately not!
• Two main “model scaling” techniques are used:

– Same agents, – Same environment


– Environment – Agents represent
scaled down groups

© The AnyLogic Company | www.anylogic.com 123

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

© The AnyLogic Company | www.anylogic.com 124


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

SIR Model.
Calibration
Thispresentationisapartof
AnyLogicStandardTrainingProgram

© The AnyLogic Company | www.anylogic.com

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

© The AnyLogic Company | www.anylogic.com 126


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

SIR Model.Calibration
• We willcalibrate an agentbased model of contagiousdisease
diffusion.
• In the model each person has 3 possible states: Susceptible,
Infectious or Recovered (SIR). Initially all but a few people are
susceptible, and a few are infectious. Upon contact with an
infectious persona susceptiblepersonwillget the diseasebased
on a certainprobability.
• The agentsare placedin a continuous space.The contactsoccur
between randomagents.

© The AnyLogic Company | www.anylogic.com 127

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

SIR Model.Calibration
• The objective is to find the right parameters for the agents
(contact frequencies and infection probabilities) so that the
simulationoutputmatcheshistoricaldatareflectingthe dynamics
of infectious disease spreading through a population. Since the
model is stochastic, calibration is done under uncertainty, and
simulationreplicationsare used.

© The AnyLogic Company | www.anylogic.com 128


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

SIR Model. Phase 1


• In thisphase we willbuild a simpleSIRmodel.
• Createnew model:SIR.Choosedays as the model timeunits.

© The AnyLogic Company | www.anylogic.com 129

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

SIR. Phase 1. Step 1

n Create a new agent


population: 10000 agents
of type Person

© The AnyLogic Company | www.anylogic.com 130


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

SIR. Phase 1. Step 2

© The AnyLogic Company | www.anylogic.com 131

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Open the Agent palette.


Using the New Agent Wizard,createa new population of agents.
SetPerson as the typename,people as the nameof the
population.
Do not use any animationshapesfor the agents,we do not need
themsince we willconcentratesolelyon calibration.
Let10000agentslive in the model.On the lastpage of the wizard
do not changeanything, let agentslive in the Continuous space.

© The AnyLogic Company | www.anylogic.com 132


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

SIR. Phase 1. Step 3

n On the Main diagram,


create three parameters of
the type double with the
following default values:
15.0
1.0
0.8

© The AnyLogic Company | www.anylogic.com 133

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

n Open the diagram of Main and define here agent characteristics with three
parameters of the double type.

© The AnyLogic Company | www.anylogic.com 134


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

SIR. Phase 1. Step 4


n Switch to the
Person diagram

© The AnyLogic Company | www.anylogic.com 135

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

n In the Person agent type define agent behavior with a statechart. A person has
3 possible states: Susceptible, Infectious, or Recovered.

Draw the statechart with Statechart palette's elements.


Start drawing the statechart with Statechart Entry Point element. Then add
three States, connect them with two Transitions, and finally add one internal
transition inside the Infectious state.

Statechart
• The best way to define a behavior is to use a statechart. The states in the statechart are
alternative: the object can only be in one state at a time.
• In general, single agent may have multiple statecharts, but now we need only one.

© The AnyLogic Company | www.anylogic.com 136


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

SIR. Phase 1. Step 5

n Define statistics
function counting number
of infectious people

© The AnyLogic Company | www.anylogic.com 137

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

We want to view how the numbers of infectious people change over time.
To achieve this we will define a function to calculate number of infectious
people.

Collectingstatisticsonagents
• To add a new function collecting statistics over all the agents, go to the Statistics
properties section of the agent population and click the “plus” button. We need to find
out how many agents are in the Infectious state. The statistics of type count does exactly
that: it iterates through the population and counts how many agents satisfy the given
condition.
• Specify item.inState(Person.Infectious) as the function condition. Here item represents
the current agent, inState() is a standard method of statechart, and Infectious is the
name of the state defined within the agent, that is why it needs the name prefix Person.

© The AnyLogic Company | www.anylogic.com 138


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

SIR. Phase 1. Step 6

n Add a data set to store historyof


number of infectious people

© The AnyLogic Company | www.anylogic.com 139

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

We configure the data set to record the number of infectious people. The
number is obtained by calling the statistics function defined in the
previous step. The function is defined in agent population people, so we
call it as a function of that object: people.nInfectious()

© The AnyLogic Company | www.anylogic.com 140


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

SIR. Phase 1. Step 7

n Add a time plot to display


the data collected by the data
set we have just created

© The AnyLogic Company | www.anylogic.com 141

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

The time plot will display the collected statistics on number of infected
people.
Add one data item in the plot’s Data section, select the Data set option
there and select the data set to be visualized by the chart (InfectiousDS).

© The AnyLogic Company | www.anylogic.com 142


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

SIR. Phase 1. Step 8

© The AnyLogic Company | www.anylogic.com 143

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Simulate the index patient by making one randomly chosen agent


infected on model startup.

© The AnyLogic Company | www.anylogic.com 144


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

SIR. Phase 1. Step 9

n Set the experiment to


stop at time moment 200

o Run the model in virtual


time mode. You will see how
the number of infectious
people changes.

© The AnyLogic Company | www.anylogic.com 145

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

SIR. Phase 1.Questions


1. Whichstatechartis correct?

2. Pleaseexplainhow the parametersdefinedon the Main diagram


are accessedby agents.
3. How do we infectthe firstagentin the model?

© The AnyLogic Company | www.anylogic.com 146


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

SIR. Phase 2.Calibration


• Now we will tune the parameters of the model so that its
behavior matchesa known (observed) patternunder specified
conditions
• To do this, we willuse the AnyLogic calibrationexperiment

AnyLogiccalibrationexperiment
• When you have your model structure in place, you may wish to tune some parameters
of the model so that its behavior under particular conditions matches a known
(historical) pattern. In cases where there are several parameters to tune it makes sense
to use the built-in optimizer to search for the best combination. The objective in this
case is to minimize the difference between the observed simulation output and historic
data.
• The calibration experiment uses the optimizer to find the model parameter values that
correspond to the simulation output which best fits the given data. The data may be
both in scalar and dataset form. Coefficients may be used in the case of multiple criteria.
The calibration progress and fitting of each criterion are displayed.

© The AnyLogic Company | www.anylogic.com 147

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

SIR. Phase 2. Step 1

n Create New > Experiment

© The AnyLogic Company | www.anylogic.com 148


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

SIR. Phase 2. Step 2

n Configure parameters
being calibrated

o Define the calibration criteria

© The AnyLogic Company | www.anylogic.com 149

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Configure the calibration experiment.


n Set up the parameters whose values will be varied when performing the
calibration. To include a parameter in the calibration process, choose some
value other than fixed in the parameter’s Type cell in the Parameters table of
the wizard.
o We will search for minimal differences between the simulation output (our
InfectiousDS data set defined in the top-level agent of the experiment and
thus accessible here as root.InfectiousDS) and the historic data (just specify
the name of the object containing the historic data series, we will actually
create it later in the next step).

© The AnyLogic Company | www.anylogic.com 150


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

SIR. Phase 2. Step 3

o Copy the HistoricData.txt file


contents to the Clipboard p Paste the data tothe
Table data table

n Add Table Function, name it


InfectiousHistory, right as you specified
it in the experiment creation wizard

© The AnyLogic Company | www.anylogic.com 151

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Load the historic data into the model by adding a table function on the diagram
of the calibration experiment.
o Open the HistoricData.txt file from the Models/SIR folder located on your USB
disk in a text editor. Copy the file contents to the Clipboard.
You will see the plot of the continuous function built upon the loaded table data.

Tablefunctions
• Table function (AKA lookup table) is a function defined in the table form. You can make it
continuous by interpolating and/or extrapolating. Table functions are commonly used to
load experimental data in the model as a table function and convert the function to a
continuous form.

© The AnyLogic Company | www.anylogic.com 152


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

SIR. Phase 2. Step 4

n Set Random seed for the


Calibration experiment’s
random number generator

© The AnyLogic Company | www.anylogic.com 153

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

SIR. Phase 2. Step 5

Comparison graphs

n Run the Calibration


experiment Multiple processors perform
experiment iterations in parallel

© The AnyLogic Company | www.anylogic.com 154


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

SIR. Phase 2. Step 6


Statistics on currently used
and best found objective and
parameter values

n Copy the found optimal


parameter values to the
simulation experiment

© The AnyLogic Company | www.anylogic.com 155

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Takingadvantageofprocessors withmultiplecores
• If your computer has more than one processor core, AnyLogic will place different
simulation runs on different cores in parallel. Performance is increased and experiments
are performed significantly quicker than when using a processor with a single core. This
applies to all experiments where multiple simulation runs can be done independently or
partially independently: Parameter variation, Monte Carlo, Sensitivity analysis,
Optimization, and Calibration.

• To find out how many processor cores there are on your computer and to set the
number of cores to be used by AnyLogic, open AnyLogic Preferences (menu item Tools >
Preferences).

• You should be aware that in the case of parallel execution simulations get unordered and
the code you may have written in the fields Before simulation run, After simulation run,
and After Iteration may also be executed in an arbitrary order. The other thing to notice
is that optimization experiments become un-reproducible. You can prevent parallel
execution for a particular experiment by un-checking the checkbox Allow parallel
evaluations at the very bottom of the Advanced properties of the experiment.

© The AnyLogic Company | www.anylogic.com 156


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

SIR. Phase 2. Step 7

n Apply optimal parameter values


to the simulation experiment

© The AnyLogic Company | www.anylogic.com 157

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Applyingtheresultofthecalibrationinthemodel
• Your simulation experiment will typically be run with the parameter values that resulted
in the best fit to the known historical data.

© The AnyLogic Company | www.anylogic.com 158


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Java Basics
for AnyLogic

Thispresentationisapartof
AnyLogicStandardTrainingProgram

© The AnyLogic Company | www.anylogic.com

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

General remarks

• You do not have to learn full OO programming


• You need to understand Java data types, expression
and statementsyntax
• Please note:
Java is case-sensitive: MyVar is different from myVar!
Spaces are not allowed in names: “My Var” is illegal name!
Each statement has to be finished with “;”: MyVar = 150;
Each function has to have parentheses: time(), add(a)
Dot “.” brings you “inside” the object: agent.event.restart()
Array elements have indexes from 0 to N-1

© The AnyLogic Company | www.anylogic.com 160


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Datatypes

• Primitive Types
double – represent real numbers: 1.43, 3.6E18, -14.0
int – represents integer numbers: 12, 16384, -5000
boolean – represents Boolean (true/false) values. Boolean
values are only true and false, you cannot use 1 and 0
• Compound Types –Classes
String – represents textual strings, e.g. “MSFT”, “Hi
there!”, etc
ArrayList, LinkedList – collections of objects
ShapePolyLine – represents AnyLogic polyline shape
… many others. See AnyLogic and Java Class References

© The AnyLogic Company | www.anylogic.com 161

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Expressions
Arithmeticoperations: Boolean operations:
+ addition and String concatenation && AND
- subtraction || OR
* multiplication ! NOT
/ division
% remainder from integer division
Conditional operator:
condition ? value-if-true : value-if-false
Mind integer division!!! 3/2 = 1, not 1.5
In integer divisions, the fraction part is lost, Assignments and shortcuts:
e.g. 3 / 2 equals 1, and 2 / 3 equals 0 = assignment
Multiplication operators have priority over
+= a+=b shortcut for a=a+b
addition operators
The ‘+‘ operator allows operands of type String -= a-=b shortcut for a=a-b
*= a*=b shortcut for a=a*b
Comparisonoperations: /= a/=b shortcut for a=a/b
< less than ++ a++ shortcut for a=a+1
<= less than or equal -- a-- shortcut for a=a-1
> greater than
>= greater than or equal
== equal
!= not equal
Left-to-right precedence for operators; parentheses can be used to alter precedence
© The AnyLogic Company | www.anylogic.com 162
Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Some examples

5 % 2 ൙ 1? ?
“Any”+ “Logic”൙ “AnyLogic”
5 / 2 ൙ 2? Let x = 14.3,then:
?
“x = ” + x ൙ “x= 14.3”
5.0/ 2 ൙ 5 / 2.0 ൙ 2.5
?
?
“”൙ emptystring
(double)5/ 2 ൙ 2.5
?
?
“” + x ൙ “14.3”
a += b;൙ a = a+b;
?
?
y = x > 0 ? x : 0 ൙ y = 14.3
?
a++;൙ a = a+1; x == 5 ൙ false ?
x = 5 ൙ assign5?to x

© The AnyLogic Company | www.anylogic.com 163

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Calling functions and accessing fields


• Function call
To call a function, type its name followed by parentheses. If
necessary, put parameters separated by commas within
the parentheses. Examples:
x = time();
moveTo( getX(), getY() + 100 );
traceln( “Population is increasing” );

• Accessing object fields and functions


To access a field or function of a model element (statechart,
event, animation shape), use the element name followed
by dot ‘.’ followed by the field/function name. Examples:
rectangle.setFillColor(red);
company.event.restart(10);

© The AnyLogic Company | www.anylogic.com 164


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Agent populations

• Agent population is a collection.


people [..] Items are indexed from 0 to N-1
Getting the current size of the
population:
people.size( );
Obtaining i-th agent of the population:
people( i );
Obtaining a random agent:
people.random( );
Adding a new agent to the population:
add_people( );
Removing an agent from the population:
remove_people( person );

© The AnyLogic Company | www.anylogic.com 165

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Built-in functions

• System functions
– time(), date(), pauseSimulation(), inState(…), etc

• Mathematical functions
– sqrt(), sin(), cos(), exp(), log(), round(), etc

• Random distributions
– uniform(), exponential(), bernoulli(), beta(), etc

• Print operators
– traceln() - prints text to Console
– traceToDB() - prints text to the model’s database

• And more…
– See Utilities, Engine, Agent classes in AnyLogic Class
Reference
© The AnyLogic Company | www.anylogic.com 166
Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Probability distributions
• Uniform uniform( min, max )
о We only know the minimum and the
maximum values, and do not know if any
value in between is more frequent than
another
• Triangular min max

о Is used in the conditions of limited


triangular( min, mode, max )
knowledge about the stochastic variable,
namely we know the minimum, mode
the maximum, and the modal value
о Example: service time
• Exponential min max
о It has been proven that if events occur at a
constant rate but are independent, the exponential( rate )
time between two subsequent events is
distributed exponentially
о Example: phone calls to a call center, client
arrivals, and so on.

© The AnyLogic Company | www.anylogic.com 167

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Decision operator (if … else)


• Checks the condition and executes one section of code (after if) if a
condition evaluates to true, and optionally another code (after else)
if it evaluates to false

• Full form (if … else):


if ( condition )
statement if true;
else
statement if false;
In case “if" or "else" code sections contain
• Short form (if): more than one statement, they should be
enclosed in braces { … } to become a block,
if ( inventory < s ) which is treated as a single statement
{
source.inject(10);
How would the code look like if we
inventory += 10;
need to check TWO conditions?
}

© The AnyLogic Company | www.anylogic.com 168


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

for loop
• The loop mostly used to iterate through agent populations and collections
• Population/collection iterator:
for ( agent_type name : population )
{
statements executed for each agent/element
}

for ( Person p : people )


total += p.income;

• Index-based loop:
for ( initialization; continue condition; increment )
{
statements executed for each agent/element
}

for ( int i=0; i<distributor.numberOfTrucks(); i++ )


{
Truck t = add_trucks();
t.setPosition(distributor.getPosition());
}

© The AnyLogic Company | www.anylogic.com 169

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

while loops
• "While" loops are used to repeatedly execute some code while a certain
condition evaluates to true
• While loop int i = 0;
while (continue condition ) while (excelFile.cellExists(i, 1))
{ {
statements Supplier s = add_suppliers();
} s.set_name(excelFile.
getCellStringValue(i,1));
i++;
}

• Do While loop double x;


do double y;
{ do
statements {
} x = uniform(0, 1000);
while (continue condition); y = uniform(0, 1000);
}
while (!citybounds.contains(x,y));

© The AnyLogic Company | www.anylogic.com 170


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

return
• Exits from the current function.
• The return statement has two forms: one that returns a value (e.g. result
of calculations), and one that doesn't. To return a value, simply put the
value after the return keyword.

FUNCTION
Return type: Truck

for (Truck t : fleet)


{
if (t.inState(Truck.AtDistributor))
return t;
}
return null;

© The AnyLogic Company | www.anylogic.com 171

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Writing comments in Java code

There are two kinds of comments:


A traditional comment: all the text from the ASCII
/* text */ characters /* to the ASCII characters */ is ignored
(as in C and C++)
/*
The class represents AnyLogic 3D animation. It contains the canvas
object.
author Daniil Chunosov
version 5.0
*/
public class Animation3DPanel extends javax.swing.JPanel;

// text An end-of-line comment: all the text from the ASCII


characters // to the end of the line is ignored (as in C++).

// Prepare Engine for simulation:


Engine.start(root);
Engine.runFast(); // fast mode – no animation

© The AnyLogic Company | www.anylogic.com 172


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Reference informationsources

• All the Java essentials for AnyLogic


ThecompletechapteronJavafromTheBigBookofSimulationModeling
byA.Borshchevincludedin AnyLogicdocumentation,seeAnyLogicHelp >
AdvancedModelingwithJava> JavaBasicsforAnyLogic

• Oracle tutorials:
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/index.html

• Onlinetraining:
http://www.javapassion.com/portal/

• Non-programmerbook on Java:
Essential Java for Scientists and Engineers.
By B. Hahn & K. Malan
Paperback: 352 pages ISBN-10: 0750659912

• Java API: http://java.sun.com/javase/8/docs/api


© The AnyLogic Company | www.anylogic.com 173

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

© The AnyLogic Company | www.anylogic.com 174


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Supply Chain
Model
Thispresentationisapartof
AnyLogicStandardTrainingProgram

© The AnyLogic Company | www.anylogic.com

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

© The AnyLogic Company | www.anylogic.com 176


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Supply ChainModel
• Build a simulation model of a simple supply chain.
• Distributors and retailers will be located in various places.
• From time to time retailers order a certain amount of
product from distributors. Products are delivered by trucks.
After delivery, truck returns to nearest distributor.

© The AnyLogic Company | www.anylogic.com 177

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Phase 1. Creating distributors and retailers


• In the first phase we will populate our model with
distributors and retailers and place them on a GIS map.

• We will demonstrate how to:


о Create agent populations by reading data from an MS Excel file
о Place agents into GIS space

© The AnyLogic Company | www.anylogic.com 178


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Supply Chain. Phase 1. Step 1

n Add GIS Map

o Resize the shape to fill


up all model window

© The AnyLogic Company | www.anylogic.com 179

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Create a new model. Name it Supply Chain.


Choose hours as Model time units.
Our model will be agent-based, with several types of agents: distributors, retailers,
trucks. Our agents will live in a physical space defined by a GIS map. So, first of all,
let us add a GIS map on the presentation.
n Drag the GIS Map object from the GIS section of the Space Markup palette.
o Resize this shape. We want it to fill all of the model window at the model run-time.
Hint: Please pay attention to the name of the agent type being edited at the moment:

GIS
• You can add GIS (Geographic Information System) maps in your models. With GIS at your
disposal you can develop geographically-aware models.
• GIS is commonly used in agent-based models. You can place agents on a GIS map, move agents
with some specified speed from one location to another, execute actions upon arrival, animate
agent at specific locations, establish connections based on agents layout, etc.
• Routing data (existing road and railroad networks) are obtained from OpenStreetMap server.
• Real-time data on traffic jams is not available.

© The AnyLogic Company | www.anylogic.com 180


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Supply Chain. Phase 1. Step 2

n Double-click the map to


start editing it

o Click on the map with the


left mouse button and move
the mouse while holding the
button down to pan the map

Scroll the mouse wheel to zoom the map.


Ctrl+scroll to zoom by one step.

© The AnyLogic Company | www.anylogic.com 181

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

n Double-click the map to enter its edit mode, or right-click and select the Edit
map option from the context menu, so that you can find the area at the
appropriate scale to use in the model.
The graphical editor outside the map becomes grayed out when you are editing
the map.
o We have chosen France as the place to develop this model. To pan the map,
hold down the left mouse button and move it. To zoom in the area, move the
mouse wheel away from you. The map will zoom around the area where your
mouse cursor points.
With these actions, edit the map to display France on it.
Double-click the map again or click in the graphical editor to exit the edit mode.

GIS Map
• GIS map shape automatically loads tiles from the selected server.
• A tiled map is a map that consists of seamlessly connected square images, the number of
which changes as you zoom in or out.

© The AnyLogic Company | www.anylogic.com 182


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Supply Chain. Phase 1. Step 3


• We have input data stored in
MS Excel spreadsheet file.
• The file contains two sheets
with data on distributors and
retailers.
• Let us import the data in the
AnyLogic built-in database
before we start using them in
the model.

© The AnyLogic Company | www.anylogic.com 183

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Supply Chain. Phase 1. Step 4

n Right-click Database
and select Import
database tables…

© The AnyLogic Company | www.anylogic.com 184


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Supply Chain. Phase 1. Step 5

n Select data.xlsx from


Models/Supply Chain on your USB

o In Database, you’ll see two


tables created: distributors and
retailers. Double-click the table
to see its contents.

© The AnyLogic Company | www.anylogic.com 185

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

We import data from external database (MS Excel file) into the built-in
AnyLogic database.

AnyLogic database
Each AnyLogic model now has a built-in fully integrated database to read input data and write
simulationoutput.Exportthedatabasewiththemodel,itisasportableandcross-platformasthe
modelitself.Withthenewdatabase,youcan:
• Readparametervaluesandconfiguremodels
• Createparameterizedagentpopulations
• Generateentityarrivalsintheprocessmodels
• ImportdatafromotherdatabasesorExcelspreadsheetsandstoreitinthereadilyavailableform
• Logflowchartactivities,events,statecharttransitions,messagepassing,andagentbiographies
• Viewresourceutilization,waiting,processingandtraveltimes
• Storeandexportstatistics,datasets,andcustomlogs
• ExportdatatoMSExcelspreadsheets.
YoucaneasilyimportthedatabaseinyourAnyLogicprojectfromdatabase,orspreadsheet.
Alternatively,youcancreateemptydatabasetablesandenterdatamanually.

© The AnyLogic Company | www.anylogic.com 186


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Supply Chain. Phase 1. Step 6

n Drag Agent from


Agent palette

o Select Population
of agents

© The AnyLogic Company | www.anylogic.com 187

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Supply Chain. Phase 1. Step 7

n Set the Agent type name:


Distributor

o Select Use
database table

p Click Next

© The AnyLogic Company | www.anylogic.com 188


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Supply Chain. Phase 1. Step 8

n Leave the parameters as is

o Choose 2D, Warehouse

© The AnyLogic Company | www.anylogic.com 189

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

We will start with creating a population of agents modeling a set of


distributors.
Incaseyouhavecreatedanagentpopulationbutyoucannotsee theagent's
animationonMain,clickShowpresentationintheadvancedpropertiesofthe
agentpopulation(e.g.distributors).

Creating agentpopulations
• AnyLogic provides a simple way of creating populations of agents by simply dragging the
Agent element from the Agent palette on the diagram of the agent where you want to
place the population (typically, Main).
• The Wizard creates:
• Agent type (Distributor). This is the place where the agent’s inner structure, behavior,
animation, etc. are defined.
• The agent population (distributors). It is embedded in the agent where you dragged
the Agent (Main) and consists of several (in our case, 5) instances of agent type
Distributor, each one modeling a particular agent-distributor. Near the element you
can see the embedded agent’s presentation.

© The AnyLogic Company | www.anylogic.com 190


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Supply Chain. Phase 1. Step 9

n Move agent population


here, outside the area
visible at model runtime

o Configure the population


to place agents to the
locations read from database

© The AnyLogic Company | www.anylogic.com 191

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Placingagentsof a population in GIS space


• If the database stores agents location data, then agents of the population can be easily
placed on the GIS map with the help of AnyLogic built-in feature. The properties of the
agentpopulationwhichiscreatedbasedon DBdatacontain Agentsparametersmapping
table.
• InourcaseDBstoresnamesofthecities("Paris","Marseille"),etc.Totellthemodelthat
theDBstoresnames(addresses)ofgeographicallocationswhereagentsshouldbeplaced,
select the predefined option GIS location name from the first column of the table, and
then select the name of the DB table column with the corresponding data (here it's
location)fromthesecondcolumn.Onrunningthemodel,thenamesofthecitieswillbe
readandsenttoGIS-server.Inresponsewewillreceivethecoordinatescorrespondingto
the first result of the search of the given name obtained from the GIS-server (e.g.,
"Bordeaux").
• This operation requires network access. Without network access, you should import a
different database into the model – updated_data.xlsx located in the Models/Supply
Chain/Routinggraphfolderon yourUSBdisk.ThisDBhasclearlydefinedcoordinatesof
supplychainsitesstoredin columnslatandlon.Inthiscasewe willuseotherpredefined
valuesin thetabledescribedabove:GISlocationlatitudeandGISlocationlongitude.

© The AnyLogic Company | www.anylogic.com 192


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Supply Chain. Phase 1. Step 10

n Run the model. You will see


distributors placed on the map

© The AnyLogic Company | www.anylogic.com 193

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Supply Chain. Phase 1. Step 11


• Create retailers in the same way as distributors. Name the agent
type Retailerand readdata (locations)from the AnyLogic database.

© The AnyLogic Company | www.anylogic.com 194


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Phase 2. Creatingtrucks
• Now we willcreateone more agentpopulation modelingtrucks.
• We willreaddata(numberof trucksand their location) from the
database.

© The AnyLogic Company | www.anylogic.com 195

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Supply Chain. Phase 2. Step 1

Create a population of trucks

Click Next

© The AnyLogic Company | www.anylogic.com 196


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Supply Chain. Phase 2. Step 2

Do not add parameters


and click Next

Set this population to be


empty initially and click Finish

© The AnyLogic Company | www.anylogic.com 197

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Supply Chain. Phase 2. Step 3

Modify trucks properties

© The AnyLogic Company | www.anylogic.com 198


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Supply Chain. Phase 2. Step 4

n Run the model. You will


see (rather big) truck shapes
located at distributors.

© The AnyLogic Company | www.anylogic.com 199

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

© The AnyLogic Company | www.anylogic.com 200


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Phase 3. Defining the logic


• Now we willmodel how products are requested by retailersand
delivered fromdistributorsto retailers.
• This requiresus to generateproductrequests andassignthemto
trucksand maketrucksmove to retailers andreturnto their home
locations at the distributor.

© The AnyLogic Company | www.anylogic.com 201

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Supply Chain. Phase 3. Step 1

n Drag Agent from


Agent palette

o Select Agent type only

© The AnyLogic Company | www.anylogic.com 202


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Supply Chain. Phase 3. Step 2

n Agent type name: Order

o Choose animation: None

p Add a parameter to store the


amount of products requested by
this order: amount of type int

© The AnyLogic Company | www.anylogic.com 203

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Supply Chain. Phase 3. Step 3

o Add one more parameter


(Parameter from Agent palette) to
remember the retailer - originator
n Double-click Order to of this order (retailer of type
open its graphical diagram Retailer)

© The AnyLogic Company | www.anylogic.com 204


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Supply Chain. Phase 3. Step 4

o Decrease the Lorry


picture.
n Double-click Truck to open
its graphical diagram

© The AnyLogic Company | www.anylogic.com 205

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Supply Chain. Phase 3. Step 5

n Triggered by: Message


Message type: Order
Action: moveTo( msg.retailer );

o Triggered by: Agent arrival


Action:
moveTo( getNearestAgent
p Triggered by:
( main.distributors) );
Agent arrival

© The AnyLogic Company | www.anylogic.com 206


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Define truck behavior with a statechart. In our case the truck is initially at the
distributor location. (So this is the first state – AtDistributor). While there the
truck can receive an order and move to the retailer – the originator of this
order. For now we assume that having reached the retailer, it returns
immediately. Movement is a continuous action and we can represent it with a
state. So there are two more states – MovingToRetailer and
MovingToDistributor. To end being at a state, we use transitions triggered
upon agent arrival to the defined destination.

Local variables
• We use msg variable in code of state’s Action. msg is a local variable available in the
given context. To see a list of local variables click in the field and then hover the mouse
over the bulb shown to the left of the field:

© The AnyLogic Company | www.anylogic.com 207

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

AgentmovementinGISspace
• To move an agent to some new location, call moveTo() method of this agent, passing
coordinates of the new destination as parameters.
• The following methods may be of interest also, consult AnyLogic Help for the full list:
Method Description
moveTo(double x, double y) Starts movement to the given target location
jumpTo(double x, double y) Immediately places the agent at a given location.
moveTo(String geographicPlace) Starts movement to the specified location on the map.

moveTo(node) Starts movement to the specified GIS markup element: point or region.
stop() Stops the agent and leaves it at the current location.
double timeToArrival() Returns time to arrival to the target, in model-time units.
boolean isMoving() Tests if the agent is currently moving.
double getVelocity () Returns the current velocity of the agent (agent’s "cruising speed", non-zero
velocity does not mean the agent is moving).
setVelocity( double newVelocity ) Sets the velocity ("cruising speed") of the agent. If the agent is moving, it will
continue moving from the current location with the new velocity. If the agent
is not moving, it will not start moving until you call moveTo().
setLatLon(double latitude, double Sets the coordinates of the agent location.
longitude)
double getLatitude() Returns the current latitude of the agent.
double getLongitude() Returns the current longitude of the agent.

© The AnyLogic Company | www.anylogic.com 208


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Supply Chain. Phase 3. Step 6

n Open Retailer diagram

© The AnyLogic Company | www.anylogic.com 209

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Create orderProducts event that periodically sends product requests. Make the event
occur on average 5 times per day, and define the event’s action.
Here we create a new order by calling a constructor of Order type:
new Order (amount, this). The constructor takes two arguments initializing Order
agent type’s parameters: amount and retailer. Take a look at the code of Order
Java class to understand the order for the arguments to follow. We initialize the
retailer field with a reference to this Retailer agent accessible via reserved Java
word this.
Then we search for a nearest free truck.
• The function getNearestAgent(population) returns the nearest agent from the
specified population. We do not consider all the population, but we filter the
population using the filter() function, and search for the nearest truck only from
the subpopulation, containing only the trucks that are currentlyidle.
• The first argument of filter() function takes the agent population, in this case
main.trucks. Then you specify the name for the current agent ( t -> ), and then
you may specify the filter condition(s), t.<condition>. The function will return
the subpopulation containing the agents satisfying this condition(s).
• The function inState(state) checks whether the specified state of the agent’s is
currently active. This way we filter the results and consider only idle trucks (that
are currently located at distributor).
If we finally find an idle truck, we send the message-order to its statechartto
initiate movement. If all the trucks are busy, null is returned.

© The AnyLogic Company | www.anylogic.com 210


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

AnyLogic eventobject

• Event schedulessome action at the specifiedmoment of


timein the future
• Eventsmay be triggered by
• Rate
• Condition
• Timeout. Timeout triggered events have three alternative
occurrence modes:
• Occurs once
• Cyclic
• User control

Trigger type: Timeout


Mode: Cyclic
First occurrence time: 0
Recurrence time: 1 day
Action: onEndOfDay();

© The AnyLogic Company | www.anylogic.com 211

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Rate triggeredevent

• Similar to timeoutcyclic eventswithstochastic recurrence


time

Trigger type: Rate 0 0.31 1.88 2.05 2.74


Rate: 1 …
Action: arrival();
time

• Rate – mean number of events in time unit


• 1/Rate – mean recurrence time
• Recurrence time distribution is an exponential
distribution with Rate as the shape parameter

© The AnyLogic Company | www.anylogic.com 212


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Writing Java code. How do I get to... ?

© The AnyLogic Company | www.anylogic.com 213

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

In AnyLogic you enter pieces of code in numerous properties of various model


elements. It is important to understand exactly where you are writing the code (which
class and method it belongs to) and how you can access other model elements from
there.
• The elements of the same agent type are accessed simply by their names. For
example, you are in the Action field of the event endOfFY of agent type Company.
To access the block queue you simply write queue. To increase the variable revenue
you write revenue += amount.
• To access an element of an object you should put a dot "." after the object’s name
and then write the element name. For example, to obtain the size of the queue you
write queue.size(). For the agent population, you should say which agent exactly you
want to access. To call the function performance() of the employee number 247
among employees of the company, write: employees.get(246).performance().
• Access the upper level agent by the name of the Link to upper level. If the agent
lives in Main, write main to get access to Main from the agent. To call the function
announceSale() of Main, write main.announceSale().
• To access the agent from other population living in the same environment, first get
one level up to Main, and then get down to another agent. To access a customer's
loyalty from a company, we need first to get to Main and then to Customer (with
some index): main.customers.get(i).loyalty.
© The AnyLogic Company | www.anylogic.com 214
Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Supply Chain. Phase 3. Step 7

n Run the model and


examine its behavior

© The AnyLogic Company | www.anylogic.com 215

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

© The AnyLogic Company | www.anylogic.com 216


Pedestrian Modeling

Thispresentationisapartof
AnyLogicStandardTrainingProgram

© The AnyLogic Company | www.anylogic.com

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

What are pedestrian models built for?


• Ata preliminaryprojectassessment • At operatingfacility
stage о Increase a throughput capacity,
arrange queues
о Assess the ability of a facility to о Optimize the operation of services
cope with a planned loading and (number of personnel, working
comply with safety requirements hours)
о Allocate signage
• Atthestageofthedesignofa new о Assess the throughput capacity of a
facility facility at a planned increase of
о Assess alternatives, promptly loading
assess revisions, seek the best о Optimize time schedules (for
example, train schedules)
solutions о Allocate advertisement, goods, retail
• Duringconstruction/maintenance outlets
worksat anoperatingfacility • Safety
о Seek the least inconvenient о Plan escape routes
temporary routes о Vulnerability assessment for
terroristic attacks and catastrophes

• Aswellasforpresentingyourprojectina contest
о Pedestrian models enable to obtain high quality and convincing animationand
vividly demonstrate your offer

© The AnyLogic Company | www.anylogic.com 218


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Which facilities aremodeled?


• Railwaystations
• Metrostations
transport

In general all the facilities where the


arrangement of physical space for
• Airports pedestrians affects throughput
capacity, quality of service, and safety
• Pedestrianpassageways
• Shopping malls
“attractions”

• Museums
• Amusementparks
• Stadiums
events

• Concerthalls
• Streetevents(festivals, rallies,demonstrations)
© The AnyLogic Company | www.anylogic.com 219

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Theory. Pedestrian ModelTypes


Pedestrian Models
(active developments started since about the 1980s)

ic
Macroscopic Microscopic
(flows are simulated, (every pedestrian is presented as a specific matter)
no individual pedestrians are modeled)

Gas kinetic
netic mod
model … Continuous space Discrete space
(cellular automata)

Social Force Model (ge


(geometrical,
magnetic,…)
+ Agent-based model,
“intelligence”

© The AnyLogic Company | www.anylogic.com 220


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Cellular automata
• Easy localrules
• Fast-to-calculate
?
• Can bewell-calibrated
• Poor animation
• See Blue& Adler

© The AnyLogic Company | www.anylogic.com 221

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Social ForceModel
target
• Newtonmechanics
• Realism
• Relatively slowcalculations
Driving
• Very realisticanimation force

• Extendedwithhigherlevel Resultant force


Re
decision makinglogic
• SeeHelbing& Molnar Repulsion
from other
pedestrians
Repulsion from
walls and
obstacles

© The AnyLogic Company | www.anylogic.com 222


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

How are pedestrian models built?


1 Facility plan/drawing 2 Space markup

References to
markup elements

3 Process description

© The AnyLogic Company | www.anylogic.com 223

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Space Markupelements
Walls Services ((service points)) and queues

Target lines / pedestrian


appearance lines

Waiting areas / target areas


Virtual corridors
(pathways)

Escalator

© The AnyLogic Company | www.anylogic.com 224


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Process Description Basic Blocks


PedSource Creates pedestrians on PedService Sets servicing
a line, at a point or in parameters (where
an area with a given is a delay, the selection
rate, according to a of a queue, etc.)
time schedule, etc.

PedGoTo Sets up an objective or PedWait Sets waiting


a route parameters (where to
wait, in relation to time,
until an event)

PedSelectOutput PedSink
Divides a passenger Deletes passengers
flow from the model

© The AnyLogic Company | www.anylogic.com 225

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Measurements and Statistics in Pedestrian Models


PedFlowStatistics
• Metricsspecificforpedestrianmodels
о Flow characteristics: the total number of
passenger having passed through a
section per a unit of time,
the same quantity per a unit of length
о Density in a certain area:
the number of passengers per square
PedestrianDensityMap
meter (average per a unit of time);
density charts

Terminal

© The AnyLogic Company | www.anylogic.com 226


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Individual Features of a Pedestrian


• Since eachpedestrian is modeledas an agent,individual features
canbe adheredto them
• Featuresbuiltin a basic model:
о Comfortable speed
о Dimension (“diameter”)
• These canbe added to them:
о Individual targets (flight, platform, shop)
о Servicing class (first / business / economy)
о Citizenship (US/EU/other, …)
о Servicing speed
о…
• These featurescanbe checkedduringthe pathwayof a pedestrian
throughouta processdiagramand affecttheir behavior

© The AnyLogic Company | www.anylogic.com 227

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Groups
• Pedestrian behavior in groupsconsiderablydiffersfrom thatof
independent pedestrians
о Hold together; how to go (“in a rank”, “in a convoy”, “in a flock”)?
о The presence or absence of a leader (for example, a guide)
о Service: one pedestrian is serviced for all? (buys tickets for all, whereas
̌security check should be passed by everybody)
о Does everybody stand in a queue? Where are those who are not
standing in a queue waiting?

PedSource Is able to set groups, sets initial PedGroupChangeFormation


construction as well as default
behavior at servicing points Changes a group
formation type

PedGroupAssemble PedGroupDisassemble
The same but out of the existing Divides a group into individual
independent pedestrians independent pedestrians

© The AnyLogic Company | www.anylogic.com 228


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Groups. Demo

© The AnyLogic Company | www.anylogic.com 229

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Stairs, Escalators, Roads,Floors


• To set sloped surfaces as well as to modify speed on a
Demo
surfacePedAreawitha Slopedoptionandits”descriptor”
Slope Demo
is used
PedAreaDescriptor
Demo
Limits / multiplies speed of pedestrians or sets a
Escalator Demo
moving surface

• Eachmarkupelementbelongsto a certainlevel
о On default it is a ground level, but you may set new ones
• Specialblock is usedto move betweenthe levels:

PedChangeGround
Moves pedestrians from
one level to another Demo
Change ground
© The AnyLogic Company | www.anylogic.com 230
Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Stairs, etc. Demo

© The AnyLogic Company | www.anylogic.com 231

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Normal Process Interruption.Evacuation


• Allthe pedestrian processblocks where pedestrian spend nonzero
amount of time , have a special exit where pedestrians can be
redirectedat any timein the event of a specialevent

… an evacuation process

When a pedestrian block’s cancel()


function is called pedestrians are
immediately directed to this exit and
thereafter they will follow a process
defined by you by using pedestrian Demo
blocks
TerroristAttack
© The AnyLogic Company | www.anylogic.com 232
Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Combination with Other Model Types


• There are other objectsin the model requiring other
technologies
о For example, transport Demo
Railway station
• If a large facilityis modeled, thenpedestrian modelingis
importantfor some of its partsonly
о For example, in an airport terminal pedestrian problems are
suspected in security check and passport control areas, however
everything should be modeled from check-in to gate
о Then for the remaining process part pedestrians should not be
used. Use ordinary discrete event modeling which is much faster

PedExit PedEnter
Transforms a pedestrian Transforms a request
into an ordinary “request” into a pedestrian

© The AnyLogic Company | www.anylogic.com 233

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Pedestrians + ...Demo

© The AnyLogic Company | www.anylogic.com 234


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Eiffel Tower.Demo

© The AnyLogic Company | www.anylogic.com 235

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Project Example: Printemps Shopping Mall

© The AnyLogic Company | www.anylogic.com 236


Airport Model
Thispresentationisapartof
AnyLogicStandardTrainingProgram

© The AnyLogic Company | www.anylogic.com

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Airport Model

• Let’s build a simulation model of passenger flows inside a


small airport.
• Passengers arrive at the airport, check in at counters, pass
the security check point and go to the waiting area. When
boarding starts, passengers get on board.
• In the last phase we will simulate how an infection is
spreading in the airport. From time to time infected
people will enter the airport, and in case of long queues
they will infect the passengers that will be standing near
them for a reasonable time.

© The AnyLogic Company | www.anylogic.com 238


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Airport Model. Phase1

• In the first phase we will create a simple model where


passengers arrive at the airport and move to the gate
inside thebuilding.

© The AnyLogic Company | www.anylogic.com 239

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Pedestrian Library
• Traditional (discrete-event, queuing) modeling may give incorrect results in areas with
dense pedestrian movement.
• AnyLogic Pedestrian Library enables simulating pedestrian flows in a “physical”
environment. It allows you to create models of buildings (like subway stations, security
checks etc.) or streets (large number of pedestrians).
• In models created with the Pedestrian Library, pedestrians move in continuous space,
reacting to different kinds of obstacles (walls) and other pedestrians. You can accurately
model the interaction of pedestrians and visualize pedestrian movement.
• Models enable you to collect statistics on pedestrian density in different areas, to
ensure acceptable performance levels for service points with a hypothetical load,
estimate lengths of stay in specific areas, or detect potential problems with interior
geometry changes such as the effect of adding or removing obstacles.

© The AnyLogic Company | www.anylogic.com 240


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Airport. Phase 1. Step 1

n Add the layout image

o Choose the image

© The AnyLogic Company | www.anylogic.com 241

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Create a new model. Name it Airport. Set model time units: minutes.
Typically you start creating pedestrian dynamics model by adding a
layout of the simulated space and drawing walls over it.
Superimposing Anylogic Walls over the walls in the image.
nAdd Image from the Presentation palette.
oChoose the image file to be displayed by this object: layout.png
from Models\Airport folder located on your USB disk.
Select the Lock checkbox to lock the image shape.

Locking presentation shapes


• You can lock a shape so it will not react on mouse click and it will be impossible
to select it in the graphical editor until you unlock it. This is frequently needed
when you have some background image on the presentation (e.g. a layout of a
factory or a hospital department), used as a base for your animation. In
this case when editing some shape laying over your layout you may
accidentally edit the layout itself. Locking your background image will
significantly simplify animation editing as you will not be able to select the
layout with an inaccurate mouse click.

© The AnyLogic Company | www.anylogic.com 242


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Airport. Phase 1. Step 2

n Disable the grid (the button


should become unpressed)

o Double-click the Wall in the


Pedestrian Library palette

p Draw the wall over the


exterior wall on the image

© The AnyLogic Company | www.anylogic.com 243

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Now let’s draw the exterior wall using new space markup shape Wall.

Drawing walls
• When drawing walls, use the drawing mode: first double-click the Wall in the
palette and then draw the wall in the diagram, subsequently adding points
with mouse clicks and putting the final point with a double click.

Clicking in a new point adds


a linear wall segment
• To add a linear wall, just do the mouse click
where this wall ends.

• To add a curved segment, press the mouse


button in a point where the curved segment
ends, and then move your mouse with the left Add a curved wall by
mouse button being pressed. Release the left pressing the mouse
mouse button only when you got the segment button and moving
of the required form. the mouse with the
pressed button

© The AnyLogic Company | www.anylogic.com 244


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

How to continue drawing the wall


• You may end drawing the wall for a while (with a double-click) and continue drawing it
later following the scenario described below:

n Right-click the wall,


choose Append line

p Continue drawing the wall


from this point as usual
o Click the end point where you
want to continue drawing the wall

© The AnyLogic Company | www.anylogic.com 245

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Howtotransforma linearwalltoa curved(andviceversa)

Linear -> Curved

n Right-click the wall,


choose Edit Using
Guiding Lines

o Drag the circle handle


(guiding line end point)

Curved -> Linear

n Select the wall &


Ctrl-drag the point o The neighboringwalls
will become linear

© The AnyLogic Company | www.anylogic.com 246


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Airport. Phase 1. Step 3

n Circular wall

o Rectangularwalls

© The AnyLogic Company | www.anylogic.com 247

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Let’s continue drawing the walls and obstacles in the airport building.
n Draw the column using the Circular Wall.
o Draw the working spaces in the airport using the Rectangular Wall.

Walls
There are three space markup shapes to draw walls in pedestrian models:
Wall - Use it to draw walls of complex forms (exterior wall, interior walls,
guard rails, etc.)
Rectangular Wall - Use it to draw rectangular areas non-accessible by
pedestrians (e.g. working spaces).
Circular Wall - Use circular walls to draw circular obstacles inside the
simulated area (e.g. columns, fountains, skating rinks, etc.)

© The AnyLogic Company | www.anylogic.com 248


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Airport. Phase 1. Step 4

n Put Target Line here.


Name it gateLine

o Add one more target line


defining the arrival place.
Name it entryLine

© The AnyLogic Company | www.anylogic.com 249

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

n Draw the line to which passengers will move on entering the airport. Place it
e.g. in the gate area. Name this line gateLine.
o Draw the airport entry with a line. Name it entryLine.
Please mind that either target lines, and all space markup shapes defining
services, queues, etc. must be placed inside the walls so that they are
reachable by pedestrians.

Targetline
• Target line is used to graphically define the following things in pedestrian models:
• Place where pedestrians appear in the simulated space (referred by PedSource or
PedEnter flowchart block)
• The destination of the pedestrian movement (referred by PedGoTo block)
• The pedestrians waiting location (referred by PedWait)
• When you model how pedestrians go from one floor to another you draw two target
lines: one for the place where pedestrians leave the current floor and another one
for the place where pedestrians enter new floor. In this case you specify both target
lines in PedChangeGround flowchart block.

© The AnyLogic Company | www.anylogic.com 250


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Airport. Phase 1. Step 5

n Draw the flowchart


PedSource - PedGoTo - PedSink

© The AnyLogic Company | www.anylogic.com 251

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

nCreate a flowchart for a simple process. Start with the pedestrian generator
PedSource, then place the PedGoTo block that simulates how pedestrians
move to the specified location and finally place PedSink – which discards
incoming pedestrians. Each pedestrian flowchart typically starts with
PedSource and ends with the PedSink block.

Definingprocessesinpedestrianmodels
• Processes in pedestrian dynamics models are defined using flowcharts, in the same way
as in regular discrete-event models built with Process Modeling Library. Alike agents in
discrete-event models, pedestrians pass through a flowchart, subsequently performing
commands and operations defined by the blocks.

© The AnyLogic Company | www.anylogic.com 252


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Airport. Phase 1. Step 6

n PedSource
Target line: entryLine
Arrival rate: 100 per hour

o PedGoTo
Target line: gateLine

© The AnyLogic Company | www.anylogic.com 253

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

n We tellthepedSourceblocktogenerateinaverage100passengersperhourandputthem
onthetargetlineentryLine.
o pedGoToblocksimulateshowthepassengersmovetothegate(thedestinationisdefined
withgateLine).
Choosing the element from the drop-down list

n Choose the element from the


drop-down list that contains only
the elements of the proper type

Selecting the element in the graphical editor

n Click the button

o You will see only the elements


of the proper type, all other
elements are made pale
p Select the shape with a click

© The AnyLogic Company | www.anylogic.com 254


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Airport. Phase 1. Step 7

n Run the model. You will see


passengers (animated by small circles),
moving from the entry line to the gate.

© The AnyLogic Company | www.anylogic.com 255

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Airport Model. Phase2

• In this phase we will add check-in counters.


• We will also add 3D animation.

© The AnyLogic Company | www.anylogic.com 256


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Airport. Phase 2. Step 1

n Drag Pedestrian Type

You will see the diagram of the


created pedestrian type with 3D
animation shape in the axis origin.
Open Main diagram to continue
developing the model.

© The AnyLogic Company | www.anylogic.com 257

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

n Create a new pedestrian type. We need it to define a custom animation for


our pedestrian (in our case – 3D shape instead of the default circles that will
appear in 3D just as many-colored cylinders).
Name the pedestrian type Passenger and leave the default animation choice:
3D figure Person.

Creatingcustompedestriantypes
• If you need to define some custom animation, add some attributes or behavior to
pedestrians, you need to create a custom pedestrian type.
• Since pedestrians are agents and support all the agent functionality, you can add any
model elements on the graphical diagram of the pedestrian alike you do with agents:
define behavior with a statechart, add variables and parameters, define some continuous
behavior with system dynamics stock-and-flow diagram, schedule events, etc.

© The AnyLogic Company | www.anylogic.com 258


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Airport. Phase 2. Step 2

n Add 3D Window

© The AnyLogic Company | www.anylogic.com 259

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Airport. Phase 2. Step 3

n Choose Passenger as the


type of pedestrians
generated by pedSource.
© The AnyLogic Company | www.anylogic.com 260
Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Airport. Phase 2. Step 4

p Switch to 3D animation
(window3d view area).

o Open the developer panel

n Run the model

© The AnyLogic Company | www.anylogic.com 261

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

To be able to see 3D animation of the simulated process, we added 3D Window


from the Presentation palette.
n Now we can run the model and see 3D animation. Navigate to 3D animation
scene using the automatically created view area [window3d].

You will see pedestrians moving from the entry to the gate inside the airport
building.

Navigationin3Dscene
• Drag the mouse to move the camera right,
left, forward or backward on the same
height.
• Rotate the mouse wheel to move the
camera closer or further from the current
center of the scene.
• Hold Alt (Mac OS: Option) + drag the mouse
to rotate the scene relative to the camera.

© The AnyLogic Company | www.anylogic.com 262


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Airport. Phase 2. Step 5

n Draw internal walls

© The AnyLogic Company | www.anylogic.com 263

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Let’s draw internal walls. Use the same space markup shape Wall as before.
Please check that there is no gap between walls.

Run the model. You will see that


passengers changed their route,
considering the internal walls.

© The AnyLogic Company | www.anylogic.com 264


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Airport. Phase 2. Step 6

n Drag Service with Lines here

o Rotate the services


ices

© The AnyLogic Company | www.anylogic.com 265

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Now we can start modeling processes going on in the airport. Let’s simulate the
check-in counter first. It is actually a service – passengers should get serviced
there and in case the service is in use by some other passenger they wait in a
queue until it becomes free.

Servicesinpedestrianmodels
ServicewithLines- Usedtodefineservice(s)withqueuelines(e.g.turnstiles,cashdesk,
passportcontrol checkpoint.)

ServicewithArea- Usedtodefineservice(s)withelectronicqueue,whenpedestrianswait
in the hall /office until the service becomes available (e.g. ticket office, bank office, info
point.)

© The AnyLogic Company | www.anylogic.com 266


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Airport. Phase 2. Step 7

n Make one more click on this


service point and move it here

© The AnyLogic Company | www.anylogic.com 267

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Workingwithcomplexspacemarkupelements
• Sincesomespacemarkupshapesmayconsistof severalprimitivemarkupelements,and
alsoallpedestrianmarkupshapesmake up ground(s),it is importantto understandhow
youselectmarkupshapestobeabletoeditthemgraphicallyinan easyway.

2. The second click selects the shape


1. The first click selects all the shapes
you have clicked
composing the complex element

3. One more click on the currently selected 4. Clicking another shape selects it and starts
shape selects all the shapes of this ground the selection process from the beginning

© The AnyLogic Company | www.anylogic.com 268


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Airport. Phase 2. Step 8

n Reduce the queue


shape, right-click it and
choose Add points

o Draw the queue by putting its


turning points with mouse clicks.
Place the points in the middle of the
passage. Put the end point with a
double click.

© The AnyLogic Company | www.anylogic.com 269

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Airport. Phase 2. Step 9

n Add five 3D objects Table into


the placeholders on the image

© The AnyLogic Company | www.anylogic.com 270


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Airport. Phase 2. Step 10

n PedService

© The AnyLogic Company | www.anylogic.com 271

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Now let’s add flowchart block simulating security check point services. Insert
PedService in the flowchart to make pedestrians pass through the service
defined via the referenced services shape.

Connect the block as shown on the slide above.

© The AnyLogic Company | www.anylogic.com 272


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Airport. Phase 2. Step 11

Run the model and enjoy 3D


animation. You can add 3D
models of office workers
behind the check-in counters.

© The AnyLogic Company | www.anylogic.com 273

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Airport Model. Phase3

• In this phase we will add security check points.


• Having passed security check points, passengers wait in a
waiting area and after some time go on board.

© The AnyLogic Company | www.anylogic.com 274


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Airport. Phase 3. Step 1

n Add Service with Lines

o Put service points inside the


metal detector placeholders

p We need one snake


queue of this shape

© The AnyLogic Company | www.anylogic.com 275

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Airport. Phase 3. Step 2

n Add a pair of Metal Detector


and two XRay Scanner
3D shapes into the placeholders

© The AnyLogic Company | www.anylogic.com 276


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Airport. Phase 3. Step 3

n PedService

o Set Type of service: Linear


and place the service lines so that
they go through the metal detector

© The AnyLogic Company | www.anylogic.com 277

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Pointandlinearservices
There are two types of services: Linear and Point. We used point services to define check-in
services, now we need linear services to define how people go through metal detectors
at security checkpoints.
• Linear service defines a line, along which pedestrians should move. Pedestrian goes to
the start point of the line and starts waiting there for the specified delay. Then
pedestrian moves to end point of line. Recovery phase begins when pedestrian either
finishes service (wait for ped to exit is off) or passes end point of line (wait for ped to
exit is on). After recovery, the service becomes idle and ready to accept new
pedestrians.
• Point service defines a point, where pedestrians should stay on for service delay time.

© The AnyLogic Company | www.anylogic.com 278


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Airport. Phase 3. Step 4

Run the model and


observe 3D animation

© The AnyLogic Company | www.anylogic.com 279

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Airport. Phase 3. Step 5

n Draw the waiting area near


the gate using Polygonal area

o PedWait

© The AnyLogic Company | www.anylogic.com 280


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Airport. Phase 3. Step 6

Run the model and watch how


people are waiting for boarding

© The AnyLogic Company | www.anylogic.com 281

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

© The AnyLogic Company | www.anylogic.com 282


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Airport. Phase4
• In thisphase we willshow how to benefitfromour true
integrationof all modelingmethods.
• We willmodel how an infection is spreading in the airport.
• Fromtimeto timeinfectedpeople willenter the airport, andin
caseof longqueuestheywillinfectthe passengers thatwillbe
standingnearthemfor a reasonable time.

© The AnyLogic Company | www.anylogic.com 283

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Airport. Phase 4. Step 1

n Open Passenger diagram by


double-clicking it in the Projects tree

o Add a Variable (from


the Agent palette) that will
define the health status

© The AnyLogic Company | www.anylogic.com 284


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Airport. Phase 4. Step 2

n Make the existing shape


be shown only in 3D o Draw a circle (Oval from
the Presentation palette) of
radius 3 and make it shown
only in 2D. Let the shape
color depend on the health
status.

© The AnyLogic Company | www.anylogic.com 285

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Differentanimationshapesfor2D& 3D
• Bydefaultallshapesareshownbothin 2Dand3D.
• Sometimesyoumayneedtoanimatethesameobjectwithdifferent2D and3Dshapes.
• Youcandrawtwoanimations,andsetoneshapetobeshownonlyin 2D,whileanother
onlyin 3D(in theshape’sAdvancedpropertysection,Showin property).

© The AnyLogic Company | www.anylogic.com 286


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Airport. Phase 4. Step 3

Run the model. In 2D you can see the infected


passenger animated with a red circle.

© The AnyLogic Company | www.anylogic.com 287

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Airport. Phase 4. Step 4


n Draw a statechart, consisting of
two states: Susceptible (marked as
initial with Statechart entry point),
and Infectious.

o The transition brings theperson


to Infectious state when the
specified condition becomes true

© The AnyLogic Company | www.anylogic.com 288


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Airport. Phase 4. Step 5

n Add an internal transition inside


the state Infectious that will model
how the infected person gradually
infects his neighbors.

© The AnyLogic Company | www.anylogic.com 289

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

“for”loop.“Collectioniterator”form
• Here we use the “collection iterator” form of the for loop. This form is used to
iterate through populations and collections. Whenever you need to do
something with each agent of some population we recommend to use this loop
because it is more compact and easy to read, and also is supported by all
collection types (unlike index-based iteration).

© The AnyLogic Company | www.anylogic.com 290


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Airport. Phase 4. Step 6

n Find connections element


on the Passenger diagram

o Here you define how the


connected agents react on
the message reception

© The AnyLogic Company | www.anylogic.com 291

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Each agent has a non-removable link connections – this is for standard networks
with bidirectional connections.

In the Communication properties section, you define the reaction on the


message reception. Here we increase the value of infection variable by 0.001.

As we defined earlier (Phase 4, Step 4), the person is considered infected when
infection variable surmounts the given threshold (0.5).

According to this logic, what time does it take for the person to become infected
when standing near some infectious person?
Can you propose some alternative implementations of the infection logic?

© The AnyLogic Company | www.anylogic.com 292


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Airport. Phase 4. Step 7

Run the model. You can


see how the infection is
spreads in long queues.

© The AnyLogic Company | www.anylogic.com 293

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Airport. Exercise
• Let one security checkpoint operate permanently, while another
servicepoint willbe operatingonly whenthe numberof people in
the queue is critical(e.g.exceeds20 people).

© The AnyLogic Company | www.anylogic.com 294


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel
Production Line
Thispresentationisapartof
AnyLogicStandardTrainingProgram

© The AnyLogic Company | www.anylogic.com

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel ProductionLine


• Let us build a simulation model of the solar panel productionline.
• The processconsists
of the following
operations:
• Layup station Layup Bussing
• Bussing
• Lamination
• Trimming
Lamination
• Frame assembly
(includes edge
sealing, automatic
framing, junction
Frame assembly Trimming
box applying)

© The AnyLogic Company | www.anylogic.com 296


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 1. Step 1

Create a new model

n Select the Scale element

o Adjust the ruler scale

© The AnyLogic Company | www.anylogic.com 297

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Create a new model and name it Solar Panel Production Line.


The Main agent diagram will open.

n Select the Scale element located above the visible area marked by the blue
rectangle. To find the element, pan the graphical editor by pressing the
right mouse button and moving the mouse without releasing the mouse
button.
o In the Properties of the Scale element, set the Ruler length corresponds to
property value to 5 meters.

© The AnyLogic Company | www.anylogic.com 298


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 1. Step 2


n Open the Material
Handling Library palette

o Double-click the
Conveyor element p Click to start
drawing the conveyor

q Add bend points


with clicks

r Double-click to
finish drawing

© The AnyLogic Company | www.anylogic.com 299

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Now we will add an animation shape for the conveyor.


n - o Double-click the Conveyor element in the Space Markup section of
the Material Handling Library palette to enter drawing mode.
p Click in the conveyor’s starting point to start drawing. Draw the U-shape
conveyor. To add a bend when drawing a conveyor, click in the bend point.
q Double-click in the conveyor’s end point to finish drawing the conveyor.

Conveyor direction
Conveyors are unidirectional. Material items will always be conveyed from the
conveyor's start point to its end point. The conveyor direction is indicated with arrows
drawn over the conveyor shape:

© The AnyLogic Company | www.anylogic.com 300


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 1. Step 3

n Adjust the
conveyor properties

You should get the


conveyor of this shape

© The AnyLogic Company | www.anylogic.com 301

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 1. Step 4

n Turntable
p Name the conveyor
prelaminatingLine

o Transfer Table

q Name the conveyor


finishingLine

© The AnyLogic Company | www.anylogic.com 302


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 1. Step 5

n Source
Arrivals defined by: Interarrival time
Interarrival time: 1 minute
Advanced
Forced pushing:
Agents which can’t exit: wait in this block

o Convey
Source conveyor:
prelaminatingLine
Target conveyor:
finishingLine

p Sink

© The AnyLogic Company | www.anylogic.com 303

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 1. Step 6

n Run the model. Observe


the conveyor animation and
the animated flowchart.

© The AnyLogic Company | www.anylogic.com 304


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 2. Step 1

n Create new Material Item Type

o Name the material item


type SolarPanel and click Next

p Set the animation shape to None

© The AnyLogic Company | www.anylogic.com 305

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

By now, solar panels are represented by colored rectangles.


We will customize its appearance by creating a material item type: SolarPanel.
You do not need to choose any animation figure for the solar panel: we will
draw it on the next step.

© The AnyLogic Company | www.anylogic.com 306


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 2. Step 2

n The new agent type will


appear in the model tree.
Double-click SolarPanel to open
its graphical diagram.

o Set the solar panel


dimensions

© The AnyLogic Company | www.anylogic.com 307

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 2. Step 3

n For the SolarPanel agent, change the scale:


Ruler length corresponds to 1 meter

o The item animation placeholder


will change its size

p Draw the Rectangle (from


Presentation palette). Make it
fit the placeholder exactly.

© The AnyLogic Company | www.anylogic.com 308


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 2. Step 4

© The AnyLogic Company | www.anylogic.com 309

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 2. Step 5

n Run the model.


Now you can see how solar panels
are turned by the turntable.

© The AnyLogic Company | www.anylogic.com 310


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 3.


Adding stations
• In thisphase, we willaddstationsperformingthe following
operations:
• Layup station
• Bussing
• Lamination
• Trimming
• Frame assembly
(includes edge sealing, automatic framing, junction box applying)

© The AnyLogic Company | www.anylogic.com 311

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 3. Step 1

n Name: layupStation
Process time: 5 minutes o Name: bussing
Loading: Starts when Process time: 3 minutes
unloading completes Loading: Starts when
Position and size unloading completes
Length: 4.5 meters Length: 2.0 meters

© The AnyLogic Company | www.anylogic.com 312


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 3. Step 2

n Name: laminationStation
Process time: 25 minutes
Quantity: 4
Length: 7.0 meters

o Name: frameAssembly
Process time: 5 minutes
Loading: Starts when unloading completes
Length: 5.5 meters

© The AnyLogic Company | www.anylogic.com 313

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 3. Step 3

o Turn Station
Name: trimmingStation
Rotate by: 1 turn
n Position and size Rotation speed: 3 rpm
Width: 1.5 meters

p Enlarge the turn station


by dragging the handle

q Target conveyor: finishingLine1


© The AnyLogic Company | www.anylogic.com 314
Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 3. Step 4

n Run the model.


Now you can see how solar panels
are processed by the stations.

© The AnyLogic Company | www.anylogic.com 315

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 4.


Adding 3Danimation
• In thisphase,we willimprovethe model appearance and add3D
animation toit.

© The AnyLogic Company | www.anylogic.com 316


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 4. Step 1

n Increase the model window size


by setting the frame Height to 800

o Add 3D Window

© The AnyLogic Company | www.anylogic.com 317

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 4. Step 2

n Run the model

p Switch to 3D animation

o Open the developer panel

© The AnyLogic Company | www.anylogic.com 318


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 4. Step 3

n Draw the statechart


for the SolarPanel

o Set all three transitions to


be Triggered by: Message

© The AnyLogic Company | www.anylogic.com 319

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 4. Step 4

n Select the animation of the


glass panel in the SolarPanel

o Switch the Visible property


to dynamic value editor

p Make the shape visible


only when the agent is in
the first state (glass)

© The AnyLogic Company | www.anylogic.com 320


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 4. Step 5

n Image
USB: Models/Solar Panel
Production Line/laidupPanel.jpg
Visible: inState(afterLayup)
Z: 1

o Rectangle
Visible: inState(laminated)
Fill color: whiteSmoke
Line color: No color
Z-Height: 2

© The AnyLogic Company | www.anylogic.com 321

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 4. Step 6

n Image
Models/Solar Panel Production
Line/finishedPanel.jpg
Visible: inState(finished)
Z: 2

© The AnyLogic Company | www.anylogic.com 322


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 4. Step 7

n Actions
On process finished:
send (“nextState”, agent);
o On trailing edge enter:
send (“nextState”, agent);

p On process finished:
send (“nextState”, agent);

© The AnyLogic Company | www.anylogic.com 323

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 4. Step 8

n Run the model

© The AnyLogic Company | www.anylogic.com 324


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 4. Step 9

n Navigate to the CNC Machines


section of the 3D Objects palette
o Add the CNC Cutter 4 State1
and switch it to the List view
3D model

p Click Yes

© The AnyLogic Company | www.anylogic.com 325

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

We will add a 3D object to represent the layup station.


n Drag the CNC Cutter 4 State 1 element from the CNC Machines section of
the 3D Objects palette onto the Main agent diagram.
o AnyLogic will prompt you to automatically adjust the scale of the 3D object
to match the agent scale. Click Yes.
Position the 3D object so that it appears over the first station.

© The AnyLogic Company | www.anylogic.com 326


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 4. Step 10

n CNC Vertical Machining Center4


State 2
Additional scale: 125%
Colors: make grey colors transparent
(via the Other colors… option)

o CNC Cutter 5 State1

© The AnyLogic Company | www.anylogic.com 327

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 4. Step 11

n Run the model

© The AnyLogic Company | www.anylogic.com 328


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 5.


Adding resources
• In thisphase,we willaddresources: twobussingoperatorsrequired
to performthe bussingoperation

© The AnyLogic Company | www.anylogic.com 329

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 5. Step 1

n Create new Resource Type

o Name the resource type


Operator and click Next

p Leave the default Person


animation shape and click Finish

© The AnyLogic Company | www.anylogic.com 330


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 5. Step 2

n Draw a bussing operators area


with a rectangular node. Name it
nodeBussing and add two attractors
facing the conveyor.

© The AnyLogic Company | www.anylogic.com 331

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 5. Step 3

n bussingOperators
Capacity: 2
New resource unit: Operator
Home location (nodes): nodeBussing

© The AnyLogic Company | www.anylogic.com 332


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 5. Step 4

© The AnyLogic Company | www.anylogic.com 333

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 5. Step 5

n Run the model. You will


see multiple solar panels
waiting to be laminated

© The AnyLogic Company | www.anylogic.com 334


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 6.


Adding AGV
• In thisphase,we willaddAGV (automatedguidedvehicles).AGVwill
move alongthe rails.

© The AnyLogic Company | www.anylogic.com 335

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 6. Step 1

n Create new
Transporter Type

o Name the transporter type


AGV and click Next

p Leave the default animation


shape and click Finish

© The AnyLogic Company | www.anylogic.com 336


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 6. Step 2

o Move the AGV


animation shape
inside the placeholder p Add Java code to shift
the cargo animation shape
from the AGV center

n Adjust the AGV


dimensions and speed

© The AnyLogic Company | www.anylogic.com 337

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 6. Step 3

n Name this rectangular


node nodeStorage

Draw the rail network for


AGV using the space
markup elements

o Name this point


node nodeAGV

© The AnyLogic Company | www.anylogic.com 338


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 6. Step 4

o MoveByTransporter
Node: nodeStorage
Seize transporter
Fleet: AGV

n TransporterFleet
Capacity: 1
Home locations: nodeAGV
Transporter
New transporter: AGV

© The AnyLogic Company | www.anylogic.com 339

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 6. Step 5

n Run the model. You will see how


AGV transports finished solar
panels to the storage zone.

© The AnyLogic Company | www.anylogic.com 340


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 7.


Adding the unloadingstation
• In thisphase,we willaddthe unloading station.It takessolar panels
fromthe conveyor and provides themfor the AGV to pickup.

© The AnyLogic Company | www.anylogic.com 341

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 7. Step 1

n Point node, nodeUnloading

o ResourcePool
Name: unloadingMachine
Home location (nodes): nodeUnloading

© The AnyLogic Company | www.anylogic.com 342


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 7. Step 2

n Seize
Resource sets: unloadingMachine
Send seized resources:
Attach seized resources:
o ConveyorExit

p MoveTo
Node: nodeUnloading q Release

© The AnyLogic Company | www.anylogic.com 343

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 7. Step 3

n Batch (from ProcessModeling


Library palette)
Batch size: 10
New batch: SolarPanel
Location of batch: Network/GIS node
Node: nodeUnloading

© The AnyLogic Company | www.anylogic.com 344


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Solar Panel Production Line. Phase 7. Step 4

n Run the model. You will see that


batches of 10 solar panels are
transported now.

© The AnyLogic Company | www.anylogic.com 345

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

© The AnyLogic Company | www.anylogic.com 346


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del
Colosseo
Thispresentationisapartof
AnyLogicStandardTrainingProgram

© The AnyLogic Company | www.anylogic.com

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza delColosseo
• Let’s build a simulation model of road traffic around Piazza del Colosseo in Rome,
Italy, with the help of AnyLogic Road Traffic Library. We will model an intersection
withcarsarrivingfromfourdifferentdirections.
• Inthelastphasewewilladdtrafficlightstothemodelandexaminethedistribution
oftimespentbyvehiclesontheintersection.Wewillthenset upanoptimization
experimentthatwillanalyzethephases’lengthofthetrafficlightstooptimizethe
road networkthroughput.

Click here to view the video of the Piazza del Colosseo intersection

© The AnyLogic Company | www.anylogic.com 348


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza delColosseo

Road Traffic Library

• Roads,lanes,intersections,parkinglots, traffic
lights
• Logic:
о Routing (shortest distance)
о Keeping distance
о Overtaking
о Giving way
• Animation:2D,3D,Heat (density)map
• Interoperabilitywith the ProcessModeling
andother standardLibraries

© The AnyLogic Company | www.anylogic.com 349

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 1


• In thisphase, we willaddthe layoutandsimulatethe vehicletraffic
alongthe first road.

© The AnyLogic Company | www.anylogic.com 350


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 1. Step 1

o Lock the Image element


n Add the Image element

p Verify the Position and size properties

© The AnyLogic Company | www.anylogic.com 351

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Create a new model and name it Piazza del Colosseo.


n Add the layout image onto the Main agent diagram to draw the
actual road network upon it.
Choose the image file to be displayed by this Image shape:
piazza_layout.png from the Models\Piazza del Colosseo folder
located on your USB disk.
We will now set the Image element properties.
o Select the Lock check box. Since we will not need to further move
or resize the image, we can lock it in the graphical editor. This will
prevent us from accidentally selecting it.
p Adjust the Image element Position and size properties. We will set
X and Y to 0 so that the image top-left corner matches the axis
origin. We will also ensure that the Image element Width and
Height correspond to the picture dimensions (1100 x 700).

© The AnyLogic Company | www.anylogic.com 352


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 1. Step 2


o Select Road Traffic library
n Disable grid
in the Palette and double-
click the Road element

p Click to start drawing the road

r Hold down the mouse button


and drag in the necessary direction
to add a curved road segment

q Click to add a straight


road segment
~Double-click to finish
drawing the road

© The AnyLogic Company | www.anylogic.com 353

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

We will draw the first road in the West-to-East direction (Via dei Fori Imperiali
– Via Labicana).
n Disable grid by clicking the Enable/Disable grid button on the main
toolbar. This will allow us to position the road points freely, without
snapping them to grid.
o Open the Road Traffic Library palette and double-click the Road element
to enter the road drawing mode.
We will now draw the road point by point.
p Start drawing by clicking in the graphical editor.
q To add a straight road segment, click in the graphical editor.
r To add a curved road segment, click in the graphical editor and hold down
the mouse button. Drag in the necessary direction to adjust the curve
shape and release the mouse button when done.
Repeat the steps q-r as necessary so that the resulting road shape
resembles the one on the layout image.
~ To finish drawing the road, double-click in the graphical editor.

© The AnyLogic Company | www.anylogic.com 354


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 1. Step 3


o Notice the scale value in the bottom-
right corner of the layout image
n Click Yes

p Select the Scale element

q Adjust the ruler scale

© The AnyLogic Company | www.anylogic.com 355

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

We will adjust the model scale so that it fits the selected layout image.
n When you finish drawing the road, AnyLogic will prompt you to
automatically adjust the model scale. Click Yes. The model scale will be
adjusted to 4px per meter.
o If you look at the bottom-right corner of the layout image, you will notice
that the image is scaled so that two grid squares correspond to 50 meters.
We will now adjust the model scale accordingly.
p Select the Scale element located above the layout image.
q Set the Ruler length corresponds to property value to 50 meters. Our
model is now scaled in full correspondence with the layout image.

© The AnyLogic Company | www.anylogic.com 356


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 1. Step 4

n Click the road to select it.

o Click the road again to select the road network

p Adjust the road network Lane width parameters

© The AnyLogic Company | www.anylogic.com 357

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

We will adjust the parameters of the road network.


n Select the road by clicking it.
o With the road selected, click it again to select the road network.
p Set the road network Lane width to 3.0meters.

Road network
A road network joins several roads together. Its parameters affect all roads belonging to
the network.
Several important parameters, such as lane width, traffic direction (left-hand or right-
hand) and road background color can be defined only for the road network but not for
individual roads.

© The AnyLogic Company | www.anylogic.com 358


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 1. Step 5

n CarSource o CarMoveTo p CarDispose


Road: road Road: road

© The AnyLogic Company | www.anylogic.com 359

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

We will now create the flowchart to define the vehicles movement along the
road.
n-p Add flowchart elements that define the West-to-East vehicles
movement along the forward lane.

© The AnyLogic Company | www.anylogic.com 360


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 1. Step 6

n Select the blue frame on o Adjust the model


the Simulation diagram window dimensions

p Run the model

© The AnyLogic Company | www.anylogic.com 361

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

We are ready to run the simulation experiment.


n - o Adjust the model window dimensions so that the layout image fits the
window. Set Width and Height to 1100 and 700, respectively.
p You can now run the model and watch the animation in the model window.
You will see the vehicles moving along the road in the West-to-East
direction.

© The AnyLogic Company | www.anylogic.com 362


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 1. Step 7

p CarDispose

o CarMoveTo
Road: road
Destination: end of backward lane
n CarSource
Road: road
Enters: backward lane
q Run the model

© The AnyLogic Company | www.anylogic.com 363

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

We will extend the flowchart to define the vehicles movement along the road
in the East-to-West direction.
n-o Add the elements to the flowchart and customize them to define the
East-to-West vehicles movement along the backward lane.
p Connect the Car Move To element to the Car Dispose element defined on
the previous step.
q Run the model. You will see the vehicles moving along the road in both
directions.

© The AnyLogic Company | www.anylogic.com 364


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 2


• In thisphase,we willsetup 3D animationand add 3D modelsfor cars
and theColosseo.

© The AnyLogic Company | www.anylogic.com 365

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

© The AnyLogic Company | www.anylogic.com 366


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 2. Step 1

n Drag the 3D Window element


from the Presentation palette to
the Main agent diagram

© The AnyLogic Company | www.anylogic.com 367

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

We will start creating 3D animation.


n Drag the 3D Window element from the Presentation palette onto the Main
diagram and place it on the right of the layout image.
AnyLogic will automatically create a view area for the 3D window, which will
allow us to easily navigate to it during the model run.

© The AnyLogic Company | www.anylogic.com 368


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 2. Step 2

n Select image

p Select Simulation: Main o Adjust the


image Z-coordinate

q Disable panning and zoom

© The AnyLogic Company | www.anylogic.com 369

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

We will perform several preparatory steps for running the model in 3D.
n-o In the Projects view, select image and set its Z-coordinate to -0.1.
Initially, the Z-coordinate is set to 0 and the road shares the same plane with
the layout image. This causes visual interference when viewing 3D animation:

By setting the Z-coordinate to -0.1, we move the image slightly below the road
thus eliminating interference:

p-q In the Projects view, select Simulation: Main and disable panning and
zooming at model runtime, since we will rely on view areas for navigating the
model instead of doing it manually.

© The AnyLogic Company | www.anylogic.com 370


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 2. Step 3

p Switch to 3D animation
(window3d view area).

o Open the developer panel

n Run the model

© The AnyLogic Company | www.anylogic.com 371

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

We are ready to run our model in 3D.


n Run the model. You will see the 2D animation of the model.
o Click the Navigate to view area button on the toolbar and select
[window3d]. The model animation will switch to 3D.
Note that cars are currently displayed as colored parallelepipeds. In the next
step, we will adjust the model so that custom 3D shapes are used for
displaying cars.

© The AnyLogic Company | www.anylogic.com 372


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 2. Step 4

n Drag the Car Type element


from the Road Traffic Library
palette to the Main agent diagram

o Click Next p Click Finish

© The AnyLogic Company | www.anylogic.com 373

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

We will now add a new Car Type agent type that will allow us to use 3D
models for cars.
n Drag the Car Type element from the Road Traffic Library palette onto the
Main agent diagram. The New Agent wizard will open.
o-p We will start with creating a new car type with the default properties.
Click Next and Finish to create a car type and exit the wizard.

Why should we create a car type?


•We need this to set realistic 3D shapes to our cars. To diversify cars in your model, you
should create several car types, each one with a specific 3D model. Afterwards, set Car
Source blocks to generate cars of the different car types.

© The AnyLogic Company | www.anylogic.com 374


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 2. Step 5

n Select the CarSource block

p Repeat the steps n-o for the


second CarSource block

o Set Car as New car

© The AnyLogic Company | www.anylogic.com 375

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

We will now configure the flowchart so that the newly created car is used in
the road network.
n-o Select the first Car Source element in the flowchart and set Car as New
car in the Properties section.
p Repeat the steps n-o for the second Car Source element. Both elements
will now generate cars of the Car type.

© The AnyLogic Company | www.anylogic.com 376


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 2. Step 6

o Locate the 3D object file

n Drag the 3D Object element


from the Presentation palette
to the Main agent diagram

p Adjust the 3D
object properties

© The AnyLogic Company | www.anylogic.com 377

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

We will add a 3D object for the 3D figure of the Colosseo.


n Drag the 3D Object element from the Presentation palette onto the Main
diagram.
o Click the Browse button and browse for the file used by 3D Object:
Colosseo.dae from the Models\Piazza del Colosseo folder located on your
USB disk.
p Set the element properties as displayed on the screenshot.

Importing 3D objects into the model


3D object supports importing of 3D objects stored in Collada (.dae) files. You can follow this
scenario to import a custom 3D object into a model:

• Search for the 3D object file and download it in the Google Earth KMZ format. You can
get it from an online gallery (for example, 3DWarehouse).

• Change the file extension to zip end extract its contents into a folder. Verify that the
Collada model file (with the .dae extension) is present inside the folder.
• The exported file can now be added in AnyLogic model as 3D object.

© The AnyLogic Company | www.anylogic.com 378


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 2. Step 7

n Drag the View Area element


from the Presentation palette
to the Main agent diagram

o Specify the View Area title

© The AnyLogic Company | www.anylogic.com 379

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

We will add a view area to the model, which will allow us to navigate between
animation and flowchart during the model run.
n Drag the View Area element from the Presentation palette onto the Main
agent diagram and position it between the layout image and the flowchart
(as displayed on the screenshot). Change the view area’s title (it will appear
in the navigation drop-down list, see the next slide).
This will mark out the flowchart area and allow us to easily navigate to it
during the model run.

Viewareas
• View area enablesthe user to mark out some particular areas on a diagram, containing some logically
detachedpartsorgroupsofelements(e.g.presentation,flowchart,charts,etc.).Oncehavingdefinedthe
view areas, you can easilynavigate between them usingspecialnavigation tools at designtimeand/or
runtime.

© The AnyLogic Company | www.anylogic.com 380


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 2. Step 8

p Switch to 3D animation
(window3d view area).

o Open the developer panel

n Run the model

© The AnyLogic Company | www.anylogic.com 381

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 3


• In thisphase, we willaddtwo moreroads,set up the intersection
betweenthemand define carsmovement on the intersection

© The AnyLogic Company | www.anylogic.com 382


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 3. Step 1

o Connect the roads

p Adjust the
intersection

n Draw a road

© The AnyLogic Company | www.anylogic.com 383

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

We will now add a second road in the South-to-North direction (Via Celio
Vibenna) and create an intersection connecting both roads.
n Draw a new road (as displayed on the screenshot).
o Create an intersection by connecting the roads. To connect roads, create
the end point by double clicking when the point is cyan-colored.
p Adjust the shape of the intersection so that it better fits the layout. Drag
the connection point farther from the intersection. Note that you should
release the mouse button while the connection point cyan-colored. If the
connection point becomes white-colored, releasing the mouse will
disconnect the road from the intersection.
If you accidentally disconnect the road, press Ctrl+Z to undo the action.

© The AnyLogic Company | www.anylogic.com 384


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 3. Step 2


n Select the road
o Rename the road

p CarSource
Name: carSourceW q CarMoveTo
Road: roadW Name: carMoveToE
Road: roadE

© The AnyLogic Company | www.anylogic.com 385

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

When we added the intersection, our existing West-to-East road was split into
two separate roads. We will now rename the roads and make the appropriate
edits in the flowchart.
n-o Select the road to the West of the intersection and rename it to roadW.
Similarly, rename the second road to roadE.
Note that since the road is now split into two, cars are generated at the
beginning of one road and move to the end of the other road.
p Rename the Car Source element to carSourceW. In the block properties,
set Road to roadW.
q Rename the Car Move To element to carMovesToE and set Road to roadE.
Perform the steps p-q for the second Car Source - Car Move To pair. In this
case, cars will be generated at the beginning of roadE and move to the end of
roadW.

© The AnyLogic Company | www.anylogic.com 386


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 3. Step 3

p Connect the outputs with


the CCaarrMMoovveeTTooblocks
n CarSource
Name: carSourceS
Road: roadS
o SelectOutput
New car: Car
Name: selectOutputWE

© The AnyLogic Company | www.anylogic.com 387

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Our South-to-North road does not currently have any cars moving along it. We
will now add the corresponding elements to the flowchart.
n Rename the South-to-North road to roadS. Add a new Car Source element
to the flowchart, which will generate cars at the beginning of the roadS
forward lane.
o Add a Select Output block and connect it to the Car Source element. We
will use this block to split the single car flow (South-to-North) into two
flows, each moving in a separate direction (to the East and to the West).
We will leave the default Probability (0.5) so that the flows are
approximately equal.
p Connect the output ports of the Select Output block with the carMoveToE
and carMoveToW input ports. Our cars moving from the South can now
move in the eastern and western directions.

© The AnyLogic Company | www.anylogic.com 388


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 3. Step 4

n SelectOutput
Name: selectOutputES
Probability: 0.7

o SelectOutput p CarMoveTo
Name: selectOutputWS Name: carMoveToS
Probability: 0.7 Road: roadS
Destination: end of backward lane

© The AnyLogic Company | www.anylogic.com 389

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

We will now add Select Output blocks to our flowchart so that some of the
cars moving along the roadE and roadW will turn to roadS.
n Add a new Car Move To block and set it up so that cars move to the end of
its backward lane.
o-p Add two Select Output blocks, and connect them as follows:
• carSourceW is connected with carMoveToE and carMoveToS

• carSourceE is connected with carMoveToW and carMoveToS

We assume that at intersections cars mostly do not turn but continue moving
directly. For this reason, we will set Probability to 0.7 for both blocks.
If you run the model now, you will see the cars moving according to the
directions we have specified:

© The AnyLogic Company | www.anylogic.com 390


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 3. Step 5

n Draw the road and


connect it to the intersection

o Select One way

© The AnyLogic Company | www.anylogic.com 391

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

We will now add the last road (Via Nicola Salvi) and connect it to our road
network.
n-o Draw the road in the North-to-South direction (as displayed on the
screenshot) and name it roadN. Set the road to be one-way.
When connecting the road to the intersection, release the mouse button as
soon as the connection point is cyan-colored. By doing so, you will achieve the
required shape of the intersection:

If you drag the connection point too far into the middle of the intersection,
the intersection shape will be distorted:

Correcting this intersection will probably be time consuming.


We recommend that you press Ctrl+Z (Mac OS: Cmd+Z) to undo
the action or select the road, delete it and draw a new one.

© The AnyLogic Company | www.anylogic.com 392


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 3. Step 6

n Car Source
Name: carSourceN
Road: roadN
New car: Car

o Select Output
Name: selectOutputWES
Probability 1: 0.2
Probability 2: 0.2
Probability 3: 0.6
Probability 4: 0
Probability 5: 0

© The AnyLogic Company | www.anylogic.com 393

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

We will now adjust our flowchart so that it includes roadN.


n Add a new Car Source element, which will generate cars at the beginning
of the roadN forward lane.
o Cars entering from the North can move in three different directions: to the
West, to the East and to the South. For this reason, we add a Select
Output5 element instead of Select Output. We assume that the majority of
cars do not change the initial direction (North-to-South) and set the
appropriate probabilities.
Name the Select Output5 element selectWES and connect its outputs to
carMoveToE, carMoveToW and carMoveToS.

© The AnyLogic Company | www.anylogic.com 394


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 3. Step 7

n Run the model. You will see


heavy traffic on the intersection.

© The AnyLogic Company | www.anylogic.com 395

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 4


• In thisphase, we willmakethe intersectioncontrolled by traffic
lights.
• We willalsomeasuretime-in-systemfor our cars.

© The AnyLogic Company | www.anylogic.com 396


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 4. Step 1

o Select intersection

n Add Traffic Light

© The AnyLogic Company | www.anylogic.com 397

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

We will now make the intersection controlled by adding traffic lights.


n Add the Traffic Light element from the Road Traffic Library palette to the
flowchart. You can position it freely since it is not connected to any other
elements.
o Select intersection for the Intersection property to link this element to our
intersection.

© The AnyLogic Company | www.anylogic.com 398


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 4. Step 2

n Double-click and edit


o Click the header
the phase duration

p Click the stop line to change


its state for the phase

© The AnyLogic Company | www.anylogic.com 399

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

We will now set up traffic lights phases.


n Double-click in the table header to adjust the phase duration. Set the first
phase duration to 15 seconds and the second phase duration to 10
seconds.
o Click the table header to select the entire phase column. The graphical
editor will switch to editing mode with all elements except the stop lines
grayed out.
p Click the stop line to switch the traffic light phase. The stop line and the
corresponding cell in the table will change its color. Set up phases in
accordance with the following logic:
• During the first phase, cars move in the East-to-West and West-to-East directions.

• During the second phase, cars move in the North-to-South and South-to-North directions.

© The AnyLogic Company | www.anylogic.com 400


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 4. Step 3

n Run the model

© The AnyLogic Company | www.anylogic.com 401

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

We have successfully created a controlled intersection.


n Run the model. You will see traffic lights switching. If you increase
execution speed, you will notice traffic jams. You may also notice that
when such a jam occurs, cars stop entering a road after a certain time
period
:

This happens due to the fact that a car enters the road network only when
there is enough distance for it to stop in accordance with its initial speed and
maximum deceleration. The more initial speed of the car, the longer distance
is needed for the car to safely enter the network.
Later we will adjust vehicles’ initial speed for the CarSourceE block. We will
also modify arrival rates based on historical data collected for the intersection.

© The AnyLogic Company | www.anylogic.com 402


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 4. Step 4

o Add a TimeMeasureEnd block

n Add four TimeMeasureStart blocks

© The AnyLogic Company | www.anylogic.com 403

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Now we will measure the time that cars spend in our road network (time in
system). We will do it by extending our flowchart with TimeMeasureStart and
TimeMeasureEnd blocks.
n Add four TimeMeasureStart blocks. Place each block between the
corresponding Car Source and SelectOutput block (as displayed on the
screenshot). Ensure that all blocks are connected properly.
o Add a single TimeMeasureEnd block and place it between the CarMoveTo
and CarDispose blocks. Ensure that all three CarMoveTo blocks are
properly connected to it. Select all four TimeMeasureStart blocks as the
TimeMeasureStart blocks value.

© The AnyLogic Company | www.anylogic.com 404


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 4. Step 5

o Click Add histogram data


n Drag the Histogram element p Set the histogram
from the Analysis palette to title and data source
the Main agent diagram

© The AnyLogic Company | www.anylogic.com 405

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

The TimeMeasureEnd block collects the distribution of the time spent by the
agents in the marked part of the flowchart (starting from the
TimeMeasureStart block).
We will now add a Histogram chart to view the cars’ time-in-system
distribution.
n Drag the Histogram element from the Analysis palette onto the Main agent
diagram.
o The added histogram contains no data. Click the Add histogramdata
button to add a new data element.
p Name the data element Time in system, seconds and set the Histogram
field to timeMeasureEnd.distribution.

© The AnyLogic Company | www.anylogic.com 406


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 4. Step 6

CarSourceW
Arrival rate: 800

CarSourceE
Initial speed: 45
Arrival rate: 800

CarSourceS
Arrival rate: 500

CarSourceN
Arrival rate: 400

© The AnyLogic Company | www.anylogic.com 407

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 4. Step 7

o Click the TimeMeasureEnd block

n Run the model

© The AnyLogic Company | www.anylogic.com 408


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

n Run the model and switch to the [Logic] view area. You will see the chart
displaying the distribution of time in system for the cars at the intersection.
o Click the TimeMeasureEnd block to open the inspect window. Notice the
Mean value (the mean of the cars’ time in system) that is automatically
calculated based on the data collected by the TimeMeasureEnd block.
In the next phase, we will create an optimization experiment, which will
calculate the optimal durations for the traffic lights’ phases so that time in
system for the cars at the intersection is minimal.

© The AnyLogic Company | www.anylogic.com 409

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 5


• In this phase, we will run the optimization experiment, which will
comprise multiple simulation runs. Duringeach run, the systemwill
apply a different combinationof the trafficlightsphases’durations
and measurethe meanof the cars’ timein system.The experiment
goalis to achievethe minimummean.

© The AnyLogic Company | www.anylogic.com 410


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 5. Step 1

n Drag two Parameter


elements from the Agent
palette to the Main agent
diagram

q Use the parameters


o Name:greenEW for the phases’ durations
Type: int
Default value: 15

p Name: redEW
Type: int
Default value: 10

© The AnyLogic Company | www.anylogic.com 411

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

We will add two parameters to the model and assign them to the traffic lights’
phases durations.
n Drag two Parameter elements from the Agent palette onto the Main agent
diagram. Place these elements outside of the view area since we do not
want to observe them during the simulation run.
o-p Set the parameters’ Name and Default value.
q In the Properties view of the Traffic Light element, double click each
column heading and choose the greenEW for the first phase and redEW for
the second phase.
The phases’ durations are now defined by parameters instead of constant
values, which allows us to vary them during the experiment.

© The AnyLogic Company | www.anylogic.com 412


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 5. Step 2

n Right-click the model and


select New > Experiment

o Select Optimization

p Click Finish

© The AnyLogic Company | www.anylogic.com 413

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

We will now create an optimization experiment.


n In the Projects view, right-click the model and select New > Experiment.
The New Experiment wizard will open.
o Choose Optimization in the Experiment Type list and click Finish. The
experiment will be created.

Optimization
• If you need to run a simulation and observe system behavior under certain conditions, as well
as improve system performance (for example, by making decisions about system parameters
and/or structure) you can use the optimization capability of AnyLogic. Optimization is the
process of finding the combination of conditions resulting in the best possible solution.
• AnyLogic optimization is built on top of the OptQuest Optimization Engine, one of the most
flexible and user-friendly optimization tools on the market. The OptQuest Engine automatically
finds the best parameters of a model, with respect to certain constraints. AnyLogic provides a
convenient graphical user interface to set up and control the optimization.
• The optimization process consists of repetitive simulations of a model with different sets of
parameters. Using sophisticated algorithms, the OptQuest Engine varies controllable
parameters from simulation to simulation to find the optimal parameters for solving a problem.

© The AnyLogic Company | www.anylogic.com 414


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 5. Step 3

o Define the objective function

n Select Optimization: Main p Adjust the


number of iterations

q Set up the experiment parameters

r Adjust Stop time

© The AnyLogic Company | www.anylogic.com 415

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

We will now set up the created experiment.


n Select Optimization: Main in the Projectsview.
o Define the objective function, which is the value that we want to minimize
as a result of the experiment. In our case, it is the mean of the cars’ time in
system. This value is provided by the Time Measure End block defined in
the top-level agent of the experiment. Since top-level agent is accessed as
root in experiment's code, we type here:
root.timeMeasureEnd.distribution.mean().
p Set the Number of iterations to 200. We decrease the value so that the
optimization process does not take too long. In business cases, the number
of iterations is normally much higher (e.g. 1000).
q The table in the Parameters section lists all parameters of the top level
agent. Adjust the greenEW and redEW parameters as displayed on the
screenshot. During the experiment run, the parameters will vary according
to the provided values.
r Set the experiment to simulate one hour and thus set the experiment Stop
time to 3600 (since our model time units are seconds, this value defines
the model lifetime in seconds).

© The AnyLogic Company | www.anylogic.com 416


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 5. Step 4

n Click Create default UI

o Select the experiment

© The AnyLogic Company | www.anylogic.com 417

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

We are ready to run the experiment.


n In the Properties view, click the Create default UI button. The default user
interface for the experiment window will be created. It contains a number
of controls displaying all the necessary information regarding the current
optimization status.
o Click the arrow to the right of the toolbar Run button and choose the
optimization experiment from the list.

© The AnyLogic Company | www.anylogic.com 418


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 5. Step 5


The system will run multiple simulations using
different combinations of the greenEW and redEW
parameters. Here you will see statistics on current and
best found objective and parameter values.

n After the experiment is


finished, copy the found
optimal parameter values
to the clipboard

© The AnyLogic Company | www.anylogic.com 419

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 5. Step 6

n Select Simulation: Main

o Apply optimal parameter values


to the simulation experiment

© The AnyLogic Company | www.anylogic.com 420


Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Piazza del Colosseo. Phase 5. Step 7

o Observe the time in system statistics


n Run the model

© The AnyLogic Company | www.anylogic.com 421

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

n-o Run the simulation experiment again and switch to the [Logic] view area.
Click the Time Measure End block to open the inspect window.

Notice the difference in the shape of the histogram and the calculated Mean
value before and after the optimization experiment:

Before optimization After optimization

© The AnyLogic Company | www.anylogic.com 422


AnyLogic.
Your next steps

© The AnyLogic Company | www.anylogic.com

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Do moretutorials
• Followtutorialsin AnyLogic
Help ->Tutorials
о Job Shop (discrete event
model with production and
a small warehouse)
о Wind Turbine Maintenance
• Buildextramodelsdescribed
in the trainingmaterials(Call
Center,HumpYard).You will
find them on your USB, in
Extrasfolder
• Read “AnyLogic in Three
Days”(av.onlinefor free)
© The AnyLogic Company | www.anylogic.com 424
Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Study the best modeling techniques on


• Watch AnyLogicwebinarsandshort how-tovideos
о “The AnyLogic Company” channel on Youtube

© The AnyLogic Company | www.anylogic.com 425

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Study ourexamples
• InvestigateAnyLogic examplemodels,study & reuse the
besttechniques

• Signup at the AnyLogic Cloud https://cloud.anylogic.com


and study the modelsuploaded by other users
• Readtheoryin “The BigBook of SimulationModeling”
(available on AmazonKindle)
© The AnyLogic Company | www.anylogic.com 426
Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Stay incontact
• Subscribe to AL newsletter (e.g.by downloadingthe book or
software fromwww.anylogic.com)

• ANY technicalquestions (fixingerrors,gettingmodeling


advices):
о Contact support team for help (support@anylogic.com) using
the “Get Support” toolbar button

© The AnyLogic Company | www.anylogic.com 427

Material provided free of charge for the exclusive use for Genoa's AnyLogic online training.
Any copy, reproduction, exploitation, display, alteration of any of its contents for any purpose is strictly prohibited.

Try the followingscenario

• Selectone problem/applicationarea(distributioncenter,
railwaystation,airport, supplychain)
• Investigatethisspecifictopic
• Getthe problemdefinition (or inventit by yourself)
• Createa pilotsimulation project
• Uploadyourmodel to AnyLogic Cloud
• Publishthe topic featuringour model in AnyLogicUsers
LinkedIn Groups
• Getresponse fromthe AL users
• Addmore detailsintoyoursimulationproject/ continue with
nextproject
© The AnyLogic Company | www.anylogic.com 428

You might also like