Skip to content

Commit df853ad

Browse files
Using new safe sequence computation also for DAGs
1 parent 7510841 commit df853ad

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

examples/inexact_flow_solver.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,7 @@ def get_solution(self):
129129
if self._solution is not None:
130130
return self._solution
131131

132-
solution_weights_dict = self.solver.get_variable_values("w", [int])
133-
# solution_weights_dict = self.solver.get_values(self.path_weights_vars)
132+
solution_weights_dict = self.solver.get_values(self.path_weights_vars)
134133
self._solution = {
135134
"paths": self.get_solution_paths(),
136135
"weights": [solution_weights_dict[i] for i in range(self.k)],

flowpaths/abstractpathmodeldag.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import flowpaths.stdag as stdag
22
from flowpaths.utils import safetypathcovers
3+
from flowpaths.utils import safetypathcoverscycles
34
from flowpaths.utils import solverwrapper as sw
45
import flowpaths.utils as utils
56
import time
@@ -248,11 +249,15 @@ def __init__(
248249

249250
if self.optimize_with_safe_sequences and not self.is_solved():
250251
start_time = time.perf_counter()
251-
self.safe_lists += safetypathcovers.safe_sequences(
252+
# self.safe_lists += safetypathcovers.safe_sequences(
253+
# G=self.G,
254+
# edges_or_subpath_constraints_to_cover=self.trusted_edges_for_safety,
255+
# no_duplicates=False,
256+
# threads=self.threads,
257+
# )
258+
self.safe_lists += safetypathcoverscycles.maximal_safe_sequences_via_dominators(
252259
G=self.G,
253-
edges_or_subpath_constraints_to_cover=self.trusted_edges_for_safety,
254-
no_duplicates=False,
255-
threads=self.threads,
260+
X=self.trusted_edges_for_safety,
256261
)
257262
self.solve_statistics["safe_sequences_time"] = time.perf_counter() - start_time
258263

flowpaths/utils/safetypathcoverscycles.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import flowpaths.stdigraph as stdigraph
2+
import flowpaths.stdag as stdag
3+
import flowpaths.abstractsourcesinkgraph as abssg
24
import flowpaths.utils.dominators as dominators
35
from queue import Queue
46

@@ -69,7 +71,7 @@ def find_idom(adj_dict, s, t) -> list:
6971

7072
return first_bridge
7173

72-
def maximal_safe_sequences_via_dominators(G : stdigraph.stDiGraph, X = set()) -> list :
74+
def maximal_safe_sequences_via_dominators(G : abssg.AbstractSourceSinkGraph, X = set()) -> list :
7375

7476
if X == None or len(X) == 0:
7577
return []

0 commit comments

Comments
 (0)