mirror of
https://github.com/Telecominfraproject/oopt-gnpy.git
synced 2025-10-30 17:47:50 +00:00
small fixes on stdout
- indicate when a mode is selected if the selected path does not pass + some reformatting of columns Signed-off-by: EstherLerouzic <esther.lerouzic@orange.com>
This commit is contained in:
@@ -198,6 +198,13 @@ def compute_path_with_disjunction(network, equipment, pathreqlist, pathlist):
|
|||||||
if total_path :
|
if total_path :
|
||||||
if pathreq.baud_rate is not None:
|
if pathreq.baud_rate is not None:
|
||||||
total_path = propagate(total_path,pathreq,equipment, show=False)
|
total_path = propagate(total_path,pathreq,equipment, show=False)
|
||||||
|
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' +\
|
||||||
|
f'\tcomputedSNR in 0.1nm = {temp_snr01nm} - required osnr {pathreq.OSNR}\n'
|
||||||
|
print(msg)
|
||||||
|
logger.warning(msg)
|
||||||
|
total_path = []
|
||||||
else:
|
else:
|
||||||
total_path,mode = propagate_and_optimize_mode(total_path,pathreq,equipment, show=False)
|
total_path,mode = propagate_and_optimize_mode(total_path,pathreq,equipment, show=False)
|
||||||
# if no baudrate satisfies spacing, no mode is returned and an empty path is returned
|
# if no baudrate satisfies spacing, no mode is returned and an empty path is returned
|
||||||
@@ -340,24 +347,26 @@ if __name__ == '__main__':
|
|||||||
end = time.time()
|
end = time.time()
|
||||||
print(f'computation time {end-start}')
|
print(f'computation time {end-start}')
|
||||||
|
|
||||||
header = ['demand','snr@bandwidth','snr@0.1nm','Receiver minOSNR', 'mode', 'Gbit/s' , 'nb of tsp pairs']
|
header = ['req id', ' demand',' snr@bandwidth',' snr@0.1nm',' Receiver minOSNR', ' mode', ' Gbit/s' , ' nb of tsp pairs']
|
||||||
data = []
|
data = []
|
||||||
data.append(header)
|
data.append(header)
|
||||||
for i, p in enumerate(propagatedpths):
|
for i, p in enumerate(propagatedpths):
|
||||||
if p:
|
if p:
|
||||||
line = [f'{rqs[i].request_id} {rqs[i].source} to {rqs[i].destination} : ', f'{round(mean(p[-1].snr),2)}',\
|
line = [f'{rqs[i].request_id}', f' {rqs[i].source} to {rqs[i].destination} : ', f'{round(mean(p[-1].snr),2)}',\
|
||||||
f'{round(mean(p[-1].snr+lin2db(rqs[i].baud_rate/(12.5e9))),2)}',\
|
f'{round(mean(p[-1].snr+lin2db(rqs[i].baud_rate/(12.5e9))),2)}',\
|
||||||
f'{rqs[i].OSNR}', f'{rqs[i].tsp_mode}' , f'{round(rqs[i].path_bandwidth * 1e-9,2)}' , f'{ceil(rqs[i].path_bandwidth / rqs[i].bit_rate) }']
|
f'{rqs[i].OSNR}', f'{rqs[i].tsp_mode}' , f'{round(rqs[i].path_bandwidth * 1e-9,2)}' , f'{ceil(rqs[i].path_bandwidth / rqs[i].bit_rate) }']
|
||||||
else:
|
else:
|
||||||
line = [f'{rqs[i].request_id} no path from {rqs[i].source} to {rqs[i].destination} ']
|
line = [f'{rqs[i].request_id}',f' {rqs[i].source} to {rqs[i].destination} : not feasible ']
|
||||||
data.append(line)
|
data.append(line)
|
||||||
|
|
||||||
col_width = max(len(word) for row in data for word in row[1:]) # padding
|
col_width = max(len(word) for row in data for word in row[2:]) # padding
|
||||||
firstcol_width = max(len(row[0]) for row in data ) # padding
|
firstcol_width = max(len(row[0]) for row in data ) # padding
|
||||||
|
secondcol_width = max(len(row[1]) for row in data ) # padding
|
||||||
for row in data:
|
for row in data:
|
||||||
firstcol = ''.join(row[0].ljust(firstcol_width))
|
firstcol = ''.join(row[0].ljust(firstcol_width))
|
||||||
remainingcols = ''.join(word.ljust(col_width) for word in row[1:])
|
secondcol = ''.join(row[1].ljust(secondcol_width))
|
||||||
print(f'{firstcol} {remainingcols}')
|
remainingcols = ''.join(word.center(col_width,' ') for word in row[2:])
|
||||||
|
print(f'{firstcol} {secondcol} {remainingcols}')
|
||||||
|
|
||||||
|
|
||||||
if args.output :
|
if args.output :
|
||||||
|
|||||||
@@ -433,13 +433,13 @@ def propagate_and_optimize_mode(path, req, equipment, show=False):
|
|||||||
# only get to this point if no baudrate/mode satisfies OSNR requirement
|
# only get to this point if no baudrate/mode satisfies OSNR requirement
|
||||||
|
|
||||||
# returns the last propagated path and mode
|
# returns the last propagated path and mode
|
||||||
msg = f'Warning! Request {req.request_id}: no mode satisfies path SNR requirement.\n'
|
msg = f'\tWarning! Request {req.request_id}: no mode satisfies path SNR requirement.\n'
|
||||||
print(msg)
|
print(msg)
|
||||||
logger.info(msg)
|
logger.info(msg)
|
||||||
return [],None
|
return [],None
|
||||||
else :
|
else :
|
||||||
# no baudrate satisfying spacing
|
# no baudrate satisfying spacing
|
||||||
msg = f'Warning! Request {req.request_id}: no baudrate satisfies spacing requirement.\n'
|
msg = f'\tWarning! Request {req.request_id}: no baudrate satisfies spacing requirement.\n'
|
||||||
print(msg)
|
print(msg)
|
||||||
logger.info(msg)
|
logger.info(msg)
|
||||||
return [], None
|
return [], None
|
||||||
|
|||||||
Reference in New Issue
Block a user