pub struct Constraint {
pub expr: LinExpr,
pub rhs: f64,
pub cmp: Cmp,
}Expand description
A linear constraint of the form expr cmp rhs.
§Examples
let x = VarId(0);
let expr = LinExpr::new(x, 2.0) + 3.0;
let c1 = Constraint::leq(expr.clone(), 5.0); // 2*x0 + 3 <= 5
let c2 = Constraint::geq(expr.clone(), 1.0); // 2*x0 + 3 >= 1
let c3 = Constraint::eq(expr, 4.0); // 2*x0 + 3 == 4Fields§
§expr: LinExprThe left-hand side linear expression of the constraint.
rhs: f64The right-hand side value of the constraint.
cmp: CmpThe comparison operator (==, <=, >=).
Implementations§
Trait Implementations§
Source§impl AddAssign<Constraint> for Model
Allows adding constraints to the model using the += operator.
impl AddAssign<Constraint> for Model
Allows adding constraints to the model using the += operator.
§Example
let mut model = Model::new();
let x = model.add_var().finish();
model += x.geq(0.0);Source§fn add_assign(&mut self, rhs: Constraint)
fn add_assign(&mut self, rhs: Constraint)
Performs the
+= operation. Read moreSource§impl Clone for Constraint
impl Clone for Constraint
Source§fn clone(&self) -> Constraint
fn clone(&self) -> Constraint
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Constraint
impl Debug for Constraint
Auto Trait Implementations§
impl Freeze for Constraint
impl RefUnwindSafe for Constraint
impl Send for Constraint
impl Sync for Constraint
impl Unpin for Constraint
impl UnsafeUnpin for Constraint
impl UnwindSafe for Constraint
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more