Skip to content

Commit 61257ac

Browse files
committed
Testing out models
1 parent dcaa223 commit 61257ac

File tree

6 files changed

+852
-1
lines changed

6 files changed

+852
-1
lines changed

pumpkin-py/examples/testing.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from pumpkin_py import Model, constraints, Comparator
2+
3+
model = Model()
4+
5+
iv = model.new_integer_variable(0,1)
6+
a = model.new_boolean_variable(name="a")
7+
b = model.new_boolean_variable(name="b")
8+
c = model.new_boolean_variable(name="c")
9+
10+
model.add_constraint(constraints.Clause([a, b])) # a \/ b
11+
model.add_constraint(constraints.Clause([b.negate(),c])) # b -> c
12+
model.add_constraint(constraints.Clause([model.predicate_as_boolean(iv, Comparator.Equal, 1)])) # iv == 1
13+
model.add_implication(constraints.Equals([iv], 0), c) # c -> iv == 0
14+
15+
model.satisfy(proof="test")

pumpkin-py/test

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
i 1 -1
2+
n 2 1 0 1
3+
i 3 1 2
4+
n 4 -2 0 2 3
5+
i 5 -2 -3
6+
n 6 3 0 4 5
7+
i 7 3 -4
8+
n 8 4 0 6 7
9+
i 9 4 5
10+
n 10 -5 0 8 9

pumpkin-py/test.drcp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
i 1 1 2
2+
i 2 4 0 -3
3+
i 3 4 0 -5
4+
i 4 4 0 -6
5+
i 5 4 0 -7
6+
n 6 -8 0 5 4 3 2 1
7+
i 7 9 1
8+
i 8 1 0 -10
9+
n 9 11 0 8 6 7
10+
i 10 9 7
11+
i 11 9 0 -5
12+
n 12 -12 0 6 11 9 10
13+
i 13 10 3
14+
n 14 -3 0 12 13
15+
i 15 10 5
16+
n 16 -5 0 12 15
17+
i 17 10 6
18+
n 18 -6 0 12 17
19+
i 19 7 2
20+
i 20 10 0 -6
21+
i 21 10 0 -5
22+
i 22 10 0 -3
23+
n 23 0 9 12 22 21 20 19
24+
c UNSAT

pumpkin-py/test.lits

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
8 [q0 <= 0]
2+
7 [q1 == 0]
3+
10 [q0 == 2]
4+
2 [q2 == 1]
5+
4 [q0 == 0]
6+
5 [q1 == 1]
7+
3 [q2 == 2]
8+
9 [q0 == 1]
9+
6 [q2 == 0]
10+
1 [q1 == 2]
11+
11 [q1 <= 1]
12+
12 [q0 <= 1]

pumpkin-solver/src/engine/constraint_satisfaction_solver.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1336,7 +1336,20 @@ impl ConstraintSatisfactionSolver {
13361336
continue;
13371337
}
13381338

1339-
if let Some(step_id) = self.unit_nogood_step_ids.get(&trail_entry.predicate) {
1339+
if let Some(step_id) = self
1340+
.unit_nogood_step_ids
1341+
.get(&trail_entry.predicate)
1342+
.or_else(|| {
1343+
// It could be the case that we attempt to get the reason for the predicate
1344+
// [x >= v] but that the corresponding unit nogood idea is the one for the
1345+
// predicate [x == v]
1346+
let domain_id = trail_entry.predicate.get_domain();
1347+
let right_hand_side = trail_entry.predicate.get_right_hand_side();
1348+
1349+
self.unit_nogood_step_ids
1350+
.get(&predicate!(domain_id == right_hand_side))
1351+
})
1352+
{
13401353
self.internal_parameters.proof_log.add_propagation(*step_id);
13411354
} else {
13421355
panic!(

0 commit comments

Comments
 (0)