mirror of
https://github.com/Telecominfraproject/oopt-gnpy.git
synced 2025-10-30 01:32:21 +00:00
Refactor step4 of the compute_path_dsjctn
Previous implementation selected last candidate in case both routing and disjunction constraints could not be applied. The new implementation elaborates an alternate list where each feasible paths satisfyng disjunction constraint but not route constraint is recorded. The algorithm then preferably selects a feasible path that satisfies all constraints and if none is found and route constraint is LOOSE, the first set of paths that satisfy disjunction is selected (instead of the last one). Signed-off-by: EstherLerouzic <esther.lerouzic@orange.com> Change-Id: Iba44397d105006a98539494d821cc83dc3e3bbd9
This commit is contained in:
@@ -788,33 +788,34 @@ def compute_path_dsjctn(network, equipment, pathreqlist, disjunctions_list):
|
||||
# TODO: keep a version without the loose constraint
|
||||
for this_d in disjunctions_list:
|
||||
temp = []
|
||||
alternatetemp = []
|
||||
for j, sol in enumerate(candidates[this_d.disjunction_id]):
|
||||
testispartok = True
|
||||
testispartnokloose = True
|
||||
for pth in sol:
|
||||
# print(f'test {allpaths[id(pth)].req.request_id}')
|
||||
# print(f'length of route {len(allpaths[id(pth)].req.nodes_list)}')
|
||||
if allpaths[id(pth)].req.nodes_list:
|
||||
# if pth does not containt the ordered list node, remove sol from the candidate
|
||||
# except if this was the last solution: then check if the constraint is loose
|
||||
# or not
|
||||
# if any pth from sol does not contain the ordered list node,
|
||||
# remove sol from the candidate, except if constraint was loose:
|
||||
# then keep sol as an alternate solution
|
||||
if not ispart(allpaths[id(pth)].req.nodes_list, pth):
|
||||
# print(f'nb of solutions {len(temp)}')
|
||||
if j < len(candidates[this_d.disjunction_id]) - 1:
|
||||
msg = f'removing {sol}'
|
||||
LOGGER.info(msg)
|
||||
testispartok = False
|
||||
# break
|
||||
else:
|
||||
if 'LOOSE' in allpaths[id(pth)].req.loose_list:
|
||||
LOGGER.info(f'Could not apply route constraint' +
|
||||
f'{allpaths[id(pth)].req.nodes_list} on request' +
|
||||
f' {allpaths[id(pth)].req.request_id}')
|
||||
else:
|
||||
LOGGER.info(f'removing last solution from candidate paths\n{sol}')
|
||||
testispartok = False
|
||||
testispartok = False
|
||||
if 'STRICT' in allpaths[id(pth)].req.loose_list:
|
||||
LOGGER.info(f'removing solution from candidate paths\n{pth}')
|
||||
testispartnokloose = False
|
||||
break
|
||||
if testispartok:
|
||||
temp.append(sol)
|
||||
candidates[this_d.disjunction_id] = temp
|
||||
elif testispartnokloose:
|
||||
LOGGER.info(f'Adding solution as alternate solution not satisfying constraint\n{pth}')
|
||||
alternatetemp.append(sol)
|
||||
if temp:
|
||||
candidates[this_d.disjunction_id] = temp
|
||||
elif alternatetemp:
|
||||
candidates[this_d.disjunction_id] = alternatetemp
|
||||
else:
|
||||
candidates[this_d.disjunction_id] = []
|
||||
|
||||
# step 5 select the first combination that works
|
||||
pathreslist_disjoint = {}
|
||||
|
||||
Reference in New Issue
Block a user