Auxiliary algorithms and data structures

Algorithms

InsertionCache

class routingblocks.InsertionMove(vertex_id: VertexID, after_node_location: NodeLocation, delta_cost: float)
Parameters:
  • vertex_id (VertexID) – The vertex to be inserted.

  • after_node – The node after which the vertex should be inserted.

  • delta_cost (float) – The change in cost incurred from inserting the vertex at the specified position.

  • after_node_location (NodeLocation) –

vertex_id
after_node
delta_cost
class routingblocks.InsertionCache(instance: Instance)
Parameters:

instance (Instance) –

clear()
Return type:

None

get_best_insertions_for_vertex(vertex_id: VertexID)
Parameters:

vertex_id (VertexID) –

Return type:

List[InsertionMove]

invalidate_route(route: Route, route_index: int)
Parameters:
  • route (Route) –

  • route_index (int) –

Return type:

None

rebuild(evaluation: Evaluation, solution: Solution, vertex_ids: List[VertexID])
Parameters:
Return type:

None

stop_tracking(vertex_id: VertexID)
Parameters:

vertex_id (VertexID) –

Return type:

None

tracks_vertex(vertex_id: VertexID)
Parameters:

vertex_id (VertexID) –

Return type:

bool

property moves_in_order
Return type:

List[InsertionMove]

property tracked_vertices
Return type:

List[VertexID]

RemovalCache

class routingblocks.RemovalMove(vertex_id: VertexID, node_location: NodeLocation, delta_cost: float)
Parameters:
  • vertex_id (VertexID) – The vertex ID of the node to be removed.

  • node_location (NodeLocation) – The location of the node to be removed.

  • delta_cost (float) – The change in cost of the solution if the node is removed.

vertex_id
node_location
delta_cost
class routingblocks.RemovalCache(instance: Instance)
Parameters:

instance (Instance) –

clear()
Return type:

None

invalidate_route(route: Route, route_index: int)
Parameters:
  • route (Route) –

  • route_index (int) –

Return type:

None

rebuild(evaluation: Evaluation, solution: Solution)
Parameters:
Return type:

None

property moves_in_order
Return type:

List[RemovalMove]

Miscellaneous

class routingblocks.Random

Initializes a new instance of the Random class with a provided seed.

The seed is a number used to initialize the underlying pseudo-random number generator.

Parameters:

seed (int) – The seed value for the random number generator. Providing the same seed will generate the same sequence of random numbers.

__init__(self):

Initializes a new instance of the Random class without a seed.

If no seed value is provided, it uses the current system time or another system-specific source of randomness to generate random numbers.

__init__(self, seed: int):

Initializes a new instance of the Random class with a provided seed.

The seed is a number used to initialize the underlying pseudo-random number generator.

Parameters:

seed (int) – The seed value for the random number generator. Providing the same seed will generate the same sequence of random numbers.

randint(min: int, max: int)

Returns a random integer from the specified range [min, max], including both endpoints.

Parameters:
  • min (int) – The lower bound of the range.

  • max (int) – The upper bound of the range.

Returns:

A random integer value from the specified range [min, max].

Return type:

int

uniform(min: float, max: float)

Returns a random floating-point number between the specified min and max values, including min and potentially up to max.

Parameters:
  • min (float) – The lower bound of the range.

  • max (float) – The upper bound of the range.

Returns:

A random floating-point number within the specified range [min, max).

Return type:

float