pub struct Expression { /* private fields */ }Expand description
Represents an affine expression, such as 2x + 3 or x + y + z
Implementations§
Source§impl Expression
impl Expression
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create an expression that has the value 0, but has memory allocated
for capacity coefficients.
Sourcepub fn from_other_affine<E: IntoAffineExpression>(source: E) -> Self
pub fn from_other_affine<E: IntoAffineExpression>(source: E) -> Self
Create a concrete expression struct from anything that has linear coefficients and a constant
Expression::from_other_affine(0.); // A constant expressionSourcepub fn leq<RHS>(self, rhs: RHS) -> Constraint
pub fn leq<RHS>(self, rhs: RHS) -> Constraint
Creates a constraint indicating that this expression is lesser than or equal to the right hand side
Sourcepub fn geq<RHS: Sub<Expression, Output = Expression>>(
self,
rhs: RHS,
) -> Constraint
pub fn geq<RHS: Sub<Expression, Output = Expression>>( self, rhs: RHS, ) -> Constraint
Creates a constraint indicating that this expression is greater than or equal to the right hand side
Sourcepub fn eq<RHS>(self, rhs: RHS) -> Constraint
pub fn eq<RHS>(self, rhs: RHS) -> Constraint
Creates a constraint indicating that this expression is equal to the right hand side
Sourcepub fn add_mul<N: Into<f64>, E: IntoAffineExpression>(&mut self, a: N, b: E)
pub fn add_mul<N: Into<f64>, E: IntoAffineExpression>(&mut self, a: N, b: E)
Performs self = self + (a * b)
Trait Implementations§
Source§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§impl Add<Expression> for i32
impl Add<Expression> for i32
Source§type Output = Expression
type Output = Expression
The resulting type after applying the
+ operator.Source§impl<RHS: IntoAffineExpression> Add<RHS> for Expression
impl<RHS: IntoAffineExpression> Add<RHS> for Expression
Source§impl<RHS: IntoAffineExpression> AddAssign<RHS> for Expression
impl<RHS: IntoAffineExpression> AddAssign<RHS> for Expression
Source§fn add_assign(&mut self, rhs: RHS)
fn add_assign(&mut self, rhs: RHS)
Performs the
+= operation. Read moreSource§impl Clone for Expression
impl Clone for Expression
Source§impl Debug for Expression
impl Debug for Expression
Source§impl Default for Expression
impl Default for Expression
Source§impl FormatWithVars for Expression
impl FormatWithVars for Expression
Source§fn format_with<FUN>(
&self,
f: &mut Formatter<'_>,
variable_format: FUN,
) -> Result
fn format_with<FUN>( &self, f: &mut Formatter<'_>, variable_format: FUN, ) -> Result
Write the element to the formatter. See std::fmt::Display
Source§fn format_debug(&self, f: &mut Formatter<'_>) -> Result
fn format_debug(&self, f: &mut Formatter<'_>) -> Result
Write the elements, naming the variables v0, v1, … vn
Source§impl From<Variable> for Expression
impl From<Variable> for Expression
Source§fn from(x: Variable) -> Expression
fn from(x: Variable) -> Expression
Converts to this type from the input type.
Source§impl From<f64> for Expression
impl From<f64> for Expression
Source§fn from(x: f64) -> Expression
fn from(x: f64) -> Expression
Converts to this type from the input type.
Source§impl From<i32> for Expression
impl From<i32> for Expression
Source§fn from(x: i32) -> Expression
fn from(x: i32) -> Expression
Converts to this type from the input type.
Source§impl<'a> IntoAffineExpression for &'a Expression
This implementation copies all the variables and coefficients from the referenced
Expression into the created iterator
impl<'a> IntoAffineExpression for &'a Expression
This implementation copies all the variables and coefficients from the referenced Expression into the created iterator
Source§type Iter = <&'a LinearExpression as IntoAffineExpression>::Iter
type Iter = <&'a LinearExpression as IntoAffineExpression>::Iter
The iterator returned by
linear_coefficients.Source§fn linear_coefficients(self) -> Self::Iter
fn linear_coefficients(self) -> Self::Iter
An iterator over variables and their coefficients.
For instance
a + 2b - 3a - 7 should yield [(a, -2), (b, 2)]Source§fn constant(&self) -> f64
fn constant(&self) -> f64
The constant factor in the expression.
For instance,
a + 2b - 7 will give -7Source§fn into_expression(self) -> Expressionwhere
Self: Sized,
fn into_expression(self) -> Expressionwhere
Self: Sized,
Transform the value into a concrete Expression struct.
Source§impl IntoAffineExpression for Expression
impl IntoAffineExpression for Expression
Source§type Iter = <LinearExpression as IntoAffineExpression>::Iter
type Iter = <LinearExpression as IntoAffineExpression>::Iter
The iterator returned by
linear_coefficients.Source§fn linear_coefficients(self) -> Self::Iter
fn linear_coefficients(self) -> Self::Iter
An iterator over variables and their coefficients.
For instance
a + 2b - 3a - 7 should yield [(a, -2), (b, 2)]Source§fn constant(&self) -> f64
fn constant(&self) -> f64
The constant factor in the expression.
For instance,
a + 2b - 7 will give -7Source§fn into_expression(self) -> Expressionwhere
Self: Sized,
fn into_expression(self) -> Expressionwhere
Self: Sized,
Transform the value into a concrete Expression struct.
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§impl Mul<Expression> for i32
impl Mul<Expression> for i32
Source§type Output = Expression
type Output = Expression
The resulting type after applying the
* operator.Source§impl<N: Into<f64>> MulAssign<N> for Expression
impl<N: Into<f64>> MulAssign<N> for Expression
Source§fn mul_assign(&mut self, rhs: N)
fn mul_assign(&mut self, rhs: N)
Performs the
*= operation. Read moreSource§impl Neg for Expression
impl Neg for Expression
Source§impl PartialEq for Expression
impl PartialEq for Expression
Source§impl<RHS> Shl<RHS> for Expressionwhere
Self: Sub<RHS, Output = Expression>,
impl<RHS> Shl<RHS> for Expressionwhere
Self: Sub<RHS, Output = Expression>,
Source§impl<RHS: Sub<Self, Output = Expression>> Shr<RHS> for Expression
impl<RHS: Sub<Self, Output = Expression>> Shr<RHS> for Expression
Source§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§impl Sub<Expression> for i32
impl Sub<Expression> for i32
Source§type Output = Expression
type Output = Expression
The resulting type after applying the
- operator.Source§impl<RHS: IntoAffineExpression> Sub<RHS> for Expression
impl<RHS: IntoAffineExpression> Sub<RHS> for Expression
Source§impl<RHS: IntoAffineExpression> SubAssign<RHS> for Expression
impl<RHS: IntoAffineExpression> SubAssign<RHS> for Expression
Source§fn sub_assign(&mut self, rhs: RHS)
fn sub_assign(&mut self, rhs: RHS)
Performs the
-= operation. Read moreSource§impl<E: IntoAffineExpression> Sum<E> for Expression
impl<E: IntoAffineExpression> Sum<E> for Expression
Auto Trait Implementations§
impl Freeze for Expression
impl RefUnwindSafe for Expression
impl Send for Expression
impl Sync for Expression
impl Unpin 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> 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