pub struct Population {
pub species: Vec<Specie>,
/* private fields */
}
Expand description
All species in the network
Fields§
§species: Vec<Specie>
container of species
Implementations§
Source§impl Population
impl Population
Sourcepub fn create_population(population_size: usize) -> Population
pub fn create_population(population_size: usize) -> Population
Create a new population of size X.
Examples found in repository?
examples/simple_sample.rs (line 59)
55fn main() {
56 #[cfg(feature = "telemetry")]
57 enable_telemetry();
58
59 let mut population = Population::create_population(150);
60 let mut environment = XORClassification;
61 let mut champion: Option<Organism> = None;
62 while champion.is_none() {
63 population.evolve();
64 population.evaluate_in(&mut environment);
65 for organism in &population.get_organisms() {
66 if organism.fitness > 15.9f64 {
67 champion = Some(organism.clone());
68 }
69 }
70 }
71 println!("{:?}", champion.unwrap().genome);
72}
Sourcepub fn evolve(&mut self)
pub fn evolve(&mut self)
Create offspring by mutation and mating. May create new species.
Examples found in repository?
examples/simple_sample.rs (line 63)
55fn main() {
56 #[cfg(feature = "telemetry")]
57 enable_telemetry();
58
59 let mut population = Population::create_population(150);
60 let mut environment = XORClassification;
61 let mut champion: Option<Organism> = None;
62 while champion.is_none() {
63 population.evolve();
64 population.evaluate_in(&mut environment);
65 for organism in &population.get_organisms() {
66 if organism.fitness > 15.9f64 {
67 champion = Some(organism.clone());
68 }
69 }
70 }
71 println!("{:?}", champion.unwrap().genome);
72}
Sourcepub fn evaluate_in(&mut self, environment: &mut dyn Environment)
pub fn evaluate_in(&mut self, environment: &mut dyn Environment)
TODO
Examples found in repository?
examples/simple_sample.rs (line 64)
55fn main() {
56 #[cfg(feature = "telemetry")]
57 enable_telemetry();
58
59 let mut population = Population::create_population(150);
60 let mut environment = XORClassification;
61 let mut champion: Option<Organism> = None;
62 while champion.is_none() {
63 population.evolve();
64 population.evaluate_in(&mut environment);
65 for organism in &population.get_organisms() {
66 if organism.fitness > 15.9f64 {
67 champion = Some(organism.clone());
68 }
69 }
70 }
71 println!("{:?}", champion.unwrap().genome);
72}
Sourcepub fn get_organisms(&self) -> Vec<Organism>
pub fn get_organisms(&self) -> Vec<Organism>
Return all organisms of the population
Examples found in repository?
examples/simple_sample.rs (line 65)
55fn main() {
56 #[cfg(feature = "telemetry")]
57 enable_telemetry();
58
59 let mut population = Population::create_population(150);
60 let mut environment = XORClassification;
61 let mut champion: Option<Organism> = None;
62 while champion.is_none() {
63 population.evolve();
64 population.evaluate_in(&mut environment);
65 for organism in &population.get_organisms() {
66 if organism.fitness > 15.9f64 {
67 champion = Some(organism.clone());
68 }
69 }
70 }
71 println!("{:?}", champion.unwrap().genome);
72}
Sourcepub fn epochs_without_improvements(&self) -> usize
pub fn epochs_without_improvements(&self) -> usize
How many iterations without improvement
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Population
impl RefUnwindSafe for Population
impl Send for Population
impl Sync for Population
impl Unpin for Population
impl UnwindSafe for Population
Blanket Implementations§
Source§impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
Source§fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
Convert the given value into an approximately equivalent representation.
Source§impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
Source§type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
The error type produced by a failed conversion.
Source§fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
Convert the subject into an approximately equivalent representation.
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
Mutably borrows from an owned value. Read more
Source§impl<T, Dst> ConvAsUtil<Dst> for T
impl<T, Dst> ConvAsUtil<Dst> for T
Source§impl<T> ConvUtil for T
impl<T> ConvUtil for T
Source§fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
Approximate the subject to a given type with the default scheme.
Source§fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
Approximate the subject to a given type with a specific scheme.