Skip to main content

BasicPopulationState

Struct BasicPopulationState 

Source
pub struct BasicPopulationState<V> { /* private fields */ }
Expand description

Default PopulationState implementation: λ candidate parameters and parallel costs. The solver keeps both sorted by ascending cost at the start and end of every next_iter, so State::param / State::cost always return the current best candidate.

Vehicle for RandomSearch; will be reused by CMA-ES (S8) without changes.

Implementations§

Source§

impl<V> BasicPopulationState<V>

Source

pub fn from_population(candidates: Vec<V>) -> Self

Build from a pre-constructed population (advanced users; custom initial distributions). Costs are filled by the solver in Solver::init.

§Panics

Panics if candidates is empty — a population must have at least one member.

Source

pub fn with_size(lambda: usize) -> Self

Empty container with lambda capacity reserved. The solver fills it in Solver::init (e.g. by sampling uniformly in the problem’s box).

Use this constructor when the solver owns the initial- population distribution (the random-search style); use from_population when the caller owns it.

§Panics

Panics if lambda == 0.

Trait Implementations§

Source§

impl<V> PopulationState for BasicPopulationState<V>

Source§

fn candidates(&self) -> &[V]

All λ candidates, sorted by ascending cost.
Source§

fn costs(&self) -> &[f64]

Costs in parallel with candidates, sorted ascending.
Source§

impl<P, V, M> Solver<P, BasicPopulationState<V>> for BoundedCmaEs<V, M>

Source§

fn init( &mut self, problem: &P, state: BasicPopulationState<V>, ) -> BasicPopulationState<V>

One-time setup before the iteration loop. Read more
Source§

fn next_iter( &mut self, problem: &P, state: BasicPopulationState<V>, ) -> (BasicPopulationState<V>, Option<TerminationReason>)

Advance one iteration. Read more
Source§

fn terminate( &self, _state: &BasicPopulationState<V>, ) -> Option<TerminationReason>

Optional pre-iteration solver-specific termination test. Read more
Source§

impl<P, I, V, M> Solver<P, BasicPopulationState<V>> for BoundedCmaInject<I, V, M>

Source§

fn init( &mut self, problem: &P, state: BasicPopulationState<V>, ) -> BasicPopulationState<V>

One-time setup before the iteration loop. Read more
Source§

fn next_iter( &mut self, problem: &P, state: BasicPopulationState<V>, ) -> (BasicPopulationState<V>, Option<TerminationReason>)

Advance one iteration. Read more
Source§

fn terminate( &self, state: &BasicPopulationState<V>, ) -> Option<TerminationReason>

Optional pre-iteration solver-specific termination test. Read more
Source§

impl<P, V, M> Solver<P, BasicPopulationState<V>> for CmaEs<V, M>

Source§

fn init( &mut self, problem: &P, state: BasicPopulationState<V>, ) -> BasicPopulationState<V>

One-time setup before the iteration loop. Read more
Source§

fn next_iter( &mut self, problem: &P, state: BasicPopulationState<V>, ) -> (BasicPopulationState<V>, Option<TerminationReason>)

Advance one iteration. Read more
Source§

fn terminate( &self, _state: &BasicPopulationState<V>, ) -> Option<TerminationReason>

Optional pre-iteration solver-specific termination test. Read more
Source§

impl<P, I, V, M> Solver<P, BasicPopulationState<V>> for CmaInject<I, V, M>
where P: CostFunction<Param = V, Output = f64>, I: MemeticInner<V> + Solver<P, <I as MemeticInner<V>>::State>, I::State: State<Param = V, Float = f64>, V: VectorLen + Clone + ScaledAdd<f64> + ScaleInPlace + ComponentMulAssign + NormSquared + SampleStandardNormal + Index<usize, Output = f64> + IndexMut<usize, Output = f64>, M: MatrixIdentity + MatVec<V> + MatTransposeVec<V> + ScaleInPlace + RankOneUpdate<V> + SymmetricEigen<V> + Clone,

Source§

fn init( &mut self, problem: &P, state: BasicPopulationState<V>, ) -> BasicPopulationState<V>

One-time setup before the iteration loop. Read more
Source§

fn next_iter( &mut self, problem: &P, state: BasicPopulationState<V>, ) -> (BasicPopulationState<V>, Option<TerminationReason>)

Advance one iteration. Read more
Source§

fn terminate( &self, state: &BasicPopulationState<V>, ) -> Option<TerminationReason>

Optional pre-iteration solver-specific termination test. Read more
Source§

impl<P, V> Solver<P, BasicPopulationState<V>> for RandomSearch
where P: CostFunction<Param = V, Output = f64> + BoxConstrained<Param = V>, V: SampleUniformBox + Clone,

Source§

fn init( &mut self, problem: &P, state: BasicPopulationState<V>, ) -> BasicPopulationState<V>

One-time setup before the iteration loop. Read more
Source§

fn next_iter( &mut self, problem: &P, state: BasicPopulationState<V>, ) -> (BasicPopulationState<V>, Option<TerminationReason>)

Advance one iteration. Read more
Source§

fn terminate(&self, _state: &S) -> Option<TerminationReason>

Optional pre-iteration solver-specific termination test. Read more
Source§

impl<P, V> Solver<P, BasicPopulationState<V>> for Ssga
where P: CostFunction<Param = V, Output = f64> + BoxConstrained<Param = V>, V: VectorLen + Clone + SampleUniformBox + ScaledAdd<f64> + NormSquared + Index<usize, Output = f64> + IndexMut<usize, Output = f64>,

Source§

fn init( &mut self, problem: &P, state: BasicPopulationState<V>, ) -> BasicPopulationState<V>

One-time setup before the iteration loop. Read more
Source§

fn next_iter( &mut self, problem: &P, state: BasicPopulationState<V>, ) -> (BasicPopulationState<V>, Option<TerminationReason>)

Advance one iteration. Read more
Source§

fn terminate(&self, _state: &S) -> Option<TerminationReason>

Optional pre-iteration solver-specific termination test. Read more
Source§

impl<V> State for BasicPopulationState<V>

Source§

type Param = V

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

type Float = f64

The scalar type of the objective. In practice always f64 (see the module docs).
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 count of cost-function evaluations performed so far. 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.
Source§

fn increment_cost_evals(&mut self, by: u64)

Increase the cost-eval counter by by. Solvers call this whenever they invoke the problem’s cost function.
Source§

fn param(&self) -> &V

Current iterate. Stable between Solver::next_iter calls; safe to read at any iteration including iter 0.
Source§

fn cost(&self) -> f64

Cost at the current param. Read more

Auto Trait Implementations§

§

impl<V> Freeze for BasicPopulationState<V>

§

impl<V> RefUnwindSafe for BasicPopulationState<V>
where V: RefUnwindSafe,

§

impl<V> Send for BasicPopulationState<V>
where V: Send,

§

impl<V> Sync for BasicPopulationState<V>
where V: Sync,

§

impl<V> Unpin for BasicPopulationState<V>
where V: Unpin,

§

impl<V> UnsafeUnpin for BasicPopulationState<V>

§

impl<V> UnwindSafe for BasicPopulationState<V>
where V: UnwindSafe,

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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