pub enum ACOperatorKind {
And,
Or,
Product,
Sum,
}
Expand description
The possible kinds of associative-commutative (AC) operator.
AC operators take a single vector as input and are commonly used alongside comprehensions.
Variants§
Implementations§
Source§impl ACOperatorKind
impl ACOperatorKind
Sourcepub fn as_expression(&self, child_expr: Expression) -> Expression
pub fn as_expression(&self, child_expr: Expression) -> Expression
Creates a new Expression of this AC operator kind with the given child expression.
The child expression given should be of type matrix.
Sourcepub fn identity(&self) -> Literal
pub fn identity(&self) -> Literal
Returns the identity element of this operation.
§Example
use conjure_core::ast::{ac_operators::ACOperatorKind,Literal};
let identity = ACOperatorKind::And.identity();
assert_eq!(identity,Literal::Bool(true));
Sourcepub fn make_skip_operation(
&self,
guard_expr: Expression,
tail_expr: Expression,
) -> Expression
pub fn make_skip_operation( &self, guard_expr: Expression, tail_expr: Expression, ) -> Expression
Given some guard and tail expressions, constructs the skipping operator for this operation.
The skipping operator is operator that takes some boolean guard expression b and some tail expression x. If b is true, then it evaluates to x, otherwise it evaluates to the identity element.
§Usage
This can be used to add guards to elements of AC operations. In the example model below, we only want to multiply y*z by 2 if multiplyByTwo is true:
find multiplyByTwo: bool
find x: int(1..5)
find y: int(1..5)
find z: int(1..5)
such that
x = product([y,z,[1,x;int(0..1)][toInt(b)]])
[1,x;int(0..1)][toInt(b)]
is the skipping operator for product.
This method constructs the skipping operator, substituting in the given expressions for b and x.
Trait Implementations§
Source§impl Clone for ACOperatorKind
impl Clone for ACOperatorKind
Source§fn clone(&self) -> ACOperatorKind
fn clone(&self) -> ACOperatorKind
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ACOperatorKind
impl Debug for ACOperatorKind
Source§impl Hash for ACOperatorKind
impl Hash for ACOperatorKind
Source§impl PartialEq for ACOperatorKind
impl PartialEq for ACOperatorKind
Source§impl TryFrom<&Expression> for ACOperatorKind
impl TryFrom<&Expression> for ACOperatorKind
Source§fn try_from(
expr: &Expression,
) -> Result<ACOperatorKind, <ACOperatorKind as TryFrom<&Expression>>::Error>
fn try_from( expr: &Expression, ) -> Result<ACOperatorKind, <ACOperatorKind as TryFrom<&Expression>>::Error>
Source§impl TryFrom<Box<Expression>> for ACOperatorKind
impl TryFrom<Box<Expression>> for ACOperatorKind
Source§fn try_from(
value: Box<Expression>,
) -> Result<ACOperatorKind, <ACOperatorKind as TryFrom<Box<Expression>>>::Error>
fn try_from( value: Box<Expression>, ) -> Result<ACOperatorKind, <ACOperatorKind as TryFrom<Box<Expression>>>::Error>
Source§impl TryFrom<Expression> for ACOperatorKind
impl TryFrom<Expression> for ACOperatorKind
Source§fn try_from(
value: Expression,
) -> Result<ACOperatorKind, <ACOperatorKind as TryFrom<Expression>>::Error>
fn try_from( value: Expression, ) -> Result<ACOperatorKind, <ACOperatorKind as TryFrom<Expression>>::Error>
impl Copy for ACOperatorKind
impl Eq for ACOperatorKind
impl StructuralPartialEq for ACOperatorKind
Auto Trait Implementations§
impl Freeze for ACOperatorKind
impl RefUnwindSafe for ACOperatorKind
impl Send for ACOperatorKind
impl Sync for ACOperatorKind
impl Unpin for ACOperatorKind
impl UnwindSafe for ACOperatorKind
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 1 byte
Size for each variant:
And
: 0 bytesOr
: 0 bytesProduct
: 0 bytesSum
: 0 bytes