pub struct BoundedCmaInject<I, V, M>where
I: MemeticInner<V>,{ /* private fields */ }Expand description
Memetic BoundedCmaEs with Hansen (2011) injection. Sibling of
CmaInject; the outer is the bounded variant
of CMA-ES, and bound-respecting inners (notably
LBFGSB) see the same bounds the outer
enforces via BoundPenalty.
The injection mechanism (Hansen 2011 eq. 4 — Mahalanobis clip,
plug back into the standard CMA update) is unchanged from
CmaInject; only the outer solver is replaced. Adaptive
boundary-penalty bookkeeping inside BoundedCmaEs is orthogonal
to injection — BoundedCmaInject reads the same post-update
m, σ, B, D^{-1} for clipping, and re-evaluates injected
candidates with the same γ-weighted penalty regular samples
receive (otherwise an out-of-box LM/L-BFGS-B refinement would
dominate the population at a spuriously low raw cost — bug
noticed when writing the LM example).
§Inner solver
Generic over any I: MemeticInner<V>. The associated I::State
determines the inner state shape. Shipped impls cover
NelderMead,
LevenbergMarquardt, and
LBFGSB. L-BFGS-B is the natural inner
here — its P: BoxConstraints bound matches the outer’s, and the
same box flows through both ends of the composition.
Note an asymmetry: NM and LM are unconstrained solvers, so even when the outer enforces bounds, their inner polish may step outside the box. The outer’s BoundPenalty re-pulls injected candidates back into feasibility through the penalized re-evaluation below.
§Backends
Same coverage as BoundedCmaEs: nalgebra (DVector / DMatrix)
and faer (Col / Mat). Vec<f64> and ndarray produce a
compile-time error per tenet 5.
§Examples
See BoundedCmaEs for the bounded population-based Executor
pattern; BoundedCmaInject adds a bound-respecting local-search inner.
Implementations§
Source§impl<I, V, M> BoundedCmaInject<I, V, M>where
I: MemeticInner<V>,
impl<I, V, M> BoundedCmaInject<I, V, M>where
I: MemeticInner<V>,
Sourcepub fn with_inner_solver(cma: BoundedCmaEs<V, M>, inner: I) -> Self
pub fn with_inner_solver(cma: BoundedCmaEs<V, M>, inner: I) -> Self
Wrap a configured BoundedCmaEs with inner as the local
refinement step. Defaults: k = 1, inner max_iter = 50,
c_y = Hansen-2011 Table 1 default.
Sourcepub fn with_k(self, k: usize) -> Self
pub fn with_k(self, k: usize) -> Self
Number of best-ranked candidates to refine and inject each
generation. Default 1.
§Panics
Panics if k == 0.
Sourcepub fn with_c_y(self, c_y: f64) -> Self
pub fn with_c_y(self, c_y: f64) -> Self
Override the Hansen-2011 clipping threshold c_y (default
√n + 2n/(n+2)).
§Panics
Panics if c_y <= 0.
Sourcepub fn with_inner_max_iter(self, n: u64) -> Self
pub fn with_inner_max_iter(self, n: u64) -> Self
Inner solver iteration budget per outer generation (default 50).
Sourcepub fn inner_terminate_on<C>(self, criterion: C) -> Selfwhere
C: TerminationCriterion<I::State> + 'static,
pub fn inner_terminate_on<C>(self, criterion: C) -> Selfwhere
C: TerminationCriterion<I::State> + 'static,
Register a stateless termination criterion on the inner loop.
See CmaInject::inner_terminate_on
for the statelessness contract.
Trait Implementations§
Source§impl<P, I, V, M> Solver<P, BasicPopulationState<V>> for BoundedCmaInject<I, V, M>where
P: CostFunction<Param = V, Output = f64> + BoxConstraints,
I: MemeticInner<V> + Solver<P, <I as WarmStart<V>>::State>,
I::State: State<Param = V, Float = f64>,
V: VectorLen + Clone + ScaledAdd<f64> + ScaleInPlace + ComponentMulAssign + ClampInPlace + NormSquared + SampleStandardNormal + Index<usize, Output = f64> + IndexMut<usize, Output = f64>,
M: MatrixIdentity + MatrixFromDiagonal<V> + MatVec<V> + MatTransposeVec<V> + MatDiagonal<V> + ScaleInPlace + RankOneUpdate<V> + SymmetricEigen<V> + Clone,
impl<P, I, V, M> Solver<P, BasicPopulationState<V>> for BoundedCmaInject<I, V, M>where
P: CostFunction<Param = V, Output = f64> + BoxConstraints,
I: MemeticInner<V> + Solver<P, <I as WarmStart<V>>::State>,
I::State: State<Param = V, Float = f64>,
V: VectorLen + Clone + ScaledAdd<f64> + ScaleInPlace + ComponentMulAssign + ClampInPlace + NormSquared + SampleStandardNormal + Index<usize, Output = f64> + IndexMut<usize, Output = f64>,
M: MatrixIdentity + MatrixFromDiagonal<V> + MatVec<V> + MatTransposeVec<V> + MatDiagonal<V> + ScaleInPlace + RankOneUpdate<V> + SymmetricEigen<V> + Clone,
Source§fn init(
&mut self,
problem: &P,
state: BasicPopulationState<V>,
) -> BasicPopulationState<V>
fn init( &mut self, problem: &P, state: BasicPopulationState<V>, ) -> BasicPopulationState<V>
Source§fn next_iter(
&mut self,
problem: &P,
state: BasicPopulationState<V>,
) -> (BasicPopulationState<V>, Option<TerminationReason>)
fn next_iter( &mut self, problem: &P, state: BasicPopulationState<V>, ) -> (BasicPopulationState<V>, Option<TerminationReason>)
Source§fn terminate(
&self,
state: &BasicPopulationState<V>,
) -> Option<TerminationReason>
fn terminate( &self, state: &BasicPopulationState<V>, ) -> Option<TerminationReason>
Auto Trait Implementations§
impl<I, V, M> Freeze for BoundedCmaInject<I, V, M>
impl<I, V, M> !RefUnwindSafe for BoundedCmaInject<I, V, M>
impl<I, V, M> !Send for BoundedCmaInject<I, V, M>
impl<I, V, M> !Sync for BoundedCmaInject<I, V, M>
impl<I, V, M> Unpin for BoundedCmaInject<I, V, M>
impl<I, V, M> UnsafeUnpin for BoundedCmaInject<I, V, M>
impl<I, V, M> !UnwindSafe for BoundedCmaInject<I, V, M>
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
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>
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>
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
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>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
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
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.