Skip to main content

SimulatedAnnealingState

Struct SimulatedAnnealingState 

Source
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,

Source

pub fn temperature(&self) -> F

Temperature that will be used for the next proposal.

Source

pub fn accepted_moves(&self) -> u64

Number of accepted proposals.

Source

pub fn rejected_moves(&self) -> u64

Number of rejected proposals.

Source

pub fn reannealings(&self) -> u64

Number of completed schedule restarts.

Source

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,

Source§

fn last_accepted_iter(&self) -> u64

Absolute iteration of the most recently accepted proposal.
Source§

fn accepted_moves(&self) -> u64

Cumulative number of accepted proposals.
Source§

fn rejected_moves(&self) -> u64

Cumulative number of rejected proposals.
Source§

impl<P: Clone, N: Clone, F: Clone, R: Clone> Clone for SimulatedAnnealingState<P, N, F, R>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

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)

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<P: Debug, N: Debug, F: Debug, R: Debug> Debug for SimulatedAnnealingState<P, N, F, R>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de, P, N, F, R> Deserialize<'de> for SimulatedAnnealingState<P, N, F, R>
where P: Deserialize<'de>, N: Deserialize<'de>, F: Deserialize<'de>, R: Deserialize<'de>,

Available on crate feature serde only.
Source§

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,

Source§

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>
where P: Serialize, N: Serialize, F: Serialize, R: Serialize,

Available on crate feature serde only.
Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<P, V, N, F, R> Solver<P, SimulatedAnnealingState<V, N, F, R>> for SimulatedAnnealing<N, F, R>
where P: CostFunction<Param = V, Output = F>, V: Clone, N: Neighbor<V, F, R, Error = P::Error>, F: Scalar, R: Rng,

Source§

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>

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>

Advance one iteration. Read more
Source§

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)

Reset per-run convergence history without changing algorithm state. Read more
Source§

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>
where P: Clone, F: Scalar,

Source§

type Param = P

The parameter type the solver iterates over (e.g. Vec<f64>, nalgebra::DVector<f64>).
Source§

type Float = F

The scalar type of the objective, such as f64 or f32.
Source§

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)

Increment iter by one. Called by the executor after a successful Solver::next_iter.
Source§

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 more
Source§

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 cost(&self) -> F

Cost at the current param. Read more
Source§

fn best_param(&self) -> &P

Selected incumbent under this state’s best-tracking rule. Read more
Source§

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

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

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)

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)

Reset the best-so-far slots to their pre-init defaults (best_cost = +∞, all best counters zero). Read more

Auto 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>

§

impl<P, N, F, R> Send for SimulatedAnnealingState<P, N, F, R>
where P: Send, Option<F>: Send, Option<P>: Send, F: Send, N: Send, R: Send, TemperatureSchedule<F>: Send,

§

impl<P, N, F, R> Sync for SimulatedAnnealingState<P, N, F, R>
where P: Sync, Option<F>: Sync, Option<P>: Sync, F: Sync, N: Sync, R: Sync, TemperatureSchedule<F>: Sync,

§

impl<P, N, F, R> Unpin for SimulatedAnnealingState<P, N, F, R>
where P: Unpin, Option<F>: Unpin, Option<P>: Unpin, F: Unpin, N: Unpin, R: Unpin, TemperatureSchedule<F>: Unpin,

§

impl<P, N, F, R> UnsafeUnpin for SimulatedAnnealingState<P, N, F, R>

§

impl<P, N, F, R> UnwindSafe for SimulatedAnnealingState<P, N, F, R>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

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

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V