pub struct DNA {
pub pool_size: u16,
pub gene_size: u16,
pub genes: Vec<Gene>,
}
Fields§
§pool_size: u16
§gene_size: u16
§genes: Vec<Gene>
Implementations§
source§impl DNA
impl DNA
sourcepub fn is_valid(dna_str: String) -> bool
pub fn is_valid(dna_str: String) -> bool
Check if current DNA string is valid.
§Examples
use genome::DNA;
let dna = DNA::new(2, 2);
let is_valid = DNA::is_valid(dna.to_string());
sourcepub fn merge(left_dna: DNA, right_dna: DNA, mutate: bool) -> Option<DNA>
pub fn merge(left_dna: DNA, right_dna: DNA, mutate: bool) -> Option<DNA>
Merge two DNA
into one
§Examples
use genome::DNA;
let dna1 = DNA::new(2, 2);
let dna2 = DNA::new(2, 2);
let merged = DNA::merge(dna1, dna2, false);
sourcepub fn compare(left_dna: DNA, right_dna: DNA) -> f64
pub fn compare(left_dna: DNA, right_dna: DNA) -> f64
Compare two DNA
similarity, return the percentage of same genes
§Examples
use genome::DNA;
let dna1 = DNA::new(256, 2);
let dna_str = dna1.to_string();
let dna2 = DNA::new(256, 2);
let merged = DNA::merge(dna1, dna2, false).unwrap();
let is_parent = DNA::compare(DNA::from(dna_str), merged) > 0.3;
sourcepub fn to_latent_vec(&self) -> Vec<f32>
pub fn to_latent_vec(&self) -> Vec<f32>
Convert DNA to GAN latent vector
§Examples
use genome::DNA;
let dna1 = DNA::new(2, 2);
let latent = dna1.to_latent_vec();
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for DNA
impl Send for DNA
impl Sync for DNA
impl Unpin for DNA
impl UnwindSafe for DNA
Blanket Implementations§
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