pub struct StrongestFitForager<S, M>where
S: PlanningSolution,
M: Move<S>,{ /* private fields */ }Expand description
Strongest Fit forager - picks the move with the highest strength value.
This forager evaluates each candidate move using a strength function and selects the move with the maximum strength. This is useful for assigning the “strongest” or most constraining values first.
§Example
use solverforge_solver::phase::construction::{StrongestFitForager, ConstructionForager};
use solverforge_solver::heuristic::r#move::ChangeMove;
use solverforge_core::domain::PlanningSolution;
use solverforge_core::score::SimpleScore;
#[derive(Clone, Debug)]
struct Task { priority: Option<i32> }
#[derive(Clone, Debug)]
struct Solution { tasks: Vec<Task>, score: Option<SimpleScore> }
impl PlanningSolution for Solution {
type Score = SimpleScore;
fn score(&self) -> Option<Self::Score> { self.score }
fn set_score(&mut self, score: Option<Self::Score>) { self.score = score; }
}
// Strength function: priority value (higher = stronger)
fn priority_strength(m: &ChangeMove<Solution, i32>) -> i64 {
m.to_value().map(|&v| v as i64).unwrap_or(0)
}
let forager = StrongestFitForager::<Solution, ChangeMove<Solution, i32>>::new(priority_strength);Implementations§
Source§impl<S, M> StrongestFitForager<S, M>where
S: PlanningSolution,
M: Move<S>,
impl<S, M> StrongestFitForager<S, M>where
S: PlanningSolution,
M: Move<S>,
Trait Implementations§
Source§impl<S, M> ConstructionForager<S, M> for StrongestFitForager<S, M>where
S: PlanningSolution,
M: Move<S>,
impl<S, M> ConstructionForager<S, M> for StrongestFitForager<S, M>where
S: PlanningSolution,
M: Move<S>,
Auto Trait Implementations§
impl<S, M> Freeze for StrongestFitForager<S, M>
impl<S, M> RefUnwindSafe for StrongestFitForager<S, M>where
S: RefUnwindSafe,
impl<S, M> Send for StrongestFitForager<S, M>
impl<S, M> Sync for StrongestFitForager<S, M>
impl<S, M> Unpin for StrongestFitForager<S, M>where
S: Unpin,
impl<S, M> UnwindSafe for StrongestFitForager<S, M>where
S: 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