pub struct StatisticsCollector<Sc: Score> { /* private fields */ }Expand description
Thread-safe collector for solver statistics.
Use this to record statistics during solving. After solving, call
into_statistics() to get the final SolverStatistics.
Implementations§
Source§impl<Sc: Score> StatisticsCollector<Sc>
impl<Sc: Score> StatisticsCollector<Sc>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new statistics collector.
The start time is recorded when this is called.
Sourcepub fn record_move_evaluated(&self)
pub fn record_move_evaluated(&self)
Records a move evaluation.
Call this each time a move is evaluated, regardless of whether it was accepted.
Sourcepub fn record_move_accepted(&self)
pub fn record_move_accepted(&self)
Records an accepted move.
Call this when a move is accepted (in addition to record_move_evaluated).
Sourcepub fn record_move(&self, accepted: bool)
pub fn record_move(&self, accepted: bool)
Records both evaluation and acceptance for a move.
Convenience method when you know the move was accepted.
Sourcepub fn record_step(&self)
pub fn record_step(&self)
Records a step completion.
Sourcepub fn record_score_calculation(&self)
pub fn record_score_calculation(&self)
Records a score calculation.
Sourcepub fn record_improvement(&self, score: Sc)
pub fn record_improvement(&self, score: Sc)
Records a score improvement.
Call this when a new best score is found.
Sourcepub fn start_phase(&self, phase_type: impl Into<String>) -> usize
pub fn start_phase(&self, phase_type: impl Into<String>) -> usize
Starts a new phase and returns its index.
Call this at the beginning of each phase.
Sourcepub fn end_phase(
&self,
phase_index: usize,
duration: Duration,
step_count: u64,
moves_evaluated: u64,
moves_accepted: u64,
starting_score: Option<Sc>,
ending_score: Option<Sc>,
)
pub fn end_phase( &self, phase_index: usize, duration: Duration, step_count: u64, moves_evaluated: u64, moves_accepted: u64, starting_score: Option<Sc>, ending_score: Option<Sc>, )
Ends the current phase with the given statistics.
Call this at the end of each phase.
Sourcepub fn current_step_count(&self) -> u64
pub fn current_step_count(&self) -> u64
Returns the current step count.
Sourcepub fn current_moves_evaluated(&self) -> u64
pub fn current_moves_evaluated(&self) -> u64
Returns the current moves evaluated count.
Sourcepub fn current_moves_accepted(&self) -> u64
pub fn current_moves_accepted(&self) -> u64
Returns the current moves accepted count.
Sourcepub fn current_score_calculations(&self) -> u64
pub fn current_score_calculations(&self) -> u64
Returns the current score calculation count.
Sourcepub fn into_statistics(self) -> SolverStatistics<Sc>
pub fn into_statistics(self) -> SolverStatistics<Sc>
Converts this collector into final statistics.
This consumes the collector and returns the complete statistics.
Sourcepub fn snapshot(&self) -> SolverStatistics<Sc>
pub fn snapshot(&self) -> SolverStatistics<Sc>
Takes a snapshot of current statistics without consuming the collector.