Remove debug printing from propagate()

This is inspired by #293. The original issue was that the transponder
OSNR was not accounted for. Rather than making the propagate() and
propagate2() more complex, let's move the actual path printing to the
demo code. There's no secret sauce in there, it's just a simple
for-each-print thingy, so let's remove it from the library code.

fixes #262
This commit is contained in:
Jan Kundrát
2019-09-18 20:04:17 +02:00
parent 325721545e
commit acafc78456
4 changed files with 10 additions and 13 deletions

View File

@@ -168,7 +168,7 @@ def compute_path(network, equipment, pathreqlist):
print(f'Computed path (roadms):{[e.uid for e in total_path if isinstance(e, Roadm)]}\n')
if total_path :
total_path = propagate(total_path,pathreq,equipment, show=False)
total_path = propagate(total_path,pathreq,equipment)
else:
total_path = []
# we record the last tranceiver object in order to have th whole
@@ -205,7 +205,7 @@ 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:
total_path = propagate(total_path,pathreq,equipment, show=False)
total_path = propagate(total_path,pathreq,equipment)
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' +\

View File

@@ -153,7 +153,10 @@ def main(network, equipment, source, destination, sim_params, req=None):
print(f'\nPropagating with input power = {lin2db(req.power*1e3):.2f}dBm :')
else:
print(f'\nPropagating in gain mode: power cannot be set manually')
infos = propagate2(path, req, equipment, show=len(power_range)==1)
infos = propagate2(path, req, equipment)
if len(power_range) == 1:
for elem in path[:-1]:
print(elem)
if power_mode:
print(f'\nTransmission result for input power = {lin2db(req.power*1e3):.2f}dBm :')
else:

View File

@@ -393,18 +393,16 @@ def compute_constrained_path(network, req):
return total_path
def propagate(path, req, equipment, show=False):
def propagate(path, req, equipment):
si = create_input_spectral_information(
req.f_min, req.f_max, req.roll_off, req.baud_rate,
req.power, req.spacing)
for el in path:
si = el(si)
if show :
print(el)
path[-1].update_snr(req.tx_osnr, equipment['Roadm']['default'].add_drop_osnr)
return path
def propagate2(path, req, equipment, show=False):
def propagate2(path, req, equipment):
si = create_input_spectral_information(
req.f_min, req.f_max, req.roll_off, req.baud_rate,
req.power, req.spacing)
@@ -413,12 +411,10 @@ def propagate2(path, req, equipment, show=False):
before_si = si
after_si = si = el(si)
infos[el] = before_si, after_si
if show :
print(el)
path[-1].update_snr(req.tx_osnr, equipment['Roadm']['default'].add_drop_osnr)
return infos
def propagate_and_optimize_mode(path, req, equipment, show=False):
def propagate_and_optimize_mode(path, req, equipment):
# if mode is unknown : loops on the modes starting from the highest baudrate fiting in the
# step 1: create an ordered list of modes based on baudrate
baudrate_to_explore = list(set([m['baud_rate'] for m in equipment['Transceiver'][req.tsp].mode
@@ -442,8 +438,6 @@ def propagate_and_optimize_mode(path, req, equipment, show=False):
b, req.power, req.spacing)
for el in path:
si = el(si)
if show:
print(el)
for m in modes_to_explore :
if path[-1].snr is not None:
path[-1].update_snr(m['tx_osnr'], equipment['Roadm']['default'].add_drop_osnr)

View File

@@ -72,7 +72,7 @@ def test_automaticmodefeature(net,eqpt,serv,expected_mode):
if pathreq.baud_rate is not None:
print(pathreq.format)
path_res_list.append(pathreq.format)
total_path = propagate(total_path,pathreq,equipment, show=False)
total_path = propagate(total_path,pathreq,equipment)
else:
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