Fleet  0.0.9
Inference in the LOT
PartialMCTSNode.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "MCTSBase.h"
4 
12 template<typename this_t, typename HYP>
13 class PartialMCTSNode : public MCTSBase<this_t,HYP> {
15  using Super::Super; // get constructors
16 
17  using data_t = typename HYP::data_t;
18 
19  virtual generator<HYP&> search_one(HYP& current) override {
20  if(DEBUG_MCTS) DEBUG("PartialMCTSNode SEARCH ONE ", this, "\t["+current.string()+"] ", (unsigned long)this->nvisits);
21 
22  auto c = this->descend_to_childless(current); //sets current and returns the node.
23 
24 // DEBUG("descend_to_childless ", this, "\t["+current.string()+"] ");
25 
26  // if we are a terminal
27  if(current.is_evaluable()) {
28  c->process_evaluable(current);
29  co_yield current;
30  }
31  else {
32  // else add the next row of children and choose one to playout
33  c->add_children(current);
34  auto idx = c->sample_child_index(current);
35  current.expand_to_neighbor(idx);
36  for(auto& h : c->child(idx).playout(current)) { // the difference is that here, we call playout instead of search_one
37  co_yield h;
38  }
39  }
40  }
41 
47  virtual generator<HYP&> playout(HYP& current) {
48  if(current.is_evaluable()) {
49  this->process_evaluable(current);
50  co_yield current;
51  }
52  else {
53  PriorInference samp(current.get_grammar(), this->data, &current);
55  co_yield h;
56  this->add_sample(h.posterior);
57  }
58  }
59  }
60 };
61 
unsigned long inner_runtime
Definition: FleetArgs.h:26
#define DEBUG_MCTS
Definition: MCTSBase.h:3
typename HYP::data_t data_t
Definition: MCTSBase.h:46
Definition: Control.h:23
virtual void process_evaluable(HYP &current)
If we can evaluate this current node (usually: compute a posterior and add_sample) ...
Definition: MCTSBase.h:193
Definition: generator.hpp:21
virtual this_t * descend_to_childless(HYP &current)
This goes down the tree to a node with no children (OR evaluable)
Definition: MCTSBase.h:300
unsigned long inner_restart
Definition: FleetArgs.h:27
Definition: PartialMCTSNode.h:13
Definition: MCTSBase.h:41
void add_sample(const float v)
Definition: MCTSBase.h:163
void DEBUG(FIRST f, ARGS... args)
Print to std:ccout with debugging info.
Definition: IO.h:73
Definition: PriorInference.h:17
unsigned long inner_steps
Definition: FleetArgs.h:13
std::atomic< unsigned int > nvisits
Definition: MCTSBase.h:59
static data_t * data
Definition: MCTSBase.h:57