Download presentation
Presentation is loading. Please wait.
Published byEugene Carson Modified over 8 years ago
1
1 Integrating Repast Library and Running RePast Examples using JBuilder X 07/19/2004 by Deddy Koesrindartoto Department of Economics Iowa State University
2
2 Configuring RePast Library in Jbuilder X To be able to be called in the program, we have to create references to RePast library. After launching Jbuilder, choose Tools | Configure Libraries (1) as shown in Fig. 1A. Configure Libraries dialog box, as in Fig. 1.B will appear. Select New button (2) New Library Wizard as in Fig. 1.C will appear. Fill in Name and Location fields as shown (3). Then select Add to add this library to the JBuilderX (4). (2) Fig 1.A Fig 1.BFig 1.C (4) (1) (3)
3
3 (1) select repast.jar file (2) (3) Navigate through your file browser, and go to RePast-2.2/lib directory, and select the repast.jar file (1) and click the OK button (2). The New Library Wizard will look like Fig.2.B, then select the OK button (3). When Repast library is successfully added in Jbuilder, Configure Library dialog box will look like Fig. 2.C. Click OK to complete (4). Fig. 2.A Fig. 2.B RePast library is successfully added (4) Fig. 2.C
4
4 Download RePast source code examples Navigate to the following link: http://www.courses.fas.harvard.edu/~gov2015/Tutorial/ Choose and download the source code of any example you want in a working directory. Proceed with unzipping the files.
5
5 Running RePast examples using Jbuilder X IDE (1) (2) (3) After launching Jbuilder, select File | Open Project (1) as shown in Fig.3.A. It will bring up to the Open Project or Project Group dialog box as shown in Fig. 3.B. Navigate through your file browser and select the working directory of the example that you downloaded and unzipped earlier and select the file with.jpx or.jpr extension (2). (In this tutorial I select GraphIPD.jar) Proceed by selecting OK button (3). Fig. 3.A Fig. 3.B
6
6 Errors, why ? Fig 4.
7
7 Incorporating Repast-2.2 Library to a project (1) Fig 5. Errors are caused by an undefined library. To fix this, click Project | Project Properties from the main menu (1)
8
8 Select the Required Libraries folder (1). The dialog box in Fig 6.A will show up. Select the Repast-2.0 library (with red letters) (2) and select Remove (3). Fig 6.A. Fig 6.B. (1) (2) (3) (4) The next step is to incorporate the RePast-2.2 library into this project. Click Add (4) button in Fig 6.A. The dialog box as shown in Fig 6.B will appear. Select RePast-2.2 library (we defined earlier) (5), and click the OK button (6). Once this process done, the error messages shown in Fig 4. will disappear when the program is compiled and run. (5) (6)
9
9 Fig 7
10
10 To compile and run this program, select ModelGUI.java (1) from the project pane click the right Mouse button, and select Run using GraphIPD (2). It will show the RePast standard GUI. An explanation of how to use the RePast GUI can be found in an earlier tutorial. (6/21/2004). It can be downloaded at : http://www.econ.iastate.edu/tesfatsi/RePastTutorial.I.DK.ppt http://www.econ.iastate.edu/tesfatsi/RePastTutorial.I.DK.ppt
11
11 A complete tutorial on JBuilder X can be freely downloaded as a zip file at: (this file is included in the commercial version but not in the Foundation version). ftp://ftpc.borland.com/pub/jbuilder/techpubs/jbuilderx/jbxpdfdocs_f.zip A “compact” explanation of how to use Jbuilder ver. 9.0 can be seen at Prof. Andrew Rau-Chaplin of Dalhousie University, Canada. http://www.cs.dal.ca/~arc/teaching/CS2110/Tutorials/introToJBuilderTutorial.htm I found “Learn Jbuilder” by Charlie Calvert and Margie Calvert, WordWare publishing, 2002, to be very easy to follow even for a beginner. Get it cheap at http://addall.comhttp://addall.com Additional info on Jbuilder IDE
12
12 Gov 2015 Introduction to Computational Modeling for Social Scientists http://www.courses.fas.harvard.edu/~gov2015/ March 5, 2003 Lars-Erik Cederman Most of these slides are taken from
13
13 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/sfi/publications/99wplist.html In The Evolution of Cooperation, Robert Axelrod (1984) created a computer tournament of IPD –cooperation sometimes emerges –Tit For Tat a particularly effective strategy
14
14 Prisoner’s Dilemma Game Column: C D C 3,30,5 Row: D 5,01,1
15
15 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
16
16 The Four Strategies
17
17 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
18
18 Payoffs for 4 x 4 Strategies
19
19 “Soup-like” topology ALLC TFT ALLD ATFT TFT ALLD In each time period, a player interacts with four other randomly selected players.
20
20 Adaptation through imitation ALLC TFT ALLD ATFT TFT? ALLD Neighbors at t Imitation
21
21 Setup() buildModel() step() Initialization Setting parameters Object/ Entities Creation Creating players with different strategy Activities Sequencing resetPlayers();// Reset the agents’statistics interactions();// Let them interact with each other adaptation(); // Let them adapt reportResults();// Calculate and report some statistics
22
22 Public Access: My methods reset(); Protocols : play(int Time); remember(); Evaluations : getAveragePayoff(); addPayOff(); Adaptations : adapt(); updateType(); Private Access My attributes (data) PlayerID; Type; CumulPayoff; memory ; actions ; prefs; Type; newType; numPlays; otherList; etc. A Virtual Player
23
23 HW : Add New Strategy
24
24 Next Week : Get your hands dirty !!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.