pub struct RoyalRoad {
pub schema_size: usize,
pub num_schemas: usize,
}Expand description
Royal Road function
Tests the “building block hypothesis” - fitness is the count of complete schemas (contiguous blocks of 1s). Rewards completing full blocks rather than partial solutions.
For example, with schema_size=8 and num_schemas=4 (32-bit string):
- 11111111 00000000 11111111 00000000 has fitness 2 (two complete blocks)
- 11111110 11111111 11111111 11111111 has fitness 3 (one incomplete)
Fields§
§schema_size: usizeSize of each schema (block of consecutive 1s)
num_schemas: usizeNumber of schemas in the genome
Implementations§
Source§impl RoyalRoad
impl RoyalRoad
Sourcepub fn new(schema_size: usize, num_schemas: usize) -> Self
pub fn new(schema_size: usize, num_schemas: usize) -> Self
Create a new Royal Road function
§Arguments
schema_size- Number of bits in each schema (typically 8)num_schemas- Number of schemas (typically 8)
Sourcepub fn genome_length(&self) -> usize
pub fn genome_length(&self) -> usize
Total genome length required
Sourcepub fn count_complete_schemas(&self, bits: &[bool]) -> usize
pub fn count_complete_schemas(&self, bits: &[bool]) -> usize
Count the number of complete schemas
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RoyalRoad
impl RefUnwindSafe for RoyalRoad
impl Send for RoyalRoad
impl Sync for RoyalRoad
impl Unpin for RoyalRoad
impl UnsafeUnpin for RoyalRoad
impl UnwindSafe for RoyalRoad
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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<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>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
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
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.