pub struct DiscreteConstraint<V, T: Hash + Eq> { /* private fields */ }
Expand description
A generic form of Constraints on discrete variables.
§Note
This is not the most efficient implementation,
as it effectively tries to store all possible assignments.
Whilst this lets it be as flexible as possible, it:
- uses a lot more space
- has much worse time complexity
Than specialised implementations of constraints.
If you want a more performant implementation, check out others in crate::systems
.
Trait Implementations§
Source§impl<V: Hash + Eq + Clone, T: Hash + Eq + Clone> Constraint for DiscreteConstraint<V, T>
impl<V: Hash + Eq + Clone, T: Hash + Eq + Clone> Constraint for DiscreteConstraint<V, T>
Source§type Solution = DiscreteAssignment<V, T>
type Solution = DiscreteAssignment<V, T>
Any solution to a Constraint
Source§type ConflictErr = ()
type ConflictErr = ()
The error raised when 2 constraints conflict with each other
Source§fn size(&self) -> usize
fn size(&self) -> usize
An approximation to the number of unique assignments that
self
has. Read moreSource§fn decompositions(&self) -> impl Iterator<Item = Self>
fn decompositions(&self) -> impl Iterator<Item = Self>
Possible decompositions for this constraint. Read more
Source§fn reduce(&mut self, other: &Self) -> Result<bool, Self::ConflictErr>
fn reduce(&mut self, other: &Self) -> Result<bool, Self::ConflictErr>
Removes the overlap between another constraint and this one.
This is useful as it lets us remove uncertainty from the system
and make it simpler to solve. Read more
This is useful as it lets us remove uncertainty from the system
and make it simpler to solve. Read more
Source§fn pop_solution(&mut self) -> Option<Self::Solution>
fn pop_solution(&mut self) -> Option<Self::Solution>
Pops all variables that have a unique assignment in this constraint
Source§impl<V: Hash + Eq + Debug, T: Hash + Eq, I: IntoIterator<Item = (V, T)>> FromIterator<I> for DiscreteConstraint<V, T>
impl<V: Hash + Eq + Debug, T: Hash + Eq, I: IntoIterator<Item = (V, T)>> FromIterator<I> for DiscreteConstraint<V, T>
Source§fn from_iter<U: IntoIterator<Item = I>>(iter: U) -> Self
fn from_iter<U: IntoIterator<Item = I>>(iter: U) -> Self
Creates a value from an iterator. Read more
impl<V: Eq, T: Eq + Hash + Eq> Eq for DiscreteConstraint<V, T>
impl<V, T: Hash + Eq> StructuralPartialEq for DiscreteConstraint<V, T>
Auto Trait Implementations§
impl<V, T> Freeze for DiscreteConstraint<V, T>
impl<V, T> RefUnwindSafe for DiscreteConstraint<V, T>where
V: RefUnwindSafe,
T: RefUnwindSafe,
impl<V, T> Send for DiscreteConstraint<V, T>
impl<V, T> Sync for DiscreteConstraint<V, T>
impl<V, T> Unpin for DiscreteConstraint<V, T>
impl<V, T> UnwindSafe for DiscreteConstraint<V, T>where
V: UnwindSafe,
T: UnwindSafe,
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