Agent-Based Modeling & Python @ PyData DC 2016

Preview:

Citation preview

Agent-Based Modeling & Python

By Jackie Kazil DC, Oct. 8, 2016

1

2

PSF

PyLadies

WDSDC

Data Community DC

PIFF

Byte Back

3

PyData 2016 DC host and sponsor

4

Class of 2019?

5

Overview1. What Agent-based modeling (& Complexity)2. Background in Agent-based modeling tools3. Modeling in Python using Mesa4. Future of Mesa

6

7

8

AGENT-BASED MODELS!An Overview of Applications

9

AGENT-BASED MODELS!ABMsMASGame theoryCellular automataMicrosimulationIndividual-based modelsComplex Simulations

10

What is agent-based modeling?Computer simulationConsisting of agents... interacting with one another... in order to study an overall system

11

Components of a modelSpace

Agents

Time

Visualization (not required)

Conway’s Game of Life

Source:Wikipedia user LucasVB,https://commons.wikimedia.org/wiki/File:Gospers_glider_gun.gif

12

Schelling Segregation Model

Source:Case, “Parable of the Polygons”http://ncase.me/polygons/

Source:Schelling, 1971. “Dynamic Models of Segregation.” Journal of Mathematical Sociology.

13

14

Why ABMs?Flows: evacuation, traffic, and customer flow management.

Markets: stock market, shopbots and software agents, and strategic simulation.

Organizations: operational risk and organizational design.

Diffusion: diffusion of innovation and adoption dynamics.

15

Why ABMs?ABMs capture the path as well as the solution, so one can analyze the system’s dynamic history.

Most social processes involve spatial or network attributes, which ABMs can incorporate explicitly.

When a model (A) produces a result (R), one has established a sufficiency theorem, meaning R if A.

16

Why ABMs?Individual behavior is nonlinear; characterized by thresholds, if-then rules, or nonlinear coupling

Individual behavior exhibits memory, path-dependence, or temporal correlations, including learning and adaptation

Agent interactions are heterogeneous; can generate network effects --> lead to deviations from predicted aggregate behavior

Predator-Prey Dynamics

Source:Wilensky, U. (1997). NetLogo Wolf Sheep Predation model. http://ccl.northwestern.edu/netlogo/models/WolfSheepPredation. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.

17

Political Dynamics

Source:Cederman et al. “GeoSim Framework.” http://www.icr.ethz.ch/research/geosim

18

Migration Modeling

Source:Gulden et al. 2011, “Modeling Cities and Displacement through an Agent-Based Spatial Interaction Model,” Computational Social Science Society of America Conference

19

Epidemiological Simulation

Source:Los Alamos National Laboratory, OPPIE epidemiological model.http://www.lanl.gov/projects/mathematical-computational-epidemiology/agent-based-modeling.php

20

22

Open Source ABM Library Ecosystem

MIMOSE (Micro-und Multilevel Modelling Software) [53]GAMA [28]

ABLE (Agent Building and Learning Environment) [2]Jason (Jason:Interpreter for extension of AgentSpeak) [40]MAS-SOC (Multi-Agent Simulations for the SOCial Sciences) [51]Brahms [11]ECHO [22]FLAME [25]FLAME GPU [26]Construct [13]MOOSE(Multimodeling Object-Oriented Simulation Environment) [55]Jade’s sim++SimBioSys [68]SimPack [69]DeX [20]

LSD (Laboratory for Simulation Development)[45]iGen [31]FLUXY [27]MASS (Multi-Agent Simulation Suit) [50]FramsticksSimPlusPlus [66]Descartes[19]

A3 / AAA (Agent Anytime Anywhere) [1]ADK (TryllianAgent Development Kit)[4]AOR Simulation[6]Ascape [8]BDI4Jade [9]Cougaar[15]CybelePro[17]FAMOJA(Framework for Agent-based MOdelling with JAva) [24]ICARO-T [32]JABM [34]JADEJAS-mine [38]

JASA (Java Auction Simulator API) [39]jES (Java Enterprise Simulator) [42]jEcho [43]MASON [49]Moduleco [54]

MASS (Multi-Agent Simulation Suit) [50]FramsticksSimPlusPlus [66]Descartes[19]

A3 / AAA (Agent Anytime Anywhere) [1]ADK (TryllianAgent Development Kit)[4]AOR Simulation[6]Ascape [8]BDI4Jade [9]Cougaar[15]CybelePro[17]FAMOJA(Framework for Agent-based MOdelling with JAva) [24]ICARO-T [32]JABM [34]JADEJAS-mine [38]

JASA (Java Auction Simulator API) [39]jES (Java Enterprise Simulator) [42]jEcho [43]MASON [49]Moduleco [54]netLogoJIAC [64]Sugarscape [71]VSEit [74]Xholon [75]D-OMAR(Distributed Operator Model Architecture) [21]RepastJanus [37]EVE [23]JCA-Sim [41]Boris[12]MaDKit (Multi Agent Development Kit)[46]SwarmAnyLogicJESS [44]Insight Maker [33]AgentBuilder [5]TerraME[72]MacStarLogoMAGSY [47]MAML (Multi-Agent Modeling Language) [48]AgentService [7]OBEUS (Object Based Environment for Urban Simulation) [56]OpenOME [58]Behaviour Composer (Rich Internet Application building on NetLogo) [10]NetLogoSpatial Modeling Environment(SME) [70]JAMEL (Java Agent-based MacroEconomic Laboratory) [35]PS-I (Political Science-Identity)[60]

Altreva Adaptive Modeler [3]oRIS [59]SimAgent (alsosim agent) [67]DigiHiveMesa [52]DALI[18]

Insight Maker [33]AgentBuilder [5]TerraME[72]MacStarLogoMAGSY [47]MAML (Multi-Agent Modeling Language) [48]AgentService [7]OBEUS (Object Based Environment for Urban Simulation) [56]OpenOME [58]Behaviour Composer (Rich Internet Application building on NetLogo) [10]NetLogoSpatial Modeling Environment(SME) [70]JAMEL (Java Agent-based MacroEconomic Laboratory) [35]PS-I (Political Science-Identity)[60]

Altreva Adaptive Modeler [3]oRIS [59]SimAgent (alsosim agent) [67]DigiHiveMesa [52]DALI[18]BreveSeSAm (Shell for Simulated Agent Systems) (fully integrated graphical simulation environment) [63]Cormas(Common-pool Resources and Multi-Agent Systems) [14]

SDML (Strictly Declarative Modeling Language) [61]SoarStarLogoOpenStarLogoStarLogo TNGStarLogoT

SEAS (System Effectiveness Analysis Simulation) [62]GPU Agents [29]GROWlab [30]AgentSheetsVisualBots [73]ZEUS [76]

MIMOSE (Micro-und Multilevel Modelling Software) [53]GAMA [28]

ABLE (Agent Building and Learning Environment) [2]Jason (Jason:Interpreter for extension of AgentSpeak) [40]MAS-SOC (Multi-Agent Simulations for the SOCial Sciences) [51]Brahms [11]ECHO [22]FLAME [25]FLAME GPU [26]Construct [13]MOOSE(Multimodeling Object-Oriented Simulation Environment) [55]Jade’s sim++SimBioSys [68]SimPack [69]DeX [20]

LSD (Laboratory for Simulation Development)[45]iGen [31]FLUXY [27]MASS (Multi-Agent Simulation Suit) [50]FramsticksSimPlusPlus [66]Descartes[19]

A3 / AAA (Agent Anytime Anywhere) [1]ADK (TryllianAgent Development Kit)[4]AOR Simulation[6]Ascape [8]BDI4Jade [9]Cougaar[15]CybelePro[17]FAMOJA(Framework for Agent-based MOdelling with JAva) [24]ICARO-T [32]JABM [34]JADEJAS-mine [38]

JASA (Java Auction Simulator API) [39]jES (Java Enterprise Simulator) [42]jEcho [43]MASON [49]Moduleco [54]

MASS (Multi-Agent Simulation Suit) [50]FramsticksSimPlusPlus [66]Descartes[19]

A3 / AAA (Agent Anytime Anywhere) [1]ADK (TryllianAgent Development Kit)[4]AOR Simulation[6]Ascape [8]BDI4Jade [9]Cougaar[15]CybelePro[17]FAMOJA(Framework for Agent-based MOdelling with JAva) [24]ICARO-T [32]JABM [34]JADEJAS-mine [38]

JASA (Java Auction Simulator API) [39]jES (Java Enterprise Simulator) [42]jEcho [43]MASON [49]Moduleco [54]netLogoJIAC [64]Sugarscape [71]VSEit [74]Xholon [75]D-OMAR(Distributed Operator Model Architecture) [21]RepastJanus [37]EVE [23]JCA-Sim [41]Boris[12]MaDKit (Multi Agent Development Kit)[46]SwarmAnyLogicJESS [44]Insight Maker [33]AgentBuilder [5]TerraME[72]MacStarLogoMAGSY [47]MAML (Multi-Agent Modeling Language) [48]AgentService [7]OBEUS (Object Based Environment for Urban Simulation) [56]OpenOME [58]Behaviour Composer (Rich Internet Application building on NetLogo) [10]NetLogoSpatial Modeling Environment(SME) [70]JAMEL (Java Agent-based MacroEconomic Laboratory) [35]PS-I (Political Science-Identity)[60]

Altreva Adaptive Modeler [3]oRIS [59]SimAgent (alsosim agent) [67]DigiHiveMesa [52]DALI[18]

Insight Maker [33]AgentBuilder [5]TerraME[72]MacStarLogoMAGSY [47]MAML (Multi-Agent Modeling Language) [48]AgentService [7]OBEUS (Object Based Environment for Urban Simulation) [56]OpenOME [58]Behaviour Composer (Rich Internet Application building on NetLogo) [10]NetLogoSpatial Modeling Environment(SME) [70]JAMEL (Java Agent-based MacroEconomic Laboratory) [35]PS-I (Political Science-Identity)[60]

Altreva Adaptive Modeler [3]oRIS [59]SimAgent (alsosim agent) [67]DigiHiveMesa [52]DALI[18]BreveSeSAm (Shell for Simulated Agent Systems) (fully integrated graphical simulation environment) [63]Cormas(Common-pool Resources and Multi-Agent Systems) [14]

SDML (Strictly Declarative Modeling Language) [61]SoarStarLogoOpenStarLogoStarLogo TNGStarLogoT

SEAS (System Effectiveness Analysis Simulation) [62]GPU Agents [29]GROWlab [30]AgentSheetsVisualBots [73]ZEUS [76]

http://bit.ly/wiki-abms

Free w/ strings attached 27

GPL 16

LGPL 14

Custom licenses 10

Generic ‘Open Source’ 7

Academic free license 4

Apache 2.0 4

‘Unknown’ 4

BSD 3

ABM licenses

26

Most models are from... netLogo (Logo) - bit.ly/abm-netlogo (~60%)

MASON (Java) - bit.ly/abm-mason

RePast (Java) -bit.ly/abm-repast

27

Name 2.7 3+ Active Dates

PyPI Description

Simx Y N 11/12-12/14

Y Framework for discrete simulations, optimized for parallel computing; no built in visualization

PyCX Y Y 06/11-03/16

N Repository of ABM examples & GUI script for desktop visualization; Focused on ease of writing; Mostly pure python; not a framework

PyABM Y N 09/12-03/14

Y Partial ABM framework, not working

Indra N Y 12/14-Today

N ABM framework to write models similar to Netlogo; lacks documentation; visualization ability in the future?

Mesa N Y 09/14-Today

Y ABM framework to build models with repeatable components; uses browser for visualization

Modeling in browser

Parable of the Polygons (Javascript & HTML) - ncase.me/polygons

Agent Base (Javascript) - bit.ly/abm-ants

Agent Script (CoffeeScript) - agentscript.org

Mesa (Python) - bit.ly/abm-mesa

28

29

Mesa, ABMs in Python

30

Demos of Models

Docs: bit.ly/abm-mesa

Code: github.com/projectmesa/mesa

Complex model

32

Simple model

Mesa’s Scheduling FeatureNotebook example & source: Prisoner’s dilemma

● Sequential activation, where agents are

activated in the order they were added to the

model

● Random activation, where they are activated in

random order every step

● Simultaneous activation, simulating them all

being activated simultaneously.

33

Mesa’s Scheduling FeatureNotebook example & source: Prisoner’s dilemma

34

Sequential

Random

Simultaneous

Mesa35

Models built using Mesa

Mesa37

Models built using Mesa

Mesa38

Networks

Geo-Mesa

Mesa39

Networks

Mesa40

Econ-Mesa

Mesa41

Bio-Mesa

Mesa42

Other school of thought

43

Mesa Growth / UsageStarted in 2014 with 2 people. Now 26!21 were from Sprints!Most were not ABM experts.Students have used it. Gov has shown interest.

ToDo list: Networks (in progress), GIS, Parallelization of models, Front-end, Increase usability, fix all things

44

Getting Started & ContributingDocs & tutorial: bit.ly/abm-mesaLook at Examples in repo

Help with ticket #223Translate a model from NetLogo

45

Things to readCioffi-Revilla, C. (2013). Introduction to computational social science.

Epstein, J. M., & Axtell, R. (1996). Growing artificial societies: social

science from the bottom up.

Gilbert, N., & Troitzsch, K. (2005). Simulation for the social scientist.

McGraw-Hill Education (UK).

Kupers, R., & Colander, D. (2014). Complexity & the Art of Public Policy.

Miller, J. H., & Page, S. E. (2009). Complex adaptive systems.

Simon, H. A. (1996). The sciences of the artificial.

46

The End.Questions?

@jackiekazilgithub.com/projectmesa/mesa

Recommended