agent-based modeling & python @ pydata dc 2016

46
Agent-Based Modeling & Python By Jackie Kazil DC, Oct. 8, 2016 1

Upload: jackie-kazil

Post on 08-Jan-2017

280 views

Category:

Data & Analytics


3 download

TRANSCRIPT

Page 1: Agent-Based Modeling & Python @ PyData DC 2016

Agent-Based Modeling & Python

By Jackie Kazil DC, Oct. 8, 2016

1

Page 2: Agent-Based Modeling & Python @ PyData DC 2016

2

PSF

PyLadies

WDSDC

Data Community DC

PIFF

Byte Back

Page 3: Agent-Based Modeling & Python @ PyData DC 2016

3

PyData 2016 DC host and sponsor

Page 4: Agent-Based Modeling & Python @ PyData DC 2016

4

Class of 2019?

Page 5: Agent-Based Modeling & Python @ PyData DC 2016

5

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

Page 6: Agent-Based Modeling & Python @ PyData DC 2016

6

Page 7: Agent-Based Modeling & Python @ PyData DC 2016

7

Page 8: Agent-Based Modeling & Python @ PyData DC 2016

8

AGENT-BASED MODELS!An Overview of Applications

Page 9: Agent-Based Modeling & Python @ PyData DC 2016

9

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

Page 10: Agent-Based Modeling & Python @ PyData DC 2016

10

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

Page 11: Agent-Based Modeling & Python @ PyData DC 2016

11

Components of a modelSpace

Agents

Time

Visualization (not required)

Page 12: Agent-Based Modeling & Python @ PyData DC 2016

Conway’s Game of Life

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

12

Page 13: Agent-Based Modeling & Python @ PyData DC 2016

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

Page 14: Agent-Based Modeling & Python @ PyData DC 2016

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.

Page 15: Agent-Based Modeling & Python @ PyData DC 2016

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.

Page 16: Agent-Based Modeling & Python @ PyData DC 2016

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

Page 17: Agent-Based Modeling & Python @ PyData DC 2016

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

Page 18: Agent-Based Modeling & Python @ PyData DC 2016

Political Dynamics

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

18

Page 19: Agent-Based Modeling & Python @ PyData DC 2016

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

Page 20: Agent-Based Modeling & Python @ PyData DC 2016

Epidemiological Simulation

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

20

Page 22: Agent-Based Modeling & Python @ PyData DC 2016

22

Open Source ABM Library Ecosystem

Page 23: Agent-Based Modeling & Python @ PyData DC 2016

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]

Page 24: Agent-Based Modeling & Python @ PyData DC 2016

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

Page 25: Agent-Based Modeling & Python @ PyData DC 2016

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

Page 26: Agent-Based Modeling & Python @ PyData DC 2016

26

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

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

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

Page 27: Agent-Based Modeling & Python @ PyData DC 2016

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

Page 28: Agent-Based Modeling & Python @ PyData DC 2016

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

Page 29: Agent-Based Modeling & Python @ PyData DC 2016

29

Mesa, ABMs in Python

Page 30: Agent-Based Modeling & Python @ PyData DC 2016

30

Demos of Models

Docs: bit.ly/abm-mesa

Code: github.com/projectmesa/mesa

Page 32: Agent-Based Modeling & Python @ PyData DC 2016

Complex model

32

Simple model

Page 33: Agent-Based Modeling & Python @ PyData DC 2016

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

Page 34: Agent-Based Modeling & Python @ PyData DC 2016

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

34

Sequential

Random

Simultaneous

Page 35: Agent-Based Modeling & Python @ PyData DC 2016

Mesa35

Models built using Mesa

Page 36: Agent-Based Modeling & Python @ PyData DC 2016
Page 37: Agent-Based Modeling & Python @ PyData DC 2016

Mesa37

Models built using Mesa

Page 38: Agent-Based Modeling & Python @ PyData DC 2016

Mesa38

Networks

Page 39: Agent-Based Modeling & Python @ PyData DC 2016

Geo-Mesa

Mesa39

Networks

Page 40: Agent-Based Modeling & Python @ PyData DC 2016

Mesa40

Econ-Mesa

Page 41: Agent-Based Modeling & Python @ PyData DC 2016

Mesa41

Bio-Mesa

Page 42: Agent-Based Modeling & Python @ PyData DC 2016

Mesa42

Other school of thought

Page 43: Agent-Based Modeling & Python @ PyData DC 2016

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

Page 44: Agent-Based Modeling & Python @ PyData DC 2016

44

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

Help with ticket #223Translate a model from NetLogo

Page 45: Agent-Based Modeling & Python @ PyData DC 2016

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.

Page 46: Agent-Based Modeling & Python @ PyData DC 2016

46

The End.Questions?

@jackiekazilgithub.com/projectmesa/mesa