pub struct SubSetCodec<T> { /* private fields */ }
Expand description
A Codec
for a subset of items. This is useful for problems where the goal is to find the best subset of items
from a larger set of items. The encode
function creates a Genotype
with a single chromosome of BitGenes
where each gene represents an item in the items
vector. The decode
function creates a Vec<&T>
from the
Genotype
where the Vec
contains the items that are selected by the BitGenes
- the true
genes.
A SubSetCodec
is useful for problems like the Knapsack problem, where the goal is to find the best subset of items
that fit in a knapsack. The items
vector would contain the items that can be placed in the knapsack and the Genotype
would contain BitGenes
that represent weather or not the item is in the knapsack.
Implementations§
Trait Implementations§
Source§impl<T: Clone> Clone for SubSetCodec<T>
impl<T: Clone> Clone for SubSetCodec<T>
Source§fn clone(&self) -> SubSetCodec<T>
fn clone(&self) -> SubSetCodec<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<T> Codec<BitChromosome, Vec<Arc<T>>> for SubSetCodec<T>
impl<T> Codec<BitChromosome, Vec<Arc<T>>> for SubSetCodec<T>
Auto Trait Implementations§
impl<T> Freeze for SubSetCodec<T>
impl<T> RefUnwindSafe for SubSetCodec<T>where
T: RefUnwindSafe,
impl<T> Send for SubSetCodec<T>
impl<T> Sync for SubSetCodec<T>
impl<T> Unpin for SubSetCodec<T>
impl<T> UnwindSafe for SubSetCodec<T>where
T: RefUnwindSafe,
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