Package mosp :: Module routing :: Class RoutingNode
[hide private]
[frames] | no frames]

Class RoutingNode

source code


A routing node.


Author: F. Ludwig

Instance Methods [hide private]
 
__cmp__(self, o)
Compares two RoutingNodes by their id.
source code
 
__init__(self, id)
Inits the RoutingNode.
source code
 
__repr__(self)
String respresentation of RoutingNode.
source code
 
cleanup(self)
Clears RoutingNode's route_dist and neighbors
source code
RoutingNode
get_route(self, node)
Returns the next RoutingNode on the route from this routingNode to <node>
source code
[RoutingNode, float]
get_route_dist(self, node)
Returns the next RoutingNode and distance to it on the route from this routingNode to <node>
source code
 
get_routes(self)
Yields all distances from this RoutingNode to all nodes as 2-tuples <n, distance>.
source code
 
on_visit(self, visitor)
What has to be done when a Person visits this node in simulation?
source code
 
set_route(self, to, next, dist)
Sets value of route_next (<next>) and route_dist (<dist>) for route from this RoutingNode to <to>
source code
 
setup(self, nodes_num)
Set up arrays route_next and route_dist with default values
source code
 
setup2(self, nodes_num)
Feed arrays route_next and route_dist with routing information to direct neighbors.
source code
Boolean
update(self, nodes_num)
Calculate some routing data for all RoutingNodes in self.todo.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Instance Variables [hide private]
  id
RoutingNode id
  n
list of sorted neighbor keys = mapping of route_next ids (0..254) to mosp nodes (any id)
  neighbors
dict of neighbor RoutingNodes of this RoutingNode, keys=RoutingNode, values=its distance
  todo
todo list for routing table calculation
  ways
dict of ways the RoutingNode is connect with
  worldobject
Stores a Location or other real world objects at this road network node/place, e.g used for act_at_node()
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, id)
(Constructor)

source code 

Inits the RoutingNode.

Overrides: object.__init__

__repr__(self)
(Representation operator)

source code 

String respresentation of RoutingNode.

Overrides: object.__repr__

get_route(self, node)

source code 

Returns the next RoutingNode on the route from this routingNode to <node>

Parameters:
  • node - destination node
Returns: RoutingNode
next RoutingNode on route

get_route_dist(self, node)

source code 

Returns the next RoutingNode and distance to it on the route from this routingNode to <node>

Parameters:
  • node - destination node
Returns: [RoutingNode, float]
2-tupel list <next RoutingNode, distance>

on_visit(self, visitor)

source code 

What has to be done when a Person visits this node in simulation?

Must be overwritten in simulation implementation to make it come alive.

Parameters:
  • visitor - visiting Person

set_route(self, to, next, dist)

source code 

Sets value of route_next (<next>) and route_dist (<dist>) for route from this RoutingNode to <to>

Updates a routing table entry within table calculation, also marks destination as dirty for recalculation.

setup(self, nodes_num)

source code 

Set up arrays route_next and route_dist with default values

  • route_dist default = 0.
  • route_next default = max_int = 255: a RoutingNode should never have 255 neighbors! for performace (mem usage) reasons we store id of the x-th sorted neighbor instead of the mosp wide node id.
Parameters:
  • nodes_num - number of way nodes

setup2(self, nodes_num)

source code 

Feed arrays route_next and route_dist with routing information to direct neighbors.

self is source, for all neighbors as destination: self.set_route(neighborX, via itself (neighborX), distance)

Parameters:
  • nodes_num - number of way nodes

update(self, nodes_num)

source code 

Calculate some routing data for all RoutingNodes in self.todo.

For any node X in todo: set distance from any of my neighbor to X as the sum of the distance from my neighbor to me plus the distance from me to X. Finally: empty todo list.

Returns: Boolean
self.todo has not been empty?