Skip to content

Commit

Permalink
[CP-SAT] fix diffn cut; more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lperron committed Jan 29, 2025
1 parent 9a77900 commit 446f853
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ortools/sat/diffn_cuts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,8 @@ CutGenerator CreateNoOverlap2dEnergyCutGenerator(
rectangles.reserve(num_rectangles);
for (const auto& component :
helper->connected_components().AsVectorOfSpan()) {
rectangles.clear();
for (const int rect : component) {
rectangles.clear();
if (helper->IsAbsent(rect)) continue;
// We do not consider rectangles controlled by 2 different unassigned
// enforcement literals.
Expand Down
6 changes: 6 additions & 0 deletions ortools/sat/python/cp_model_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1940,6 +1940,7 @@ def test_small_series(self) -> None:
model = cp_model.CpModel()
x = model.new_bool_var("foo")
y = model.new_bool_var("bar")
z = model.new_bool_var("baz")

s1 = pd.Series([x, y], index=[1, 2])
self.assertEqual(str(s1.sum()), "(foo + bar)")
Expand All @@ -1951,6 +1952,11 @@ def test_small_series(self) -> None:
s4 = pd.Series([1], index=[1])
self.assertIs(s3.dot(s4), x)

s5 = pd.Series([x, y, z], index=[1, 2, 3])
self.assertEqual(str(s5.sum()), "(foo + bar + baz)")
s6 = pd.Series([1, -2, 1], index=[1, 2, 3])
self.assertEqual(str(s5.dot(s6)), "(foo + (-2 * bar) + baz)")

def test_issue4376_sat_model(self) -> None:
letters: str = "BCFLMRT"

Expand Down

0 comments on commit 446f853

Please sign in to comment.