pub struct ArithmeticGrammarPrior {
pub terminal_prob: f64,
pub max_depth: usize,
pub n_vars: usize,
pub p_var: f64,
pub const_std: f64,
pub n_functions: usize,
}Expand description
A probabilistic context-free grammar prior over arithmetic expression trees.
Fields§
§terminal_prob: f64Probability that a node (below max depth) is a terminal.
max_depth: usizeMaximum tree depth; nodes at this depth are forced terminal.
n_vars: usizeNumber of input variables x0..x{n_vars-1}.
p_var: f64Probability that a terminal is a variable (vs a constant).
const_std: f64Standard deviation of the Gaussian prior over constants.
n_functions: usizeRestrict the function set to the first n_functions entries of
ArithmeticFunction::functions (e.g. 4 = {Add, Sub, Mul, Div}).
Trait Implementations§
Source§impl Clone for ArithmeticGrammarPrior
impl Clone for ArithmeticGrammarPrior
Source§fn clone(&self) -> ArithmeticGrammarPrior
fn clone(&self) -> ArithmeticGrammarPrior
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ArithmeticGrammarPrior
impl Debug for ArithmeticGrammarPrior
Source§impl Default for ArithmeticGrammarPrior
impl Default for ArithmeticGrammarPrior
Source§impl GenomePrior for ArithmeticGrammarPrior
impl GenomePrior for ArithmeticGrammarPrior
Source§fn trace_of(&self, genome: &Self::Genome) -> Trace
fn trace_of(&self, genome: &Self::Genome) -> Trace
Encode a tree under the grammar’s own address scheme (the inverse of
running Self::model): a deterministic walk emitting the
#leaf/#tkind/#var/#const/#func choices at each node path.
This is what makes EvolutionModel::score, to_weighted_trace, and
EvolutionChain::init_from work for grammar-driven trees: replaying
the encoding through the grammar program recovers the genuine PCFG
log-prior. A tree using a function outside the restricted
n_functions set, or deeper than max_depth, scores −∞ under
replay (out of the prior’s support) rather than erroring.
Erc terminals are encoded as constants (evaluation-identical; the
grammar itself only generates Variable/Constant).
Source§type Genome = TreeGenome
type Genome = TreeGenome
Auto Trait Implementations§
impl Freeze for ArithmeticGrammarPrior
impl RefUnwindSafe for ArithmeticGrammarPrior
impl Send for ArithmeticGrammarPrior
impl Sync for ArithmeticGrammarPrior
impl Unpin for ArithmeticGrammarPrior
impl UnsafeUnpin for ArithmeticGrammarPrior
impl UnwindSafe for ArithmeticGrammarPrior
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,
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<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.