Skip to main content

Landscape

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

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>

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>

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>

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>

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 fn name(&self) -> &str

The landscape’s label.

pub fn dimension(&self) -> usize

The number of decision variables.

pub const fn schema(&self) -> &SpaceSchema

The declared search space.

pub fn shift(&self) -> &[f64]

The global minimizer, in problem coordinates.

pub fn rotation(&self) -> Option<&[f64]>

The rotation R, row-major, or None for an axis-aligned landscape.

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

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

The stiffest direction of an ellipsoid (coefficient cond), the counterpart of flat_direction.

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>

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§

§

impl Clone for Landscape

§

fn clone(&self) -> Landscape

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
§

impl Debug for Landscape

§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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
§

impl<T> ByRef<T> for T

§

fn by_ref(&self) -> &T

§

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

§

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

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

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 = 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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more