pumpkin_solver

Macro predicate

source
macro_rules! predicate {
    ($($var:ident).+$([$index:expr])? >= $bound:expr) => { ... };
    ($($var:ident).+$([$index:expr])? <= $bound:expr) => { ... };
    ($($var:ident).+$([$index:expr])? == $value:expr) => { ... };
    ($($var:ident).+$([$index:expr])? != $value:expr) => { ... };
}
Expand description

A macro which allows for the creation of an IntegerPredicate.

ยงExample

let mut solver = Solver::default();
let x = solver.new_bounded_integer(0, 10);

let lower_bound_predicate = predicate!(x >= 5);
assert_eq!(
    lower_bound_predicate,
    IntegerPredicate::LowerBound {
        domain_id: x,
        lower_bound: 5
    }
    .into()
);

let upper_bound_predicate = predicate!(x <= 5);
assert_eq!(
    upper_bound_predicate,
    IntegerPredicate::UpperBound {
        domain_id: x,
        upper_bound: 5
    }
    .into()
);

let equality_predicate = predicate!(x == 5);
assert_eq!(
    equality_predicate,
    IntegerPredicate::Equal {
        domain_id: x,
        equality_constant: 5
    }
    .into()
);

let disequality_predicate = predicate!(x != 5);
assert_eq!(
    disequality_predicate,
    IntegerPredicate::NotEqual {
        domain_id: x,
        not_equal_constant: 5
    }
    .into()
);