pub struct CompositeGenome<A, B>where
A: EvolutionaryGenome,
B: EvolutionaryGenome,{
pub first: A,
pub second: B,
}Expand description
A composite genome combining two different genome types
This is useful for problems that require multiple representations, such as:
- Continuous parameters + discrete choices
- Feature selection (binary) + feature weights (continuous)
- Topology (permutation) + parameters (continuous)
§Type Parameters
A: The first genome typeB: The second genome type
Fields§
§first: AFirst component genome
second: BSecond component genome
Implementations§
Source§impl<A, B> CompositeGenome<A, B>where
A: EvolutionaryGenome,
B: EvolutionaryGenome,
impl<A, B> CompositeGenome<A, B>where
A: EvolutionaryGenome,
B: EvolutionaryGenome,
Sourcepub fn second_mut(&mut self) -> &mut B
pub fn second_mut(&mut self) -> &mut B
Get a mutable reference to the second component
Sourcepub fn into_parts(self) -> (A, B)
pub fn into_parts(self) -> (A, B)
Consume and return the components
Sourcepub fn map_first<F, C>(self, f: F) -> CompositeGenome<C, B>where
F: FnOnce(A) -> C,
C: EvolutionaryGenome,
pub fn map_first<F, C>(self, f: F) -> CompositeGenome<C, B>where
F: FnOnce(A) -> C,
C: EvolutionaryGenome,
Map a function over the first component
Sourcepub fn map_second<F, C>(self, f: F) -> CompositeGenome<A, C>where
F: FnOnce(B) -> C,
C: EvolutionaryGenome,
pub fn map_second<F, C>(self, f: F) -> CompositeGenome<A, C>where
F: FnOnce(B) -> C,
C: EvolutionaryGenome,
Map a function over the second component
Trait Implementations§
Source§impl<A, B> Clone for CompositeGenome<A, B>
impl<A, B> Clone for CompositeGenome<A, B>
Source§fn clone(&self) -> CompositeGenome<A, B>
fn clone(&self) -> CompositeGenome<A, B>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<A, B> Debug for CompositeGenome<A, B>
impl<A, B> Debug for CompositeGenome<A, B>
Source§impl<'de, A, B> Deserialize<'de> for CompositeGenome<A, B>where
A: EvolutionaryGenome + Serialize + for<'de2> Deserialize<'de2>,
B: EvolutionaryGenome + Serialize + for<'de2> Deserialize<'de2>,
impl<'de, A, B> Deserialize<'de> for CompositeGenome<A, B>where
A: EvolutionaryGenome + Serialize + for<'de2> Deserialize<'de2>,
B: EvolutionaryGenome + Serialize + for<'de2> Deserialize<'de2>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<A, B> EvolutionaryGenome for CompositeGenome<A, B>where
A: EvolutionaryGenome + Clone + Send + Sync + Serialize + for<'de> Deserialize<'de>,
B: EvolutionaryGenome + Clone + Send + Sync + Serialize + for<'de> Deserialize<'de>,
impl<A, B> EvolutionaryGenome for CompositeGenome<A, B>where
A: EvolutionaryGenome + Clone + Send + Sync + Serialize + for<'de> Deserialize<'de>,
B: EvolutionaryGenome + Clone + Send + Sync + Serialize + for<'de> Deserialize<'de>,
Source§type Allele = (<A as EvolutionaryGenome>::Allele, <B as EvolutionaryGenome>::Allele)
type Allele = (<A as EvolutionaryGenome>::Allele, <B as EvolutionaryGenome>::Allele)
Source§type Phenotype = (<A as EvolutionaryGenome>::Phenotype, <B as EvolutionaryGenome>::Phenotype)
type Phenotype = (<A as EvolutionaryGenome>::Phenotype, <B as EvolutionaryGenome>::Phenotype)
Source§fn generate<R: Rng>(rng: &mut R, bounds: &MultiBounds) -> Self
fn generate<R: Rng>(rng: &mut R, bounds: &MultiBounds) -> Self
Source§fn try_distance(&self, other: &Self) -> Result<f64, GenomeError>
fn try_distance(&self, other: &Self) -> Result<f64, GenomeError>
Source§fn as_slice(&self) -> Option<&[Self::Allele]>
fn as_slice(&self) -> Option<&[Self::Allele]>
Source§fn as_mut_slice(&mut self) -> Option<&mut [Self::Allele]>
fn as_mut_slice(&mut self) -> Option<&mut [Self::Allele]>
Source§impl<A, B> PartialEq for CompositeGenome<A, B>
impl<A, B> PartialEq for CompositeGenome<A, B>
Source§impl<A, B> Serialize for CompositeGenome<A, B>where
A: EvolutionaryGenome + Serialize + for<'de2> Deserialize<'de2>,
B: EvolutionaryGenome + Serialize + for<'de2> Deserialize<'de2>,
impl<A, B> Serialize for CompositeGenome<A, B>where
A: EvolutionaryGenome + Serialize + for<'de2> Deserialize<'de2>,
B: EvolutionaryGenome + Serialize + for<'de2> Deserialize<'de2>,
impl<A, B> StructuralPartialEq for CompositeGenome<A, B>
Source§impl<A, B> TraceGenome for CompositeGenome<A, B>where
A: TraceGenome + Clone + Send + Sync + Serialize + for<'de> Deserialize<'de>,
B: TraceGenome + Clone + Send + Sync + Serialize + for<'de> Deserialize<'de>,
Available on crate feature ppl only.
impl<A, B> TraceGenome for CompositeGenome<A, B>where
A: TraceGenome + Clone + Send + Sync + Serialize + for<'de> Deserialize<'de>,
B: TraceGenome + Clone + Send + Sync + Serialize + for<'de> Deserialize<'de>,
ppl only.Source§fn to_trace(&self) -> Trace
fn to_trace(&self) -> Trace
Convert composite genome to Fugue trace.
Each component is delegated to its own
to_trace,
and every entry of the resulting nested trace is copied verbatim under a
namespace prefix ("first/" / "second/"). This preserves full fidelity
for any component genome type — including Permutation, TreeGenome
and future encodings — rather than special-casing a fixed set of address
name literals.
Source§fn from_trace(trace: &Trace) -> Result<Self, GenomeError>
fn from_trace(trace: &Trace) -> Result<Self, GenomeError>
Reconstruct composite genome from Fugue trace.
Strips the "first/" / "second/" namespace back off each entry to
rebuild the two component sub-traces, then delegates to each component’s
own from_trace.
Source§fn trace_prefix() -> &'static str
fn trace_prefix() -> &'static str
"gene").Auto Trait Implementations§
impl<A, B> Freeze for CompositeGenome<A, B>
impl<A, B> RefUnwindSafe for CompositeGenome<A, B>where
A: RefUnwindSafe,
B: RefUnwindSafe,
impl<A, B> Send for CompositeGenome<A, B>
impl<A, B> Sync for CompositeGenome<A, B>
impl<A, B> Unpin for CompositeGenome<A, B>
impl<A, B> UnsafeUnpin for CompositeGenome<A, B>where
A: UnsafeUnpin,
B: UnsafeUnpin,
impl<A, B> UnwindSafe for CompositeGenome<A, B>where
A: UnwindSafe,
B: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Scalar for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.