conjure_oxide

Struct Reduction

Source
#[non_exhaustive]
pub struct Reduction { pub new_expression: Expression, pub new_top: Expression, pub symbols: HashMap<Name, DecisionVariable>, }
Expand description

Represents the result of applying a rule to an expression within a model.

A Reduction encapsulates the changes made to a model during a rule application. It includes a new expression to replace the original one, an optional top-level constraint to be added to the model, and any updates to the model’s symbol table.

This struct allows for representing side-effects of rule applications, ensuring that all modifications, including symbol table expansions and additional constraints, are accounted for and can be applied to the model consistently.

§Fields

  • new_expression: The updated Expression that replaces the original one after applying the rule.
  • new_top: An additional top-level Expression constraint that should be added to the model. If no top-level constraint is needed, this field can be set to Expression::Nothing.
  • symbols: A SymbolTable containing any new symbol definitions or modifications to be added to the model’s symbol table. If no symbols are modified, this field can be set to an empty symbol table.

§Usage

A Reduction can be created using one of the provided constructors:

  • Reduction::new: Creates a reduction with a new expression, top-level constraint, and symbol modifications.
  • Reduction::pure: Creates a reduction with only a new expression and no side-effects on the symbol table or constraints.
  • Reduction::with_symbols: Creates a reduction with a new expression and symbol table modifications, but no top-level constraint.
  • Reduction::with_top: Creates a reduction with a new expression and a top-level constraint, but no symbol table modifications.

The apply method allows for applying the changes represented by the Reduction to a Model.

§Example

// Need to add an example

§See Also

  • ApplicationResult: Represents the result of applying a rule, which may either be a Reduction or an ApplicationError.
  • Model: The structure to which the Reduction changes are applied.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§new_expression: Expression§new_top: Expression§symbols: HashMap<Name, DecisionVariable>

Implementations§

Source§

impl Reduction

Source

pub fn new( new_expression: Expression, new_top: Expression, symbols: HashMap<Name, DecisionVariable>, ) -> Reduction

Source

pub fn pure(new_expression: Expression) -> Reduction

Represents a reduction with no side effects on the model.

Source

pub fn with_symbols( new_expression: Expression, symbols: HashMap<Name, DecisionVariable>, ) -> Reduction

Represents a reduction that also modifies the symbol table.

Source

pub fn with_top(new_expression: Expression, new_top: Expression) -> Reduction

Represents a reduction that also adds a top-level constraint to the model.

Source

pub fn apply(self, model: &mut Model)

Trait Implementations§

Source§

impl Clone for Reduction

Source§

fn clone(&self) -> Reduction

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Reduction

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more