pub struct SimulatedAnnealingState<P, N, F = f64, R = ChaCha8Rng> { /* private fields */ }Expand description
State for SimulatedAnnealing.
This type stores every evolving component of the Markov chain: the stateful
neighbor, RNG, cooling phase, reannealing progress, incumbent, best-so-far
history, and counters. With the serde feature, serializing this state and
passing the restored value to
Executor::resume continues the same chain.
Solver-aware ExactCheckpoint snapshots remain
available through
Executor::resume_from_checkpoint.
Implementations§
Source§impl<P, N, F, R> SimulatedAnnealingState<P, N, F, R>where
F: Scalar,
impl<P, N, F, R> SimulatedAnnealingState<P, N, F, R>where
F: Scalar,
Sourcepub fn temperature(&self) -> F
pub fn temperature(&self) -> F
Temperature that will be used for the next proposal.
Sourcepub fn accepted_moves(&self) -> u64
pub fn accepted_moves(&self) -> u64
Number of accepted proposals.
Sourcepub fn rejected_moves(&self) -> u64
pub fn rejected_moves(&self) -> u64
Number of rejected proposals.
Sourcepub fn reannealings(&self) -> u64
pub fn reannealings(&self) -> u64
Number of completed schedule restarts.
Sourcepub fn last_accepted_iter(&self) -> u64
pub fn last_accepted_iter(&self) -> u64
Absolute iteration of the most recently accepted proposal.
Trait Implementations§
Source§impl<P, N, F, R> AcceptanceState for SimulatedAnnealingState<P, N, F, R>where
SimulatedAnnealingState<P, N, F, R>: State,
impl<P, N, F, R> AcceptanceState for SimulatedAnnealingState<P, N, F, R>where
SimulatedAnnealingState<P, N, F, R>: State,
Source§fn last_accepted_iter(&self) -> u64
fn last_accepted_iter(&self) -> u64
Absolute iteration of the most recently accepted proposal.
Source§fn accepted_moves(&self) -> u64
fn accepted_moves(&self) -> u64
Cumulative number of accepted proposals.
Source§fn rejected_moves(&self) -> u64
fn rejected_moves(&self) -> u64
Cumulative number of rejected proposals.
Source§impl<P, N, F, R> CountsMirror for SimulatedAnnealingState<P, N, F, R>where
SimulatedAnnealingState<P, N, F, R>: State,
impl<P, N, F, R> CountsMirror for SimulatedAnnealingState<P, N, F, R>where
SimulatedAnnealingState<P, N, F, R>: State,
Source§fn mirror(&mut self, counts: &EvalCounts)
fn mirror(&mut self, counts: &EvalCounts)
Overwrite the state’s counters from the per-run wrapper delta.
Called by the executor after every successful
Solver::init /
Solver::next_iter.Source§impl<'de, P, N, F, R> Deserialize<'de> for SimulatedAnnealingState<P, N, F, R>
Available on crate feature serde only.
impl<'de, P, N, F, R> Deserialize<'de> for SimulatedAnnealingState<P, N, F, R>
Available on crate feature
serde only.Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<P, N, F, R> ExactResumeState for SimulatedAnnealingState<P, N, F, R>where
SimulatedAnnealingState<P, N, F, R>: State,
impl<P, N, F, R> ExactResumeState for SimulatedAnnealingState<P, N, F, R>where
SimulatedAnnealingState<P, N, F, R>: State,
Source§fn resume_counts(&self) -> EvalCounts
fn resume_counts(&self) -> EvalCounts
Complete evaluation counts at the point represented by this snapshot.
Source§impl<P, N, F, R> Serialize for SimulatedAnnealingState<P, N, F, R>
Available on crate feature serde only.
impl<P, N, F, R> Serialize for SimulatedAnnealingState<P, N, F, R>
Available on crate feature
serde only.Source§impl<P, V, N, F, R> Solver<P, SimulatedAnnealingState<V, N, F, R>> for SimulatedAnnealing<N, F, R>
impl<P, V, N, F, R> Solver<P, SimulatedAnnealingState<V, N, F, R>> for SimulatedAnnealing<N, F, R>
Source§type Error = <P as CostFunction>::Error
type Error = <P as CostFunction>::Error
Hard-abort error type, mirroring the underlying problem’s
type Error. See the trait docs.Source§fn init(
&mut self,
problem: &mut Problem<P>,
state: SimulatedAnnealingState<V, N, F, R>,
) -> Result<SimulatedAnnealingState<V, N, F, R>, Self::Error>
fn init( &mut self, problem: &mut Problem<P>, state: SimulatedAnnealingState<V, N, F, R>, ) -> Result<SimulatedAnnealingState<V, N, F, R>, Self::Error>
One-time setup before the iteration loop. Read more
Source§fn next_iter(
&mut self,
problem: &mut Problem<P>,
state: SimulatedAnnealingState<V, N, F, R>,
) -> Result<(SimulatedAnnealingState<V, N, F, R>, Option<TerminationReason>), Self::Error>
fn next_iter( &mut self, problem: &mut Problem<P>, state: SimulatedAnnealingState<V, N, F, R>, ) -> Result<(SimulatedAnnealingState<V, N, F, R>, Option<TerminationReason>), Self::Error>
Advance one iteration. Read more
Source§fn terminate(
&self,
state: &SimulatedAnnealingState<V, N, F, R>,
) -> Option<TerminationReason>
fn terminate( &self, state: &SimulatedAnnealingState<V, N, F, R>, ) -> Option<TerminationReason>
Optional pre-iteration solver-specific termination test. Read more
Source§fn reset_convergence(&mut self)
fn reset_convergence(&mut self)
Reset per-run convergence history without changing algorithm state. Read more
Source§fn check_convergence(
&mut self,
_problem: &Problem<P>,
state: &S,
) -> Option<TerminationReason>
fn check_convergence( &mut self, _problem: &Problem<P>, state: &S, ) -> Option<TerminationReason>
Check convergence at an initialized iteration boundary. Read more
Source§impl<P, N, F, R> State for SimulatedAnnealingState<P, N, F, R>
impl<P, N, F, R> State for SimulatedAnnealingState<P, N, F, R>
Source§type Param = P
type Param = P
The parameter type the solver iterates over (e.g.
Vec<f64>,
nalgebra::DVector<f64>).Source§fn iter(&self) -> u64
fn iter(&self) -> u64
Number of fully completed iterations. A
Solver::next_iter
that bails mid-iteration with Some(reason) does not increment
this counter; see the
executor module for the exact ordering.Source§fn increment_iter(&mut self)
fn increment_iter(&mut self)
Increment
iter by one. Called by the executor
after a successful Solver::next_iter.Source§fn cost_evals(&self) -> u64
fn cost_evals(&self) -> u64
Cumulative evaluation work under the state’s
CountsMirror mapping.
In Basin 1.x this can include residual or derivative work as well as
cost-function calls; it is not uniformly the raw cost-call count.
Diverges from iter() whenever a single iteration evaluates the
cost more than once (line searches, Nelder-Mead shrinks, etc.);
this is what users actually budget against. Read moreSource§fn param(&self) -> &P
fn param(&self) -> &P
Current iterate. Stable between
Solver::next_iter
calls; available after successful initialization, including iter 0.
Some constructors supply it immediately, while an empty population
such as BasicPopulationState::with_size must first be initialized.Source§fn best_param(&self) -> &P
fn best_param(&self) -> &P
Selected incumbent under this state’s best-tracking rule. Read more
Source§fn best_cost(&self) -> F
fn best_cost(&self) -> F
Cost of the selected incumbent. This is the historical minimum for
objective-ordered states, but can increase under constrained
incumbent selection.
Source§fn best_iter(&self) -> u64
fn best_iter(&self) -> u64
Iteration recorded by the most recent incumbent update. Objective-
ordered states record strict improvements; states that mirror a
solver-selected incumbent may refresh this on every publication.
Source§fn best_cost_evals(&self) -> u64
fn best_cost_evals(&self) -> u64
cost_evals at the publication boundary that
recorded the incumbent. This need not be the precise evaluation
that found the point.Source§fn update_best(&mut self)
fn update_best(&mut self)
Refresh the incumbent using this state’s selection rule. Most
states retain strict objective improvements; population states can
also consider exposed samples, and constrained states can mirror
the solver’s selected incumbent. Read more
Source§fn reset_best(&mut self)
fn reset_best(&mut self)
Reset the best-so-far slots to their pre-init defaults
(
best_cost = +∞, all best counters zero). Read moreAuto Trait Implementations§
impl<P, N, F, R> Freeze for SimulatedAnnealingState<P, N, F, R>
impl<P, N, F, R> RefUnwindSafe for SimulatedAnnealingState<P, N, F, R>where
P: RefUnwindSafe,
Option<F>: RefUnwindSafe,
Option<P>: RefUnwindSafe,
F: RefUnwindSafe,
N: RefUnwindSafe,
R: RefUnwindSafe,
TemperatureSchedule<F>: RefUnwindSafe,
impl<P, N, F, R> Send for SimulatedAnnealingState<P, N, F, R>
impl<P, N, F, R> Sync for SimulatedAnnealingState<P, N, F, R>
impl<P, N, F, R> Unpin for SimulatedAnnealingState<P, N, F, R>
impl<P, N, F, R> UnsafeUnpin for SimulatedAnnealingState<P, N, F, R>where
P: UnsafeUnpin,
Option<F>: UnsafeUnpin,
Option<P>: UnsafeUnpin,
F: UnsafeUnpin,
N: UnsafeUnpin,
R: UnsafeUnpin,
TemperatureSchedule<F>: UnsafeUnpin,
impl<P, N, F, R> UnwindSafe for SimulatedAnnealingState<P, N, F, R>where
P: UnwindSafe,
Option<F>: UnwindSafe,
Option<P>: UnwindSafe,
F: UnwindSafe,
N: UnwindSafe,
R: UnwindSafe,
TemperatureSchedule<F>: 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T, U> Imply<T> for U
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.