pub struct TriConstraintStream<S, A, K, E, KE, F, Sc>where
Sc: Score,{ /* private fields */ }Implementations§
Source§impl<S, A, K, E, KE, Sc> TriConstraintStream<S, A, K, E, KE, TrueFilter, Sc>
impl<S, A, K, E, KE, Sc> TriConstraintStream<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> TriConstraintStream<S, A, K, E, KE, F, Sc>
impl<S, A, K, E, KE, F, Sc> TriConstraintStream<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, ) -> TriConstraintStream<S, A, K, E, KE, AndTriFilter<F, FnTriFilter<impl Fn(&S, &A, &A, &A) -> bool + Send + Sync>>, Sc>
pub fn penalize(
self,
weight: Sc,
) -> TriConstraintBuilder<S, A, K, E, KE, F, impl Fn(&A, &A, &A) -> Sc + Send + Sync, Sc>where
Sc: Copy,
pub fn penalize_with<W>( self, weight_fn: W, ) -> TriConstraintBuilder<S, A, K, E, KE, F, W, Sc>
pub fn penalize_hard_with<W>( self, weight_fn: W, ) -> TriConstraintBuilder<S, A, K, E, KE, F, W, Sc>
pub fn reward(
self,
weight: Sc,
) -> TriConstraintBuilder<S, A, K, E, KE, F, impl Fn(&A, &A, &A) -> Sc + Send + Sync, Sc>where
Sc: Copy,
pub fn reward_with<W>( self, weight_fn: W, ) -> TriConstraintBuilder<S, A, K, E, KE, F, W, Sc>
pub fn reward_hard_with<W>( self, weight_fn: W, ) -> TriConstraintBuilder<S, A, K, E, KE, F, W, Sc>
Source§impl<S, A, K, E, KE, F, Sc> TriConstraintStream<S, A, K, E, KE, F, Sc>
impl<S, A, K, E, KE, F, Sc> TriConstraintStream<S, A, K, E, KE, F, Sc>
Sourcepub fn join_self<J>(
self,
joiner: J,
) -> QuadConstraintStream<S, A, K, E, KE, impl QuadFilter<S, A, A, A, A>, Sc>where
J: Joiner<A, A> + 'static,
F: 'static,
pub fn join_self<J>(
self,
joiner: J,
) -> QuadConstraintStream<S, A, K, E, KE, impl QuadFilter<S, A, A, A, A>, Sc>where
J: Joiner<A, A> + 'static,
F: 'static,
Joins this stream with a fourth element to create quadruples.
§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 four 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))
.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: 1 },
Task { team: 2 },
],
};
// One quadruple on team 1: (0, 1, 2, 3) = -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 TriConstraintStream<S, A, K, E, KE, F, Sc>
impl<S, A, K, E, KE, F, Sc> RefUnwindSafe for TriConstraintStream<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 TriConstraintStream<S, A, K, E, KE, F, Sc>
impl<S, A, K, E, KE, F, Sc> Sync for TriConstraintStream<S, A, K, E, KE, F, Sc>
impl<S, A, K, E, KE, F, Sc> Unpin for TriConstraintStream<S, A, K, E, KE, F, Sc>
impl<S, A, K, E, KE, F, Sc> UnwindSafe for TriConstraintStream<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