37
Agent-based modelling of complex systems Janusz Szwabi ski ń Lecture #8: Components of ABMs

Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

Agent-based modelling of complex systems

Janusz Szwabi skiń

Lecture #8: Components of ABMs

Page 2: Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

Outlook

● Motivation and overview● Agents● Example: simple traffic model● Environments● Interactions● Schedule

Page 3: Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

Motivation

Divide each difficulty into as many parts as is feasible and necessary to resolve it.

Rene Descartes

The whole is more than the sum of parts.Aristotle

It’s turtles all the way down.Author unknown

Page 4: Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

Overview

● reason for using ABM● complex systems can be productively modeled and

explained by:● creating agents and environments● describing their behavior through rules● specifying agent-agent and agent-environment

interactions● agent – basic ontological units of a model● environment – the world in which the agents lives● distinction between agents and environment can be fluid

(parts of the environment can be modeled as agents)● interactions can occur between different parts of the

model

Page 5: Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

Overview

● agents’ actions can occur internally, directly affecting only the agent’s internal state

● environment is not merely passive, it may act autonomously (like e.g. regrowing grass in predator-prey systems)

● schedule is to tell the agents when to act

Page 6: Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

Agents

● the basic unit of agent-based modeling● important to choose the design of the agents carefully● two aspects while creating agents:

● properties – the internal and external state of an agent (their data and description)

● actions (sometimes called behaviors or methods) – what the agents can do

● issues related to agent design:● agent “grain size” - which is most effective for the

chosen model?● agent cognition – how much capability do they have

to observe the world around and make decisions

Page 7: Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

Granularity of agents

● agents can represent:● individuals (consumers, traders, entrepreneurs,…)● social groupings (households, communities,…)● institutions (markets, corporations, gov’t agencies,…)● biological entities (crops, livestock, forests,…)● physical entities (weather, landscape, electric grids,

…)● choosing a proper granularity is one of the first

considerations when designing an ABM● the obvious choice (for instance taking agents as people

in social simulations) is often not the best one

Page 8: Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

Granularity of agents

● how to choose the level of granularity?● agents should represent the fundamental level of

interaction that pertains to the question about the phenomenon:

● tumor model – cells within the human body (research question examines how tumor cells spread)

● AIDS model – people (more concerned with how the disease spreads between humans)

● traffic model – cars● segregation model – households● forest fire model – trees● predator-prey models – wolfs and sheeps

Page 9: Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

Granularity of agents

● choosing the appropriate granularity can make a model easier to create

● unnecessary aspects of a phenomenon are ignored● focus is put on the interactions of interest● a critical early step in the development of a successful

ABM● within a model, granularities of agents should be usually

comparable (agents should operate on roughly the same time scales and have similar physical presence)

● if not at the same scale, the model behavior should be usually adjusted so that they can interact appropriately

Page 10: Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

Example: simple traffic model

● traffic flow is a rich domain for studying collective behavior● interactions among cars in a traffic flow can lead to surprising

group phenomena● consider a long road with no cross streets or intersections

● what if we added some traffic lights along the road?● no constructive purpose at first glance● natural to assume that they would reduce the overall traffic

throughput (number of cars per unit time)● but in some situations, additional traffic lights actually

improve overall traffic throughput!!!● New York City Port Authority found that traffic throughput in

the Holland Tunnel could be increased by 6 percent by deliberately stopping some cars before they entered the tunnel (Herman & Gardels, 1963)

Page 11: Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

Example: simple traffic model

● traditional studies of traffic flow rely on sophisticated analytic techniques (from fields like queuing theory)

● many of the same traffic phenomena can be explored with simple programs

Page 12: Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

Example: simple traffic model

● an early version of the model proposed by two high school students (see M. Resnick, “Beyond the centralized mindset”, Journal of Learning Sciences 5 (1996) 1-22)

● they wanted to include traffic accidents, radar traps and other forms of traffic diversion to create traffic jams

● traffic jams appeared in an initial model with only one radar trap!

● traffic jams still formed after the removal of the radar trap!!!

Page 13: Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

Example: simple traffic model

● components of the original model:● agents – cars (or drivers)● environment – single-lane highway● two basic rules:

● if there is a car close ahead you, slow down● if there are not any cars close ahead of you, speed up

(unless you are already moving at the speed limit)

Page 14: Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

Example: simple traffic model

● some of the high-school students’ predictions:● Emily: [The cars will] just speed along, just keep going

along...they will end up staggered, in intervals.● Frank: Nothing will be wrong with it. Cars will just

go...There's no obstacles. The cars will just keep going, and that's it.

● Ramesh:They will probably adjust themselves to a uniform distance from each other.

Page 15: Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

Example: simple traffic model

Page 16: Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

Agent cognition

● decision-making process● different types of agent cognition:

● reflexive agents – they use if-then rules to react to inputs and take actions (e.g. cars in the basic traffic model); most basic form of agent cognition

● utility-based agents – agents may have to speed up and slow down at different times to minimize their gas usage while still not causing accidents

● goal-based agents – if the agents have a goal that dictates theirs action (e.g. turning right or left to come home in a more advanced traffic model)

● adaptive agents – agents that are able to change their strategy based on prior experience (e.g. learning the best rate of acceleration in the traffic model)

Page 17: Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

Agent cognition: utility-based

Page 18: Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

Agent cognition: goal-based

Page 19: Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

Agent cognition: adaptive

Page 20: Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

Agent cognition

● decision-making agents are capable (in different degrees) of:

● behavioral adaptation● goal-directed learning ● social communication (talking with each other!)● endogenous formation of interaction networks

● autonomy of agents:● self-activation and self-determination based on private

internal data and methods as well as on external data streams (including those from real world)

Page 21: Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

Agents’ properties

● properties describe an agent’s current state● a subset of the properties may have default values, e.g.

common for all agents in the model● some of the properties, like e.g. speed of cars in the

traffic model, have to be analyzed with different values for different agents● if we want all agents to have roughly the same value but

with some variations, we set the property with a normally distributed random variable

● if we want each value to be possessed by a similar number of agents, we use a uniformly distributed random variable to initialize the property

Page 22: Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

Agents’ properties

Page 23: Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

Agents’ properties

● it is a common practice to read the values from a file or a database

● this method enables us to recreate particular empirical examples

● some of the properties may be changed during the simulation (e.g. speed in the traffic model)

Page 24: Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

Agents’ behaviors

● ways in which an agent can change the state of the environment, other agents or itself

● in case of the traffic model:● slowing down – each car checks if there is another car

ahead of it and then slows down to a speed below the car’s ahead one

● speeding up – if there is no other car ahead, the agent accelerates

● adjusting speed according to speed limits ● the first two behaviors are interactions – a car interacts

with another car by sensing that car’s speed and changing its own accordingly (the action of each agent affects the actions of other agents)

Page 25: Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

Agents’ behaviors

● it haven’t been implemented in the basic traffic model, but we could imagine cars affecting the road, i.e. the environment of the model

● for instance, the more traffic on the road, the more worn down the road might be

● this in turn might affect the top speed that the cars can reach on a worn section of the road etc.

Page 26: Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

Collections of agents

● agents are typically divided into two main types:● mobile agents can move about the landscape (e.g.

human agents in the segregation model)● stationary agents that cannot move at all (e.g. trees in

the forest fire model)● in some modeling frameworks (e.g. NetLogo), there is a

third basic type of agents – links, which connect other agents with each other

● from a geometric standpoint, agents are very often treated as shapeless area-less points, although the may be visualized with various shapes and sizes

● other types can be added by model designers

Page 27: Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

Agents and OOP

● agents with their types, properties and methods are closely related to the concept of object oriented programing

● OOP allows to encapsulate all properties and methods characteristic for a given type in a single object (a class)

● implementation of a model may become easier with OOP● important: with OOP, procedures encapsulated into the

methods of a particular agent can only be implemented using the particular resources available to that agent

● realistic representation of real-world systems composed of interacting distributed entities with limited information and computational capabilities

Page 28: Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

Agents and OOP

● in principle, as a result of agent encapsulation:● any decision-making agent interacting within an ABM

through a particular input-output public interface can be replaced by a person that interacts with the ABM through this same public interface

● since method implementations by the decision-making agent and its human replacement need not be the same, the resulting outcomes under replacement could differ

● the only claim here is the feasibility of replacement due to the imposition of agent boundaries in ABMs

Page 29: Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

Environments

● another early and critical decision● an environment consists of the conditions and habitats

surrounding agents● it can affect agent decisions and can be affected by agent

decisions● different approaches possible

● composed of many agents (different parts of the environment may have different properties and act differently)

● one large agent (global set of properties and actions)● implemented outside an ABM toolkit (for instance by a

GIS)

Page 30: Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

Environments

● spatial environments● discrete spaces

● usually lattice graphs (square lattice being the most common one)

● continuous spaces● may be implemented only approximately!● no notion of a cell or a node● agents are located at points in the space, that can be as

small as the resolution of the number representation allows

● agents can move smoothly through space● can be represented only at the level of screen resolution

● finite or infinite

Page 31: Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

Environments

● spatial environments● boundary conditions

● toroidal topology (periodic boundary conditions) – when an agent move off the world in one direction, it reappears at the opposite side (think of a famous Asteroids game)

● bounded topology – agents are not allowed to move beyond the edges

● infinite plane topology – there are no bounds, agents can keep moving in any direction

Page 32: Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

Environments

● network-based environments● very popular in social context● reasonable choice if interactions not defined by physical

proximity● most common topologies are random, scale-free and small-

world● avoid to use networks for regular 2D lattices (efficiency

issues)● 3D worlds

● it is not always a good idea to simplify the model to 2D space (i.e. flocks of birds)

● however, characteristics similar to 2D worlds

Page 33: Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

Environments

● GIS-based environments● related to physical locations in the world● widely used by environmental scientists, urban palnners, park

managers, transportation engineers and many others● can serve as interaction topology (agents moving on a GIS

terrain may be constrained to interact on that terrain)● may be used to encode large amounts of data, not

necessarily strictly geographical (e.g. socioeconomic status)

Page 34: Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

Interactions

● five basic classes that exist in ABMs:● agent-self

● no interaction with others needed● agents consider their current state and decide what to do ● advanced cognition examples belong to this class

● environment-self● areas of the environment change themselves (regrowing

grass in the predator-prey model)● agent-agent

● most important type of interaction in ABMs● interaction between two or more agents (e.g. a wolf eating

a sheep, a car sensing another car in the traffic model)● communication (information sharing) belongs to this

category as well

Page 35: Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

Interactions

● five basic classes that exist in ABMs:● environment-environment

● interactions between different parts of the environment● the least common type in ABMs

● agent-environment● when an agent manipulates or examines a part of the

world in which it exists, or…● when the environment in some way alters or observes an

agent● examples: agents’ movement, role of advertisement in

opinion spreading

Page 36: Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

Schedule

● description of the order in which the model operates● form of updating the state of the entire system may have a big

impact on the results of the model● synchronous updates

● all agents updating at the same time● model operates in parallel● changes made to an agent are not seen by other agents until the

next clock tick● the order in which agents take actions does not matter● cellular automata usually use this type of updates

Page 37: Agent-based modelling of complex systemsprac.im.pwr.wroc.pl/~szwabin/assets/abm/lec/8.pdf · Agent cognition decision-making process different types of agent cognition: reflexive

Schedule

● asynchronous updates ● some agents updating before others● model operates sequentially● when agents change their state, that state is immediately seen by

other agents● often more realistic than synchronous updates: in the real world

people very often act independently of each other rather than waiting for each other

● easier to design (for the agent to act truly in parallel we would need parallel hardware)