Enum dypdl::CostExpression
source · pub enum CostExpression {
Integer(IntegerExpression),
Continuous(ContinuousExpression),
}
Expand description
Wrapper for an integer expression or a continuous expression.
Variants§
Integer(IntegerExpression)
Integer numeric expression.
Continuous(ContinuousExpression)
Continuous numeric expression.
Implementations§
source§impl CostExpression
impl CostExpression
sourcepub fn eval<T: Numeric, U: StateInterface>(
&self,
state: &U,
registry: &TableRegistry,
) -> T
pub fn eval<T: Numeric, U: StateInterface>( &self, state: &U, registry: &TableRegistry, ) -> T
Returns the evaluation result.
§Panics
Panics if the cost of the transition state is used or a min/max reduce operation is performed on an empty set or vector.
§Examples
use dypdl::prelude::*;
let mut model = Model::default();
let variable = model.add_integer_variable("x", 2).unwrap();
let state = model.target.clone();
let expression = CostExpression::from(IntegerExpression::from(variable));
assert_eq!(expression.eval::<Integer, _>(&state, &model.table_registry), 2);
sourcepub fn eval_cost<T: Numeric, U: StateInterface>(
&self,
cost: T,
state: &U,
registry: &TableRegistry,
) -> T
pub fn eval_cost<T: Numeric, U: StateInterface>( &self, cost: T, state: &U, registry: &TableRegistry, ) -> T
Returns the evaluation result.
§Panics
Panics if a min/max reduce operation is performed on an empty set or vector.
§Examples
use dypdl::prelude::*;
let mut model = Model::default();
let variable = model.add_integer_variable("x", 2).unwrap();
let state = model.target.clone();
let expression = CostExpression::from(variable + IntegerExpression::Cost);
assert_eq!(expression.eval_cost(1, &state, &model.table_registry), 3);
sourcepub fn simplify(&self, registry: &TableRegistry) -> CostExpression
pub fn simplify(&self, registry: &TableRegistry) -> CostExpression
Returns a simplified version by precomputation.
§Panics
Panics if a min/max reduce operation is performed on an empty set or vector.
Trait Implementations§
source§impl Clone for CostExpression
impl Clone for CostExpression
source§fn clone(&self) -> CostExpression
fn clone(&self) -> CostExpression
Returns a copy 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 CostExpression
impl Debug for CostExpression
source§impl Default for CostExpression
impl Default for CostExpression
source§impl From<ContinuousExpression> for CostExpression
impl From<ContinuousExpression> for CostExpression
source§fn from(cost: ContinuousExpression) -> Self
fn from(cost: ContinuousExpression) -> Self
Converts to this type from the input type.
source§impl From<ContinuousResourceVariable> for CostExpression
impl From<ContinuousResourceVariable> for CostExpression
source§fn from(cost: ContinuousResourceVariable) -> Self
fn from(cost: ContinuousResourceVariable) -> Self
Converts to this type from the input type.
source§impl From<ContinuousVariable> for CostExpression
impl From<ContinuousVariable> for CostExpression
source§fn from(cost: ContinuousVariable) -> Self
fn from(cost: ContinuousVariable) -> Self
Converts to this type from the input type.
source§impl<T> From<T> for CostExpressionwhere
IntegerExpression: From<T>,
impl<T> From<T> for CostExpressionwhere
IntegerExpression: From<T>,
source§impl From<f64> for CostExpression
impl From<f64> for CostExpression
source§fn from(cost: Continuous) -> Self
fn from(cost: Continuous) -> Self
Converts to this type from the input type.
source§impl PartialEq for CostExpression
impl PartialEq for CostExpression
source§fn eq(&self, other: &CostExpression) -> bool
fn eq(&self, other: &CostExpression) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl StructuralPartialEq for CostExpression
Auto Trait Implementations§
impl Freeze for CostExpression
impl RefUnwindSafe for CostExpression
impl Send for CostExpression
impl Sync for CostExpression
impl Unpin for CostExpression
impl UnwindSafe for CostExpression
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