|
| Lexicon () |
|
size_t | nfactors () const |
| Return the number of factors. More...
|
|
auto & | get_value () |
|
const auto & | get_value () const |
|
INNER & | at (const key_t &k) |
|
const INNER & | at (const key_t &k) const |
|
INNER & | operator[] (const key_t &k) |
|
const INNER & | operator[] (const key_t &k) const |
|
bool | contains (const key_t &key) |
|
Grammar_t * | get_grammar () |
|
virtual std::string | string (std::string prefix="") const override |
|
virtual size_t | hash () const override |
|
virtual bool | operator== (const this_t &l) const override |
| Equality checks equality on each part. More...
|
|
virtual void | push_program (Program< VirtualMachineState_t > &s, const key_t k) override |
| A lexicon has valid indices if calls to op_RECURSE, op_MEM_RECURSE, op_SAFE_RECURSE, and op_SAFE_MEM_RECURSE all have arguments that are less than the size. (So this places no restrictions on the calling earlier factors) More...
|
|
virtual void | complete () override |
| Fill in all the holes in this hypothesis, at random, modifying self. NOTE for LOTHypotheses this will also compile, which is what we need to do for a LOTHypothesis. More...
|
|
virtual double | compute_prior () override |
|
virtual std::optional< std::pair< this_t, double > > | propose () const override |
| This proposal guarantees that there will be at least one factor that is proposed to. Each individual factor is proposed to with p_factor_propose. More...
|
|
virtual this_t | restart () const override |
|
int | neighbors () const override |
| Count the number of neighbors that are possible. (This should be size_t but int is more convenient.) More...
|
|
void | expand_to_neighbor (int k) override |
| Modify this hypothesis to become the k'th neighbor. NOTE This does not compile since it might not be complete. More...
|
|
virtual double | neighbor_prior (int k) override |
| What is the prior of the k'th neighbor? This does not need to return the full prior, only relative (among ks) More...
|
|
bool | is_evaluable () const override |
| Check if we can evaluate this node (meaning compute a prior and posterior). NOTE that this is not the same as whether it has zero neighbors, since lexica might have neighbors but be evalable. More...
|
|
virtual DiscreteDistribution< output_t > | call (const key_t k, const input_t x, const output_t &err=output_t{}) |
|
virtual std::string | serialize () const override |
|
| MCMCable () |
|
virtual bool | operator!= (const this_t &h) const |
|
| Bayesable () |
|
virtual double | compute_single_likelihood (const datum_t &datum) |
| Compute the likelihood of a single data point. More...
|
|
virtual void | clear_bayes () |
|
virtual double | compute_likelihood (const data_t &data, const double breakout=-infinity) |
| Compute the likelihood of a collection of data, by calling compute_single_likelihood on each. This stops if our likelihood falls below breakout. More...
|
|
virtual double | compute_posterior (const data_t &data, const std::pair< double, double > breakoutpair=std::make_pair(-infinity, 1.0)) |
| Compute the posterior, by calling prior and likelihood. This includes only a little bit of fanciness, which is that if our prior is -inf, then we don't both computing the likelihood. More...
|
|
virtual double | at_temperature (double t) const |
|
auto | operator (const Bayesable< datum_t, data_t > &other) const |
|
virtual void | show (std::string prefix="") |
|
virtual this_t | make_neighbor (int k) const |
| Return a new hypothesis which is the k'th neighbor (just calls expand_to_neighbor) NOTE This does not compile since it might not be complete. More...
|
|
virtual void | push_program (Program< _VirtualMachineState_t > &s) |
|
virtual void | push_program (Program< _VirtualMachineState_t > &s, const short a) |
|
virtual void | push_program (Program< _VirtualMachineState_t > &s, const int a) |
|
virtual void | push_program (Program< _VirtualMachineState_t > &s, const std::string k) |
|
template<typename this_t, typename _key_t, typename INNER, typename _input_t, typename _output_t, typename datum_t = defaultdatum_t<_input_t, _output_t>, typename _VirtualMachineState_t = typename INNER::Grammar_t::VirtualMachineState_t>
virtual void Lexicon< this_t, _key_t, INNER, _input_t, _output_t, datum_t, _VirtualMachineState_t >::complete |
( |
| ) |
|
|
inlineoverridevirtual |
template<typename this_t, typename _key_t, typename INNER, typename _input_t, typename _output_t, typename datum_t = defaultdatum_t<_input_t, _output_t>, typename _VirtualMachineState_t = typename INNER::Grammar_t::VirtualMachineState_t>
virtual double Lexicon< this_t, _key_t, INNER, _input_t, _output_t, datum_t, _VirtualMachineState_t >::compute_prior |
( |
| ) |
|
|
inlineoverridevirtual |
template<typename this_t, typename _key_t, typename INNER, typename _input_t, typename _output_t, typename datum_t = defaultdatum_t<_input_t, _output_t>, typename _VirtualMachineState_t = typename INNER::Grammar_t::VirtualMachineState_t>
static this_t Lexicon< this_t, _key_t, INNER, _input_t, _output_t, datum_t, _VirtualMachineState_t >::deserialize |
( |
const std::string |
s | ) |
|
|
inlinestatic |
Convert a string to a lexicon of this type
- Parameters
-
- Returns
template<typename this_t, typename _key_t, typename INNER, typename _input_t, typename _output_t, typename datum_t = defaultdatum_t<_input_t, _output_t>, typename _VirtualMachineState_t = typename INNER::Grammar_t::VirtualMachineState_t>
void Lexicon< this_t, _key_t, INNER, _input_t, _output_t, datum_t, _VirtualMachineState_t >::expand_to_neighbor |
( |
int |
k | ) |
|
|
inlineoverridevirtual |
template<typename this_t, typename _key_t, typename INNER, typename _input_t, typename _output_t, typename datum_t = defaultdatum_t<_input_t, _output_t>, typename _VirtualMachineState_t = typename INNER::Grammar_t::VirtualMachineState_t>
virtual size_t Lexicon< this_t, _key_t, INNER, _input_t, _output_t, datum_t, _VirtualMachineState_t >::hash |
( |
| ) |
const |
|
inlineoverridevirtual |
template<typename this_t, typename _key_t, typename INNER, typename _input_t, typename _output_t, typename datum_t = defaultdatum_t<_input_t, _output_t>, typename _VirtualMachineState_t = typename INNER::Grammar_t::VirtualMachineState_t>
bool Lexicon< this_t, _key_t, INNER, _input_t, _output_t, datum_t, _VirtualMachineState_t >::is_evaluable |
( |
| ) |
const |
|
inlineoverridevirtual |
Check if we can evaluate this node (meaning compute a prior and posterior). NOTE that this is not the same as whether it has zero neighbors, since lexica might have neighbors but be evalable.
Implements Searchable< this_t, _input_t, _output_t >.
template<typename this_t, typename _key_t, typename INNER, typename _input_t, typename _output_t, typename datum_t = defaultdatum_t<_input_t, _output_t>, typename _VirtualMachineState_t = typename INNER::Grammar_t::VirtualMachineState_t>
virtual double Lexicon< this_t, _key_t, INNER, _input_t, _output_t, datum_t, _VirtualMachineState_t >::neighbor_prior |
( |
int |
k | ) |
|
|
inlineoverridevirtual |
template<typename this_t, typename _key_t, typename INNER, typename _input_t, typename _output_t, typename datum_t = defaultdatum_t<_input_t, _output_t>, typename _VirtualMachineState_t = typename INNER::Grammar_t::VirtualMachineState_t>
int Lexicon< this_t, _key_t, INNER, _input_t, _output_t, datum_t, _VirtualMachineState_t >::neighbors |
( |
| ) |
const |
|
inlineoverridevirtual |
template<typename this_t, typename _key_t, typename INNER, typename _input_t, typename _output_t, typename datum_t = defaultdatum_t<_input_t, _output_t>, typename _VirtualMachineState_t = typename INNER::Grammar_t::VirtualMachineState_t>
size_t Lexicon< this_t, _key_t, INNER, _input_t, _output_t, datum_t, _VirtualMachineState_t >::nfactors |
( |
| ) |
const |
|
inline |
Return the number of factors.
- Returns
template<typename this_t, typename _key_t, typename INNER, typename _input_t, typename _output_t, typename datum_t = defaultdatum_t<_input_t, _output_t>, typename _VirtualMachineState_t = typename INNER::Grammar_t::VirtualMachineState_t>
virtual bool Lexicon< this_t, _key_t, INNER, _input_t, _output_t, datum_t, _VirtualMachineState_t >::operator== |
( |
const this_t & |
l | ) |
const |
|
inlineoverridevirtual |
template<typename this_t, typename _key_t, typename INNER, typename _input_t, typename _output_t, typename datum_t = defaultdatum_t<_input_t, _output_t>, typename _VirtualMachineState_t = typename INNER::Grammar_t::VirtualMachineState_t>
virtual std::optional<std::pair<this_t,double> > Lexicon< this_t, _key_t, INNER, _input_t, _output_t, datum_t, _VirtualMachineState_t >::propose |
( |
| ) |
const |
|
inlineoverridevirtual |
This proposal guarantees that there will be at least one factor that is proposed to. Each individual factor is proposed to with p_factor_propose.
- Returns
Implements MCMCable< this_t, datum_t >.
Reimplemented in MyHypothesis.
template<typename this_t, typename _key_t, typename INNER, typename _input_t, typename _output_t, typename datum_t = defaultdatum_t<_input_t, _output_t>, typename _VirtualMachineState_t = typename INNER::Grammar_t::VirtualMachineState_t>
A lexicon has valid indices if calls to op_RECURSE, op_MEM_RECURSE, op_SAFE_RECURSE, and op_SAFE_MEM_RECURSE all have arguments that are less than the size. (So this places no restrictions on the calling earlier factors)
- Returns
- Check if the last factor call everything else transitively (e.g. are we "wasting" factors) We do this by making a graph of what factors call which others and then computing the transitive closure. NOTE that this requires the key_type and assumes that a rule of that type can be gotten directly from the first child of a recursive call (e.g. a terminal)
-
Dispatch key k – push its program onto the stack.
- Parameters
-
template<typename this_t, typename _key_t, typename INNER, typename _input_t, typename _output_t, typename datum_t = defaultdatum_t<_input_t, _output_t>, typename _VirtualMachineState_t = typename INNER::Grammar_t::VirtualMachineState_t>
virtual std::string Lexicon< this_t, _key_t, INNER, _input_t, _output_t, datum_t, _VirtualMachineState_t >::serialize |
( |
| ) |
const |
|
inlineoverridevirtual |
template<typename this_t, typename _key_t, typename INNER, typename _input_t, typename _output_t, typename datum_t = defaultdatum_t<_input_t, _output_t>, typename _VirtualMachineState_t = typename INNER::Grammar_t::VirtualMachineState_t>
virtual std::string Lexicon< this_t, _key_t, INNER, _input_t, _output_t, datum_t, _VirtualMachineState_t >::string |
( |
std::string |
prefix = "" | ) |
const |
|
inlineoverridevirtual |