Struct dypdl::SetVariable
source · pub struct SetVariable(/* private fields */);Expand description
A struct wrapping an id.
Implementations§
source§impl SetVariable
impl SetVariable
sourcepub fn contains<T>(self, element: T) -> Conditionwhere
ElementExpression: From<T>,
pub fn contains<T>(self, element: T) -> Conditionwhere
ElementExpression: From<T>,
Returns a condition checking if an element is included in this set.
§Examples
use dypdl::prelude::*;
let mut model = Model::default();
let object_type = model.add_object_type("object_type", 4).unwrap();
let set = model.create_set(object_type, &[0, 1]).unwrap();
let variable = model.add_set_variable("variable", object_type, set).unwrap();
let state = model.target.clone();
let condition = variable.contains(0);
assert!(condition.eval(&state, &model.table_registry));sourcepub fn is_equal<T>(self, set: T) -> Conditionwhere
SetExpression: From<T>,
pub fn is_equal<T>(self, set: T) -> Conditionwhere
SetExpression: From<T>,
Returns a condition checking if this set is equal to the other.
§Examples
use dypdl::prelude::*;
let mut model = Model::default();
let object_type = model.add_object_type("object_type", 4).unwrap();
let a = model.create_set(object_type, &[0, 1]).unwrap();
let a = model.add_set_variable("a", object_type, a).unwrap();
let b = model.create_set(object_type, &[0, 1]).unwrap();
let state = model.target.clone();
let condition = a.is_equal(b);
assert!(condition.eval(&state, &model.table_registry));sourcepub fn is_not_equal<T>(self, set: T) -> Conditionwhere
SetExpression: From<T>,
pub fn is_not_equal<T>(self, set: T) -> Conditionwhere
SetExpression: From<T>,
Returns a condition checking if this set is not equal to the other.
§Examples
use dypdl::prelude::*;
let mut model = Model::default();
let object_type = model.add_object_type("object_type", 4).unwrap();
let a = model.create_set(object_type, &[0, 1]).unwrap();
let a = model.add_set_variable("a", object_type, a).unwrap();
let b = model.create_set(object_type, &[1, 2]).unwrap();
let state = model.target.clone();
let condition = a.is_not_equal(b);
assert!(condition.eval(&state, &model.table_registry));sourcepub fn is_subset<T>(self, set: T) -> Conditionwhere
SetExpression: From<T>,
pub fn is_subset<T>(self, set: T) -> Conditionwhere
SetExpression: From<T>,
Returns a condition checking if this set is a subset of the other.
§Examples
use dypdl::prelude::*;
let mut model = Model::default();
let object_type = model.add_object_type("object_type", 4).unwrap();
let a = model.create_set(object_type, &[0, 1]).unwrap();
let a = model.add_set_variable("a", object_type, a).unwrap();
let b = model.create_set(object_type, &[0, 1, 2]).unwrap();
let state = model.target.clone();
let condition = a.is_not_equal(b);
assert!(condition.eval(&state, &model.table_registry));sourcepub fn is_empty(self) -> Condition
pub fn is_empty(self) -> Condition
Returns a condition checking if this set is empty.
§Examples
use dypdl::prelude::*;
let mut model = Model::default();
let object_type = model.add_object_type("object_type", 4).unwrap();
let set = model.create_set(object_type, &[]).unwrap();
let variable = model.add_set_variable("variable", object_type, set).unwrap();
let state = model.target.clone();
let condition = variable.is_empty();
assert!(condition.eval(&state, &model.table_registry));source§impl SetVariable
impl SetVariable
sourcepub fn len_continuous(self) -> ContinuousExpression
pub fn len_continuous(self) -> ContinuousExpression
Returns an expression representing the cardinality of a set.
§Examples
use dypdl::prelude::*;
use approx::assert_relative_eq;
let mut model = Model::default();
let object_type = model.add_object_type("object", 4).unwrap();
let set = model.create_set(object_type, &[0, 1]).unwrap();
let variable = model.add_set_variable("variable", object_type, set).unwrap();
let state = model.target.clone();
let expression = variable.len_continuous();
assert_relative_eq!(expression.eval(&state, &model.table_registry), 2.0);source§impl SetVariable
impl SetVariable
sourcepub fn len(self) -> IntegerExpression
pub fn len(self) -> IntegerExpression
Returns an expression representing the cardinality of a set.
§Examples
use dypdl::prelude::*;
let mut model = Model::default();
let object_type = model.add_object_type("object", 4).unwrap();
let set = model.create_set(object_type, &[0, 1]).unwrap();
let variable = model.add_set_variable("variable", object_type, set).unwrap();
let state = model.target.clone();
let expression = variable.len();
assert_eq!(expression.eval(&state, &model.table_registry), 2);Trait Implementations§
source§impl AccessTarget<SetVariable, FixedBitSet> for Model
impl AccessTarget<SetVariable, FixedBitSet> for Model
source§fn get_target(&self, variable: SetVariable) -> Result<Set, ModelErr>
fn get_target(&self, variable: SetVariable) -> Result<Set, ModelErr>
source§fn set_target(
&mut self,
variable: SetVariable,
target: Set
) -> Result<(), ModelErr>
fn set_target( &mut self, variable: SetVariable, target: Set ) -> Result<(), ModelErr>
source§impl AddEffect<SetVariable, SetExpression> for Transition
impl AddEffect<SetVariable, SetExpression> for Transition
source§fn add_effect<V>(
&mut self,
v: SetVariable,
expression: V
) -> Result<(), ModelErr>where
SetExpression: From<V>,
fn add_effect<V>(
&mut self,
v: SetVariable,
expression: V
) -> Result<(), ModelErr>where
SetExpression: From<V>,
source§impl BitAnd<FixedBitSet> for SetVariable
impl BitAnd<FixedBitSet> for SetVariable
source§fn bitand(self, rhs: Set) -> SetExpression
fn bitand(self, rhs: Set) -> SetExpression
Returns an expression representing the intersection.
§type Output = SetExpression
type Output = SetExpression
& operator.source§impl BitAnd<SetExpression> for SetVariable
impl BitAnd<SetExpression> for SetVariable
source§fn bitand(self, rhs: SetExpression) -> SetExpression
fn bitand(self, rhs: SetExpression) -> SetExpression
Returns an expression representing the intersection.
§type Output = SetExpression
type Output = SetExpression
& operator.source§impl BitAnd<SetVariable> for Set
impl BitAnd<SetVariable> for Set
source§fn bitand(self, rhs: SetVariable) -> SetExpression
fn bitand(self, rhs: SetVariable) -> SetExpression
Returns an expression representing the intersection.
§type Output = SetExpression
type Output = SetExpression
& operator.source§impl BitAnd<SetVariable> for SetExpression
impl BitAnd<SetVariable> for SetExpression
source§fn bitand(self, rhs: SetVariable) -> SetExpression
fn bitand(self, rhs: SetVariable) -> SetExpression
Returns an expression representing the intersection.
§type Output = SetExpression
type Output = SetExpression
& operator.source§impl BitAnd for SetVariable
impl BitAnd for SetVariable
source§fn bitand(self, rhs: SetVariable) -> SetExpression
fn bitand(self, rhs: SetVariable) -> SetExpression
Returns an expression representing the intersection.
§type Output = SetExpression
type Output = SetExpression
& operator.source§impl BitOr<FixedBitSet> for SetVariable
impl BitOr<FixedBitSet> for SetVariable
source§fn bitor(self, rhs: Set) -> SetExpression
fn bitor(self, rhs: Set) -> SetExpression
Returns an expression representing the union.
§type Output = SetExpression
type Output = SetExpression
| operator.source§impl BitOr<SetExpression> for SetVariable
impl BitOr<SetExpression> for SetVariable
source§fn bitor(self, rhs: SetExpression) -> SetExpression
fn bitor(self, rhs: SetExpression) -> SetExpression
Returns an expression representing the union.
§type Output = SetExpression
type Output = SetExpression
| operator.source§impl BitOr<SetVariable> for Set
impl BitOr<SetVariable> for Set
source§fn bitor(self, rhs: SetVariable) -> SetExpression
fn bitor(self, rhs: SetVariable) -> SetExpression
Returns an expression representing the union.
§type Output = SetExpression
type Output = SetExpression
| operator.source§impl BitOr<SetVariable> for SetExpression
impl BitOr<SetVariable> for SetExpression
source§fn bitor(self, rhs: SetVariable) -> SetExpression
fn bitor(self, rhs: SetVariable) -> SetExpression
Returns an expression representing the union.
§type Output = SetExpression
type Output = SetExpression
| operator.source§impl BitOr for SetVariable
impl BitOr for SetVariable
source§fn bitor(self, rhs: SetVariable) -> SetExpression
fn bitor(self, rhs: SetVariable) -> SetExpression
Returns an expression representing the union.
§type Output = SetExpression
type Output = SetExpression
| operator.source§impl CheckVariable<SetVariable> for StateMetadata
impl CheckVariable<SetVariable> for StateMetadata
source§fn check_variable(&self, v: SetVariable) -> Result<(), ModelErr>
fn check_variable(&self, v: SetVariable) -> Result<(), ModelErr>
source§impl Clone for SetVariable
impl Clone for SetVariable
source§fn clone(&self) -> SetVariable
fn clone(&self) -> SetVariable
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for SetVariable
impl Debug for SetVariable
source§impl From<SetVariable> for ArgumentExpression
impl From<SetVariable> for ArgumentExpression
source§fn from(v: SetVariable) -> ArgumentExpression
fn from(v: SetVariable) -> ArgumentExpression
source§impl From<SetVariable> for SetExpression
impl From<SetVariable> for SetExpression
source§fn from(v: SetVariable) -> Self
fn from(v: SetVariable) -> Self
source§impl GetObjectTypeOf<SetVariable> for Model
impl GetObjectTypeOf<SetVariable> for Model
source§fn get_object_type_of(&self, v: SetVariable) -> Result<ObjectType, ModelErr>
fn get_object_type_of(&self, v: SetVariable) -> Result<ObjectType, ModelErr>
source§impl GetObjectTypeOf<SetVariable> for StateMetadata
impl GetObjectTypeOf<SetVariable> for StateMetadata
source§fn get_object_type_of(&self, v: SetVariable) -> Result<ObjectType, ModelErr>
fn get_object_type_of(&self, v: SetVariable) -> Result<ObjectType, ModelErr>
source§impl Not for SetVariable
impl Not for SetVariable
source§fn not(self) -> Self::Output
fn not(self) -> Self::Output
Returns an expression representing the complement.
§Examples
use dypdl::prelude::*;
let mut model = Model::default();
let object_type = model.add_object_type("object", 4).unwrap();
let set = model.create_set(object_type, &[0, 1]).unwrap();
let variable = model.add_set_variable("variable", object_type, set).unwrap();
let state = model.target.clone();
let expression = !variable;
let expected = model.create_set(object_type, &[2, 3]).unwrap();
assert_eq!(expression.eval(&state, &model.table_registry), expected);§type Output = SetExpression
type Output = SetExpression
! operator.source§impl PartialEq for SetVariable
impl PartialEq for SetVariable
source§fn eq(&self, other: &SetVariable) -> bool
fn eq(&self, other: &SetVariable) -> bool
self and other values to be equal, and is used
by ==.source§impl SetElementOperation<ElementExpression> for SetVariable
impl SetElementOperation<ElementExpression> for SetVariable
source§fn add(self, rhs: ElementExpression) -> SetExpression
fn add(self, rhs: ElementExpression) -> SetExpression
source§fn remove(self, rhs: ElementExpression) -> SetExpression
fn remove(self, rhs: ElementExpression) -> SetExpression
source§impl SetElementOperation<ElementResourceVariable> for SetVariable
impl SetElementOperation<ElementResourceVariable> for SetVariable
source§fn add(self, rhs: ElementResourceVariable) -> SetExpression
fn add(self, rhs: ElementResourceVariable) -> SetExpression
source§fn remove(self, rhs: ElementResourceVariable) -> SetExpression
fn remove(self, rhs: ElementResourceVariable) -> SetExpression
source§impl SetElementOperation<ElementVariable> for SetVariable
impl SetElementOperation<ElementVariable> for SetVariable
source§fn add(self, rhs: ElementVariable) -> SetExpression
fn add(self, rhs: ElementVariable) -> SetExpression
source§fn remove(self, rhs: ElementVariable) -> SetExpression
fn remove(self, rhs: ElementVariable) -> SetExpression
source§impl SetElementOperation<usize> for SetVariable
impl SetElementOperation<usize> for SetVariable
source§fn add(self, rhs: Element) -> SetExpression
fn add(self, rhs: Element) -> SetExpression
source§fn remove(self, rhs: Element) -> SetExpression
fn remove(self, rhs: Element) -> SetExpression
source§impl Sub<FixedBitSet> for SetVariable
impl Sub<FixedBitSet> for SetVariable
source§fn sub(self, rhs: Set) -> SetExpression
fn sub(self, rhs: Set) -> SetExpression
Returns an expression representing the difference.
§type Output = SetExpression
type Output = SetExpression
- operator.source§impl Sub<SetExpression> for SetVariable
impl Sub<SetExpression> for SetVariable
source§fn sub(self, rhs: SetExpression) -> SetExpression
fn sub(self, rhs: SetExpression) -> SetExpression
Returns an expression representing the difference.
§type Output = SetExpression
type Output = SetExpression
- operator.source§impl Sub<SetVariable> for Set
impl Sub<SetVariable> for Set
source§fn sub(self, rhs: SetVariable) -> SetExpression
fn sub(self, rhs: SetVariable) -> SetExpression
Returns an expression representing the difference.
§type Output = SetExpression
type Output = SetExpression
- operator.source§impl Sub<SetVariable> for SetExpression
impl Sub<SetVariable> for SetExpression
source§fn sub(self, rhs: SetVariable) -> SetExpression
fn sub(self, rhs: SetVariable) -> SetExpression
Returns an expression representing the difference.
§type Output = SetExpression
type Output = SetExpression
- operator.source§impl Sub for SetVariable
impl Sub for SetVariable
source§fn sub(self, rhs: SetVariable) -> SetExpression
fn sub(self, rhs: SetVariable) -> SetExpression
Returns an expression representing the difference.
§type Output = SetExpression
type Output = SetExpression
- operator.