Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion pumpkin-crates/core/src/constraints/arithmetic/inequality.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub fn greater_than<Var: IntegerVariable + 'static>(
rhs: i32,
constraint_tag: ConstraintTag,
) -> impl NegatableConstraint {
greater_than_or_equals(terms, rhs - 1, constraint_tag)
greater_than_or_equals(terms, rhs + 1, constraint_tag)
}

/// Create the [`NegatableConstraint`] `\sum terms_i >= rhs`.
Expand Down Expand Up @@ -140,3 +140,38 @@ impl<Var: IntegerVariable + 'static> NegatableConstraint for Inequality<Var> {
}
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn less_than_conflict() {
let mut solver = Solver::default();

let constraint_tag = solver.new_constraint_tag();
let x = solver.new_named_bounded_integer(0, 0, "x");

let result = less_than([x], 0, constraint_tag).post(&mut solver);
assert_eq!(
result,
Err(ConstraintOperationError::InfeasiblePropagator),
"Expected {result:?} to be an `InfeasiblePropagator` error"
);
}

#[test]
fn greater_than_conflict() {
let mut solver = Solver::default();

let constraint_tag = solver.new_constraint_tag();
let x = solver.new_named_bounded_integer(0, 0, "x");

let result = greater_than([x], 0, constraint_tag).post(&mut solver);
assert_eq!(
result,
Err(ConstraintOperationError::InfeasiblePropagator),
"Expected {result:?} to be an `InfeasiblePropagator` error"
);
}
}
Loading