Skip to content

Commit eea347e

Browse files
committed
better handling of time limit
1 parent f7a286c commit eea347e

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

pycona/query_generation/pqgen_solve.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class PQGenSolve(QGenBase):
1414
Dimos Tsouros, Senne Berden, and Tias Guns. "Guided Bottom-Up Interactive Constraint Acquisition." CP, 2023
1515
"""
1616

17-
def __init__(self, ca_env: ActiveCAEnv = None, *, objective_function=None, time_limit=10, blimit=5000):
17+
def __init__(self, ca_env: ActiveCAEnv = None, *, objective_function=None, time_limit=3, blimit=5000):
1818
"""
1919
Initialize the PQGen with the given parameters.
2020
@@ -83,8 +83,6 @@ def generate(self, X=None):
8383
if X is None:
8484
X = self.env.instance.X
8585
B = get_con_subset(self.env.instance.bias, X)
86-
# Start time (for the cutoff t)
87-
t0 = time.time()
8886

8987
# Project down to only vars in scope of B
9088
#Y = frozenset(get_variables(B))
@@ -132,11 +130,14 @@ def generate(self, X=None):
132130
if self.env.verbose > 2:
133131
print("Solving first without objective (to find at least one solution)...")
134132

133+
# Start time (for the cutoff t)
134+
t0 = time.time()
135135
# Solve first without objective (to find at least one solution)
136136
flag = s.solve(num_workers=8)
137137

138138
t1 = time.time() - t0
139139
if not flag or (t1 > self.time_limit):
140+
print("UNSAT or already above time_limit, stop here --- cannot optimize")
140141
# UNSAT or already above time_limit, stop here --- cannot optimize
141142
return X if flag else set()
142143

0 commit comments

Comments
 (0)