movement
Class MovementModel

java.lang.Object
  extended by movement.MovementModel
Direct Known Subclasses:
ExtendedMovementModel, ExternalMovement, MapBasedMovement, RandomWalk, RandomWaypoint, StationaryMovement

public abstract class MovementModel
extends java.lang.Object

Superclass for all movement models. All subclasses must contain at least a constructor with one Settings parameter and also a copy-constructor. They must also implement the replicate() method, which should return an instance of the movement model class with same parameters as the object (immutable fields can be shared, but mutable fields must be copied).

To make a new movement model do something useful, also at least getInitialLocation() and getPath() are worthwhile to override.


Field Summary
static double[] DEF_SPEEDS
          default setting for speed distribution
static double[] DEF_WAIT_TIMES
          default setting for wait time distribution
protected  double maxSpeed
           
protected  double maxWaitTime
           
protected  double minSpeed
           
protected  double minWaitTime
           
static java.lang.String MOVEMENT_MODEL_NS
          MovementModel namespace (where world size and rng seed settings are looked from ("MovementModel")
protected static java.util.Random rng
          common rng for all movement models in the simulation
static java.lang.String RNG_SEED
          movement models' rng seed -setting id ("rngSeed")
static java.lang.String SPEED
          node's speed CSV (min, max) -setting id ("speed")
static java.lang.String WAIT_TIME
          node's wait time CSV (min, max) -setting id ("waitTime")
static java.lang.String WORLD_SIZE
          world's size CSV (width, height) -setting id ("worldSize")
 
Constructor Summary
MovementModel()
          Empty constructor for testing purposes.
MovementModel(MovementModel mm)
          Copyconstructor.
MovementModel(Settings settings)
          Creates a new MovementModel based on a Settings object's settings.
 
Method Summary
protected  double generateSpeed()
          Generates and returns a speed value between min and max of the WAIT_TIME setting.
protected  double generateWaitTime()
          Generates and returns a suitable waiting time at the end of a path.
abstract  Coord getInitialLocation()
          Returns a new initial placement for a node
 int getMaxX()
          Returns the largest X coordinate value this model uses
 int getMaxY()
          Returns the largest Y coordinate value this model uses
abstract  Path getPath()
          Returns a new path by this movement model or null if no new path could be constructed at the moment (node should wait where it is).
 boolean isActive()
          Returns true if this node is active at the moment (false if not)
 double nextPathAvailable()
          Returns a sim time when the next path is available.
abstract  MovementModel replicate()
          Creates a replicate of the movement model.
static void reset()
          Resets all static fields to default values
 java.lang.String toString()
          Returns simply the name of the movement model class
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SPEED

public static final java.lang.String SPEED
node's speed CSV (min, max) -setting id ("speed")

See Also:
Constant Field Values

WAIT_TIME

public static final java.lang.String WAIT_TIME
node's wait time CSV (min, max) -setting id ("waitTime")

See Also:
Constant Field Values

DEF_SPEEDS

public static final double[] DEF_SPEEDS
default setting for speed distribution


DEF_WAIT_TIMES

public static final double[] DEF_WAIT_TIMES
default setting for wait time distribution


MOVEMENT_MODEL_NS

public static final java.lang.String MOVEMENT_MODEL_NS
MovementModel namespace (where world size and rng seed settings are looked from ("MovementModel")

See Also:
Constant Field Values

WORLD_SIZE

public static final java.lang.String WORLD_SIZE
world's size CSV (width, height) -setting id ("worldSize")

See Also:
Constant Field Values

RNG_SEED

public static final java.lang.String RNG_SEED
movement models' rng seed -setting id ("rngSeed")

See Also:
Constant Field Values

rng

protected static java.util.Random rng
common rng for all movement models in the simulation


minSpeed

protected double minSpeed

maxSpeed

protected double maxSpeed

minWaitTime

protected double minWaitTime

maxWaitTime

protected double maxWaitTime
Constructor Detail

MovementModel

public MovementModel()
Empty constructor for testing purposes.


MovementModel

public MovementModel(Settings settings)
Creates a new MovementModel based on a Settings object's settings.

Parameters:
settings - The Settings object where the settings are read from

MovementModel

public MovementModel(MovementModel mm)
Copyconstructor. Creates a new MovementModel based on the given prototype.

Parameters:
mm - The MovementModel prototype to base the new object to
Method Detail

getMaxX

public int getMaxX()
Returns the largest X coordinate value this model uses

Returns:
Maximum of X coordinate values

getMaxY

public int getMaxY()
Returns the largest Y coordinate value this model uses

Returns:
Maximum of Y coordinate values

generateSpeed

protected double generateSpeed()
Generates and returns a speed value between min and max of the WAIT_TIME setting.

Returns:
A new speed between min and max values

generateWaitTime

protected double generateWaitTime()
Generates and returns a suitable waiting time at the end of a path. (i.e. random variable whose value is between min and max of the WAIT_TIME setting).

Returns:
The time as a double

getPath

public abstract Path getPath()
Returns a new path by this movement model or null if no new path could be constructed at the moment (node should wait where it is). A new path should not be requested before the destination of the previous path has been reached.

Returns:
A new path or null

getInitialLocation

public abstract Coord getInitialLocation()
Returns a new initial placement for a node

Returns:
The initial coordinates for a node

isActive

public boolean isActive()
Returns true if this node is active at the moment (false if not)

Returns:
true if this node is active (false if not)

nextPathAvailable

public double nextPathAvailable()
Returns a sim time when the next path is available. This implementation returns a random time in future that is WAIT_TIME from now.

Returns:
The sim time when node should ask the next time for a path

toString

public java.lang.String toString()
Returns simply the name of the movement model class

Overrides:
toString in class java.lang.Object
Returns:
the name of the movement model class

replicate

public abstract MovementModel replicate()
Creates a replicate of the movement model.

Returns:
A new movement model with the same settings as this model

reset

public static void reset()
Resets all static fields to default values