pub struct TrieFn<A, T> {
pub func: fn(&mut TrieFnState<A, T>, A) -> T,
}Expand description
Wrapper struct for functions that use the TrieFnState DSL (sample_at and trace_at) and automatically implement the GFI.
Fields§
§func: fn(&mut TrieFnState<A, T>, A) -> TA random function that takes in a mutable reference to a TrieFnState<A,T> and some args A, effectfully mutates the state, and produces a value T.
Implementations§
Trait Implementations§
Source§impl<Args: Clone + 'static, Ret: 'static> GenFn<Args, Trie<(Rc<dyn Any>, f64)>, Ret> for TrieFn<Args, Ret>
impl<Args: Clone + 'static, Ret: 'static> GenFn<Args, Trie<(Rc<dyn Any>, f64)>, Ret> for TrieFn<Args, Ret>
Source§fn simulate(&self, args: Args) -> Trace<Args, Trie<(Rc<dyn Any>, f64)>, Ret>
fn simulate(&self, args: Args) -> Trace<Args, Trie<(Rc<dyn Any>, f64)>, Ret>
Execute the generative function and return a sampled trace.
Source§fn generate(
&self,
args: Args,
constraints: Trie<(Rc<dyn Any>, f64)>,
) -> (Trace<Args, Trie<(Rc<dyn Any>, f64)>, Ret>, f64)
fn generate( &self, args: Args, constraints: Trie<(Rc<dyn Any>, f64)>, ) -> (Trace<Args, Trie<(Rc<dyn Any>, f64)>, Ret>, f64)
Execute the generative function consistent with
constraints.
Return the log probability
log[p(t; args) / q(t; constraints, args)]Auto Trait Implementations§
impl<A, T> Freeze for TrieFn<A, T>
impl<A, T> RefUnwindSafe for TrieFn<A, T>
impl<A, T> Send for TrieFn<A, T>
impl<A, T> Sync for TrieFn<A, T>
impl<A, T> Unpin for TrieFn<A, T>
impl<A, T> UnwindSafe for TrieFn<A, T>
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<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§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 moreSource§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).Source§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.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.