From 8107ddeb79744266cbbe2d67daff77ff9824d3a4 Mon Sep 17 00:00:00 2001 From: EstherLerouzic Date: Fri, 6 Sep 2019 18:31:27 +0100 Subject: [PATCH] Change the processing of blocking case in main program In compute_path_with_disjunction, and in case user mode is not feasible returns the blocking reason instead of an empty path. If the user does not give the mode and the automatic selection does not give any feasible mode instead of checking if a mode exists, the function now checks the presence of a blocking reason. if the blocking reason is among BLOCKING_NOPATH reasons, than an empty path is returned if the blocking reason is among BLOCKING_NOMODE, then a path could be computed and the mode information correspond to the last explored mode. Signed-off-by: EstherLerouzic --- examples/path_requests_run.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/examples/path_requests_run.py b/examples/path_requests_run.py index 2ad533ac..320aae01 100755 --- a/examples/path_requests_run.py +++ b/examples/path_requests_run.py @@ -178,8 +178,8 @@ def compute_path_with_disjunction(network, equipment, pathreqlist, pathlist): # print(f'{pathreq.baud_rate} {pathreq.power} {pathreq.spacing} {pathreq.nb_channel}') if total_path : if pathreq.baud_rate is not None: + # means that at this point the mode was entered/forced by user and thus a baud_rate was defined total_path = propagate(total_path,pathreq,equipment) - # for el in total_path: print(el) temp_snr01nm = round(mean(total_path[-1].snr+lin2db(pathreq.baud_rate/(12.5e9))),2) if temp_snr01nm < pathreq.OSNR : msg = f'\tWarning! Request {pathreq.request_id} computed path from {pathreq.source} to {pathreq.destination} does not pass with {pathreq.tsp_mode}\n' +\ @@ -191,17 +191,27 @@ def compute_path_with_disjunction(network, equipment, pathreqlist, pathlist): total_path,mode = propagate_and_optimize_mode(total_path,pathreq,equipment) # if no baudrate satisfies spacing, no mode is returned and an empty path is returned # a warning is shown in the propagate_and_optimize_mode - if mode is not None : - # propagate_and_optimize_mode function returns the mode with the highest bitrate - # that passes. if no mode passes, then it returns an empty path + # propagate_and_optimize_mode function returns the mode with the highest bitrate + # that passes. if no mode passes, then a attribute blocking_reason is added on pathreq + # that contains the reason for blocking: 'NO_PATH', 'NO_FEASIBLE_MODE', ... + try: + if pathreq.blocking_reason in BLOCKING_NOPATH: + total_path = [] + elif pathreq.blocking_reason in BLOCKING_NOMODE : + pathreq.baud_rate = mode['baud_rate'] + pathreq.tsp_mode = mode['format'] + pathreq.format = mode['format'] + pathreq.OSNR = mode['OSNR'] + pathreq.tx_osnr = mode['tx_osnr'] + pathreq.bit_rate = mode['bit_rate'] + # other blocking reason should not appear at this point + except: pathreq.baud_rate = mode['baud_rate'] pathreq.tsp_mode = mode['format'] pathreq.format = mode['format'] pathreq.OSNR = mode['OSNR'] pathreq.tx_osnr = mode['tx_osnr'] pathreq.bit_rate = mode['bit_rate'] - else : - total_path = [] # we record the last tranceiver object in order to have th whole # information about spectrum. Important Note: since transceivers # attached to roadms are actually logical elements to simulate