pub struct LinExpr {
pub terms: Vec<LinTerm>,
pub constant: f64,
}Expand description
Represents a linear expression of the form a1*x1 + a2*x2 + ... + c.
Fields§
§terms: Vec<LinTerm>All variable terms in the expression.
constant: f64Constant term in the expression.
Implementations§
Source§impl LinExpr
impl LinExpr
Sourcepub fn new(var: VarId, coeff: f64) -> Self
pub fn new(var: VarId, coeff: f64) -> Self
Creates a new linear expression from a single variable and coefficient.
§Example
let x = VarId(0);
let expr = LinExpr::new(x, 3.0); // 3*VarId(0)Sourcepub fn leq(self, rhs: f64) -> Constraint
pub fn leq(self, rhs: f64) -> Constraint
Creates a <= constraint from this linear expression.
Sourcepub fn geq(self, rhs: f64) -> Constraint
pub fn geq(self, rhs: f64) -> Constraint
Creates a >= constraint from this linear expression.
Sourcepub fn eq(self, rhs: f64) -> Constraint
pub fn eq(self, rhs: f64) -> Constraint
Creates a == constraint from this linear expression.
Trait Implementations§
Source§impl AddAssign<VarId> for LinExpr
LinExpr += VarId
impl AddAssign<VarId> for LinExpr
LinExpr += VarId
Source§fn add_assign(&mut self, rhs: VarId)
fn add_assign(&mut self, rhs: VarId)
Performs the
+= operation. Read moreSource§impl AddAssign for LinExpr
LinExpr += LinExpr
impl AddAssign for LinExpr
LinExpr += LinExpr
Source§fn add_assign(&mut self, rhs: LinExpr)
fn add_assign(&mut self, rhs: LinExpr)
Performs the
+= operation. Read moreAuto Trait Implementations§
impl Freeze for LinExpr
impl RefUnwindSafe for LinExpr
impl Send for LinExpr
impl Sync for LinExpr
impl Unpin for LinExpr
impl UnsafeUnpin for LinExpr
impl UnwindSafe for LinExpr
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