Skip to content

Commit aede912

Browse files
Fix logic in Engine's conflict resolution and update undo method visibility
1 parent c33cc99 commit aede912

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,15 +276,15 @@ impl Engine {
276276
counter += 1;
277277
} else {
278278
// This literal comes from a previous decision level
279-
self.learnt.push(!lit);
279+
self.learnt.push(lit.clone());
280280
}
281281
}
282282
}
283283

284284
// 2. Find the next variable from the trail assigned at this level
285285
p = loop {
286286
let v = self.propagated_vars.pop().expect("There should be a variable to resolve away");
287-
if !self.seen[v] {
287+
if self.seen[v] {
288288
let sign = self.value(v) == &LBool::True;
289289
let reason = self.reason[v].expect("There should be a reason clause for this variable");
290290
self.undo(v);
@@ -313,7 +313,7 @@ impl Engine {
313313
self.undo(self.decision_var);
314314
}
315315

316-
fn undo(&mut self, var: usize) {
316+
pub fn undo(&mut self, var: usize) {
317317
self.assigns[var] = LBool::Undef;
318318
self.reason[var] = None;
319319
self.decision_vars[var] = None;
@@ -525,7 +525,7 @@ mod tests {
525525
engine.assert(neg(x1));
526526

527527
let explanation = engine.get_conflict_explanation().expect("There should be a conflict explanation");
528-
let expected_explanation = vec![neg(x4), pos(x8), pos(x9)];
528+
let expected_explanation = vec![neg(x4), pos(x9), pos(x8)];
529529
assert_eq!(explanation, expected_explanation, "Conflict explanation should match expected");
530530
}
531531
}

0 commit comments

Comments
 (0)