pub struct DiminishedReturnsTermination<S: PlanningSolution> { /* private fields */ }Expand description
Terminates when the rate of score improvement falls below a threshold.
Tracks score improvements over a sliding time window and terminates when the improvement rate drops below a minimum, indicating diminished returns from continued optimization.
§Example
use std::time::Duration;
use solverforge_solver::termination::DiminishedReturnsTermination;
use solverforge_core::score::SimpleScore;
use solverforge_core::domain::PlanningSolution;
#[derive(Clone)]
struct MySolution;
impl PlanningSolution for MySolution {
type Score = SimpleScore;
fn score(&self) -> Option<Self::Score> { None }
fn set_score(&mut self, _: Option<Self::Score>) {}
}
// Terminate when improvement rate falls below 0.1 per second over a 10s window
let term = DiminishedReturnsTermination::<MySolution>::new(
Duration::from_secs(10),
0.1,
);Implementations§
Source§impl<S: PlanningSolution> DiminishedReturnsTermination<S>
impl<S: PlanningSolution> DiminishedReturnsTermination<S>
Sourcepub fn new(window: Duration, min_rate: f64) -> Self
pub fn new(window: Duration, min_rate: f64) -> Self
Creates a new diminished returns termination.
§Arguments
window- Time window for measuring improvement ratemin_rate- Minimum improvement rate (score units per second)
Sourcepub fn with_seconds(window_secs: u64, min_rate: f64) -> Self
pub fn with_seconds(window_secs: u64, min_rate: f64) -> Self
Creates with a window in seconds.
Trait Implementations§
Source§impl<S: PlanningSolution> Debug for DiminishedReturnsTermination<S>
impl<S: PlanningSolution> Debug for DiminishedReturnsTermination<S>
Source§impl<S: PlanningSolution, D: ScoreDirector<S>> Termination<S, D> for DiminishedReturnsTermination<S>
impl<S: PlanningSolution, D: ScoreDirector<S>> Termination<S, D> for DiminishedReturnsTermination<S>
Source§fn is_terminated(&self, solver_scope: &SolverScope<'_, S, D>) -> bool
fn is_terminated(&self, solver_scope: &SolverScope<'_, S, D>) -> bool
Returns true if solving should terminate.
impl<S: PlanningSolution> Send for DiminishedReturnsTermination<S>
Auto Trait Implementations§
impl<S> !Freeze for DiminishedReturnsTermination<S>
impl<S> !RefUnwindSafe for DiminishedReturnsTermination<S>
impl<S> !Sync for DiminishedReturnsTermination<S>
impl<S> Unpin for DiminishedReturnsTermination<S>
impl<S> UnwindSafe for DiminishedReturnsTermination<S>
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
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>
Converts
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>
Converts
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