Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## uchicago.src.repastdemos.rabbitPopulation
Class RabbitPopulationModel

    java.lang.Object
      uchicago.src.sim.engine.SimModelImpl
          uchicago.src.repastdemos.rabbitPopulation.RabbitPopulationModel

All Implemented Interfaces:
  DescriptorContainer, SimEventProducer, SimModel

    public class RabbitPopulationModel

extends SimModelImpl

This is an example model demonstrating how to use the CEquation and CEquationFactory classes to create system dynamics type models. This particular simple model of a rabbit population is based on that described in http://sysdyn.clexchange.org/sdep/Roadmaps/RM5/D-4432-2.pdf. The general idea here is to link the CEquations together so that the variables in one equation are the results of another. For example, population = population + (births - deaths) * dt. When this equation is evaluated the value of births and deaths are the results of a previous evalutation of the births and deaths equations. This model encapsulates the equations in classes (psuedo-agents) and associates them with one another via the classes' init methods. The classes and the equations they encapsulate are listed below:

- RabbitPopulation : population + (births - deaths) * dt
- Births : population * birthRate
- Deaths : (population / lifeTime) * deathMultiplier
- PopulationDensity : population / area
- DeathMultiplier : graph-type table lookup (0.00, 1.00), (100, 1.00), (200, 1.00), (300, 1.00), (400, 1.50), (500, 2.00), (600, 2.70), (700, 3.70), (800, 4.70), (900, 5.70), (1000, 7.50)

The simulation proceeds by first evaluating and assigning the births, deaths, and population density equations. In the process of the evaluation these objects will query the population for its current value. The population equation is then evaluated and assigned. In doing so, the population equation will query the births and deaths objects for the result of their evaluation. So, in short, we first calculate the number of births and deaths based on the previous years population, and then use that data to calculate the new population.

Version:
  $Revision: 1.1 $ $Date: 2005/08/12 20:04:58 $
Author:
  Nick Collier

Field Summary

Fields inherited from class uchicago.src.sim.engine.SimModelImpl
`descriptors, modelManipulator`

Constructor Summary
`RabbitPopulationModel()`

Method Summary
`void` | `begin()` Begins a simulation run.
`double` | `getInitialPopulation()`
`java.lang.String[]` | `getInitParam()` Gets the names of the initial model parameters to set.
`java.lang.String` | `getName()` Gets the name of the model/simulation.
`Schedule` | `getSchedule()` Gets the Schedule created by the model.
`static void` | `main(java.lang.String[] args)`
`void` | `setInitialPopulation(double initialPopulation)`
`void` | `setup()` Prepares a model for a new run, typically by deallocating objects or setting them to some reasonable default.

Methods inherited from class uchicago.src.sim.engine.SimModelImpl
`addPropertyListener, addSimEventListener, clearMediaProducers, clearPropertyListeners, fireBooleanPropertyEvent, fireEndSim, fireNumericPropertyEvent, fireObjectPropertyEvent, firePauseSim, fireSimEvent, fireStopSim, fireStringPropertyEvent, generateNewSeed, getController, getMediaProducers, getModelManipulator, getParameterDescriptors, getPropertiesValues, getRngSeed, getTickCount, pause, registerDisplaySurface, registerMediaProducer, removePropertyListener, removeSimEventListener, setController, setRngSeed, stop`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### RabbitPopulationModel

    public RabbitPopulationModel()

Method Detail

### begin

    public void begin()

  Description copied from interface: `SimModel`
  Begins a simulation run. All initialization, building the model, diplay, etc. should take place here. This method is called whenever the start button (or the step button if the run has not yet begun) is clicked. If running in batch mode this is called to kick off a new simulation run.

### setup

    public void setup()

  Description copied from interface: `SimModel`
  Prepares a model for a new run, typically by deallocating objects or setting them to some reasonable default. Called whenever the setup button is clicked or if operating in batch mode whenever a single run has ended in preparation for the next. Also called when the model is first loaded.

### getInitParam

    public java.lang.String[] getInitParam()

  Description copied from interface: `SimModel`
  Gets the names of the initial model parameters to set. These names must have get and set methods supplied by the model. For example, for the parameter maxAge, the model must have getMaxAge and setMaxAge methods.

  Returns:
    a String[] of the initial parameter names

### getInitialPopulation

    public double getInitialPopulation()

### setInitialPopulation

    public void setInitialPopulation(double initialPopulation)

### getSchedule

    public Schedule getSchedule()

  Description copied from interface: `SimModel`
  Gets the Schedule created by the model.

  Returns:
    the schedule created by the model

### getName

    public java.lang.String getName()

  Description copied from interface: `SimModel`
  Gets the name of the model/simulation.

  Returns:
    the name of the model/simulation

### main

    public static void main(java.lang.String[] args)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD