HillClimbBuilder

Struct HillClimbBuilder 

Source
pub struct HillClimbBuilder<G: HillClimbGenotype, F: Fitness<Genotype = G>, SR: StrategyReporter<Genotype = G>> {
Show 13 fields pub genotype: Option<G>, pub variant: Option<HillClimbVariant>, pub fitness: Option<F>, pub fitness_ordering: FitnessOrdering, pub fitness_cache: Option<FitnessCache>, pub par_fitness: bool, pub max_stale_generations: Option<usize>, pub max_generations: Option<usize>, pub target_fitness_score: Option<FitnessValue>, pub valid_fitness_score: Option<FitnessValue>, pub replace_on_equal_fitness: bool, pub reporter: SR, pub rng_seed: Option<u64>,
}
Expand description

The builder for an HillClimb struct.

Fields§

§genotype: Option<G>§variant: Option<HillClimbVariant>§fitness: Option<F>§fitness_ordering: FitnessOrdering§fitness_cache: Option<FitnessCache>§par_fitness: bool§max_stale_generations: Option<usize>§max_generations: Option<usize>§target_fitness_score: Option<FitnessValue>§valid_fitness_score: Option<FitnessValue>§replace_on_equal_fitness: bool§reporter: SR§rng_seed: Option<u64>

Implementations§

Source§

impl<G: HillClimbGenotype, F: Fitness<Genotype = G>> Builder<G, F, StrategyReporterNoop<G>>

Source

pub fn new() -> Self

Source§

impl<G: HillClimbGenotype, F: Fitness<Genotype = G>, SR: StrategyReporter<Genotype = G>> Builder<G, F, SR>

Source

pub fn build(self) -> Result<HillClimb<G, F, SR>, TryFromBuilderError>

Source

pub fn with_genotype(self, genotype: G) -> Self

Source

pub fn with_variant(self, variant: HillClimbVariant) -> Self

Source

pub fn with_fitness_ordering(self, fitness_ordering: FitnessOrdering) -> Self

Source

pub fn with_fitness_cache(self, fitness_cache_size: usize) -> Self

Only works when genes_hash is stored on chromosome, as this is the cache key. Only useful for long stale runs. Silently ignore cache_size of zero, to support superset builder which delays specialization

Source

pub fn with_par_fitness(self, par_fitness: bool) -> Self

Source

pub fn with_fitness(self, fitness: F) -> Self

Source

pub fn with_max_stale_generations(self, max_stale_generations: usize) -> Self

Source

pub fn with_max_stale_generations_option( self, max_stale_generations_option: Option<usize>, ) -> Self

Source

pub fn with_max_generations(self, max_generations: usize) -> Self

Source

pub fn with_max_generations_option( self, max_generations_option: Option<usize>, ) -> Self

Source

pub fn with_target_fitness_score( self, target_fitness_score: FitnessValue, ) -> Self

Source

pub fn with_target_fitness_score_option( self, target_fitness_score_option: Option<FitnessValue>, ) -> Self

Source

pub fn with_valid_fitness_score(self, valid_fitness_score: FitnessValue) -> Self

Source

pub fn with_valid_fitness_score_option( self, valid_fitness_score_option: Option<FitnessValue>, ) -> Self

Source

pub fn with_replace_on_equal_fitness( self, replace_on_equal_fitness: bool, ) -> Self

Source

pub fn with_reporter<SR2: StrategyReporter<Genotype = G>>( self, reporter: SR2, ) -> Builder<G, F, SR2>

Source

pub fn with_rng_seed_from_u64(self, rng_seed: u64) -> Self

Source

pub fn with_rng_seed_from_u64_option(self, rng_seed_option: Option<u64>) -> Self

Source§

impl<G: HillClimbGenotype, F: Fitness<Genotype = G>, SR: StrategyReporter<Genotype = G>> Builder<G, F, SR>

Source

pub fn rng(&self) -> SmallRng

Source

pub fn call(self) -> Result<HillClimb<G, F, SR>, TryFromBuilderError>

Source

pub fn call_repeatedly( self, max_repeats: usize, ) -> Result<(HillClimb<G, F, SR>, Vec<HillClimb<G, F, SR>>), TryFromBuilderError>

Source

pub fn call_par_repeatedly( self, max_repeats: usize, ) -> Result<(HillClimb<G, F, SR>, Vec<HillClimb<G, F, SR>>), TryFromBuilderError>

Source

pub fn extract_best_run( &self, runs: &mut Vec<HillClimb<G, F, SR>>, ) -> HillClimb<G, F, SR>

Trait Implementations§

Source§

impl<G: Clone + HillClimbGenotype, F: Clone + Fitness<Genotype = G>, SR: Clone + StrategyReporter<Genotype = G>> Clone for Builder<G, F, SR>

Source§

fn clone(&self) -> Builder<G, F, SR>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<G: Debug + HillClimbGenotype, F: Debug + Fitness<Genotype = G>, SR: Debug + StrategyReporter<Genotype = G>> Debug for Builder<G, F, SR>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<G: HillClimbGenotype, F: Fitness<Genotype = G>> Default for Builder<G, F, StrategyReporterNoop<G>>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<G: HillClimbGenotype, F: Fitness<Genotype = G>, SR: StrategyReporter<Genotype = G>> TryFrom<Builder<G, F, SR>> for HillClimb<G, F, SR>

Source§

type Error = TryFromStrategyBuilderError

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

fn try_from(builder: HillClimbBuilder<G, F, SR>) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<G, F, SR> Freeze for Builder<G, F, SR>
where SR: Freeze, G: Freeze, F: Freeze,

§

impl<G, F, SR> RefUnwindSafe for Builder<G, F, SR>

§

impl<G, F, SR> Send for Builder<G, F, SR>

§

impl<G, F, SR> Sync for Builder<G, F, SR>

§

impl<G, F, SR> Unpin for Builder<G, F, SR>
where SR: Unpin, G: Unpin, F: Unpin,

§

impl<G, F, SR> UnwindSafe for Builder<G, F, SR>
where SR: UnwindSafe, G: UnwindSafe, F: 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> 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.

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

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

Source§

fn vzip(self) -> V