pub struct BiConstraintStream<S, A, K, E, KE, F, Sc>where
Sc: Score,{ /* private fields */ }Implementations§
Source§impl<S, A, K, E, KE, Sc> BiConstraintStream<S, A, K, E, KE, TrueFilter, Sc>
impl<S, A, K, E, KE, Sc> BiConstraintStream<S, A, K, E, KE, TrueFilter, Sc>
pub fn new_self_join(extractor: E, key_extractor: KE) -> Self
Source§impl<S, A, K, E, KE, F, Sc> BiConstraintStream<S, A, K, E, KE, F, Sc>
impl<S, A, K, E, KE, F, Sc> BiConstraintStream<S, A, K, E, KE, F, Sc>
pub fn new_self_join_with_filter( extractor: E, key_extractor: KE, filter: F, ) -> Self
pub fn filter<P>( self, predicate: P, ) -> BiConstraintStream<S, A, K, E, KE, AndBiFilter<F, FnBiFilter<P>>, Sc>
pub fn penalize(
self,
weight: Sc,
) -> BiConstraintBuilder<S, A, K, E, KE, F, impl Fn(&A, &A) -> Sc + Send + Sync, Sc>where
Sc: Clone,
pub fn penalize_with<W>( self, weight_fn: W, ) -> BiConstraintBuilder<S, A, K, E, KE, F, W, Sc>
pub fn penalize_hard_with<W>( self, weight_fn: W, ) -> BiConstraintBuilder<S, A, K, E, KE, F, W, Sc>
pub fn reward(
self,
weight: Sc,
) -> BiConstraintBuilder<S, A, K, E, KE, F, impl Fn(&A, &A) -> Sc + Send + Sync, Sc>where
Sc: Clone,
pub fn reward_with<W>( self, weight_fn: W, ) -> BiConstraintBuilder<S, A, K, E, KE, F, W, Sc>
pub fn reward_hard_with<W>( self, weight_fn: W, ) -> BiConstraintBuilder<S, A, K, E, KE, F, W, Sc>
Source§impl<S, A, K, E, KE, F, Sc> BiConstraintStream<S, A, K, E, KE, F, Sc>
impl<S, A, K, E, KE, F, Sc> BiConstraintStream<S, A, K, E, KE, F, Sc>
Sourcepub fn join_self<J>(
self,
joiner: J,
) -> TriConstraintStream<S, A, K, E, KE, impl TriFilter<A, A, A>, Sc>where
J: Joiner<A, A> + 'static,
F: 'static,
pub fn join_self<J>(
self,
joiner: J,
) -> TriConstraintStream<S, A, K, E, KE, impl TriFilter<A, A, A>, Sc>where
J: Joiner<A, A> + 'static,
F: 'static,
Joins this stream with a third element to create triples.
§Example
use solverforge_scoring::stream::ConstraintFactory;
use solverforge_scoring::stream::joiner::equal;
use solverforge_scoring::api::constraint_set::IncrementalConstraint;
use solverforge_core::score::SimpleScore;
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
struct Task { team: u32 }
#[derive(Clone)]
struct Solution { tasks: Vec<Task> }
// Penalize when three tasks are on the same team
let constraint = ConstraintFactory::<Solution, SimpleScore>::new()
.for_each(|s: &Solution| s.tasks.as_slice())
.join_self(equal(|t: &Task| t.team))
.join_self(equal(|t: &Task| t.team))
.penalize(SimpleScore::of(1))
.as_constraint("Team clustering");
let solution = Solution {
tasks: vec![
Task { team: 1 },
Task { team: 1 },
Task { team: 1 },
Task { team: 2 },
],
};
// One triple on team 1: (0, 1, 2) = -1 penalty
assert_eq!(constraint.evaluate(&solution), SimpleScore::of(-1));Trait Implementations§
Auto Trait Implementations§
impl<S, A, K, E, KE, F, Sc> Freeze for BiConstraintStream<S, A, K, E, KE, F, Sc>
impl<S, A, K, E, KE, F, Sc> RefUnwindSafe for BiConstraintStream<S, A, K, E, KE, F, Sc>where
E: RefUnwindSafe,
KE: RefUnwindSafe,
F: RefUnwindSafe,
S: RefUnwindSafe,
A: RefUnwindSafe,
K: RefUnwindSafe,
Sc: RefUnwindSafe,
impl<S, A, K, E, KE, F, Sc> Send for BiConstraintStream<S, A, K, E, KE, F, Sc>
impl<S, A, K, E, KE, F, Sc> Sync for BiConstraintStream<S, A, K, E, KE, F, Sc>
impl<S, A, K, E, KE, F, Sc> Unpin for BiConstraintStream<S, A, K, E, KE, F, Sc>
impl<S, A, K, E, KE, F, Sc> UnwindSafe for BiConstraintStream<S, A, K, E, KE, F, Sc>where
E: UnwindSafe,
KE: UnwindSafe,
F: UnwindSafe,
S: UnwindSafe,
A: UnwindSafe,
K: UnwindSafe,
Sc: 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