[−][src]Struct jeans::Settings
A settings object for storing all of the settings we might care about for a GA.
You should usually instantiate this using the default method. All member variables of this struct are public, which makes editing this easy. In most cases, simply reassign the member variables:
let mut set = jeans::Settings::default(); set.elitism = false;
The most notable exception is for the fitness_function
field. To set that, you have to use a
special method:
let mut set = jeans::Settings::default(); set.set_fitness_function(| x: Vec<f64> | x[0] + x[1])
Fields
population_size: u32
The size of the population
number_of_generations: u32
The number of generations
crossover_probability: f64
The crossover probability
mutation_probability: f64
The probability of mutation
verbose: bool
A bool
indicating whether or not code should run in verbose mode
elitism: bool
A bool
indicating whether or not to implement elitism
elitism_fraction: f64
The fraction of each generation that should be carried forward via elitism
maximize_fitness: bool
Whether the package should maximize fitness (true
) or minimize fitness (false
)
number_of_dimensions: u32
The number of dimensions of the problem space
upper_bound: Vec<f64>
The upper bounds for each dimension of the problem space
lower_bound: Vec<f64>
The lower bounds for each dimension of the problem space
fitness_function: Box<dyn FnMut(Vec<f64>) -> f64>
The fitness function used to evaluate how good solutions are
Implementations
impl Settings
[src]
pub fn set_fitness_function<F: 'static + FnMut(Vec<f64>) -> f64>(
&mut self,
f: F
)
[src]
&mut self,
f: F
)
This functions allows you to set the fitness function
For instance, you can use one of hte built-in function found here:
let mut set = jeans::Settings::default(); set.set_fitness_function(jeans::functions::sphere);
Or you can use a lambda to implement your own:
let mut set = jeans::Settings::default(); set.set_fitness_function(| x | x[0] + x[1]);
Or you can define and use a completely new function
fn fitness_whole_pizza(x: Vec<f64>) -> f64 { let mut fx = 0f64; for i in 0..x.len() { fx *= x[i] } fx } let mut set = jeans::Settings::default(); set.set_fitness_function(fitness_whole_pizza);
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Settings
impl !Send for Settings
impl !Sync for Settings
impl Unpin for Settings
impl !UnwindSafe for Settings
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,