Skip to content

Commit b62b958

Browse files
Copilotmballance
andcommitted
Fix IndexError in variable bound propagators during unsolvable constraint solving
Co-authored-by: mballance <1340805+mballance@users.noreply.github.com>
1 parent 9f2a932 commit b62b958

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/vsc/model/variable_bound_max_propagator.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ def propagate(self):
3434
must_propagate = False
3535
if i >= 0:
3636
# print("i: " + str(i) + " " + str(self.target.domain.range_l[i][0]))
37-
if range_l[i][1] > max_v:
37+
# Check if range_l is not empty before accessing
38+
if len(range_l) > i and range_l[i][1] > max_v:
3839
range_l[i][1] = max_v
3940
must_propagate = True
4041

@@ -43,6 +44,7 @@ def propagate(self):
4344
must_propagate = True
4445
# print("Removing domain element " + str(range_l[i+1]))
4546
self.target.domain.range_l = range_l[:i+1]
47+
range_l = self.target.domain.range_l # Update local reference
4648
else:
4749
# print("ran off the end")
4850
pass

src/vsc/model/variable_bound_min_propagator.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ def propagate(self):
3737
# Need to trim off full range elements
3838
must_propagate = True
3939
self.target.domain.range_l = range_l[i:]
40+
range_l = self.target.domain.range_l # Update local reference
4041

41-
if min_v > range_l[0][0]:
42+
# Check if range_l is not empty before accessing
43+
if len(range_l) > 0 and min_v > range_l[0][0]:
4244
range_l[0][0] = min_v
4345
must_propagate = True
4446
else:

0 commit comments

Comments
 (0)