macro_rules! constraint {
(($lhs:expr) <= $rhs:expr) => { ... };
(($lhs:expr) >= $rhs:expr) => { ... };
(($lhs:expr) == $rhs:expr) => { ... };
($lhs:ident <= $rhs:expr) => { ... };
($lhs:ident >= $rhs:expr) => { ... };
($lhs:ident == $rhs:expr) => { ... };
}Expand description
Build a Constraint using natural inequality syntax.
§Examples
use otspot_model::{Model, constraint};
let mut model = Model::new("demo");
let x = model.add_var("x", 0.0, f64::INFINITY);
let y = model.add_var("y", 0.0, 10.0);
model.add_constraint(constraint!((2.0 * x + 3.0 * y) <= 12.0));
model.add_constraint(constraint!((x + y) >= 3.0));Build a Constraint using natural inequality syntax.
Supported forms:
constraint!(x <= 5.0)— single variable on the leftconstraint!((expr) <= rhs)— parenthesised expression on the left
For complex LHS expressions, wrap them in parentheses:
model.add_constraint(constraint!((2.0 * x + 3.0 * y) <= 12.0));or use the method API directly:
model.add_constraint((2.0 * x + 3.0 * y).leq(12.0));