Struct genome::Gene

source ·
pub struct Gene {
    pub num_markers: u16,
    pub markers: Vec<Marker>,
}

Fields§

§num_markers: u16§markers: Vec<Marker>

Implementations§

source§

impl Gene

First marker is influence

source

pub fn new(num_markers: u16) -> Gene

Create a new gene

§Examples
use genome::Gene;

let gene1 = Gene::new(2);
source

pub fn get_sum(&self) -> f32

Get sum of genes

§Examples
use genome::Gene;

let gene1 = Gene::new(2);

let sum = gene1.get_sum();
source

pub fn is_equal(left_gene: &Gene, right_gene: &Gene) -> bool

Compare is two gene is equal

§Examples
use genome::Gene;

let gene1 = Gene::new(2);
let gene2 = Gene::new(2);

let is_equal = Gene::is_equal(&gene1, &gene2);
source

pub fn get_influence(&self) -> f32

Get influence for this gene

§Examples
use genome::Gene;

let gene1 = Gene::new(2);

let influence = gene1.get_influence();
source

pub fn get_marker(&self, position: usize) -> Option<f32>

Get markers at position for the gene, ignore influence

§Examples
use genome::Gene;

let gene1 = Gene::new(2);

let marker = gene1.get_marker(0);
source

pub fn get_markers(&self) -> Vec<f32>

Get all markers for the gene, ignore influence

§Examples
use genome::Gene;

let gene1 = Gene::new(2);

let markers = gene1.get_markers();
source

pub fn to_string(&self) -> String

Convert gene to string

§Examples
use genome::Gene;

let gene1 = Gene::new(2);

let gene_str = gene1.to_string();
source

pub fn compare(left_gene: Gene, right_gene: Gene) -> bool

Compare gene for equality

§Examples
use genome::Gene;

let gene1 = Gene::new(2);
let gene2 = Gene::new(2);

let is_same = Gene::compare(gene1, gene2);
source

pub fn mutate(&mut self)

Mutate the gene, with 5 different types of mutation

§Examples
use genome::Gene;

let mut gene1 = Gene::new(2);

gene1.mutate();
source

pub fn zero(&mut self)

Zero this gene

§Examples
use genome::Gene;

let mut gene1 = Gene::new(2);

gene1.zero();

Trait Implementations§

source§

impl From<Gene> for String

Convert gene to string

§Examples

use genome::Gene;

let gene1 = Gene::new(2);

let gene_str = String::from(gene1);
source§

fn from(gene: Gene) -> String

Converts to this type from the input type.
source§

impl From<String> for Gene

Convert string to Gene

§Examples

use genome::Gene;

let gene1 = Gene::new(2);

let gene_str = String::from(gene1);

let gene_copy = Gene::from(gene_str);
source§

fn from(gene: String) -> Gene

Converts to this type from the input type.
source§

impl PartialEq for Gene

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

§

impl RefUnwindSafe for Gene

§

impl Send for Gene

§

impl Sync for Gene

§

impl Unpin for Gene

§

impl UnwindSafe for Gene

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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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