DEConfigBuilder

Struct DEConfigBuilder 

Source
pub struct DEConfigBuilder { /* private fields */ }
Expand description

Fluent builder for DEConfig for ergonomic configuration.

§Example

use autoeq_de::{DEConfigBuilder, Strategy, Mutation};

let config = DEConfigBuilder::new()
    .maxiter(500)
    .popsize(20)
    .strategy(Strategy::Best1Bin)
    .mutation(Mutation::Factor(0.8))
    .recombination(0.9)
    .seed(42)
    .build();

Implementations§

Source§

impl DEConfigBuilder

Source

pub fn new() -> Self

Creates a new builder with default configuration.

Source

pub fn maxiter(self, v: usize) -> Self

Sets the maximum number of iterations.

Source

pub fn popsize(self, v: usize) -> Self

Sets the population size multiplier.

Source

pub fn tol(self, v: f64) -> Self

Sets the relative convergence tolerance.

Source

pub fn atol(self, v: f64) -> Self

Sets the absolute convergence tolerance.

Source

pub fn mutation(self, v: Mutation) -> Self

Sets the mutation factor configuration.

Source

pub fn recombination(self, v: f64) -> Self

Sets the crossover probability (CR).

Source

pub fn strategy(self, v: Strategy) -> Self

Sets the mutation/crossover strategy.

Source

pub fn crossover(self, v: Crossover) -> Self

Sets the crossover type.

Source

pub fn init(self, v: Init) -> Self

Sets the population initialization scheme.

Source

pub fn seed(self, v: u64) -> Self

Sets the random seed for reproducibility.

Source

pub fn integrality(self, v: Vec<bool>) -> Self

Sets the integrality mask for mixed-integer optimization.

Source

pub fn x0(self, v: Array1<f64>) -> Self

Sets an initial guess to seed the population.

Source

pub fn disp(self, v: bool) -> Self

Enables/disables progress display.

Source

pub fn callback( self, cb: Box<dyn FnMut(&DEIntermediate) -> CallbackAction>, ) -> Self

Sets a per-iteration callback function.

Source

pub fn add_penalty_ineq<FN>(self, f: FN, w: f64) -> Self
where FN: Fn(&Array1<f64>) -> f64 + Send + Sync + 'static,

Adds an inequality constraint penalty function.

Source

pub fn add_penalty_eq<FN>(self, f: FN, w: f64) -> Self
where FN: Fn(&Array1<f64>) -> f64 + Send + Sync + 'static,

Adds an equality constraint penalty function.

Source

pub fn linear_penalty(self, lp: LinearPenalty) -> Self

Sets a linear constraint penalty.

Source

pub fn polish(self, pol: PolishConfig) -> Self

Sets the polishing configuration.

Source

pub fn adaptive(self, adaptive: AdaptiveConfig) -> Self

Sets the adaptive DE configuration.

Source

pub fn enable_adaptive_mutation(self, enable: bool) -> Self

Enables/disables adaptive mutation.

Source

pub fn enable_wls(self, enable: bool) -> Self

Enables/disables Wrapper Local Search.

Source

pub fn adaptive_weights(self, w_max: f64, w_min: f64) -> Self

Sets the adaptive weight bounds.

Source

pub fn parallel(self, parallel: ParallelConfig) -> Self

Sets the parallel evaluation configuration.

Source

pub fn enable_parallel(self, enable: bool) -> Self

Enables/disables parallel evaluation.

Source

pub fn parallel_threads(self, num_threads: usize) -> Self

Sets the number of parallel threads.

Source

pub fn build(self) -> DEConfig

Builds and returns the configuration.

Trait Implementations§

Source§

impl Default for DEConfigBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. 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
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> 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, 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