Struct Landscape
pub struct Landscape { /* private fields */ }Expand description
A continuous minimization problem: a boxed domain, a displaced minimizer, an optional rotation, and a base function.
Build one with a named constructor and hand it to run. Every landscape
declares one unstepped Distribution::Float per dimension, named
x0..x{d−1} — so every dimension is CMA-ES-driven and the comparison is
about the algorithm rather than about which parameters it models.
Implementations§
§impl Landscape
impl Landscape
pub fn sphere(dim: usize) -> Result<Self>
pub fn sphere(dim: usize) -> Result<Self>
The sphere, Σ (xᵢ − cᵢ)² over [-5.12, 5.12]^dim.
Smooth, convex, perfectly conditioned: the problem on which any sampler worth shipping must beat uniform random cleanly.
§Errors
Error::InvalidSpace if a bound is not
finite or a name repeats — which this constructor never produces.
pub fn rosenbrock(dim: usize) -> Result<Self>
pub fn rosenbrock(dim: usize) -> Result<Self>
The Rosenbrock banana over [-5, 5]^dim.
A narrow, curved valley: the gradient points across it almost everywhere, so progress needs a search distribution that has learned the valley’s local direction. Non-convex and non-separable — the classic case for a covariance, and (unlike the ellipsoid) one where the right covariance keeps changing as the search advances.
§Errors
Error::InvalidSpace if a bound is not
finite or a name repeats — which this constructor never produces.
pub fn rastrigin(dim: usize) -> Result<Self>
pub fn rastrigin(dim: usize) -> Result<Self>
The Rastrigin lattice over [-5.12, 5.12]^dim.
Highly multimodal with a smooth global bowl. CMA-ES is a local-ish searcher at the default population size, so this is the honest hard case, not a showcase.
§Errors
Error::InvalidSpace if a bound is not
finite or a name repeats — which this constructor never produces.
pub fn ellipsoid(dim: usize, condition: f64) -> Result<Self>
pub fn ellipsoid(dim: usize, condition: f64) -> Result<Self>
The axis-aligned ellipsoid, Σ cond^(i/(d−1))·(xᵢ − cᵢ)² over
[-5, 5]^dim.
Ill-conditioned but separable: an axis-aligned searcher can still make progress one coordinate at a time. It exists to isolate conditioning from rotation — the contrast that says the headline result is about the frame, not merely about the condition number.
§Errors
Error::InvalidSpace if a bound is not
finite or a name repeats — which this constructor never produces.
pub fn rotated_ellipsoid(dim: usize, condition: f64) -> Result<Self>
pub fn rotated_ellipsoid(dim: usize, condition: f64) -> Result<Self>
The distinguishing fixture: the same ellipsoid, rotated off the coordinate frame.
f(x) = Σ cond^(i/(d−1))·yᵢ² with y = R(x − c) for a fixed orthogonal
R (rotation_matrix) that mixes every axis into every other. The
spectrum is unchanged — same condition number, same difficulty for a
method that understands scale — but no coordinate is now a descent
direction, so a sampler that models dimensions independently is left with
a problem it cannot represent. This is where covariance adaptation earns
its keep or does not.
§Errors
Error::InvalidSpace if a bound is not
finite or a name repeats — which this constructor never produces.
pub const fn schema(&self) -> &SpaceSchema
pub const fn schema(&self) -> &SpaceSchema
The declared search space.
pub fn rotation(&self) -> Option<&[f64]>
pub fn rotation(&self) -> Option<&[f64]>
The rotation R, row-major, or None for an axis-aligned landscape.
pub const fn condition(&self) -> f64
pub const fn condition(&self) -> f64
The condition number of the Hessian: 1 for every fixture but the
ellipsoids.
Rotation does not change it — an orthogonal change of basis preserves the spectrum — which is exactly why the rotated fixture isolates the frame.
pub fn flat_direction(&self) -> Option<Vec<f64>>
pub fn flat_direction(&self) -> Option<Vec<f64>>
The flattest direction of an ellipsoid, in problem coordinates: the axis along which the objective grows most slowly, and therefore the one a working covariance must stretch along.
y = R(x − c), so the direction that maps to y = e₀ (coefficient
cond⁰ = 1) is row 0 of R — the coordinate axis e₀ itself when the
landscape is unrotated. None for a non-ellipsoid.
pub fn steep_direction(&self) -> Option<Vec<f64>>
pub fn steep_direction(&self) -> Option<Vec<f64>>
The stiffest direction of an ellipsoid (coefficient cond), the
counterpart of flat_direction.
pub fn eval(&self, assignment: &Assignment) -> f64
pub fn eval(&self, assignment: &Assignment) -> f64
Evaluates the objective at assignment.
Reads x0..x{d−1} in order; a missing or wrong-kinded parameter yields
NaN rather than panicking (a NaN never improves a best-so-far curve,
so a malformed assignment degrades instead of aborting a run).
pub fn optimum_in_unit_space(&self) -> Vec<f64>
pub fn optimum_in_unit_space(&self) -> Vec<f64>
The unit-hypercube coordinate of the global minimizer, per dimension.
Used by the fixture checks to prove the optimum is not sitting at the centre of the box — i.e. not on CMA-ES’s initial mean.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Landscape
impl RefUnwindSafe for Landscape
impl Send for Landscape
impl Sync for Landscape
impl Unpin for Landscape
impl UnsafeUnpin for Landscape
impl UnwindSafe for Landscape
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
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, U> Imply<T> for U
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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> ⓘ
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 more