Presentation is loading. Please wait.

Presentation is loading. Please wait.

Prof. Dr. Lars-Erik Cederman ETH - Center for Comparative and International Studies (CIS) Seilergraben 49, Room G.2,

Similar presentations


Presentation on theme: "Prof. Dr. Lars-Erik Cederman ETH - Center for Comparative and International Studies (CIS) Seilergraben 49, Room G.2,"— Presentation transcript:

1 Prof. Dr. Lars-Erik Cederman ETH - Center for Comparative and International Studies (CIS) Seilergraben 49, Room G.2, lcederman@ethz.chlcederman@ethz.ch Nils Weidmann, CIS Room E.3 weidmann@icr.gess.ethz.chweidmann@icr.gess.ethz.ch http://www.icr.ethz.ch/teaching/compmodels Lecture, December 7, 2004 Introduction to Computational Modeling of Social Systems RePast Tutorial I

2 2 Today’s agenda The RePast toolkits and its features The Iterated Prisoner‘s Dilemma How to build a model (1) SimpleIPD

3 3 What is RePast? Recursive Porous Agent Simulation Toolkit http://repast.sourceforge.net http://repast.sourceforge.net Repast is an open-source software framework for creating agent-based simulations using Java Initially developed by the Social Science Research Computing at the University of Chicago Will be further developed by the RePast Organization for Architecture and Development (ROAD) and Argonne National Laboratory

4 4 Why RePast? Alternatives: Swarm, Ascape, NetLogo... “RePast is at the moment the most suitable simulation framework for the applied modeling of social interventions based on theories and data” (2004): http://jasss.soc.surrey.ac.uk/7/1/6.html http://jasss.soc.surrey.ac.uk/7/1/6.html Modeled on Swarm but easier to use and better documented Important criteria: –abstraction, ease of use and user-friendliness –flexibility and extensibility –performance and scalability –support for modeling, simulation & experimentation –Interoperability (GIS, statistical packages, …)

5 5 What does RePast offer? Skeletons of agents and their environment Graphical user interface Scheduling of simulations Parameters management Behavior display Charting Data collection Batch and parallel runs Utilities and sample models

6 6 Tutorial Sequence December 7 SimpleIPD: strategy space December 14 EvolIPD: RWR December 21 GraphIPD: charts and GUI GridIPD: 2DK January 11 ExperIPD : batch runs and parameter sweeps

7 7 Iterated Prisoner’s Dilemma Cohen, Riolo, and Axelrod. 1999. “The Emergence of Social Organization in the Prisoner's Dilemma” (SFI Working Paper 99-01- 002) http://www.santafe.edu/research/publications/wpabstract/199901002 In The Evolution of Cooperation, Robert Axelrod (1984) created a computer tournament of IPD –cooperation sometimes emerges –Tit For Tat a particularly effective strategy

8 8 Prisoner’s Dilemma Game Column: C D C 3,3 0,5 Row: D 5,0 1,1

9 9 One-Step Memory Strategies C D C D p q Memory: C D Strategy = (i, p, q) i = prob. of cooperating at t = 0 p =prob. of cooperating if opponent cooperated q =prob. of cooperating if opponent defected t-1 t

10 10 The Four Strategies

11 11 TFT meets ALLD t01234 Row (TFT) Column (ALLD) i=1 i=0 p=1; q=0 0 5 11 11 1 1 = 8 = 3+++ +++ D C D C D D D D D D p=0; q=0 Cumulated Payoff

12 12 Payoffs for 4x4 strategies Own strategy Other‘s strategy ALLCTFTATFTALLD pay/move sum pay/move sum pay/move sum pay/move sum ALLC 3333 12 3333 12 0000 0 0000 0 TFT 3333 12 3333 12 0153 9 0111 3 ATFT 5555 20 5103 9 1313 8 1000 1 ALLD 5555 20 5111 8 1555 16 1111 4

13 13 How to build a model (1) Extending the SimpleModel class with our own model class: import uchicago.src.sim.engine.SimpleModel; public class MyModel extends SimpleModel {... }

14 14 Setting up the simulation import uchicago.src.sim.engine.SimpleModel; public class MyModel extends SimpleModel { public static final int TFT = 1; public static final int ALLD = 3; private int a1Strategy = TFT; private int a2Strategy = ALLD;... public void setup() { super.setup(); a1Strategy = TFT; a2Strategy = ALLD; } public void buildModel() { super.buildModel(); Agent a1 = new Agent(a1Strategy); Agent a2 = new Agent(a2Strategy); agentList.add(a1); agentList.add(a2); } Called when the simulation is first started and when setup button pressed Executed every time the simulation is run SimInit.loadModel()

15 15 Running the simulation import uchicago.src.sim.engine.SimpleModel; public class MyModel extends SimpleModel {... public void setup() {...} public void buildModel() {...} public void preStep() {...} public void step() { super.step(); for (Iterator it = agentList.iterator(); it.hasNext();) { Agent agent = (Agent) iterator.next(); agent.play(); } public void postStep() {...} } Executed at every time step

16 16 Model parameters import uchicago.src.sim.engine.SimpleModel; public class MyModel extends SimpleModel { public static final int TFT = 1; public static final int ALLD = 3; private int a1Strategy = TFT; private int a2Strategy = ALLD; public MyModel() { params = new String[] {“A1Strategy”}; name = “Example Model”; }... public void setA1Strategy(int strategy) { this.a1Strategy = strategy; } public int getA1Strategy() { return a1Strategy; } Introspection

17 17 SimpleModel methods setStoppingTime(long time) set the time at which the current simulation run will stop setRngSeed(long seed) set the seed for the random number generator (default: 1) getNextIntFromTo(int from, int to) returns the next random double between from and to (exclusive) getNextDoubleFromTo(double from,double to) returns the next random double between from and to (exclusive) atPause() will be executed whenever your simulation is paused atEnd() will be executed whenever your simulation ends

18 18 SimpleModel fields boolean isGui true if the simulation is running in GUI mode, false if running in batch mode long startAt the time step at which to start executing the preStep(), step(), postStep() actions (default: 1) Schedule schedule can be used to add your own actions to the schedule... For the full list, consult the RePast API: http://repast.sourceforge.net/docs/api/ http://repast.sourceforge.net/docs/api/


Download ppt "Prof. Dr. Lars-Erik Cederman ETH - Center for Comparative and International Studies (CIS) Seilergraben 49, Room G.2,"

Similar presentations


Ads by Google