SlideShare a Scribd company logo
1 of 67
一步一步学  RePast 建模 Introduction, (Sim)Model Object, CarryDrop
The CarryDrop Model  A RePast Tutorial by John Murphy by Junjie Sun Department of Economics Iowa State University
RePast 模型的元素 ,[object Object],[object Object],[object Object]
The (Sim)Model Object ,[object Object],[object Object],[object Object],[object Object]
The SimModel Object—getName() ,[object Object],[object Object],import uchicago.src.sim.engine.SimModelImpl; public class MyFirstRePastModel extends SimModelImpl { public String getName(){ return “ 第一个  RePast 模型” ; } }
The SimModel Object—begin() ,[object Object],import uchicago.src.sim.engine.SimModelImpl; public class MyFirstRePastModel extends SimModelImpl { public String getName(){ return “ 第一个  RePast  模型” ; } public void begin(){ } }
The SimModel Object— 惯例 ,[object Object],[object Object],public void begin(){ buildModel();// 模型初始化 buildSchedule();// 规划表初始化 buildDisplay();// 显示初始化 } public void buildModel(){ } public void buildSchedule(){ } public void buildDisplay(){ }
The SimModel Object—current code  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The SimModel Object—setup() ,[object Object],public class MyFirstRePastModel extends SimModelImpl { public String getName(){ return “My First RePast Model”; } public void setup(){ } public void begin(){ […]
The SimModel Object—Schedule ,[object Object],[object Object],[object Object],[object Object],[object Object]
The SimObject Model--Schedule import uchicago.src.sim.engine.SimModelImpl; import uchicago.src.sim.engine.Schedule; public class MyFirstRePastModel extends SimModelImpl { private Schedule schedule; public String getName(){ return “My First RePast Model”; } public void begin(){ buildModel(); buildSchedule(); buildDisplay(); } public void buildModel(){ } public void buildSchedule(){ } public void buildDisplay(){ } public Schedule getSchedule(){ return schedule; } }
The SimModel Object--getInitParam ,[object Object],[object Object],[object Object],[object Object],[object Object]
The SimModel Object--numAgents ,[object Object],import uchicago.src.sim.engine.SimModelImpl; import uchicago.src.sim.engine.Schedule; public class MyFirstRePastModel extends SimModelImpl { private Schedule schedule; private int numAgents; public String getName(){ return “My First Repast Model”; } […]
The SimModel Object--numAgents ,[object Object],public Schedule getSchedule(){ return schedule; } public int getNumAgents(){ return numAgents; } public void setNumAgents (int na){ numAgents=na; } }
The SimModel Object--numAgents ,[object Object],public Schedule getSchedule(){ return schedule; } public String[] getInitParam(){ String[] initParams = {“NumAgents”}; return initParams; } public int getNumAgents(){ return numAgents; }
The CarryDrop Model--Introduction ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The CarryDrop model ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
前面已经完成的代码 ,[object Object],[object Object],[object Object],[object Object],[object Object]
增加用户可以设置的参数 ,[object Object],[object Object],[object Object]
把参数设置为类变量 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
编译运行模型 ,[object Object],[object Object],[object Object],[object Object]
Codes to be Added in main Method ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Default Values for User-Settable Parameters (Step 6) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Alerts in Subroutines (Step 7) ,[object Object],[object Object],[object Object],[object Object]
The Space Object (Step 8-1) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Q: How can you know the args in  the methods / constructors?  A: See RePast/Java API (Step 8-2) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Need another parameter, the amount of money (Step 8-3) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
I ntegrate the Space Object into the Model (Step 9-1) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Overview :  What’s been done in Step 1-9 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
前面已经完成以下工作 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Step 10  –   初始化空间类 ,[object Object],[object Object]
Step 11 - Extracting reusuable code ,[object Object],[object Object],[object Object]
可视化界面设计 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Step 12  –  Using the DisplaySurface ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Step 13  –  A splash of color ,[object Object],[object Object],[object Object],[object Object]
Step 13 cont.  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Step 14  –  Generating the Display ,[object Object],[object Object],[object Object],[object Object]
Step 15  –  The Agents ,[object Object],[object Object],[object Object],[object Object],[object Object]
Step 15 cont.  –  Modifying CarryDropModel for Agents ,[object Object],[object Object],[object Object],[object Object],[object Object]
Step 16  –  Adding Agents to the model ,[object Object],[object Object]
Step 16 cont. ,[object Object],[object Object]
Step 17  –  A Space for Agents ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Step 17 cont. ,[object Object],[object Object]
Step 18  –  Adding Agents to the space ,[object Object],[object Object]
What’s been done in Step 1-18 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Reporting (Step 19-1) ,[object Object],[object Object],[object Object]
'Report' function (Step 19-2) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Unique 'ID' variable (Step 19-3) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Displaying Agents (Step 20-1) ,[object Object],[object Object],[object Object],[object Object],[object Object]
Codes for Displaying Agents (Step 20-2)    -- Create an Object2DDisplay object,  add it to the display surface, etc. ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Codes for Displaying Agents (Step 20-3)    -- Make the agents able to be drawn  by implementing 'Drawable' ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Adding a Schedule and Some Action (Step 21-1) - Motivation ,[object Object],[object Object],[object Object]
Adding a Schedule and Some Action (Step 21-2) – Three things to do ,[object Object],[object Object],[object Object]
Codes for creating a 'step' method  and a Schedule object (Step 21-3)   ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Codes for creating an inner class 'CarryDropStep' (Step 21-4) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Notes on 'shuffle' and 'scheduleAction Beginning' routine (Step 21-5) ,[object Object],[object Object]
Another Schedule Example (Step 22-1) ,[object Object],[object Object],[object Object],[object Object],[object Object]
Codes for creating 'countLivingAgents' in CarryDropModel (Step 22-2) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Codes for 'CarryDropCountLiving' and how to add it to the Schedule object (Step 22-3) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Displays and Schedules (Step 23-1) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Displays and Schedules (Step 23-2) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The Circle of Life: Agents Dying and Being Born (Step 24-1) - Motivation ,[object Object],[object Object]
The Circle of Life: Agents Dying and Being Born (Step 24-2) – Things to do ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Codes for adding 'reapDeadAgents()' to the model (Step 24-3) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Codes for adding 'removeAgentAt()' to the space object and agent reborning (Step 24-4) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What’s been done in Step 1-24 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

More Related Content

What's hot

Dynamic C++ ACCU 2013
Dynamic C++ ACCU 2013Dynamic C++ ACCU 2013
Dynamic C++ ACCU 2013aleks-f
 
深入浅出Jscex
深入浅出Jscex深入浅出Jscex
深入浅出Jscexjeffz
 
Jscex: Write Sexy JavaScript (中文)
Jscex: Write Sexy JavaScript (中文)Jscex: Write Sexy JavaScript (中文)
Jscex: Write Sexy JavaScript (中文)jeffz
 
Android UI Development: Tips, Tricks, and Techniques
Android UI Development: Tips, Tricks, and TechniquesAndroid UI Development: Tips, Tricks, and Techniques
Android UI Development: Tips, Tricks, and TechniquesEdgar Gonzalez
 
The Evolution of Async-Programming (SD 2.0, JavaScript)
The Evolution of Async-Programming (SD 2.0, JavaScript)The Evolution of Async-Programming (SD 2.0, JavaScript)
The Evolution of Async-Programming (SD 2.0, JavaScript)jeffz
 
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015NAVER / MusicPlatform
 
(3) cpp abstractions more_on_user_defined_types
(3) cpp abstractions more_on_user_defined_types(3) cpp abstractions more_on_user_defined_types
(3) cpp abstractions more_on_user_defined_typesNico Ludwig
 
J S B6 Ref Booklet
J S B6 Ref BookletJ S B6 Ref Booklet
J S B6 Ref Booklet51 lecture
 
Node Anti-Patterns and Bad Practices
Node Anti-Patterns and Bad PracticesNode Anti-Patterns and Bad Practices
Node Anti-Patterns and Bad PracticesPedro Teixeira
 
The Ring programming language version 1.7 book - Part 83 of 196
The Ring programming language version 1.7 book - Part 83 of 196The Ring programming language version 1.7 book - Part 83 of 196
The Ring programming language version 1.7 book - Part 83 of 196Mahmoud Samir Fayed
 
Using Reflections and Automatic Code Generation
Using Reflections and Automatic Code GenerationUsing Reflections and Automatic Code Generation
Using Reflections and Automatic Code GenerationIvan Dolgushin
 
The Ring programming language version 1.8 book - Part 90 of 202
The Ring programming language version 1.8 book - Part 90 of 202The Ring programming language version 1.8 book - Part 90 of 202
The Ring programming language version 1.8 book - Part 90 of 202Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 12 of 180
The Ring programming language version 1.5.1 book - Part 12 of 180The Ring programming language version 1.5.1 book - Part 12 of 180
The Ring programming language version 1.5.1 book - Part 12 of 180Mahmoud Samir Fayed
 
Computer Vision using Ruby and libJIT - RubyConf 2009
Computer Vision using Ruby and libJIT - RubyConf 2009Computer Vision using Ruby and libJIT - RubyConf 2009
Computer Vision using Ruby and libJIT - RubyConf 2009Jan Wedekind
 

What's hot (20)

Dynamic C++ ACCU 2013
Dynamic C++ ACCU 2013Dynamic C++ ACCU 2013
Dynamic C++ ACCU 2013
 
Advanced JavaScript
Advanced JavaScript Advanced JavaScript
Advanced JavaScript
 
深入浅出Jscex
深入浅出Jscex深入浅出Jscex
深入浅出Jscex
 
Jscex: Write Sexy JavaScript (中文)
Jscex: Write Sexy JavaScript (中文)Jscex: Write Sexy JavaScript (中文)
Jscex: Write Sexy JavaScript (中文)
 
Android UI Development: Tips, Tricks, and Techniques
Android UI Development: Tips, Tricks, and TechniquesAndroid UI Development: Tips, Tricks, and Techniques
Android UI Development: Tips, Tricks, and Techniques
 
The Evolution of Async-Programming (SD 2.0, JavaScript)
The Evolution of Async-Programming (SD 2.0, JavaScript)The Evolution of Async-Programming (SD 2.0, JavaScript)
The Evolution of Async-Programming (SD 2.0, JavaScript)
 
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
 
Lecture1 classes3
Lecture1 classes3Lecture1 classes3
Lecture1 classes3
 
(3) cpp abstractions more_on_user_defined_types
(3) cpp abstractions more_on_user_defined_types(3) cpp abstractions more_on_user_defined_types
(3) cpp abstractions more_on_user_defined_types
 
YUI Tidbits
YUI TidbitsYUI Tidbits
YUI Tidbits
 
J S B6 Ref Booklet
J S B6 Ref BookletJ S B6 Ref Booklet
J S B6 Ref Booklet
 
Node Anti-Patterns and Bad Practices
Node Anti-Patterns and Bad PracticesNode Anti-Patterns and Bad Practices
Node Anti-Patterns and Bad Practices
 
The Ring programming language version 1.7 book - Part 83 of 196
The Ring programming language version 1.7 book - Part 83 of 196The Ring programming language version 1.7 book - Part 83 of 196
The Ring programming language version 1.7 book - Part 83 of 196
 
OpenXR 0.90 Overview Guide
OpenXR 0.90 Overview GuideOpenXR 0.90 Overview Guide
OpenXR 0.90 Overview Guide
 
Clojure And Swing
Clojure And SwingClojure And Swing
Clojure And Swing
 
Using Reflections and Automatic Code Generation
Using Reflections and Automatic Code GenerationUsing Reflections and Automatic Code Generation
Using Reflections and Automatic Code Generation
 
Obvious Secrets of JavaScript
Obvious Secrets of JavaScriptObvious Secrets of JavaScript
Obvious Secrets of JavaScript
 
The Ring programming language version 1.8 book - Part 90 of 202
The Ring programming language version 1.8 book - Part 90 of 202The Ring programming language version 1.8 book - Part 90 of 202
The Ring programming language version 1.8 book - Part 90 of 202
 
The Ring programming language version 1.5.1 book - Part 12 of 180
The Ring programming language version 1.5.1 book - Part 12 of 180The Ring programming language version 1.5.1 book - Part 12 of 180
The Ring programming language version 1.5.1 book - Part 12 of 180
 
Computer Vision using Ruby and libJIT - RubyConf 2009
Computer Vision using Ruby and libJIT - RubyConf 2009Computer Vision using Ruby and libJIT - RubyConf 2009
Computer Vision using Ruby and libJIT - RubyConf 2009
 

Viewers also liked

Interactive vertical benchmarks
Interactive vertical benchmarksInteractive vertical benchmarks
Interactive vertical benchmarksMediaMind
 
8.2第八章 win dynamo
8.2第八章 win dynamo8.2第八章 win dynamo
8.2第八章 win dynamozhang shuren
 
[Harvard CS264] 11a - Programming the Memory Hierarchy with Sequoia (Mike Bau...
[Harvard CS264] 11a - Programming the Memory Hierarchy with Sequoia (Mike Bau...[Harvard CS264] 11a - Programming the Memory Hierarchy with Sequoia (Mike Bau...
[Harvard CS264] 11a - Programming the Memory Hierarchy with Sequoia (Mike Bau...npinto
 
[Harvard CS264] 15a - The Onset of Parallelism, Changes in Computer Architect...
[Harvard CS264] 15a - The Onset of Parallelism, Changes in Computer Architect...[Harvard CS264] 15a - The Onset of Parallelism, Changes in Computer Architect...
[Harvard CS264] 15a - The Onset of Parallelism, Changes in Computer Architect...npinto
 
Tom Gonzalez - Adv Data Visualization
Tom Gonzalez - Adv Data VisualizationTom Gonzalez - Adv Data Visualization
Tom Gonzalez - Adv Data Visualization360|Conferences
 
High-Performance Computing Needs Machine Learning... And Vice Versa (NIPS 201...
High-Performance Computing Needs Machine Learning... And Vice Versa (NIPS 201...High-Performance Computing Needs Machine Learning... And Vice Versa (NIPS 201...
High-Performance Computing Needs Machine Learning... And Vice Versa (NIPS 201...npinto
 

Viewers also liked (7)

Interactive vertical benchmarks
Interactive vertical benchmarksInteractive vertical benchmarks
Interactive vertical benchmarks
 
8.2第八章 win dynamo
8.2第八章 win dynamo8.2第八章 win dynamo
8.2第八章 win dynamo
 
[Harvard CS264] 11a - Programming the Memory Hierarchy with Sequoia (Mike Bau...
[Harvard CS264] 11a - Programming the Memory Hierarchy with Sequoia (Mike Bau...[Harvard CS264] 11a - Programming the Memory Hierarchy with Sequoia (Mike Bau...
[Harvard CS264] 11a - Programming the Memory Hierarchy with Sequoia (Mike Bau...
 
Unlocking Android
Unlocking AndroidUnlocking Android
Unlocking Android
 
[Harvard CS264] 15a - The Onset of Parallelism, Changes in Computer Architect...
[Harvard CS264] 15a - The Onset of Parallelism, Changes in Computer Architect...[Harvard CS264] 15a - The Onset of Parallelism, Changes in Computer Architect...
[Harvard CS264] 15a - The Onset of Parallelism, Changes in Computer Architect...
 
Tom Gonzalez - Adv Data Visualization
Tom Gonzalez - Adv Data VisualizationTom Gonzalez - Adv Data Visualization
Tom Gonzalez - Adv Data Visualization
 
High-Performance Computing Needs Machine Learning... And Vice Versa (NIPS 201...
High-Performance Computing Needs Machine Learning... And Vice Versa (NIPS 201...High-Performance Computing Needs Machine Learning... And Vice Versa (NIPS 201...
High-Performance Computing Needs Machine Learning... And Vice Versa (NIPS 201...
 

Similar to 6.1.1一步一步学repast代码解释

Copy of repast javagettingstarted
Copy of repast javagettingstartedCopy of repast javagettingstarted
Copy of repast javagettingstartedNimish Verma
 
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...DroidConTLV
 
DESIGNING A PERSISTENCE FRAMEWORK WITH PATTERNS.ppt
DESIGNING A PERSISTENCE FRAMEWORK WITH PATTERNS.pptDESIGNING A PERSISTENCE FRAMEWORK WITH PATTERNS.ppt
DESIGNING A PERSISTENCE FRAMEWORK WITH PATTERNS.pptAntoJoseph36
 
Android UI Tips, Tricks and Techniques
Android UI Tips, Tricks and TechniquesAndroid UI Tips, Tricks and Techniques
Android UI Tips, Tricks and TechniquesMarakana Inc.
 
How to Write Node.js Module
How to Write Node.js ModuleHow to Write Node.js Module
How to Write Node.js ModuleFred Chien
 
Java design patterns
Java design patternsJava design patterns
Java design patternsShawn Brito
 
Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)Korhan Bircan
 
Workshop 26: React Native - The Native Side
Workshop 26: React Native - The Native SideWorkshop 26: React Native - The Native Side
Workshop 26: React Native - The Native SideVisual Engineering
 
Converting Db Schema Into Uml Classes
Converting Db Schema Into Uml ClassesConverting Db Schema Into Uml Classes
Converting Db Schema Into Uml ClassesKaniska Mandal
 
Sustaining Test-Driven Development
Sustaining Test-Driven DevelopmentSustaining Test-Driven Development
Sustaining Test-Driven DevelopmentAgileOnTheBeach
 
Chap2 class,objects
Chap2 class,objectsChap2 class,objects
Chap2 class,objectsraksharao
 
Object Oriented JavaScript
Object Oriented JavaScriptObject Oriented JavaScript
Object Oriented JavaScriptJulie Iskander
 
From C++ to Objective-C
From C++ to Objective-CFrom C++ to Objective-C
From C++ to Objective-Ccorehard_by
 
Uncommon Design Patterns
Uncommon Design PatternsUncommon Design Patterns
Uncommon Design PatternsStefano Fago
 
React Native One Day
React Native One DayReact Native One Day
React Native One DayTroy Miles
 
Design pattern - part 3
Design pattern - part 3Design pattern - part 3
Design pattern - part 3Jieyi Wu
 

Similar to 6.1.1一步一步学repast代码解释 (20)

Copy of repast javagettingstarted
Copy of repast javagettingstartedCopy of repast javagettingstarted
Copy of repast javagettingstarted
 
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
 
DESIGNING A PERSISTENCE FRAMEWORK WITH PATTERNS.ppt
DESIGNING A PERSISTENCE FRAMEWORK WITH PATTERNS.pptDESIGNING A PERSISTENCE FRAMEWORK WITH PATTERNS.ppt
DESIGNING A PERSISTENCE FRAMEWORK WITH PATTERNS.ppt
 
Android UI Tips, Tricks and Techniques
Android UI Tips, Tricks and TechniquesAndroid UI Tips, Tricks and Techniques
Android UI Tips, Tricks and Techniques
 
How to Write Node.js Module
How to Write Node.js ModuleHow to Write Node.js Module
How to Write Node.js Module
 
Java design patterns
Java design patternsJava design patterns
Java design patterns
 
Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)
 
Vaadin 7
Vaadin 7Vaadin 7
Vaadin 7
 
Workshop 26: React Native - The Native Side
Workshop 26: React Native - The Native SideWorkshop 26: React Native - The Native Side
Workshop 26: React Native - The Native Side
 
Converting Db Schema Into Uml Classes
Converting Db Schema Into Uml ClassesConverting Db Schema Into Uml Classes
Converting Db Schema Into Uml Classes
 
Sustaining Test-Driven Development
Sustaining Test-Driven DevelopmentSustaining Test-Driven Development
Sustaining Test-Driven Development
 
Rhino Mocks
Rhino MocksRhino Mocks
Rhino Mocks
 
Chap2 class,objects
Chap2 class,objectsChap2 class,objects
Chap2 class,objects
 
Twins: OOP and FP
Twins: OOP and FPTwins: OOP and FP
Twins: OOP and FP
 
Object Oriented JavaScript
Object Oriented JavaScriptObject Oriented JavaScript
Object Oriented JavaScript
 
From C++ to Objective-C
From C++ to Objective-CFrom C++ to Objective-C
From C++ to Objective-C
 
Uncommon Design Patterns
Uncommon Design PatternsUncommon Design Patterns
Uncommon Design Patterns
 
Classes1
Classes1Classes1
Classes1
 
React Native One Day
React Native One DayReact Native One Day
React Native One Day
 
Design pattern - part 3
Design pattern - part 3Design pattern - part 3
Design pattern - part 3
 

More from zhang shuren

8.1第八章系统动力学与dynamo模型
8.1第八章系统动力学与dynamo模型8.1第八章系统动力学与dynamo模型
8.1第八章系统动力学与dynamo模型zhang shuren
 
7 第七章 学习与进化模型ann
7 第七章 学习与进化模型ann7 第七章 学习与进化模型ann
7 第七章 学习与进化模型annzhang shuren
 
6.1.2 用eclipse环境调试一步一步学repast操作
6.1.2 用eclipse环境调试一步一步学repast操作6.1.2 用eclipse环境调试一步一步学repast操作
6.1.2 用eclipse环境调试一步一步学repast操作zhang shuren
 
4.2第四章 swarm代码剖析 可选补充课程
4.2第四章 swarm代码剖析 可选补充课程4.2第四章 swarm代码剖析 可选补充课程
4.2第四章 swarm代码剖析 可选补充课程zhang shuren
 
4.1第四章 多主体系统仿真的软件工具
4.1第四章 多主体系统仿真的软件工具4.1第四章 多主体系统仿真的软件工具
4.1第四章 多主体系统仿真的软件工具zhang shuren
 
3第三章 多主体模型与社会科学复杂性研究
3第三章 多主体模型与社会科学复杂性研究3第三章 多主体模型与社会科学复杂性研究
3第三章 多主体模型与社会科学复杂性研究zhang shuren
 
2第二章 多主体模型与社会科学复杂性研究
2第二章 多主体模型与社会科学复杂性研究2第二章 多主体模型与社会科学复杂性研究
2第二章 多主体模型与社会科学复杂性研究zhang shuren
 
网络营销第4章 张树人
网络营销第4章 张树人网络营销第4章 张树人
网络营销第4章 张树人zhang shuren
 
网络营销 第3章 张树人
网络营销 第3章 张树人网络营销 第3章 张树人
网络营销 第3章 张树人zhang shuren
 
网络营销 第1章 张树人
网络营销 第1章 张树人网络营销 第1章 张树人
网络营销 第1章 张树人zhang shuren
 
第4章 数据库管理
第4章 数据库管理第4章 数据库管理
第4章 数据库管理zhang shuren
 
第2章 服务器管理
第2章 服务器管理第2章 服务器管理
第2章 服务器管理zhang shuren
 
第10章 权限管理
第10章 权限管理第10章 权限管理
第10章 权限管理zhang shuren
 

More from zhang shuren (13)

8.1第八章系统动力学与dynamo模型
8.1第八章系统动力学与dynamo模型8.1第八章系统动力学与dynamo模型
8.1第八章系统动力学与dynamo模型
 
7 第七章 学习与进化模型ann
7 第七章 学习与进化模型ann7 第七章 学习与进化模型ann
7 第七章 学习与进化模型ann
 
6.1.2 用eclipse环境调试一步一步学repast操作
6.1.2 用eclipse环境调试一步一步学repast操作6.1.2 用eclipse环境调试一步一步学repast操作
6.1.2 用eclipse环境调试一步一步学repast操作
 
4.2第四章 swarm代码剖析 可选补充课程
4.2第四章 swarm代码剖析 可选补充课程4.2第四章 swarm代码剖析 可选补充课程
4.2第四章 swarm代码剖析 可选补充课程
 
4.1第四章 多主体系统仿真的软件工具
4.1第四章 多主体系统仿真的软件工具4.1第四章 多主体系统仿真的软件工具
4.1第四章 多主体系统仿真的软件工具
 
3第三章 多主体模型与社会科学复杂性研究
3第三章 多主体模型与社会科学复杂性研究3第三章 多主体模型与社会科学复杂性研究
3第三章 多主体模型与社会科学复杂性研究
 
2第二章 多主体模型与社会科学复杂性研究
2第二章 多主体模型与社会科学复杂性研究2第二章 多主体模型与社会科学复杂性研究
2第二章 多主体模型与社会科学复杂性研究
 
网络营销第4章 张树人
网络营销第4章 张树人网络营销第4章 张树人
网络营销第4章 张树人
 
网络营销 第3章 张树人
网络营销 第3章 张树人网络营销 第3章 张树人
网络营销 第3章 张树人
 
网络营销 第1章 张树人
网络营销 第1章 张树人网络营销 第1章 张树人
网络营销 第1章 张树人
 
第4章 数据库管理
第4章 数据库管理第4章 数据库管理
第4章 数据库管理
 
第2章 服务器管理
第2章 服务器管理第2章 服务器管理
第2章 服务器管理
 
第10章 权限管理
第10章 权限管理第10章 权限管理
第10章 权限管理
 

Recently uploaded

Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 

Recently uploaded (20)

Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 

6.1.1一步一步学repast代码解释

  • 1. 一步一步学 RePast 建模 Introduction, (Sim)Model Object, CarryDrop
  • 2. The CarryDrop Model A RePast Tutorial by John Murphy by Junjie Sun Department of Economics Iowa State University
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11. The SimObject Model--Schedule import uchicago.src.sim.engine.SimModelImpl; import uchicago.src.sim.engine.Schedule; public class MyFirstRePastModel extends SimModelImpl { private Schedule schedule; public String getName(){ return “My First RePast Model”; } public void begin(){ buildModel(); buildSchedule(); buildDisplay(); } public void buildModel(){ } public void buildSchedule(){ } public void buildDisplay(){ } public Schedule getSchedule(){ return schedule; } }
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.

Editor's Notes

  1. Actions scheduled in a specified order should be added to ActionGroup set, which can be added to the Schedule.
  2. The word WorldXSize and WorldYSize as well as other parameters such as NumAgents will appear in the Parameters window along with the RePast control toolbar. The string that tells RePast what parameter can be used is ‘NumAgents’ because RePast will look (automatically) for methods named "get" + the string and "set" + the string, hence "getNumAgents" and "setNumAgents."
  3. The first line creates a new object of type 'SimInit'- note that this object has been imported as: import uchicago.src.sim.engine.SimInit;
  4. Notice when the model is run that the values in the GUI are all zeros. It is good coding practice to have default values defined as constant variables.
  5. Note that when the model runs, the 'Setup' routine runs. Press ‘Step' and the Build subroutine runs, calling successively BuildModel, BuildSchedule, and BuildDisplay. Keep this sequence in mind as we move forward. We can leave those lines of code in- they're harmless.
  6. (1). import uchicago.src.sim.space.Object2DGrid; (2). Note that an integer (with a small i) is a data type, while an Integer (with a capital I) is a Java object. The value of the Integer object will be the amount of money found 'on the ground' at that point in the grid space. (3).CarryDropSpace(int xSize, int ySize) is the constructor to initialize the space object.
  7. We now need to deposit some money on the landscape. To do this we will create a method of the CarryDropSpace object that will deposit an amount of money randomly around the objectSpace. We will then call that method right after the space object is created, in the buildModel method of the CarryDropModel object.
  8. Actually, some of the lines of code that we have placed in the 'spreadMoney' method of the CarryDropSpace object will be useful for several reasons; thus we will pull them out into their own method (note also some variable name changes- this is just for style and limited improvements in clarity. As an added technical note, we check for a 'null' condition, but one should never occur because we initialize the whole grid to include values):
  9. Makes 10 times the size of the space attempts to add the agent
  10. Schedule object is important in RePast. But if we don’t use it, we can switch to extend SimpleModel instead of SimModelImpl.
  11. When you run this code and step through it, the model is created, agents are green for a while, then turn blue and the disappear. For each one that disappears, however, another one appears. If you press 'play' you will see that the number of agents living, as reported every 10 timesteps, never changes.