Fleet  0.0.9
Inference in the LOT
EnumerationInference.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <queue>
4 #include <thread>
5 
6 #include "BasicEnumeration.h"
7 #include "Control.h"
8 #include "SampleStreams.h"
9 
11 
20 template<typename HYP, typename Grammar_t, typename Enumerator>
22 
23 public:
24 
25  Grammar_t* grammar;
26  typename HYP::data_t* data;
27 
28  EnumerationInference(Grammar_t* g, typename HYP::data_t* d) :
29  grammar(g), data(d) {
30  }
31 
33 
34  Enumerator ge(this->grammar);
35 
36  ctl.start();
37  while(ctl.running()) {
39  auto n = ge.toNode(nxt, grammar->start());
40  //print(n.string());
41 
42  MyHypothesis h(n);
43  h.compute_posterior(*data);
44 
45  co_yield h;
46 
48  }
49  }
50 };
EnumerationInference(Grammar_t *g, typename HYP::data_t *d)
Definition: EnumerationInference.h:28
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...
Definition: Bayesable.h:140
Definition: EnumerationInference.h:21
Grammar_t * grammar
Definition: EnumerationInference.h:25
std::atomic< uintmax_t > enumeration_steps(0)
we don&#39;t need inputs/outputs for out MyHypothesis
Definition: MyHypothesis.h:6
void start()
Definition: Control.h:54
This manages multiple threads for running inference. This requires a subclass to define run_thread...
Definition: Control.h:23
Definition: generator.hpp:21
generator< HYP & > run_thread(Control &ctl) override
Definition: EnumerationInference.h:32
unsigned long next_index()
Return the next index to operate on (in a thread-safe way).
Definition: ThreadedInferenceInterface.h:45
Definition: ThreadedInferenceInterface.h:22
bool running()
Definition: Control.h:63
size_t enumerationidx_t
Definition: IntegerizedStack.h:3
This class has all the information for running MCMC or MCTS in a little package. It defaultly constru...
HYP::data_t * data
Definition: EnumerationInference.h:26