-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #299 from jktjkt/cleanup-printing
(This replaces #261 by me and #293 by Jonas.) ## 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 ## doc: fiber length summary in km, not meters Reading `80000m` is a bit more complex than just `80 km`. Also let's add a space between the numebr and the unit for better readability. ## examples: color highlighting of the "most interesting output" I think that this SNR value represents the most important output of this example. There's plenty of debugging info on display already, so let's make this one more prominent. I was thinking about moving the highlighting to elements' each `__str__()` function, but that felt a bit like layering violation to me. I could have also changed just the transponder's `__str__()`. In the end, I think that repeating just the final GSNR at the link-end transponder makes most sense here. This is aligned with what we talked about at yesterday's (on 2019-09-18 -- note that this is a backport from #261) demo for Microsoft, after all.
- Loading branch information
Showing
5 changed files
with
17 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,6 @@ | |
from copy import copy, deepcopy | ||
from textwrap import dedent | ||
from math import ceil | ||
import time | ||
|
||
#EQPT_LIBRARY_FILENAME = Path(__file__).parent / 'eqpt_config.json' | ||
|
||
|
@@ -144,44 +143,6 @@ def load_requests(filename,eqpt_filename): | |
json_data = loads(f.read()) | ||
return json_data | ||
|
||
def compute_path(network, equipment, pathreqlist): | ||
|
||
# This function is obsolete and not relevant with respect to network building: suggest either to correct | ||
# or to suppress it | ||
|
||
path_res_list = [] | ||
|
||
for pathreq in pathreqlist: | ||
#need to rebuid the network for each path because the total power | ||
#can be different and the choice of amplifiers in autodesign is power dependant | ||
#but the design is the same if the total power is the same | ||
#TODO parametrize the total spectrum power so the same design can be shared | ||
p_db = lin2db(pathreq.power*1e3) | ||
p_total_db = p_db + lin2db(pathreq.nb_channel) | ||
build_network(network, equipment, p_db, p_total_db) | ||
pathreq.nodes_list.append(pathreq.destination) | ||
#we assume that the destination is a strict constraint | ||
pathreq.loose_list.append('strict') | ||
print(f'Computing path from {pathreq.source} to {pathreq.destination}') | ||
print(f'with path constraint: {[pathreq.source]+pathreq.nodes_list}') #adding first node to be clearer on the output | ||
total_path = compute_constrained_path(network, pathreq) | ||
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) | ||
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 | ||
# performance, several demands having the same destination may use | ||
# the same transponder for the performance simaulation. This is why | ||
# we use deepcopy: to ensure each propagation is recorded and not | ||
# overwritten | ||
|
||
path_res_list.append(deepcopy(total_path)) | ||
return path_res_list | ||
|
||
def compute_path_with_disjunction(network, equipment, pathreqlist, pathlist): | ||
|
||
# use a list but a dictionnary might be helpful to find path bathsed on request_id | ||
|
@@ -205,7 +166,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: | ||
total_path = propagate(total_path,pathreq,equipment, show=False) | ||
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' +\ | ||
|
@@ -301,7 +263,6 @@ def path_result_json(pathresult): | |
|
||
|
||
if __name__ == '__main__': | ||
start = time.time() | ||
args = parser.parse_args() | ||
basicConfig(level={2: DEBUG, 1: INFO, 0: CRITICAL}.get(args.verbose, DEBUG)) | ||
logger.info(f'Computing path requests {args.service_filename} into JSON format') | ||
|
@@ -369,8 +330,6 @@ def path_result_json(pathresult): | |
print('\x1b[1;34;40m'+f'Propagating on selected path'+ '\x1b[0m') | ||
propagatedpths = compute_path_with_disjunction(network, equipment, rqs, pths) | ||
|
||
end = time.time() | ||
print(f'computation time {end-start}') | ||
print('\x1b[1;34;40m'+f'Result summary'+ '\x1b[0m') | ||
|
||
header = ['req id', ' demand',' snr@bandwidth',' [email protected]',' Receiver minOSNR', ' mode', ' Gbit/s' , ' nb of tsp pairs'] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,5 @@ | |
''' | ||
|
||
red = '\x1b[1;31;40m' | ||
cyan = '\x1b[1;36;40m' | ||
reset = '\x1b[0m' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters