Fleet  0.0.9
Inference in the LOT
PriorInference.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Control.h"
4 #include <queue>
5 #include <thread>
6 
8 
16 template<typename HYP>
18 
19 public:
20 
21  typename HYP::Grammar_t* grammar;
22  typename HYP::data_t* data;
23  HYP* from;
24 
25  PriorInference(typename HYP::Grammar_t* g, typename HYP::data_t* d, HYP* fr=nullptr) :
26  grammar(g), data(d), from(fr) {
27  }
28 
30 
31  ctl.start();
32  while(ctl.running()) {
33  HYP h;
34  if(from != nullptr) {
35  h = *from; // copy
36  h.complete();
37  }
38  else {
40  }
41  h.compute_posterior(*data);
42  co_yield h;
43  }
44  }
45 };
HYP::data_t * data
Definition: PriorInference.h:22
PriorInference(typename HYP::Grammar_t *g, typename HYP::data_t *d, HYP *fr=nullptr)
Definition: PriorInference.h:25
static MyHypothesis sample()
Static function for making a hypothesis. Be careful using this with references because they may not f...
Definition: MCMCable.h:29
HYP::Grammar_t * grammar
Definition: PriorInference.h:21
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
HYP * from
Definition: PriorInference.h:23
Definition: generator.hpp:21
Definition: ThreadedInferenceInterface.h:22
Definition: PriorInference.h:17
bool running()
Definition: Control.h:63
This class has all the information for running MCMC or MCTS in a little package. It defaultly constru...
generator< HYP & > run_thread(Control &ctl) override
Definition: PriorInference.h:29