pub struct GepSymRegression<F: FunctionSet> { /* private fields */ }Expand description
A symbolic-regression BatchFitnessFn for GEP populations.
Holds the target dataset (input rows and expected outputs) and the alphabet
to decode against. evaluate_batch pulls
the population to host and, in parallel across rows (rayon), decodes each
chromosome to an ExpressionTree and scores it by
mean squared error. Decoding is deterministic, so the row-parallel order
does not affect results.
Implementations§
Source§impl<F: FunctionSet> GepSymRegression<F>
impl<F: FunctionSet> GepSymRegression<F>
Sourcepub fn new(
alphabet: Alphabet<F>,
genome_len: usize,
inputs: Vec<Vec<f32>>,
targets: Vec<f32>,
) -> Self
pub fn new( alphabet: Alphabet<F>, genome_len: usize, inputs: Vec<Vec<f32>>, targets: Vec<f32>, ) -> Self
Builds the fitness function from an alphabet, the genome length, the input rows, and the matching expected outputs.
§Panics
Panics if:
inputsis empty — an empty dataset would make MSE0.0 / 0.0 = NaNfitness (n_points == 0), silently poisoning the population.inputsandtargetsdiffer in length.- any input row does not have exactly
alphabet.n_varsentries — a short row is otherwise silently zero-padded byExpressionTree::eval(inputs.get(i).unwrap_or(0.0)), so the regression would quietly fit the wrong target.
Trait Implementations§
Source§impl<B: Backend, F: FunctionSet> BatchFitnessFn<B, Tensor<B, 2, Int>> for GepSymRegression<F>
impl<B: Backend, F: FunctionSet> BatchFitnessFn<B, Tensor<B, 2, Int>> for GepSymRegression<F>
Source§fn evaluate_batch(
&mut self,
population: &Tensor<B, 2, Int>,
device: &<B as BackendTypes>::Device,
) -> Tensor<B, 1>
fn evaluate_batch( &mut self, population: &Tensor<B, 2, Int>, device: &<B as BackendTypes>::Device, ) -> Tensor<B, 1>
Evaluates every member of
population and returns a fitness tensor in
the objective’s natural value space (no hand-negation). Read moreSource§fn sense(&self) -> ObjectiveSense
fn sense(&self) -> ObjectiveSense
The optimisation direction of this objective. Read more
Source§impl<F: Clone + FunctionSet> Clone for GepSymRegression<F>
impl<F: Clone + FunctionSet> Clone for GepSymRegression<F>
Source§fn clone(&self) -> GepSymRegression<F>
fn clone(&self) -> GepSymRegression<F>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<F> Freeze for GepSymRegression<F>where
F: Freeze,
impl<F> RefUnwindSafe for GepSymRegression<F>where
F: RefUnwindSafe,
impl<F> Send for GepSymRegression<F>
impl<F> Sync for GepSymRegression<F>
impl<F> Unpin for GepSymRegression<F>where
F: Unpin,
impl<F> UnsafeUnpin for GepSymRegression<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for GepSymRegression<F>where
F: 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
Mutably borrows from an owned value. Read more
Source§impl<C> CloneExpand for Cwhere
C: Clone,
impl<C> CloneExpand for Cwhere
C: Clone,
fn __expand_clone_method(&self, _scope: &mut Scope) -> C
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>
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