An Introduction to

rucksackbulgeAI and Robotics

Dec 1, 2013 (3 years and 10 months ago)

102 views

1

An Introduction to
Agent Based
Modeling

November 2002

Rosanna Garcia

© R.Garcia, Northeastern University, 2002

2

Agent Based Modeling


Computer simulation that represents
individual actors in a dynamic social
system.


‘Agents’ represent heterogeneous
individuals who interact with each other
and/or their environment based on set
rules.


From these interactions, macro
-
scale
behaviors may emerge.

3

Agents

Agents have:


Internal data representations
(
memory

or
state
)


Means for modifying their internal
data representations (
perceptions
)


Means for modifying their
environment (
behaviors
)

Copyright © 2000 by Swarm Development Group



4

Example

5

Spatial ABMs


ABM consist of a space, framework or
environment in which interactions take place
and a number of agents whose behavior is
defined in this space is defined by a basic set of
rules and by characteristic parameters.
(Reynolds, 1999)



The aim of ABM is to look at global
consequences of individual or local interactions
in a given space. Agents are seen as the
generators of emergent behavior in that space.
(Holland, 1999 & Reynolds, 1999).


6

Different types of Networks
(Space)

Figure 1
. Representation of network structures: (a)
random, (b) scale
-
free and, (c) hierarchical

7

Small World Networks






Small
-
Worlds

by Duncan Watts, 1999


8

Difference Between ABM & CA


Cellular automata (CAs) are always
homogeneous and uniformly densely
populated on the grid (all cells are
identical), whereas in ABM the agents are
heterogeneous and do not necessarily
occupy all spaces within the grid.


CAs frequently won’t interact with agents
outside their immediate ‘neighborhood’

9

Different Types of
Software

10

-2
1
1
1
-2
1
-1
1
-2
CA Diffusion Model with ‘Seeds’

Influence Level =
-
2

Indifference Point = 0

SUM (Surrounding Squares) = 2(
-
2 ) + 5(1)

1 = 0


Therefore: cell remains negative

Excel
-
Example

1
-2
-1
-1
-1
1
1
1
-1
-1
-1
-1
1
1
1
-1
1
-1
-1
-1
1
-1
1
-1
-1
1
2
1
1
-1
-1
1
-1
-1
-1
1
-1
1
-1
1
-1
1
-1
-2
1
1
-1
-1
1
1
1
1
-1
1
-1
-1
1
1
-1
-1
-1
2
1
1
-1
-1
-1
1
-1
-1
1
-1
-1
-1
-1
1
-1
-1
-1
-1
-1
-1
-1
1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1
1
-1
-2
-1
-1
-1
1
1
-1
-1
1
1
1
-2
-1
2
-2
-1
1
1
1
1
1
1
2
1
1
2
-1
2
1
-2
1
-1
1
2
-1
1
1
1
2
2
1
-1
-2
-1
-2
-1
1
1
-1
1
1
1
-1
-1
1
1
1
-2
1
-1
-1
1
1
1
2
-1
-2
1
-1
1
-2
1
-2
-1
1
-1
1
2
2
2
1
2
1
-1
2
-2
1
2
1
-1
1
-2
2
1
1
-1
-1
1
2
1
1
-1
1
-1
-1
1
1
1
-2
-1
-2
-2
1
1
-2
-2
1
-1
1
-1
1
-1
1
1
1
1
1
-1
-1
1
1
1
1
1
-1
1
1
-2
1
1
2
-1
-1
-1
1
1
1
-1
-1
1
1
1
-2
-1
1
1
1
-1
1
-1
1
-1
-1
1
-1
-2
-1
-1
-1
1
-1
-1
1
-1
-1
1
-1
1
-1
1
1
-2
2
-1
1
-1
1
-1
-2
2
-1
1
40%

12

Netlogo
http://ccl.northwestern.edu/netlogo/

This particular cellular automaton
is called the Parity Model. There is
only one rule, which all the cells
follow. The rule is that each cell
looks at its four neighbours (the
ones immediately to its left, right,
above and below) and if an odd
number of them (that is, 1 or 3) of
them are 'on', it switches itself 'on'.
If there are an even number 'on' (2
or 4), it switches itself off.

by Nigel Gilbert (Submitted: 9/15/2002 )


13

Ascape

www.brook.edu/dybdocroot/es/dynamics/models/ascape

In Ascape, agent objects
exist within
scapes
;
collections of agents such
as arrays and lattices.
These scapes are
themselves agents, so
that typical Ascape models
are made up of
"collections of collections"
of agents. Ascape
manages graphical views
and collection of statistics
for scapes and provides
mechanisms for
controlling and altering
parameters for scape
models
.


14

Starlogo/Sugarscape
http://education.mit.edu/starlogo/

StarLogo is a programmable modeling environment for exploring the
workings of decentralized systems
--

systems that are organized
without an organizer, coordinated without a coordinator. With
StarLogo, you can model (and gain insights into) many real
-
life
phenomena, such as bird flocks, traffic jams, ant colonies, and
market economies.


www.brook.edu/SUGARSCAPE

15

RePast/Sugarscape

The name RePast is an
acronym for
REcursive
Porous Agent Simulation
Toolkit
. Our goal with RePast
is to move beyond the
representation of agents as
discrete, self
-
contained
entities in favor of a view of
social actors as permeable,
interleaved and mutually
defining, with cascading and
recombinant motives. We
intend to support the
modeling of belief systems,
agents, organizations and
institutions as recursive
social constructions.

16

SWARM
www.swarm.org/

Swarm is a software
package for multi
-
agent
simulation of complex
systems, originally
developed at the Santa Fe
Institute. Swarm is
intended to be a useful
tool for researchers in a
variety of disciplines. The
basic architecture of
Swarm is the simulation
of collections of
concurrently interacting
agents: with this
architecture, we can
implement a large variety
of agent based models.


17

AgentSheets

http://agentsheets.com/

AgentSheets is an authoring tool
that allows non
-
programmers to
create agents with behaviors and
missions, teach agents to react to
information and process it in
personalized ways, and combine
agents to create sophisticated
interactive simulations and
models. Our customers use
AgentSheets to create interactive
games, virtual worlds, training
simulations, information
gathering and personalizing
agents, and other interactive
content.


18

Other Software


Aglets
-

mostly used for intelligent agent design, rather than
social science simulation.


JADE

-

is developed at the Telecom Italia Lab. It is more in the
genre of intelligent agents than the multi
-
agent systems used for
social science simulation.


IMT

-

Integrating Modeling Toolkit. It's an XML environment
for using agents to tie together diverse model components.


MAML

-

is an extension of the Swarm development
environment. It aims to simplify the development of Swarm
models through the use of various "macros" (much like Evolver
for RePast).


Evolver
-

is a what
-
you
-
see
-
is
-
what
-
you
-
get application for
simplifying the construction of models in the RePast
development environment.

19

Examples

20

Example of a Standing Ovation

Agent Model Standing Ov
21

Example of a Wave

Agent Model Wave
22

Algorithm of ABM


Von Neuman
-
Morgenstern individual
-
level
diffusion model

y
i

= [ c
i
s
i
2
/2


(1/c) ln(1
-
kp)


m
i
][σ
2

/ s
i
2
]



Bayesian rule updating

m
i

= [m
i
-
1
/s
i
-
1
2

+ z
i

2

] / [1/ s
i
-
1
2

+ 1/ σ
2

]


s
i
2

= 1/ [1/ s
i
-
1
2

+ 1/ σ
2

]




Diffusion Example in Matlab

23

Agent Characteristics



1.


Ecology mindedness


2.


Technological savvy


3.


Age


4.


Coefficient of risk aversion


5.


Performance expectation of innovation


6.


Variance of performance expectation


7.


How often agent purchases a car




Probability of purchase

=
-
1.735 +.448
**

eco
-
minded
+ .352
*

tech
-
minded + .314
*

age

Agent Model
24

Effects of Varying New Release
Periods

0
200
400
600
800
1000
1200
1400
1600
1800
2000
6
12
18
24
30
36
42
48
54
60
Technical Period Length
NPV
Total autos sold
25

Goals of Good ABM
Programming


Validity, usability, extendibility


Validity is difficult because ‘the problem is
knowing whether an unexpected result is a
reflection of a mistake in programming or a
surprising consequence of the model itself.’


In validating the program, check micro
-
dynamics, not just aggregate results.


Follow Occam’s Razor in building models


the simpler, the better.


Use commercial programs for data analysis.


Document all runs.

26

ABMs in the
Marketing/Management Literature


Diffusion:
Goldenberg, 2001; Young,
1999, Bhargava, 1993, Prietula, 2001


Innovation Networks:
Gilbert 2001


Learning Organizations: Carley & Hill,
2001


Cultural Issues: Axtell, Axelrod, Epstein


numerous publications


27

Practical Applications

BiosGroup



Supply Networks/Procurement


Adaptive Scheduling & Routines


Market Analysis & Planning


Decision Support


Risk Management



Strategic & Tactical Simulation

http://www.biosgroup.com/solutions/solutions.html

28

Differences between ABMs &
SDMs, Scholl


ABM are inductive, ie. the resulting emergent
behavior of the agents is the basic unit of analysis


leverage points are with rules & agent interactions


exploratory research


SDM (ODEs) are deductive; feedback loops,which
are used to model systemic problems at aggregate
levels, are the units of analysis.


leverage points are in feedback structure of
system


confirmatory research

29


Why agent
-
based modelling?


Traditional mathematical methods (ODE, PDE, statistical approaches):


can describe macroscopic properties of a system that is
already known, but don't explain the origin of those
properties. (e.g. rate constants)


cannot be easily extrapolated to situations where the
assumptions behind the equations no longer hold. (e.g.
Hookes law
F =
-
kx)


don't handle discontinuous systems well


don't handle heterogeneity in populations well

but
:


ABM complements and enhances rather than supplants,
traditional approaches

Copyright © 2000 by
Swarm Development Group

30

Additional resources about
ABMs


Rauch (2002), ‘Seeing Around Corners’:
www.theatlantic.com/issues/2002/04/rauch.htm


Santa Fe Institute Working Papers:
www.santafe.edu


Brookings Institute,
www.brook.edu/dybdocroot/es/dynamics/
models/


NECSI:
http://necsi.org


Cambridge Colloquium on Complexity & Social
Networks:
www.ksg.harvard.edu/complexity