movement
Class BusTravellerMovement

java.lang.Object
  extended by movement.MovementModel
      extended by movement.MapBasedMovement
          extended by movement.BusTravellerMovement
All Implemented Interfaces:
SwitchableMovement, TransportMovement

public class BusTravellerMovement
extends MapBasedMovement
implements SwitchableMovement, TransportMovement

This class controls the movement of bus travellers. A bus traveller belongs to a bus control system. A bus traveller has a destination and a start location. If the direct path to the destination is longer than the path the node would have to walk if it would take the bus, the node uses the bus. If the destination is not provided, the node will pass a random number of stops determined by Markov chains (defined in settings).


Field Summary
static java.lang.String PROBABILITIES_STRING
           
static java.lang.String PROBABILITY_TAKE_OTHER_BUS
           
static int STATE_DECIDED_TO_ENTER_A_BUS
           
static int STATE_TRAVELLING_ON_BUS
           
static int STATE_WAITING_FOR_BUS
           
static int STATE_WALKING_ELSEWHERE
           
 
Fields inherited from class movement.MapBasedMovement
backAllowed, FILE_S, lastMapNode, MAP_BASE_MOVEMENT_NS, MAP_SELECT_S, maxPathLength, minPathLength, NROF_FILES_S
 
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
BusTravellerMovement(BusTravellerMovement proto)
          Creates a BusTravellerModel from a prototype
BusTravellerMovement(Settings settings)
          Creates a BusTravellerModel
 
Method Summary
 void enterBus(Path nextPath)
          Notifies the node at the bus stop that a bus is there.
protected  double generateWaitTime()
          Switches state between getPath() calls
 int getID()
           
 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
 Coord getLocation()
          Get the location where the bus is located when it has moved its path
 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).
 int getState()
           
 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.
static void reset()
           
 void setLocation(Coord lastWaypoint)
          Tell the movement model what its current location is
 void setNextRoute(Coord nodeLocation, Coord nodeDestination)
          Sets the next route for the traveller, so that it can decide wether it should take the bus or not.
 
Methods inherited from class movement.MapBasedMovement
getMap, getOkMapNodeTypes, selectRandomOkNode
 
Methods inherited from class movement.MovementModel
generateSpeed, getMaxX, getMaxY, isActive, nextPathAvailable, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROBABILITIES_STRING

public static final java.lang.String PROBABILITIES_STRING
See Also:
Constant Field Values

PROBABILITY_TAKE_OTHER_BUS

public static final java.lang.String PROBABILITY_TAKE_OTHER_BUS
See Also:
Constant Field Values

STATE_WAITING_FOR_BUS

public static final int STATE_WAITING_FOR_BUS
See Also:
Constant Field Values

STATE_DECIDED_TO_ENTER_A_BUS

public static final int STATE_DECIDED_TO_ENTER_A_BUS
See Also:
Constant Field Values

STATE_TRAVELLING_ON_BUS

public static final int STATE_TRAVELLING_ON_BUS
See Also:
Constant Field Values

STATE_WALKING_ELSEWHERE

public static final int STATE_WALKING_ELSEWHERE
See Also:
Constant Field Values
Constructor Detail

BusTravellerMovement

public BusTravellerMovement(Settings settings)
Creates a BusTravellerModel

Parameters:
settings -

BusTravellerMovement

public BusTravellerMovement(BusTravellerMovement proto)
Creates a BusTravellerModel from a prototype

Parameters:
proto -
Method Detail

getInitialLocation

public Coord getInitialLocation()
Description copied from class: MapBasedMovement
Returns a (random) coordinate that is between two adjacent MapNodes

Overrides:
getInitialLocation in class MapBasedMovement
Returns:
The initial coordinates for a node

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.

Overrides:
getPath in class MapBasedMovement
Returns:
A new path or null

generateWaitTime

protected double generateWaitTime()
Switches state between getPath() calls

Overrides:
generateWaitTime in class MovementModel
Returns:
Always 0

replicate

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

Overrides:
replicate in class MapBasedMovement
Returns:
A new movement model with the same settings as this model

getState

public int getState()

getLocation

public Coord getLocation()
Get the location where the bus is located when it has moved its path

Returns:
The end point of the last path returned

enterBus

public void enterBus(Path nextPath)
Notifies the node at the bus stop that a bus is there. Nodes inside busses are also notified.

Parameters:
nextPath - The next path the bus is going to take

getID

public int getID()

setNextRoute

public void setNextRoute(Coord nodeLocation,
                         Coord nodeDestination)
Sets the next route for the traveller, so that it can decide wether it should take the bus or not.

Specified by:
setNextRoute in interface TransportMovement
Parameters:
nodeLocation -
nodeDestination -

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
Overrides:
getLastLocation in class MapBasedMovement
Returns:
the last location
See Also:
SwitchableMovement

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
Overrides:
setLocation in class MapBasedMovement
See Also:
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
Overrides:
isReady in class MapBasedMovement
Returns:
true if ready
See Also:
SwitchableMovement

reset

public static void reset()