pub struct Expression { /* private fields */ }Expand description
A linear expression: sum of (coefficient * variable) + constant.
Internally stored as a flat HashMap<Variable, f64> plus a scalar constant.
This representation automatically merges like terms: x + 2*x → {x: 3.0}.
Implementations§
Source§impl Expression
impl Expression
Sourcepub fn from_constant(c: f64) -> Self
pub fn from_constant(c: f64) -> Self
Create an expression representing a single scalar constant.
Sourcepub fn leq(self, rhs: impl Into<Expression>) -> Constraint
pub fn leq(self, rhs: impl Into<Expression>) -> Constraint
Create a <= constraint: self <= rhs.
Sourcepub fn geq(self, rhs: impl Into<Expression>) -> Constraint
pub fn geq(self, rhs: impl Into<Expression>) -> Constraint
Create a >= constraint: self >= rhs.
Sourcepub fn eq_constraint(self, rhs: impl Into<Expression>) -> Constraint
pub fn eq_constraint(self, rhs: impl Into<Expression>) -> Constraint
Create an == constraint: self == rhs.
Trait Implementations§
Source§impl Add for Expression
impl Add for Expression
Source§type Output = Expression
type Output = Expression
The resulting type after applying the
+ operator.Source§fn add(self, rhs: Expression) -> Expression
fn add(self, rhs: Expression) -> Expression
Performs the
+ operation. Read moreSource§impl Add<Expression> for QuadExpr
impl Add<Expression> for QuadExpr
Source§impl Add<Expression> for Variable
impl Add<Expression> for Variable
Source§type Output = Expression
type Output = Expression
The resulting type after applying the
+ operator.Source§fn add(self, rhs: Expression) -> Expression
fn add(self, rhs: Expression) -> Expression
Performs the
+ operation. Read moreSource§impl Add<Expression> for f64
impl Add<Expression> for f64
Source§type Output = Expression
type Output = Expression
The resulting type after applying the
+ operator.Source§fn add(self, rhs: Expression) -> Expression
fn add(self, rhs: Expression) -> Expression
Performs the
+ operation. Read moreSource§impl Add<QuadExpr> for Expression
impl Add<QuadExpr> for Expression
Source§impl Add<Variable> for Expression
impl Add<Variable> for Expression
Source§type Output = Expression
type Output = Expression
The resulting type after applying the
+ operator.Source§impl Add<f64> for Expression
impl Add<f64> for Expression
Source§type Output = Expression
type Output = Expression
The resulting type after applying the
+ operator.Source§impl Clone for Expression
impl Clone for Expression
Source§fn clone(&self) -> Expression
fn clone(&self) -> Expression
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 Expression
impl Debug for Expression
Source§impl Default for Expression
impl Default for Expression
Source§fn default() -> Expression
fn default() -> Expression
Returns the “default value” for a type. Read more
Source§impl From<Expression> for QuadExpr
impl From<Expression> for QuadExpr
Source§fn from(e: Expression) -> Self
fn from(e: Expression) -> Self
Converts to this type from the input type.
Source§impl From<Variable> for Expression
impl From<Variable> for Expression
Source§impl From<f64> for Expression
impl From<f64> for Expression
Source§impl From<i32> for Expression
impl From<i32> for Expression
Source§impl Mul<Expression> for Variable
impl Mul<Expression> for Variable
Source§impl Mul<Expression> for f64
impl Mul<Expression> for f64
Source§type Output = Expression
type Output = Expression
The resulting type after applying the
* operator.Source§fn mul(self, rhs: Expression) -> Expression
fn mul(self, rhs: Expression) -> Expression
Performs the
* operation. Read moreSource§impl Mul<Variable> for Expression
impl Mul<Variable> for Expression
Source§impl Mul<f64> for Expression
impl Mul<f64> for Expression
Source§type Output = Expression
type Output = Expression
The resulting type after applying the
* operator.Source§impl Neg for Expression
impl Neg for Expression
Source§type Output = Expression
type Output = Expression
The resulting type after applying the
- operator.Source§fn neg(self) -> Expression
fn neg(self) -> Expression
Performs the unary
- operation. Read moreSource§impl Sub for Expression
impl Sub for Expression
Source§type Output = Expression
type Output = Expression
The resulting type after applying the
- operator.Source§fn sub(self, rhs: Expression) -> Expression
fn sub(self, rhs: Expression) -> Expression
Performs the
- operation. Read moreSource§impl Sub<Expression> for QuadExpr
impl Sub<Expression> for QuadExpr
Source§impl Sub<Expression> for Variable
impl Sub<Expression> for Variable
Source§type Output = Expression
type Output = Expression
The resulting type after applying the
- operator.Source§fn sub(self, rhs: Expression) -> Expression
fn sub(self, rhs: Expression) -> Expression
Performs the
- operation. Read moreSource§impl Sub<Expression> for f64
impl Sub<Expression> for f64
Source§type Output = Expression
type Output = Expression
The resulting type after applying the
- operator.Source§fn sub(self, rhs: Expression) -> Expression
fn sub(self, rhs: Expression) -> Expression
Performs the
- operation. Read moreSource§impl Sub<QuadExpr> for Expression
impl Sub<QuadExpr> for Expression
Source§impl Sub<Variable> for Expression
impl Sub<Variable> for Expression
Source§type Output = Expression
type Output = Expression
The resulting type after applying the
- operator.Source§impl Sub<f64> for Expression
impl Sub<f64> for Expression
Source§type Output = Expression
type Output = Expression
The resulting type after applying the
- operator.Auto Trait Implementations§
impl Freeze for Expression
impl RefUnwindSafe for Expression
impl Send for Expression
impl Sync for Expression
impl Unpin for Expression
impl UnsafeUnpin for Expression
impl UnwindSafe for Expression
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more