Agent-Based Modeling (ABM)
Agent-Based Modeling (ABM)
(ABM)
Methods in Simulation Modeling
◼ A method is a framework we use to map a real-world system to its
model.
4
Agents
◼ Agents are NOT the same thing as cellular automata that live in discrete
space. There can be no space at all. When space is needed, in most cases it
is continuous, sometimes a geographical map or a facility floor plan.
◼ Agent based modeling does NOT assume clock "ticks" or "steps“. Most well-
built and efficient agent based models are asynchronous. Continuous time
dynamics may also be a part of agent or environment behavior
◼ There can be many and there can be very few agents in an agent based
model.
◼ There are agent based models where agents do not interact at all. Consider
agents –patients with chronic non-contagious
6
Introduction to ABM
◼ The applications of ABM are vast and can be complex.
7
Statechart
◼ Commonly, an agent’s behavior can be described by a state.
◼ Statecharts are very helpful in simulation modeling. They are used a lot in
agent-based models, and also work well with process and system dynamics
models.
8
Statechart
◼ Statecharts consist of states and transitions.
◼ Each transition has a trigger. When a transition is taken (“fired”) the state
may change, and a new set of reactions may become active. State transition
is atomic and instantaneous. Arbitrary actions can be associated with
9
transitions and with entering and exiting states.
Trigger Types
10
Trigger Types
11
Internal transition
◼ An internal transition is a cyclic transition that lies inside a state. The
transition's start and end points both lie on the state's border.
◼ Since an internal transition does not exit the enclosing state, it does not take
the statechart out of this state. Neither the exit nor entry actions are executed
when the transition occurs, and the current simple state in the state is not
exited.
12
Guards in transitions
◼ When a statechart enters a simple state, the triggers of all outgoing
transitions are collected and the statechart begins to wait for any of them to
occur.
13
Example: Laptop running on battery
14
Steps to create ABM model
◼ Step 1: Create a population of agents
◼ Step 3: Define the transitions and triggers and events (if any)
15
◼ Step 6: Create plots
Important functions for states and transitions
◼ shapeBody.setFillColor(color): controls the color of the agent
shapeBody has all the shape and color of a human agent.
For a Box use shapeBox
16
◼ For guards: RandomTrue(prob): Returns True with a prob probability
Important functions for statistics
◼ Statistics can be retrieved in “main”.
◼ Click on the agent type. Under statistics add a statistic function and give it a
name.
The name will be used in plots. Use: AgentType.StatisticsName()
17
Example 1: Passport retrieval
◼ In a town, a population of 200 people exist.
◼ The population will request a passport when they need to travel. Suppose
that a flight comes up to the town every month. (Use event to send message,
and use a guard with a random true probability of 0.005)
◼ The Passport expires every 1 year and the user will request a new passport
after that period.
◼ Color the agents without a passport in black and the ones with passports in
green.
18
Example 2: PC usage
◼ A lab has 35 PCs. Students enter the lab at a rate of 5 per hour.
Use rate= 5/35 per day.
◼ Some leave the PCs running for a simulation (probability of 25%) and the PC
remains running for 10 hours. After the end of the simulation the PCs can be
used by other students.
◼ The students use the PC for a minimum of 0,5 hrs and a maximum of 2 hrs
(Use uniform distribution)
Simulation
20