Creating a RePast Model Introduction, (Sim)Model Object, CarryDrop.

Slides:



Advertisements
Similar presentations
ArrayLists The lazy mans array. Whats the matter here? int[] list = new int[10]; list[0] = 5; list[2] = hey; list[3] = 15; list[4] = 23;
Advertisements

Programming Methodology (1). Implementing Methods main.
Based on Java Software Development, 5th Ed. By Lewis &Loftus
Java Programing PSC 120 Jeff Schank. Let’s Create a Java Program 1.Open Eclipse 2.Create a project: File -> New -> Java Project 3.Create a package: File.
LCS Non-Dynamic Version int function lcs (x, y, i, j) begin if (i = 0) or (j = 0) return 0; else if (x[i] = y[j]) return lcs(x, y, i-1, j-1)+1; else return.
Modern pipe network models
What have we learned so far… Preprocessor directives Introduction to C++ Variable Declaration Display Messages on Screen Get Information from User Performed.
Random Variables and Expectation. Random Variables A random variable X is a mapping from a sample space S to a target set T, usually N or R. Example:
CS 206 Introduction to Computer Science II 01 / 21 / 2009 Instructor: Michael Eckmann.
Objects and Classes First Programming Concepts. 14/10/2004Lecture 1a: Introduction 2 Fundamental Concepts object class method parameter data type.
1. 2 Introduction to Methods  Method Calls  Parameters  Return Type  Method Overloading  Accessor & Mutator Methods  Student Class: Revisited.
Arrays  Writing a program that uses a large amount of information.  Such as a list of 100 elements.  It is not practical to declare.
Class template Describing a generic class Instantiating classes that are type- specific version of this generic class Also are called parameterized types.
Objects & Object-Oriented Programming (OOP) CSC 1401: Introduction to Programming with Java Week 15 – Lecture 1 Wanda M. Kunkle.
Introduction to Programming with Java, for Beginners Scope.
1 Some Patterns of Novice Programs Author : Eugene Wallingford ; Dan Steinberg ; Robert Duvall ; Ralph Johnson Source : PLoP 2004 Advisor : Ku-Yaw Chang.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
CSS Cooperative Education Faculty Research Internship Spring / Summer 2013 Richard Romanus 08/23/2013 Developing and Extending the MASS Library (Java)
Visual Programming Fall 2012 – FUUAST Topic: Development environment.
OOD Case Study (For parallel treatment, see Chapter 2 of the text)
The CarryDrop Model (Steps 19-24) : A RePast Tutorial by John Murphy by Junjie Sun 8/16/2004 Department of Economics Iowa State University.
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
CS 106 Introduction to Computer Science I 03 / 19 / 2007 Instructor: Michael Eckmann.
Introduction to Computational Modeling of Social Systems Prof. Lars-Erik Cederman Center for Comparative and International Studies (CIS) Seilergraben 49,
ACO 101: Introduction to Computer Science Anatomy Part 2: Methods.
Arrays and ArrayLists in Java L. Kedigh. Array Characteristics List of values. A list of values where every member is of the same type. Each member in.
Arrays An array is a data structure that consists of an ordered collection of similar items (where “similar items” means items of the same type.) An array.
COMPUTER PROGRAMMING. Functions What is a function? A function is a group of statements that is executed when it is called from some point of the program.
CSE 114 Computer Science I Objects Lake Superior, Michigan.
Vectors and Grids Eric Roberts CS 106B April 8, 2009.
1 Java Server Pages Allows the embedding of Java commands in a page of HTML. Popular for UI heavy solutions. These commands are then interpreted by a JSP.
Topic 1 Object Oriented Programming. 1-2 Objectives To review the concepts and terminology of object-oriented programming To discuss some features of.
CSC1401 Classes - 2. Learning Goals Computing concepts Adding a method To show the pictures in the slide show Creating accessors and modifiers That protect.
Introduction to MVC Controllers NTPCUG Tom Perkins, Ph.D.
CIS 270—Application Development II Chapter 18-Generics.
Java - Classes JPatterson. What is a class? public class _Alpha { public static void main(String [] args) { } You have been using classes all year – you.
Introduction to Computational Modeling of Social Systems Prof. Lars-Erik Cederman Center for Comparative and International Studies (CIS) Seilergraben 49,
Classes. Student class We are tasked with creating a class for objects that store data about students. We first want to consider what is needed for the.
Salman Marvasti Sharif University of Technology Winter 2015.
CSI 3125, Preliminaries, page 1 Compiling the Program.
Continuation of John Murphy’s RePast Tutorial Steps Charlie Gieseler
Prof. Dr. Lars-Erik Cederman ETH - Center for Comparative and International Studies (CIS) Seilergraben 49, Room G.2,
Introduction to Computational Modeling of Social Systems Prof. Lars-Erik Cederman Center for Comparative and International Studies (CIS) Seilergraben 49,
February 28, 2005 Introduction to Classes. Object Oriented Programming An object is a software bundle of related variables and methods. Software objects.
Methods Awesomeness!!!. Methods Methods give a name to a section of code Methods give a name to a section of code Methods have a number of important uses.
Topic 1 Object Oriented Programming. 1-2 Objectives To review the concepts and terminology of object-oriented programming To discuss some features of.
C Programming Chapters 11, . . .
POLYMORPHISM Chapter 6. Chapter Polymorphism  Polymorphism concept  Abstract classes and methods  Method overriding  Concrete sub classes and.
Programming Fundamentals. Today’s Lecture Array Fundamentals Arrays as Class Member Data Arrays of Objects C-Strings The Standard C++ string Class.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Function Templates 16.2.
Chapter 9 Introduction to Arrays Fundamentals of Java.
Methods. Creating your own methods Java allows you to create custom methods inside its main body. public class Test { // insert your own methods right.
Testing It is much better to have a plan when testing your programs than it is to just randomly try values in a haphazard fashion. Testing Strategies:
Georgia Institute of Technology More on Creating Classes Barb Ericson Georgia Institute of Technology June 2006.
Defining Data Types in C++ Part 2: classes. Quick review of OOP Object: combination of: –data structures (describe object attributes) –functions (describe.
9.1 CLASS (STATIC) VARIABLES AND METHODS Defining classes is only one aspect of object-oriented programming. The real power of object-oriented programming.
Lecture 10 – Polymorphism Nancy Harris with additional slides Professor Adams from Lewis & Bernstein.
Windows Programming Lecture 03. Pointers and Arrays.
LESSON 8: INTRODUCTION TO ARRAYS. Lesson 8: Introduction To Arrays Objectives: Write programs that handle collections of similar items. Declare array.
The CarryDrop Model (Steps 4-9) : A RePast Tutorial by John Murphy by Junjie Sun 8/2/2004 Department of Economics Iowa State University.
Selected Topics in CI I Genetic Programming Dr. Widodo Budiharto 2014.
Java Programming: Guided Learning with Early Objects
Method Mark and Lyubo.
Class Inheritance (Cont.)
An Introduction to Java – Part II
Chapter 4 Writing Classes.
Implementing Classes Chapter 3.
Example with Static Variable
Class Everything if Java is in a class. The class has a constructor that creates the object. public class ClassName private Field data (instance variables)
Defining Classes and Methods
Presentation transcript:

Creating a RePast Model Introduction, (Sim)Model Object, CarryDrop

Elements of a RePast Model 1.Model Object—acts as the model itself 2.Space Object—controls the environment 3.Agent Object

The (Sim)Model Object Model object will extend RePast’s SimModelImpl object. It will react to the RePast control toolbar.

The SimModel Object—getName() getName() replaces ‘RePast’ with the name of the project on the control toolbar. import uchicago.src.sim.engine.SimModelImpl; public class MyFirstRePastModel extends SimModelImpl { public String getName(){ return “My First RePast Model”; }

The SimModel Object—begin() begin() initializes the model. import uchicago.src.sim.engine.SimModelImpl; public class MyFirstRePastModel extends SimModelImpl { public String getName(){ return “My First RePast Model”; } public void begin(){ }

The SimModel Object—tradition RePast models traditionally have a consistent ‘map’ to their model classes. We will divide the begin() method into three other methods. Thus, we will add the following code. public void begin(){ buildModel(); buildSchedule(); buildDisplay(); } public void buildModel(){ } public void buildSchedule(){ } public void buildDisplay(){ }

The SimModel Object—current code import uchicago.src.sim.engine.SimModelImpl; public class MyFirstRePastModel extends SimModelImpl { public String getName(){ return “My First RePast Model”; } public void begin(){ buildModel(); buildSchedule(); buildDisplay(); } public void buildModel(){ } public void buildSchedule(){ } public void buildDisplay(){ } }

The SimModel Object—setup() The setup() function returns the model to the initial condition. public class MyFirstRePastModel extends SimModelImpl { public String getName(){ return “My First RePast Model”; } public void setup(){ } public void begin(){ […]

The SimModel Object—Schedule Schedule manages the execution of BasicAction according to the simulation clock. Each tick is completed at the end of all BasicAction executions. Actions scheduled on a Schedule will be executed in random order.

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 getInitParam returns an array of String variables (e.g., N agents) This will change Ns by using the ‘setup’ and ‘initialize’ buttons. Two important factors: You must supply RePast with a list of the parameters you want to vary, in this case ‘NumAgents.’ You must create ‘get’ and ‘set’ methods for each parameter in the list.

The SimModel Object--numAgents First, lets insert the variable into our code. 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 Next, RePast structure requires us to provide ‘get’ and ‘set’. public Schedule getSchedule(){ return schedule; } public int getNumAgents(){ return numAgents; } public void setNumAgents (int na){ numAgents=na; }

The SimModel Object--numAgents Next, RePast structure requires us to provide ‘get’ and ‘set’. public Schedule getSchedule(){ return schedule; } public String[] getInitParam(){ String[] initParams = {“NumAgents”}; return initParams; } public int getNumAgents(){ return numAgents; }

The CarryDrop Model--Introduction We want to create a model with the following characteristics. Agents move around a gridded landscape Each cell may contain money. Agents always move in a straight line in one of the eight neighborhood directions. When an agents moves into another agent’s square, the moving agent gives money to the other. Agents have a different lifespan between max. and min. values. When it dies, the money is spread randomly and is replaced.

The CarryDrop model To accomplish this, we will need three files The class that instantiates the SimModel object CarryDropModel A class specifying the agents CarryDropAgent A class describing the space CarryDropSpace [To be continues at