pub struct CompleteAssignmentConstraint<P, K, V, F>where
P: Phenotype,
K: Eq + Hash + Debug + Clone + Send + Sync,
V: Debug + Clone + Send + Sync,
F: Fn(&P) -> HashMap<K, V> + Send + Sync + Debug,{ /* private fields */ }
Expand description
Ensures that all required keys are assigned a value.
This constraint is useful for assignment problems where each key must be assigned a value from a set of possible values.
Implementations§
Source§impl<P, K, V, F> CompleteAssignmentConstraint<P, K, V, F>
impl<P, K, V, F> CompleteAssignmentConstraint<P, K, V, F>
Sourcepub fn new<S: Into<String>>(
name: S,
extractor: F,
required_keys: HashSet<K>,
) -> Result<Self>
pub fn new<S: Into<String>>( name: S, extractor: F, required_keys: HashSet<K>, ) -> Result<Self>
Creates a new complete assignment constraint with the given name, extractor function, and set of required keys.
§Arguments
name
- The name of the constraint for error messages.extractor
- A function that extracts the assignments from the phenotype.required_keys
- The set of keys that must be assigned.
§Returns
A new complete assignment constraint, or an error if the name is empty or if the required keys set is empty.
Trait Implementations§
Source§impl<P, K, V, F> Clone for CompleteAssignmentConstraint<P, K, V, F>
impl<P, K, V, F> Clone for CompleteAssignmentConstraint<P, K, V, F>
Source§fn clone(&self) -> CompleteAssignmentConstraint<P, K, V, F>
fn clone(&self) -> CompleteAssignmentConstraint<P, K, V, F>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<P, K, V, F> Constraint<P> for CompleteAssignmentConstraint<P, K, V, F>
impl<P, K, V, F> Constraint<P> for CompleteAssignmentConstraint<P, K, V, F>
Source§fn check(&self, phenotype: &P) -> Vec<ConstraintViolation>
fn check(&self, phenotype: &P) -> Vec<ConstraintViolation>
Checks if the phenotype satisfies this constraint. Read more
Source§fn repair_with_rng(
&self,
phenotype: &mut P,
rng: &mut RandomNumberGenerator,
) -> bool
fn repair_with_rng( &self, phenotype: &mut P, rng: &mut RandomNumberGenerator, ) -> bool
Attempts to repair the phenotype using a random number generator. Read more
Source§fn repair(&self, _phenotype: &mut P) -> bool
fn repair(&self, _phenotype: &mut P) -> bool
Attempts to repair the phenotype to satisfy this constraint. Read more
Source§fn penalty_score(&self, violations: &[ConstraintViolation]) -> f64
fn penalty_score(&self, violations: &[ConstraintViolation]) -> f64
Returns a penalty score for the given constraint violations. Read more
Source§impl<P, K, V, F> Debug for CompleteAssignmentConstraint<P, K, V, F>
impl<P, K, V, F> Debug for CompleteAssignmentConstraint<P, K, V, F>
Auto Trait Implementations§
impl<P, K, V, F> Freeze for CompleteAssignmentConstraint<P, K, V, F>where
F: Freeze,
impl<P, K, V, F> RefUnwindSafe for CompleteAssignmentConstraint<P, K, V, F>
impl<P, K, V, F> Send for CompleteAssignmentConstraint<P, K, V, F>
impl<P, K, V, F> Sync for CompleteAssignmentConstraint<P, K, V, F>
impl<P, K, V, F> Unpin for CompleteAssignmentConstraint<P, K, V, F>
impl<P, K, V, F> UnwindSafe for CompleteAssignmentConstraint<P, K, V, F>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
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 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>
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