Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add domains in path breakdowns #111

Merged
merged 8 commits into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions src/sdx/pce/load_balancing/te_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,19 +427,18 @@ def _lhsbw(self, request_list, inputmatrix):
count = 0

for request in request_list:
print(
f"bwconstraints: {bwconstraints}, request: {request}, request_list: {request_list}"
)
print(
f"i: {i}, count: {count} len(inputmatrix[0]): {len(inputmatrix[0])}, inputmatrix: {inputmatrix}"
)
print(
f"i + count * len(inputmatrix[0]: {i + count * len(inputmatrix[0])}"
)

bwconstraints[i][
i + count * len(inputmatrix[0])
] = request.required_bandwidth
# print(
# f"bwconstraints: {bwconstraints}, request: {request}, request_list: {request_list}"
# )
# print(
# f"i: {i}, count: {count} len(inputmatrix[0]): {len(inputmatrix[0])}, inputmatrix: {inputmatrix}"
# )
# print(
# f"i + count * len(inputmatrix[0]: {i + count * len(inputmatrix[0])}"
# )

k = i + count * len(inputmatrix[0])
bwconstraints[i][k] = request.required_bandwidth
count += 1

return bwconstraints
Expand Down
16 changes: 13 additions & 3 deletions src/sdx/pce/topology/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,22 @@ def add_topology(self, data):
self.update_timestamp()

def get_domain_name(self, node_id):
"""
Find the topology ID associated with the given node ID.

A topology ID is expected to be of the format
"urn:ogf:network:sdx:topology:amlight.net", and from this, we
can find the domain name associated with the topology.

TODO: This function name may be a misnomer?
"""
domain_id = None
# print("len of topology_list:"+str(len(self.topology_list)))
for id, topology in self.topology_list.items():
# print(f"len of topology_list: {len(self.topology_list)}")
for topology_id, topology in self.topology_list.items():
if topology.has_node_by_id(node_id):
domain_id = id
domain_id = topology_id
break

return domain_id

def generate_id(self):
Expand Down
4 changes: 1 addition & 3 deletions src/sdx/pce/topology/temanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ def __init__(self, topology_data, connection_data):
self.topology_manager = TopologyManager()
self.connection_handler = ConnectionHandler()

self.topology_manager.topology = (
self.topology_manager.get_handler().import_topology_data(topology_data)
)
self.topology_manager.add_topology(topology_data)

print(f"TEManager: connection_data: {connection_data}")

Expand Down
32 changes: 27 additions & 5 deletions tests/test_te_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ def test_connection_breakdown_tm(self):
self.assertIsInstance(breakdown, dict)
self.assertEqual(len(breakdown), 1)

# Make sure that breakdown contains domains as keys, and dicts
# as values. The domain name is a little goofy, because the
# topology we have is goofy.
link = breakdown.get("urn:ogf:network:sdx")
self.assertIsInstance(link, dict)

def test_connection_breakdown_two_similar_requests(self):
# Solving and breaking down two similar connection requests.
request = [
Expand Down Expand Up @@ -135,7 +141,7 @@ def test_connection_breakdown_three_domains(self):

self.assertIsNotNone(breakdown)
self.assertIsInstance(breakdown, dict)
self.assertEqual(len(breakdown), 2)
self.assertEqual(len(breakdown), 1)

def test_connection_breakdown_some_input(self):
# The set of requests below should fail to find a solution,
Expand Down Expand Up @@ -206,10 +212,26 @@ def test_generate_graph_and_connection_with_sax_2_valid(self):
self.assertIsNotNone(graph)
self.assertIsInstance(graph, nx.Graph)

connection = temanager.generate_connection_te()
print(f"connection request: {connection}")
self.assertIsNotNone(connection)
self.assertIsInstance(connection, TrafficMatrix)
tm = temanager.generate_connection_te()
print(f"traffic matrix: {tm}")
self.assertIsInstance(tm, TrafficMatrix)

self.assertIsInstance(tm.connection_requests, list)

for request in tm.connection_requests:
self.assertEqual(request.source, 1)
self.assertEqual(request.destination, 0)
self.assertEqual(request.required_bandwidth, 0)
self.assertEqual(request.required_latency, 0)

solver = TESolver(graph, tm)
self.assertIsNotNone(solver)

# Solver will fail to find a solution here.
solution = solver.solve()
print(f"Solution to tm {tm}: {solution}")
self.assertIsNone(solution.connection_map, None)
self.assertEqual(solution.cost, 0.0)

def test_generate_graph_and_connection(self):
graph = self.temanager.generate_graph_te()
Expand Down