pub struct SolverScope<'t, S: PlanningSolution, D: ScoreDirector<S>> { /* private fields */ }Expand description
Top-level scope for the entire solving process.
Holds the working solution, score director, and tracks the best solution found.
§Type Parameters
't- Lifetime of the termination flag referenceS- The planning solution typeD- The score director type
Implementations§
Source§impl<'t, S: PlanningSolution, D: ScoreDirector<S>> SolverScope<'t, S, D>
impl<'t, S: PlanningSolution, D: ScoreDirector<S>> SolverScope<'t, S, D>
Sourcepub fn new(score_director: D) -> Self
pub fn new(score_director: D) -> Self
Creates a new solver scope with the given score director.
Sourcepub fn with_terminate(
score_director: D,
terminate: Option<&'t AtomicBool>,
) -> Self
pub fn with_terminate( score_director: D, terminate: Option<&'t AtomicBool>, ) -> Self
Creates a solver scope with a termination flag.
Sourcepub fn with_seed(score_director: D, seed: u64) -> Self
pub fn with_seed(score_director: D, seed: u64) -> Self
Creates a solver scope with a specific random seed.
Sourcepub fn start_solving(&mut self)
pub fn start_solving(&mut self)
Marks the start of solving.
Sourcepub fn score_director(&self) -> &D
pub fn score_director(&self) -> &D
Returns a reference to the score director.
Sourcepub fn score_director_mut(&mut self) -> &mut D
pub fn score_director_mut(&mut self) -> &mut D
Returns a mutable reference to the score director.
Sourcepub fn working_solution(&self) -> &S
pub fn working_solution(&self) -> &S
Returns a reference to the working solution.
Sourcepub fn working_solution_mut(&mut self) -> &mut S
pub fn working_solution_mut(&mut self) -> &mut S
Returns a mutable reference to the working solution.
Sourcepub fn calculate_score(&mut self) -> S::Score
pub fn calculate_score(&mut self) -> S::Score
Calculates and returns the current score.
Sourcepub fn best_solution(&self) -> Option<&S>
pub fn best_solution(&self) -> Option<&S>
Returns the best solution found so far.
Sourcepub fn best_score(&self) -> Option<&S::Score>
pub fn best_score(&self) -> Option<&S::Score>
Returns the best score found so far.
Sourcepub fn update_best_solution(&mut self)
pub fn update_best_solution(&mut self)
Updates the best solution if the current solution is better.
Sourcepub fn set_best_solution(&mut self, solution: S, score: S::Score)
pub fn set_best_solution(&mut self, solution: S, score: S::Score)
Forces an update of the best solution regardless of score comparison.
Sourcepub fn increment_step_count(&mut self) -> u64
pub fn increment_step_count(&mut self) -> u64
Increments and returns the total step count.
Sourcepub fn total_step_count(&self) -> u64
pub fn total_step_count(&self) -> u64
Returns the total step count.
Sourcepub fn take_best_solution(self) -> Option<S>
pub fn take_best_solution(self) -> Option<S>
Extracts the best solution, consuming this scope.
Sourcepub fn take_best_or_working_solution(self) -> S
pub fn take_best_or_working_solution(self) -> S
Returns the best solution or the current working solution if no best was set.
Sourcepub fn is_terminate_early(&self) -> bool
pub fn is_terminate_early(&self) -> bool
Checks if early termination was requested (external flag only).
Sourcepub fn set_time_limit(&mut self, limit: Duration)
pub fn set_time_limit(&mut self, limit: Duration)
Sets the time limit for solving.
Sourcepub fn should_terminate(&self) -> bool
pub fn should_terminate(&self) -> bool
Checks if solving should terminate (external flag OR time limit).
Sourcepub fn stats(&self) -> &SolverStats
pub fn stats(&self) -> &SolverStats
Returns a reference to the solver statistics.
Sourcepub fn stats_mut(&mut self) -> &mut SolverStats
pub fn stats_mut(&mut self) -> &mut SolverStats
Returns a mutable reference to the solver statistics.
Auto Trait Implementations§
impl<'t, S, D> Freeze for SolverScope<'t, S, D>
impl<'t, S, D> RefUnwindSafe for SolverScope<'t, S, D>
impl<'t, S, D> Send for SolverScope<'t, S, D>
impl<'t, S, D> Sync for SolverScope<'t, S, D>where
D: Sync,
impl<'t, S, D> Unpin for SolverScope<'t, S, D>
impl<'t, S, D> UnwindSafe for SolverScope<'t, S, D>
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
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>
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>
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