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.sim.engine
Class SimModelImpl

    java.lang.Object
      uchicago.src.sim.engine.SimModelImpl

All Implemented Interfaces:
  DescriptorContainer, SimEventProducer, SimModel

Direct Known Subclasses:
  EnnBase, GisBugsModel, HBNoGui, HeatBugsModel, HexaBugsModel, HyperModel, JainModel, JiggleModel, JinGirNewModelII, MouseTrapModel, OpenMapAgentsSampleModel, RabbitPopulationModel, SimpleModel, SugarModel

    public abstract class SimModelImpl

extends java.lang.Object
implements SimModel

A partial implementation of the SimModel interface. Most, if not all, actual models will inherit from this class. By default SimModelImpl initializes the random number generator in the Random class using the current timestamp as a seed. Random can then be used for random number generator. If you need to have two random number streams with different seeds, you'll need to make your own. See the random number how to in repast/docs/how_to/random.html for more information. When data is collected from a model, it is this seed for this rng that is written out.

Version:
  $Revision: 1.8 $ $Date: 2004/11/03 19:50:57 $
Author:
  Nick Collier (Modified by Michael J. North)
See Also:
  `Random`

Field Summary
`protected java.util.Hashtable` | `descriptors` Used to store property descriptors.
`protected ModelManipulator` | `modelManipulator` A ModelManipulator that can be used to manipulate the model at run time.

Constructor Summary
`SimModelImpl()` Constructs a SimModel and initializes the default random number generator in uchicago.src.sim.util.Random with the current timestamp (new java.util.Date()) as the seed.

Method Summary
`protected void` | `addPropertyListener(PropertyListener listener)` Adds a PropertyListener to this model.
`void` | `addSimEventListener(SimEventListener l)` Adds a SimEventListener to listen for SimEvents broadcast from this model.
`void` | `clearMediaProducers()` Clears the vector of media producers.
`void` | `clearPropertyListeners()` Clears the list of PropertyListeners.
`void` | `fireBooleanPropertyEvent(PropertyEvent evt)` Broadcasts a boolean property event to all this model's PropertyEventListeners.
`protected void` | `fireEndSim()` Broadcasts a SimEvent with an id of SimEvent.END_EVENT to all this model's listeners.
`void` | `fireNumericPropertyEvent(PropertyEvent evt)` Broadcasts a numeric property event to all this model's PropertyEventListeners.
`void` | `fireObjectPropertyEvent(PropertyEvent evt)` Broadcasts an object property event to all this model's PropertyEventListeners.
`protected void` | `firePauseSim()` Broadcasts a SimEvent with an id of SimEvent.PAUSE_EVENT to all this model's listeners.
`void` | `fireSimEvent(SimEvent evt)` Broadcast the specified SimEvent to all this model's SimEventListeners
`protected void` | `fireStopSim()` Broadcasts a SimEvent with an id of SimEvent.STOP_EVENT to all this model's listeners.
`void` | `fireStringPropertyEvent(PropertyEvent evt)` Broadcasts a string property event to all this model's PropertyEventListeners.
`void` | `generateNewSeed()` Generates a new seed for the random number generator using the current timestamp.
`IController` | `getController()` Gets the BaseController associated with this model.
`java.util.Vector` | `getMediaProducers()` Gets the mediaProducers registered with this model.
`ModelManipulator` | `getModelManipulator()` Gets the ModelManipulator.
`java.util.Hashtable` | `getParameterDescriptors()` Gets a hashtable of ParameterDescriptors where key is parameter name, and value is the ParameterDescriptor.
`java.lang.String` | `getPropertiesValues()` Gets a String listing the model parameters and values.
`long` | `getRngSeed()` Gets the current random seed.
`double` | `getTickCount()` Gets the current tick count
`void` | `pause()` Pause the simulation.
`void` | `registerDisplaySurface(java.lang.String name, DisplaySurface surface)` Registers a DisplaySurface with this model and associates it with a particular name.
`void` | `registerMediaProducer(java.lang.String name, MediaProducer media)` Registers a MediaProducer with this model and associates it with the specified name.
`protected void` | `removePropertyListener(PropertyListener listener)` Removes a PropertyListener from this model.
`void` | `removeSimEventListener(SimEventListener l)` Removes a SimEventListener from the list of listeners listening for SimEvents broadcast from this model.
`void` | `setController(IController controller)` Sets the controller associated with this model
`void` | `setRngSeed(long seed)` Sets the random number generator in Random to a new value.
`void` | `stop()` Stops the simulation.

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

Methods inherited from interface uchicago.src.sim.engine.SimModel
`begin, getInitParam, getName, getSchedule, setup`

Field Detail

### descriptors

    protected java.util.Hashtable descriptors

  Used to store property descriptors. The key should be the property or parameter name and the value the descriptor associated with that property.

  See Also:
    `ListPropertyDescriptor`, `BooleanPropertyDescriptor`

### modelManipulator

    protected ModelManipulator modelManipulator

  A ModelManipulator that can be used to manipulate the model at run time.

Constructor Detail

### SimModelImpl

    public SimModelImpl()

  Constructs a SimModel and initializes the default random number generator in uchicago.src.sim.util.Random with the current timestamp (new java.util.Date()) as the seed.

  See Also:
    `Random`

Method Detail

### generateNewSeed

    public void generateNewSeed()

  Generates a new seed for the random number generator using the current timestamp.

  Specified by:
    `generateNewSeed` in interface `SimModel`

### setRngSeed

    public void setRngSeed(long seed)

  Sets the random number generator in Random to a new value. Note this will invalidate any distributions created with Random. These will need to be recreated.

  Specified by:
    `setRngSeed` in interface `SimModel`
  Parameters:
    `seed` - the new rng seed
  See Also:
    `Random`

### getRngSeed

    public long getRngSeed()

  Gets the current random seed.

  Specified by:
    `getRngSeed` in interface `SimModel`

### getTickCount

    public double getTickCount()

  Gets the current tick count

  Specified by:
    `getTickCount` in interface `SimModel`
  Returns:
    the current tick count

### setController

    public void setController(IController controller)

  Sets the controller associated with this model

  Specified by:
    `setController` in interface `SimModel`
  Parameters:
    `controller` - the controller to associate with this model

### getController

    public IController getController()

  Gets the BaseController associated with this model.

  Specified by:
    `getController` in interface `SimModel`

### getPropertiesValues

    public java.lang.String getPropertiesValues()

  Gets a String listing the model parameters and values. For example,

       MaxVision: 3
       MaxMetabolism: 4
       NumAgents: 52

  Specified by:
    `getPropertiesValues` in interface `SimModel`
  Returns:
    a list of the model parameters and values.

### getModelManipulator

    public ModelManipulator getModelManipulator()

  Gets the ModelManipulator.

  Specified by:
    `getModelManipulator` in interface `SimModel`

### getMediaProducers

    public java.util.Vector getMediaProducers()

  Gets the mediaProducers registered with this model. The returned vector will contain a ProducerNamePair objects.

  Specified by:
    `getMediaProducers` in interface `SimModel`

### registerDisplaySurface

    public void registerDisplaySurface(java.lang.String name,
                                       DisplaySurface surface)

  Registers a DisplaySurface with this model and associates it with a particular name.

### registerMediaProducer

    public void registerMediaProducer(java.lang.String name,
                                      MediaProducer media)

  Registers a MediaProducer with this model and associates it with the specified name.

### clearMediaProducers

    public void clearMediaProducers()

  Clears the vector of media producers.

  Specified by:
    `clearMediaProducers` in interface `SimModel`

### clearPropertyListeners

    public void clearPropertyListeners()

  Clears the list of PropertyListeners.

  Specified by:
    `clearPropertyListeners` in interface `SimModel`

### getParameterDescriptors

    public java.util.Hashtable getParameterDescriptors()

  Gets a hashtable of ParameterDescriptors where key is parameter name, and value is the ParameterDescriptor.

  Specified by:
    `getParameterDescriptors` in interface `DescriptorContainer`
  Specified by:
    `getParameterDescriptors` in interface `SimModel`

### addSimEventListener

    public void addSimEventListener(SimEventListener l)

  Adds a SimEventListener to listen for SimEvents broadcast from this model.

  Specified by:
    `addSimEventListener` in interface `SimEventProducer`
  Parameters:
    `l` - the SimEventListener to add
  See Also:
    `SimEventListener`

### removeSimEventListener

    public void removeSimEventListener(SimEventListener l)

  Removes a SimEventListener from the list of listeners listening for SimEvents broadcast from this model.

  Specified by:
    `removeSimEventListener` in interface `SimEventProducer`
  Parameters:
    `l` - the SimEventListener to remove.
  See Also:
    `SimEventListener`

### fireSimEvent

    public void fireSimEvent(SimEvent evt)

  Broadcast the specified SimEvent to all this model's SimEventListeners

  Specified by:
    `fireSimEvent` in interface `SimEventProducer`
  Parameters:
    `evt` - the SimEvent to broadcast
  See Also:
    `SimEvent`

### addPropertyListener

    protected void addPropertyListener(PropertyListener listener)

  Adds a PropertyListener to this model.

  Parameters:
    `listener` - the PropertyListener to add.

### removePropertyListener

    protected void removePropertyListener(PropertyListener listener)

  Removes a PropertyListener from this model.

  Parameters:
    `listener` - the PropertyListener to remove.

### pause

    public void pause()

  Pause the simulation.

### stop

    public void stop()

  Stops the simulation.

### fireNumericPropertyEvent

    public void fireNumericPropertyEvent(PropertyEvent evt)

  Broadcasts a numeric property event to all this model's PropertyEventListeners.

  Parameters:
    `evt` - the PropertyEvent to broadcast

### fireStringPropertyEvent

    public void fireStringPropertyEvent(PropertyEvent evt)

  Broadcasts a string property event to all this model's PropertyEventListeners.

  Parameters:
    `evt` - the PropertyEvent to broadcast

### fireBooleanPropertyEvent

    public void fireBooleanPropertyEvent(PropertyEvent evt)

  Broadcasts a boolean property event to all this model's PropertyEventListeners.

  Parameters:
    `evt` - the PropertyEvent to broadcast

### fireObjectPropertyEvent

    public void fireObjectPropertyEvent(PropertyEvent evt)

  Broadcasts an object property event to all this model's PropertyEventListeners.

  Parameters:
    `evt` - the PropertyEvent to broadcast

### fireStopSim

    protected void fireStopSim()

  Broadcasts a SimEvent with an id of SimEvent.STOP_EVENT to all this model's listeners.

### firePauseSim

    protected void firePauseSim()

  Broadcasts a SimEvent with an id of SimEvent.PAUSE_EVENT to all this model's listeners.

### fireEndSim

    protected void fireEndSim()

  Broadcasts a SimEvent with an id of SimEvent.END_EVENT to all this model's listeners.

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