mirror of
https://github.com/Telecominfraproject/oopt-gnpy.git
synced 2025-11-03 19:47:46 +00:00
new test to check all combination of service specifications
add combination of [mode, pow, nb channel] filled or empty leading to feasible path or not, and check the propagate and propagate_and_optimize_mode functions work as expected on a reference toy example Signed-off-by: EstherLerouzic <esther.lerouzic@orange.com>
This commit is contained in:
@@ -410,7 +410,7 @@ def propagate_and_optimize_mode(path, req, equipment, show=False):
|
||||
if m['baud_rate'] == b]
|
||||
modes_to_explore = sorted(modes_to_explore,
|
||||
key = lambda x: x['bit_rate'], reverse=True)
|
||||
print(modes_to_explore)
|
||||
# print(modes_to_explore)
|
||||
# step2 : computes propagation for each baudrate: stop and select the first that passes
|
||||
found_a_feasible_mode = False
|
||||
# TODO : the case of roll of is not included: for now use SI one
|
||||
|
||||
@@ -126,6 +126,60 @@
|
||||
"cost":1
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type_variety": "Voyager",
|
||||
"frequency":{
|
||||
"min": 191.35e12,
|
||||
"max": 196.1e12
|
||||
},
|
||||
"mode":[
|
||||
{
|
||||
"format": "mode 1",
|
||||
"baud_rate": 32e9,
|
||||
"OSNR": 12,
|
||||
"bit_rate": 100e9,
|
||||
"roll_off": 0.15,
|
||||
"tx_osnr": 45,
|
||||
"cost":1
|
||||
},
|
||||
{
|
||||
"format": "mode 3",
|
||||
"baud_rate": 44e9,
|
||||
"OSNR": 18,
|
||||
"bit_rate": 300e9,
|
||||
"roll_off": 0.15,
|
||||
"tx_osnr": 45,
|
||||
"cost":1
|
||||
},
|
||||
{
|
||||
"format": "mode 2",
|
||||
"baud_rate": 66e9,
|
||||
"OSNR": 21,
|
||||
"bit_rate": 400e9,
|
||||
"roll_off": 0.15,
|
||||
"tx_osnr": 45,
|
||||
"cost":1
|
||||
},
|
||||
{
|
||||
"format": "mode 2 - fake",
|
||||
"baud_rate": 66e9,
|
||||
"OSNR": 21,
|
||||
"bit_rate": 400e9,
|
||||
"roll_off": 0.15,
|
||||
"tx_osnr": 45,
|
||||
"cost":1
|
||||
},
|
||||
{
|
||||
"format": "mode 4",
|
||||
"baud_rate": 66e9,
|
||||
"OSNR": 16,
|
||||
"bit_rate": 200e9,
|
||||
"roll_off": 0.15,
|
||||
"tx_osnr": 45,
|
||||
"cost":1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@@ -148,16 +148,16 @@
|
||||
"path-constraints": {
|
||||
"te-bandwidth": {
|
||||
"technology": "flexi-grid",
|
||||
"trx_type": "vendorA_trx-type1",
|
||||
"trx_mode": "PS_SP64_1",
|
||||
"trx_type": "Voyager",
|
||||
"trx_mode": "mode 2 - fake",
|
||||
"effective-freq-slot": [
|
||||
{
|
||||
"n": "null",
|
||||
"m": "null"
|
||||
}
|
||||
],
|
||||
"spacing": 50000000000.0,
|
||||
"max-nb-of-channel": 80,
|
||||
"spacing": 75000000000.0,
|
||||
"max-nb-of-channel": 63,
|
||||
"output-power": 0.001,
|
||||
"path_bandwidth": 300000000000.0
|
||||
}
|
||||
@@ -175,16 +175,16 @@
|
||||
"path-constraints": {
|
||||
"te-bandwidth": {
|
||||
"technology": "flexi-grid",
|
||||
"trx_type": "Voyager_16QAM",
|
||||
"trx_mode": "16QAM",
|
||||
"trx_type": "Voyager",
|
||||
"trx_mode": "mode 2",
|
||||
"effective-freq-slot": [
|
||||
{
|
||||
"n": "null",
|
||||
"m": "null"
|
||||
}
|
||||
],
|
||||
"spacing": 50000000000.0,
|
||||
"max-nb-of-channel": 80,
|
||||
"spacing": 75000000000.0,
|
||||
"max-nb-of-channel": 63,
|
||||
"output-power": 0.001,
|
||||
"path_bandwidth": 300000000000.0
|
||||
}
|
||||
@@ -245,16 +245,16 @@
|
||||
"path-constraints": {
|
||||
"te-bandwidth": {
|
||||
"technology": "flexi-grid",
|
||||
"trx_type": "vendorA_trx-type1",
|
||||
"trx_mode": "PS_SP64_1",
|
||||
"trx_type": "Voyager",
|
||||
"trx_mode": "mode 3",
|
||||
"effective-freq-slot": [
|
||||
{
|
||||
"n": "null",
|
||||
"m": "null"
|
||||
}
|
||||
],
|
||||
"spacing": 50000000000.0,
|
||||
"max-nb-of-channel": 80,
|
||||
"spacing": 62500000000.0,
|
||||
"max-nb-of-channel": 76,
|
||||
"output-power": 0.001,
|
||||
"path_bandwidth": 300000000000.0
|
||||
}
|
||||
@@ -363,6 +363,280 @@
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"request-id": "e:1# /",
|
||||
"source": "a",
|
||||
"destination": "g",
|
||||
"src-tp-id": "trx a",
|
||||
"dst-tp-id": "trx g",
|
||||
"path-constraints": {
|
||||
"te-bandwidth": {
|
||||
"technology": "flexi-grid",
|
||||
"trx_type": "Voyager_16QAM",
|
||||
"trx_mode": "16QAM",
|
||||
"effective-freq-slot": [
|
||||
{
|
||||
"n": "null",
|
||||
"m": "null"
|
||||
}
|
||||
],
|
||||
"spacing": 50000000000.0,
|
||||
"max-nb-of-channel": 80,
|
||||
"output-power": null,
|
||||
"path_bandwidth": 300000000000.0
|
||||
}
|
||||
},
|
||||
"optimizations": {
|
||||
"explicit-route-include-objects": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"request-id": "b-2a",
|
||||
"source": "a",
|
||||
"destination": "h",
|
||||
"src-tp-id": "trx a",
|
||||
"dst-tp-id": "trx h",
|
||||
"path-constraints": {
|
||||
"te-bandwidth": {
|
||||
"technology": "flexi-grid",
|
||||
"trx_type": "Voyager",
|
||||
"trx_mode": "mode 1",
|
||||
"effective-freq-slot": [
|
||||
{
|
||||
"n": "null",
|
||||
"m": "null"
|
||||
}
|
||||
],
|
||||
"spacing": 50000000000.0,
|
||||
"max-nb-of-channel": null,
|
||||
"output-power": 0.001,
|
||||
"path_bandwidth": 300000000000.0
|
||||
}
|
||||
},
|
||||
"optimizations": {
|
||||
"explicit-route-include-objects": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"request-id": "3a;?",
|
||||
"source": "f",
|
||||
"destination": "b",
|
||||
"src-tp-id": "trx f",
|
||||
"dst-tp-id": "trx b",
|
||||
"path-constraints": {
|
||||
"te-bandwidth": {
|
||||
"technology": "flexi-grid",
|
||||
"trx_type": "vendorA_trx-type1",
|
||||
"trx_mode": "PS_SP64_1",
|
||||
"effective-freq-slot": [
|
||||
{
|
||||
"n": "null",
|
||||
"m": "null"
|
||||
}
|
||||
],
|
||||
"spacing": 50000000000.0,
|
||||
"max-nb-of-channel": null,
|
||||
"output-power": null,
|
||||
"path_bandwidth": 300000000000.0
|
||||
}
|
||||
},
|
||||
"optimizations": {
|
||||
"explicit-route-include-objects": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"request-id": "ee-s",
|
||||
"source": "c",
|
||||
"destination": "f",
|
||||
"src-tp-id": "trx c",
|
||||
"dst-tp-id": "trx f",
|
||||
"path-constraints": {
|
||||
"te-bandwidth": {
|
||||
"technology": "flexi-grid",
|
||||
"trx_type": "vendorA_trx-type1",
|
||||
"trx_mode": null,
|
||||
"effective-freq-slot": [
|
||||
{
|
||||
"n": "null",
|
||||
"m": "null"
|
||||
}
|
||||
],
|
||||
"spacing": 50000000000.0,
|
||||
"max-nb-of-channel": 80,
|
||||
"output-power": 0.001,
|
||||
"path_bandwidth": 300000000000.0
|
||||
}
|
||||
},
|
||||
"optimizations": {
|
||||
"explicit-route-include-objects": [
|
||||
{
|
||||
"index": 0,
|
||||
"unnumbered-hop": {
|
||||
"node-id": "roadm e",
|
||||
"link-tp-id": "link-tp-id is not used",
|
||||
"hop-type": "loose",
|
||||
"direction": "direction is not used"
|
||||
},
|
||||
"label-hop": {
|
||||
"te-label": {
|
||||
"generic": "generic is not used",
|
||||
"direction": "direction is not used"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"index": 1,
|
||||
"unnumbered-hop": {
|
||||
"node-id": "roadm g",
|
||||
"link-tp-id": "link-tp-id is not used",
|
||||
"hop-type": "loose",
|
||||
"direction": "direction is not used"
|
||||
},
|
||||
"label-hop": {
|
||||
"te-label": {
|
||||
"generic": "generic is not used",
|
||||
"direction": "direction is not used"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"request-id": "ff-b",
|
||||
"source": "c",
|
||||
"destination": "f",
|
||||
"src-tp-id": "trx c",
|
||||
"dst-tp-id": "trx f",
|
||||
"path-constraints": {
|
||||
"te-bandwidth": {
|
||||
"technology": "flexi-grid",
|
||||
"trx_type": "Voyager",
|
||||
"trx_mode": null,
|
||||
"effective-freq-slot": [
|
||||
{
|
||||
"n": "null",
|
||||
"m": "null"
|
||||
}
|
||||
],
|
||||
"spacing": 50000000000.0,
|
||||
"max-nb-of-channel": null,
|
||||
"output-power": 0.001,
|
||||
"path_bandwidth": 300000000000.0
|
||||
}
|
||||
},
|
||||
"optimizations": {
|
||||
"explicit-route-include-objects": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"request-id": "10-z",
|
||||
"source": "a",
|
||||
"destination": "g",
|
||||
"src-tp-id": "trx a",
|
||||
"dst-tp-id": "trx g",
|
||||
"path-constraints": {
|
||||
"te-bandwidth": {
|
||||
"technology": "flexi-grid",
|
||||
"trx_type": "Voyager",
|
||||
"trx_mode": null,
|
||||
"effective-freq-slot": [
|
||||
{
|
||||
"n": "null",
|
||||
"m": "null"
|
||||
}
|
||||
],
|
||||
"spacing": 75000000000.0,
|
||||
"max-nb-of-channel": 63,
|
||||
"output-power": null,
|
||||
"path_bandwidth": 300000000000.0
|
||||
}
|
||||
},
|
||||
"optimizations": {
|
||||
"explicit-route-include-objects": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"request-id": "11 g",
|
||||
"source": "a",
|
||||
"destination": "h",
|
||||
"src-tp-id": "trx a",
|
||||
"dst-tp-id": "trx h",
|
||||
"path-constraints": {
|
||||
"te-bandwidth": {
|
||||
"technology": "flexi-grid",
|
||||
"trx_type": "Voyager",
|
||||
"trx_mode": null,
|
||||
"effective-freq-slot": [
|
||||
{
|
||||
"n": "null",
|
||||
"m": "null"
|
||||
}
|
||||
],
|
||||
"spacing": 50000000000.0,
|
||||
"max-nb-of-channel": null,
|
||||
"output-power": null,
|
||||
"path_bandwidth": 300000000000.0
|
||||
}
|
||||
},
|
||||
"optimizations": {
|
||||
"explicit-route-include-objects": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"request-id": "12<",
|
||||
"source": "f",
|
||||
"destination": "b",
|
||||
"src-tp-id": "trx f",
|
||||
"dst-tp-id": "trx b",
|
||||
"path-constraints": {
|
||||
"te-bandwidth": {
|
||||
"technology": "flexi-grid",
|
||||
"trx_type": "Voyager",
|
||||
"trx_mode": null,
|
||||
"effective-freq-slot": [
|
||||
{
|
||||
"n": "null",
|
||||
"m": "null"
|
||||
}
|
||||
],
|
||||
"spacing": 75000000000.0,
|
||||
"max-nb-of-channel": null,
|
||||
"output-power": null,
|
||||
"path_bandwidth": null
|
||||
}
|
||||
},
|
||||
"optimizations": {
|
||||
"explicit-route-include-objects": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"request-id": "12>",
|
||||
"source": "f",
|
||||
"destination": "b",
|
||||
"src-tp-id": "trx f",
|
||||
"dst-tp-id": "trx b",
|
||||
"path-constraints": {
|
||||
"te-bandwidth": {
|
||||
"technology": "flexi-grid",
|
||||
"trx_type": "Voyager",
|
||||
"trx_mode": null,
|
||||
"effective-freq-slot": [
|
||||
{
|
||||
"n": "null",
|
||||
"m": "null"
|
||||
}
|
||||
],
|
||||
"spacing": 30000000000.0,
|
||||
"max-nb-of-channel": null,
|
||||
"output-power": null,
|
||||
"path_bandwidth": null
|
||||
}
|
||||
},
|
||||
"optimizations": {
|
||||
"explicit-route-include-objects": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"synchronization": [
|
||||
|
||||
88
tests/test_automaticmodefeature.py
Normal file
88
tests/test_automaticmodefeature.py
Normal file
@@ -0,0 +1,88 @@
|
||||
#!/usr/bin/env python3
|
||||
# TelecomInfraProject/gnpy/examples
|
||||
# Module name : test_automaticmodefeature.py
|
||||
# Version :
|
||||
# License : BSD 3-Clause Licence
|
||||
# Copyright (c) 2018, Telecom Infra Project
|
||||
|
||||
"""
|
||||
@author: esther.lerouzic
|
||||
checks that empty info on mode, power, nbchannel in service file are supported
|
||||
uses combination of [mode, pow, nb channel] filled or empty defined in meshTopologyToy_services.json
|
||||
leading to feasible path or not, and check the propagate and propagate_and_optimize_mode
|
||||
return the expected based on a reference toy example
|
||||
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
import pytest
|
||||
from gnpy.core.equipment import load_equipment, trx_mode_params, automatic_nch
|
||||
from gnpy.core.network import load_network, build_network
|
||||
from examples.path_requests_run import (requests_from_json , correct_route_list ,
|
||||
load_requests , disjunctions_from_json)
|
||||
from gnpy.core.request import (compute_path_dsjctn, isdisjoint , find_reversed_path,
|
||||
propagate,propagate_and_optimize_mode)
|
||||
from gnpy.core.utils import db2lin, lin2db
|
||||
from gnpy.core.elements import Roadm
|
||||
|
||||
network_file_name = Path(__file__).parent.parent / 'tests/data/meshTopologyToy.json'
|
||||
service_file_name = Path(__file__).parent.parent / 'tests/data/meshTopologyToy_services.json'
|
||||
result_file_name = Path(__file__).parent.parent / 'tests/data/meshTopologyToy_results.json'
|
||||
eqpt_library_name = Path(__file__).parent.parent / 'tests/data/eqpt_config.json'
|
||||
|
||||
@pytest.mark.parametrize("net",[network_file_name])
|
||||
@pytest.mark.parametrize("eqpt", [eqpt_library_name])
|
||||
@pytest.mark.parametrize("serv",[service_file_name])
|
||||
@pytest.mark.parametrize("expected_mode",[['16QAM', 'PS_SP64_1', 'PS_SP64_1', 'PS_SP64_1', 'mode 2 - fake', 'mode 2', 'PS_SP64_1', 'mode 3', 'PS_SP64_1', 'PS_SP64_1', '16QAM', 'mode 1', 'PS_SP64_1', 'PS_SP64_1', 'mode 1', 'mode 3', 'mode 1', 'mode 3', 'nok']])
|
||||
def test_automaticmodefeature(net,eqpt,serv,expected_mode):
|
||||
data = load_requests(serv,eqpt)
|
||||
equipment = load_equipment(eqpt)
|
||||
network = load_network(net,equipment)
|
||||
|
||||
# Build the network once using the default power defined in SI in eqpt config
|
||||
# power density : db2linp(ower_dbm": 0)/power_dbm": 0 * nb channels as defined by
|
||||
# spacing, f_min and f_max
|
||||
p_db = equipment['SI']['default'].power_dbm
|
||||
|
||||
p_total_db = p_db + lin2db(automatic_nch(equipment['SI']['default'].f_min,\
|
||||
equipment['SI']['default'].f_max, equipment['SI']['default'].spacing))
|
||||
build_network(network, equipment, p_db, p_total_db)
|
||||
|
||||
rqs = requests_from_json(data, equipment)
|
||||
rqs = correct_route_list(network, rqs)
|
||||
dsjn = []
|
||||
pths = compute_path_dsjctn(network, equipment, rqs, dsjn)
|
||||
path_res_list = []
|
||||
|
||||
for i,pathreq in enumerate(rqs):
|
||||
|
||||
# use the power specified in requests but might be different from the one specified for design
|
||||
# the power is an optional parameter for requests definition
|
||||
# if optional, use the one defines in eqt_config.json
|
||||
p_db = lin2db(pathreq.power*1e3)
|
||||
p_total_db = p_db + lin2db(pathreq.nb_channel)
|
||||
print(f'request {pathreq.request_id}')
|
||||
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 = pths[i]
|
||||
print(f'Computed path (roadms):{[e.uid for e in total_path if isinstance(e, Roadm)]}\n')
|
||||
# for debug
|
||||
# print(f'{pathreq.baud_rate} {pathreq.power} {pathreq.spacing} {pathreq.nb_channel}')
|
||||
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)
|
||||
else:
|
||||
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
|
||||
# a warning is shown in the propagate_and_optimize_mode
|
||||
if mode is not None :
|
||||
print (mode['format'])
|
||||
path_res_list.append(mode['format'])
|
||||
else :
|
||||
print('nok')
|
||||
path_res_list.append('nok')
|
||||
print(path_res_list)
|
||||
assert path_res_list==expected_mode
|
||||
|
||||
Reference in New Issue
Block a user