Struct dypdl::SetVariable

source ·
pub struct SetVariable(/* private fields */);
Expand description

A struct wrapping an id.

Implementations§

source§

impl SetVariable

source

pub fn contains<T>(self, element: T) -> Condition

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));
source

pub fn is_equal<T>(self, set: T) -> Condition
where 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));
source

pub fn is_not_equal<T>(self, set: T) -> Condition
where 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));
source

pub fn is_subset<T>(self, set: T) -> Condition
where 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));
source

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

source

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

source

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);
source§

impl SetVariable

source

pub fn id(&self) -> usize

Returns the id.

Trait Implementations§

source§

impl AccessTarget<SetVariable, FixedBitSet> for Model

source§

fn get_target(&self, variable: SetVariable) -> Result<Set, ModelErr>

Returns the value in the target state. Read more
source§

fn set_target( &mut self, variable: SetVariable, target: Set ) -> Result<(), ModelErr>

Set the value in the target state Read more
source§

impl AddEffect<SetVariable, SetExpression> for Transition

source§

fn add_effect<V>( &mut self, v: SetVariable, expression: V ) -> Result<(), ModelErr>
where SetExpression: From<V>,

Adds an effect. Read more
source§

impl BitAnd<FixedBitSet> for SetVariable

source§

fn bitand(self, rhs: Set) -> SetExpression

Returns an expression representing the intersection.

§

type Output = SetExpression

The resulting type after applying the & operator.
source§

impl BitAnd<SetExpression> for SetVariable

source§

fn bitand(self, rhs: SetExpression) -> SetExpression

Returns an expression representing the intersection.

§

type Output = SetExpression

The resulting type after applying the & operator.
source§

impl BitAnd<SetVariable> for Set

source§

fn bitand(self, rhs: SetVariable) -> SetExpression

Returns an expression representing the intersection.

§

type Output = SetExpression

The resulting type after applying the & operator.
source§

impl BitAnd<SetVariable> for SetExpression

source§

fn bitand(self, rhs: SetVariable) -> SetExpression

Returns an expression representing the intersection.

§

type Output = SetExpression

The resulting type after applying the & operator.
source§

impl BitAnd for SetVariable

source§

fn bitand(self, rhs: SetVariable) -> SetExpression

Returns an expression representing the intersection.

§

type Output = SetExpression

The resulting type after applying the & operator.
source§

impl BitOr<FixedBitSet> for SetVariable

source§

fn bitor(self, rhs: Set) -> SetExpression

Returns an expression representing the union.

§

type Output = SetExpression

The resulting type after applying the | operator.
source§

impl BitOr<SetExpression> for SetVariable

source§

fn bitor(self, rhs: SetExpression) -> SetExpression

Returns an expression representing the union.

§

type Output = SetExpression

The resulting type after applying the | operator.
source§

impl BitOr<SetVariable> for Set

source§

fn bitor(self, rhs: SetVariable) -> SetExpression

Returns an expression representing the union.

§

type Output = SetExpression

The resulting type after applying the | operator.
source§

impl BitOr<SetVariable> for SetExpression

source§

fn bitor(self, rhs: SetVariable) -> SetExpression

Returns an expression representing the union.

§

type Output = SetExpression

The resulting type after applying the | operator.
source§

impl BitOr for SetVariable

source§

fn bitor(self, rhs: SetVariable) -> SetExpression

Returns an expression representing the union.

§

type Output = SetExpression

The resulting type after applying the | operator.
source§

impl CheckVariable<SetVariable> for StateMetadata

source§

fn check_variable(&self, v: SetVariable) -> Result<(), ModelErr>

Check if the variable is defined. Read more
source§

impl Clone for SetVariable

source§

fn clone(&self) -> SetVariable

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 SetVariable

source§

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

Formats the value using the given formatter. Read more
source§

impl From<SetVariable> for ArgumentExpression

source§

fn from(v: SetVariable) -> ArgumentExpression

Converts to this type from the input type.
source§

impl From<SetVariable> for SetExpression

source§

fn from(v: SetVariable) -> Self

Converts to this type from the input type.
source§

impl GetObjectTypeOf<SetVariable> for Model

source§

fn get_object_type_of(&self, v: SetVariable) -> Result<ObjectType, ModelErr>

Returns the object type of the variable. Read more
source§

impl GetObjectTypeOf<SetVariable> for StateMetadata

source§

fn get_object_type_of(&self, v: SetVariable) -> Result<ObjectType, ModelErr>

Returns the object type of the variable. Read more
source§

impl Not for SetVariable

source§

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

The resulting type after applying the ! operator.
source§

impl PartialEq for SetVariable

source§

fn eq(&self, other: &SetVariable) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl SetElementOperation<ElementExpression> for SetVariable

source§

fn add(self, rhs: ElementExpression) -> SetExpression

Returns a set expression, where an element is added.
source§

fn remove(self, rhs: ElementExpression) -> SetExpression

Returns a set expression, where an element is removed.
source§

impl SetElementOperation<ElementResourceVariable> for SetVariable

source§

fn add(self, rhs: ElementResourceVariable) -> SetExpression

Returns a set expression, where an element is added.
source§

fn remove(self, rhs: ElementResourceVariable) -> SetExpression

Returns a set expression, where an element is removed.
source§

impl SetElementOperation<ElementVariable> for SetVariable

source§

fn add(self, rhs: ElementVariable) -> SetExpression

Returns a set expression, where an element is added.
source§

fn remove(self, rhs: ElementVariable) -> SetExpression

Returns a set expression, where an element is removed.
source§

impl SetElementOperation<usize> for SetVariable

source§

fn add(self, rhs: Element) -> SetExpression

Returns a set expression, where an element is added.
source§

fn remove(self, rhs: Element) -> SetExpression

Returns a set expression, where an element is removed.
source§

impl Sub<FixedBitSet> for SetVariable

source§

fn sub(self, rhs: Set) -> SetExpression

Returns an expression representing the difference.

§

type Output = SetExpression

The resulting type after applying the - operator.
source§

impl Sub<SetExpression> for SetVariable

source§

fn sub(self, rhs: SetExpression) -> SetExpression

Returns an expression representing the difference.

§

type Output = SetExpression

The resulting type after applying the - operator.
source§

impl Sub<SetVariable> for Set

source§

fn sub(self, rhs: SetVariable) -> SetExpression

Returns an expression representing the difference.

§

type Output = SetExpression

The resulting type after applying the - operator.
source§

impl Sub<SetVariable> for SetExpression

source§

fn sub(self, rhs: SetVariable) -> SetExpression

Returns an expression representing the difference.

§

type Output = SetExpression

The resulting type after applying the - operator.
source§

impl Sub for SetVariable

source§

fn sub(self, rhs: SetVariable) -> SetExpression

Returns an expression representing the difference.

§

type Output = SetExpression

The resulting type after applying the - operator.
source§

impl Copy for SetVariable

source§

impl Eq for SetVariable

source§

impl StructuralEq for SetVariable

source§

impl StructuralPartialEq for SetVariable

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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

§

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>,

§

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>,

§

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.