movement
Class MapBasedMovement

java.lang.Object
  extended by movement.MovementModel
      extended by movement.MapBasedMovement
All Implemented Interfaces:
SwitchableMovement
Direct Known Subclasses:
BusTravellerMovement, CarMovement, EveningActivityMovement, HomeActivityMovement, MapRouteMovement, OfficeActivityMovement, ShortestPathMapBasedMovement

public class MapBasedMovement
extends MovementModel
implements SwitchableMovement

Map based movement model which gives out Paths that use the roads of a SimMap.


Field Summary
protected  boolean backAllowed
          May a node choose to move back the same way it came at a crossing
static java.lang.String FILE_S
          map file -setting id ("mapFile")
protected  MapNode lastMapNode
          node where the last path ended or node next to intial placement
static java.lang.String MAP_BASE_MOVEMENT_NS
          map based movent model's settings namespace ("MapBasedMovement")
static java.lang.String MAP_SELECT_S
          Per node group setting for selecting map node types that are OK for this node group to traverse trough.
protected  int maxPathLength
          max nrof map nodes to travel/path
protected  int minPathLength
          min nrof map nodes to travel/path
static java.lang.String NROF_FILES_S
          number of map files -setting id ("nrofMapFiles")
 
Fields inherited from class movement.MovementModel
DEF_SPEEDS, DEF_WAIT_TIMES, maxSpeed, maxWaitTime, minSpeed, minWaitTime, MOVEMENT_MODEL_NS, rng, RNG_SEED, SPEED, WAIT_TIME, WORLD_SIZE
 
Constructor Summary
protected MapBasedMovement(MapBasedMovement mbm)
          Copyconstructor.
  MapBasedMovement(Settings settings)
          Creates a new MapBasedMovement based on a Settings object's settings.
  MapBasedMovement(Settings settings, SimMap newMap, int nrofMaps)
          Creates a new MapBasedMovement based on a Settings object's settings but with different SimMap
 
Method Summary
 Coord getInitialLocation()
          Returns a (random) coordinate that is between two adjacent MapNodes
 Coord getLastLocation()
          Get the last location the getPath() of this movement model has returned
 SimMap getMap()
          Returns the SimMap this movement model uses
protected  int[] getOkMapNodeTypes()
          Returns map node types that are OK for this movement model in an array or null if all values are considered ok
 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 isReady()
          Checks if the movement model is finished doing its task and it's time to switch to the next movement model.
 MapBasedMovement replicate()
          Creates a replicate of the movement model.
protected  MapNode selectRandomOkNode(java.util.List<MapNode> nodes)
          Selects and returns a random node that is OK from a list of nodes.
 void setLocation(Coord lastWaypoint)
          Tell the movement model what its current location is
 
Methods inherited from class movement.MovementModel
generateSpeed, generateWaitTime, getMaxX, getMaxY, isActive, nextPathAvailable, reset, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

lastMapNode

protected MapNode lastMapNode
node where the last path ended or node next to intial placement


maxPathLength

protected int maxPathLength
max nrof map nodes to travel/path


minPathLength

protected int minPathLength
min nrof map nodes to travel/path


backAllowed

protected boolean backAllowed
May a node choose to move back the same way it came at a crossing


MAP_BASE_MOVEMENT_NS

public static final java.lang.String MAP_BASE_MOVEMENT_NS
map based movent model's settings namespace ("MapBasedMovement")

See Also:
Constant Field Values

NROF_FILES_S

public static final java.lang.String NROF_FILES_S
number of map files -setting id ("nrofMapFiles")

See Also:
Constant Field Values

FILE_S

public static final java.lang.String FILE_S
map file -setting id ("mapFile")

See Also:
Constant Field Values

MAP_SELECT_S

public static final java.lang.String MAP_SELECT_S
Per node group setting for selecting map node types that are OK for this node group to traverse trough. Value must be a comma separated list of integers in range of [1,31]. Values reference to map file indexes (see FILE_S). If setting is not defined, all map nodes are considered OK.

See Also:
Constant Field Values
Constructor Detail

MapBasedMovement

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

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

MapBasedMovement

public MapBasedMovement(Settings settings,
                        SimMap newMap,
                        int nrofMaps)
Creates a new MapBasedMovement based on a Settings object's settings but with different SimMap

Parameters:
settings - The Settings object where the settings are read from
newMap - The SimMap to use
nrofMaps - How many map "files" are in the map

MapBasedMovement

protected MapBasedMovement(MapBasedMovement mbm)
Copyconstructor.

Parameters:
mbm - The MapBasedMovement object to base the new object to
Method Detail

getInitialLocation

public Coord getInitialLocation()
Returns a (random) coordinate that is between two adjacent MapNodes

Specified by:
getInitialLocation in class MovementModel
Returns:
The initial coordinates for a node

getOkMapNodeTypes

protected int[] getOkMapNodeTypes()
Returns map node types that are OK for this movement model in an array or null if all values are considered ok

Returns:
map node types that are OK for this movement model in an array

getPath

public Path getPath()
Description copied from class: MovementModel
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.

Specified by:
getPath in class MovementModel
Returns:
A new path or null

selectRandomOkNode

protected MapNode selectRandomOkNode(java.util.List<MapNode> nodes)
Selects and returns a random node that is OK from a list of nodes. Whether node is OK, is determined by the okMapNodeTypes list. If okMapNodeTypes are defined, the given list must contain at least one OK node to prevent infinite looping.

Parameters:
nodes - The list of nodes to choose from.
Returns:
A random node from the list (that is OK if ok list is defined)

getMap

public SimMap getMap()
Returns the SimMap this movement model uses

Returns:
The SimMap this movement model uses

replicate

public MapBasedMovement replicate()
Description copied from class: MovementModel
Creates a replicate of the movement model.

Specified by:
replicate in class MovementModel
Returns:
A new movement model with the same settings as this model

getLastLocation

public Coord getLastLocation()
Description copied from interface: SwitchableMovement
Get the last location the getPath() of this movement model has returned

Specified by:
getLastLocation in interface SwitchableMovement
Returns:
the last location

setLocation

public void setLocation(Coord lastWaypoint)
Description copied from interface: SwitchableMovement
Tell the movement model what its current location is

Specified by:
setLocation in interface SwitchableMovement

isReady

public boolean isReady()
Description copied from interface: SwitchableMovement
Checks if the movement model is finished doing its task and it's time to switch to the next movement model. The method should be called between getPath() calls.

Specified by:
isReady in interface SwitchableMovement
Returns:
true if ready