demo
Class CarryDropModel

java.lang.Object
  extended byuchicago.src.sim.engine.SimModelImpl
      extended bydemo.CarryDropModel
All Implemented Interfaces:
uchicago.src.reflector.DescriptorContainer, uchicago.src.sim.engine.SimEventProducer, uchicago.src.sim.engine.SimModel

public class CarryDropModel
extends uchicago.src.sim.engine.SimModelImpl

CarryDropModel is a RePast model that demonstrates the basics of building a RePast model. The model's dynamics are straightforward: a space is populated with agents. Money is distributed on the landscape; agents move and pick up money. When agents collide the agent that initiated the collision gives one unit of money to the other agent. Agents have limited lifespans and when they die their money is distributed randomly across the landscape.

Author:
John T. Murphy
University of Arizona, Department of Anthropology
Arizona State University, Center for Environmental Studies

Constructor Summary
CarryDropModel()
           
 
Method Summary
 void begin()
          Initialize the model by building the separate elements that make up the model
 void buildDisplay()
          Build the display elements for this model.
 void buildModel()
          Initialize the basic model by creating the space and populating it with money and agents.
 void buildSchedule()
          Create the schedule object(s) that will be executed during the running of the model
 int getAgentMaxLifespan()
          Get the maximum value for an agent's lifespan
 int getAgentMinLifespan()
          Get the minimum value for an agent's lifespan
 java.lang.String[] getInitParam()
          Get the string array that lists the initialization parameters for this model
 int getMoney()
          Get the value of the parameter initializing the total amount of money in this model
 java.lang.String getName()
          Get a String that serves as the name of the model
 int getNumAgents()
          Get the parameter indicating the number of agents in this model
 uchicago.src.sim.engine.Schedule getSchedule()
          Returns the Schedule object for this model; for use internally by RePast
 int getWorldXSize()
          Get the width of the space in the model
 int getWorldYSize()
          Get the heighth of the space in the model
static void main(java.lang.String[] args)
          Main method for this model object; this runs the model.
 void setAgentMaxLifespan(int i)
          Set the maximum value for an agent's lifespan
 void setAgentMinLifespan(int i)
          Set the minimum value for an agent's lifespan
 void setMoney(int i)
          Set the new value for the total amount of money to be used when initializing the simulation
 void setNumAgents(int na)
          Set the parameter indicating the initial number of agents for this model.
 void setup()
          Tear down any existing pieces of the model and prepare for a new run.
 void setWorldXSize(int wxs)
          Set the parameter initializing the width of the space object in this model
 void setWorldYSize(int wys)
          Set the parameter initializing the heighth of the space object in this model
 
Methods inherited from class uchicago.src.sim.engine.SimModelImpl
addSimEventListener, clearMediaProducers, clearPropertyListeners, fireBooleanPropertyEvent, fireNumericPropertyEvent, fireObjectPropertyEvent, fireSimEvent, fireStringPropertyEvent, generateNewSeed, getController, getMediaProducers, getModelManipulator, getParameterDescriptors, getPropertiesValues, getRngSeed, getTickCount, getTickCountDouble, pause, registerDisplaySurface, registerMediaProducer, removeSimEventListener, setController, setRngSeed, stop
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CarryDropModel

public CarryDropModel()
Method Detail

getName

public java.lang.String getName()
Get a String that serves as the name of the model

Returns:
the name of the model

setup

public void setup()
Tear down any existing pieces of the model and prepare for a new run.


begin

public void begin()
Initialize the model by building the separate elements that make up the model


buildModel

public void buildModel()
Initialize the basic model by creating the space and populating it with money and agents.


buildSchedule

public void buildSchedule()
Create the schedule object(s) that will be executed during the running of the model


buildDisplay

public void buildDisplay()
Build the display elements for this model.


getSchedule

public uchicago.src.sim.engine.Schedule getSchedule()
Returns the Schedule object for this model; for use internally by RePast

Returns:
the Schedule object for this model

getInitParam

public java.lang.String[] getInitParam()
Get the string array that lists the initialization parameters for this model

Returns:
a String array that includes the names of all variables that can be modified by the RePast user interface

getNumAgents

public int getNumAgents()
Get the parameter indicating the number of agents in this model

Returns:
the number of agents in the model

setNumAgents

public void setNumAgents(int na)
Set the parameter indicating the initial number of agents for this model.

Parameters:
na - new value for initial number of agents.

getWorldXSize

public int getWorldXSize()
Get the width of the space in the model

Returns:
the width of the space object in the model (X-dimension)

setWorldXSize

public void setWorldXSize(int wxs)
Set the parameter initializing the width of the space object in this model

Parameters:
wxs - the new size of the X-dimension of the model.

getWorldYSize

public int getWorldYSize()
Get the heighth of the space in the model

Returns:
the heighth of the space object in the model (Y-dimension)

setWorldYSize

public void setWorldYSize(int wys)
Set the parameter initializing the heighth of the space object in this model

Parameters:
wys - the new size of the Y-dimension of the model.

getMoney

public int getMoney()
Get the value of the parameter initializing the total amount of money in this model

Returns:
the initial value for the total amount of money in the model

setMoney

public void setMoney(int i)
Set the new value for the total amount of money to be used when initializing the simulation

Parameters:
i - the new value for the total amount of money

getAgentMaxLifespan

public int getAgentMaxLifespan()
Get the maximum value for an agent's lifespan

Returns:
the maximum value for an agent's lifespan

getAgentMinLifespan

public int getAgentMinLifespan()
Get the minimum value for an agent's lifespan

Returns:
the minimum value for an agent's lifespan

setAgentMaxLifespan

public void setAgentMaxLifespan(int i)
Set the maximum value for an agent's lifespan

Parameters:
i - the maximum value for an agent's lifespan

setAgentMinLifespan

public void setAgentMinLifespan(int i)
Set the minimum value for an agent's lifespan

Parameters:
i - the minimum value for an agent's lifespan

main

public static void main(java.lang.String[] args)
Main method for this model object; this runs the model.

Parameters:
args - Any string arguments to be passed to this model (currently none)