Macro lp_modeler::constraint[][src]

macro_rules! constraint {
    ([$($left:tt)*] <= $($right:tt)*) => { ... };
    ([$($left:tt)*] >= $($right:tt)*) => { ... };
    ([$($left:tt)*]) => { ... };
    ([$($left:tt)*] $next:tt $($right:tt)*) => { ... };
    ($($all:tt)*) => { ... };
}

This macro allows defining constraints using ‘expression1 <= expression2’ instead of expression1.le(expression2).

Example:

use lp_modeler::dsl::*;
use lp_modeler::constraint;

let ref a = LpInteger::new("a");
let ref b = LpInteger::new("b");

let mut problem = LpProblem::new("One Problem", LpObjective::Maximize);
problem += 5*a + 3*b;
problem += constraint!(a + b*2 <= 10);
problem += constraint!(b >= a);