trafpy.manager.src.routers package

Submodules

trafpy.manager.src.routers.routers module

trafpy.manager.src.routers.rwa module

class trafpy.manager.src.routers.rwa.RWA(channel_names, num_k)[source]

Bases: object

check_if_channel_space(graph, edges, channel, flow_size)[source]

Takes list of edges to see if all of the edges have enough space for the given demand on a certain channel

Args: - edges (list of lists): edges we want to check if have enough space for a certain demand on a certain channel - channel (label): channel we want to check if has enough space for the given demand across all given edges - flow_size: demand size we want to check if there’s space for on the given channel across all given edges

Returns: - True/False

check_if_channel_used(graph, edges, channel)[source]

Takes list of edges to see if any one of the edges have used a certain channel

Args: - edges (list of lists): edges we want to check if have used certain channel - channel (label): channel we want to check if has been used by any of the edges

Returns: - True/False

ff_k_shortest_paths(graph, k_shortest_paths, flow_size)[source]

Applies first fit algorithm, whereby path with lowest cost (shortest path) is looked at first when considering which route to select, then next etc. When route is considered, a wavelength (starting from lowest) is considered. If not available, move to next highest wavelength. If go through all wavelengths and none available, move to next shortest path and try again. I.e. this is a ‘select route first, then select wavelength’ k-shortest path first fit RWA algorithm. If no routes- wavelength pairs are available, message is blocked.

Uses this first fit process to allocate a given demand a path and a channel.

Args: - k_shortest_paths (list of lists): the k shortest paths from the source to destination node, with shortest path first etc - channel_names (list of strings): list of channel names that algorithm can consider assigning to each path - flow_size (int, float): size of demand

Returns: - path - channel

get_action(observation)[source]

Gets an action (route+channel or blocked) for DCN simulation

get_path_edges(path)[source]

Takes a path and returns list of edges in the path

Args: - path (list): path in which you want to find all edges

Returns: - edges (list of lists): all edges contained within the path

k_shortest_paths(graph, source, target, num_k=None, weight='weight')[source]

Uses Yen’s algorithm to compute the k-shortest paths between a source and a target node. The shortest path is that with the lowest pathcost, defined by external path_cost() function. Paths are returned in order of path cost, with lowest past cost being first etc.

Args: - source (label): label of source node - target (label): label of destination node - num_k (int, float): number of shortest paths to compute - weight (dict key): dictionary key of value to be ‘minimised’ when finding ‘shortest’ paths

Returns: - A (list of lists): list of shortest paths between src and dst

path_cost(graph, path, weight=None)[source]

Calculates cost of path. If no weight specified, 1 unit of cost is 1 link/edge in the path

Args: - path (list): list of node labels making up path from src to dst - weight (dict key): label of weight to be considered when evaluating path cost

Returns: - pathcost (int, float): total cost of path

Module contents