pub struct Multiplexer { /* private fields */ }Expand description
The Boolean multiplexer of Koza (1992): k address bits select one of 2^k data bits, which
is the output. The 11-multiplexer (k = 3, 2048 cases) is Koza’s; the 6-multiplexer (k =
2) is a smaller version.
Its primitives are Koza’s: the functions and, or, not and if (of three arguments),
and the inputs a0 to a{k-1} (the address, a0 its least significant bit), then d0 to
d{2^k-1} (the data). One type: the untyped genetic programming of the paper.
use genoxide::gp::boolean::Multiplexer;
let problem = Multiplexer::new(3)?; // Koza's 11-multiplexer
assert_eq!((problem.inputs(), problem.cases()), (11, 2048));
let set = problem.primitives();
// the right output everywhere: the data bit that the address selects
let tree = set.parse(
"if(a2, if(a1, if(a0, d7, d6), if(a0, d5, d4)), if(a1, if(a0, d3, d2), if(a0, d1, d0)))",
)?;
assert_eq!(problem.errors(&tree), 0);
// one data bit is right in the cases that select it, and in half the others
assert_eq!(problem.errors(&set.parse("d0")?), 896);Implementations§
Source§impl Multiplexer
impl Multiplexer
Sourcepub fn new(address_bits: usize) -> Result<Self>
pub fn new(address_bits: usize) -> Result<Self>
The multiplexer of address_bits address bits, 1 to 4: the 3-, 6-, 11- and
20-multiplexer.
§Errors
Error::InvalidSetting (setting address_bits) for 0 or more than 4 address bits.
Sourcepub fn address_bits(&self) -> usize
pub fn address_bits(&self) -> usize
The number of address bits.
Source§impl Multiplexer
impl Multiplexer
Sourcepub fn primitives(&self) -> &PrimitiveSet<Logic>
pub fn primitives(&self) -> &PrimitiveSet<Logic>
Sourcepub fn cases(&self) -> u64
pub fn cases(&self) -> u64
The number of cases of the truth table, 2^inputs. In case c, input i (in the
order of the set’s terminals) is bit i of c.
Sourcepub fn targets(&self) -> &[u64]
pub fn targets(&self) -> &[u64]
The right outputs, 64 cases per word: case c at bit c % 64 of word c / 64.
Trait Implementations§
Source§impl Clone for Multiplexer
impl Clone for Multiplexer
Source§impl Debug for Multiplexer
impl Debug for Multiplexer
Source§impl FitnessFunction<Tree> for Multiplexer
impl FitnessFunction<Tree> for Multiplexer
Source§fn is_batch(&self) -> bool
fn is_batch(&self) -> bool
evaluate_batch (true) rather than one call of
evaluate per genome, in parallel if asked (false, the
default). See Batch.Source§fn provides(&self) -> Provided
fn provides(&self) -> Provided
Algorithm::prepare. Declare an extra here, and write it in
evaluate_with.Source§fn evaluate_batch_with(
&self,
genomes: &[&G],
extras: &mut BatchExtras<'_>,
) -> Vec<Self::Output>
fn evaluate_batch_with( &self, genomes: &[&G], extras: &mut BatchExtras<'_>, ) -> Vec<Self::Output>
genomes, in their order, with the extras that extras has buffers for,
a row per genome. The engine calls it instead of
evaluate_batch for a batch function when the
algorithm wants extras. By default, evaluate_batch(genomes) without extras, and one
evaluate_with each otherwise.Auto Trait Implementations§
impl Freeze for Multiplexer
impl RefUnwindSafe for Multiplexer
impl Send for Multiplexer
impl Sync for Multiplexer
impl Unpin for Multiplexer
impl UnsafeUnpin for Multiplexer
impl UnwindSafe for Multiplexer
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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