Fleet  0.0.9
Inference in the LOT
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Friends | List of all members
MCTSBase< this_t, HYP > Class Template Referenceabstract

#include <MCTSBase.h>

Inheritance diagram for MCTSBase< this_t, HYP >:
Inheritance graph
[legend]
Collaboration diagram for MCTSBase< this_t, HYP >:
Collaboration graph
[legend]

Public Types

using data_t = typename HYP::data_t
 

Public Member Functions

 MCTSBase ()
 
 MCTSBase (HYP &start, this_t *par, size_t w)
 
 MCTSBase (HYP &start, double ex, data_t *d)
 
 MCTSBase (const this_t &m)
 
 MCTSBase (this_t &&m)
 
void operator= (const MCTSBase &m)
 
void operator= (MCTSBase &&m)
 
void print (HYP from, std::ostream &o, const int depth, const bool sort)
 
void print (HYP &start, const bool sort=true)
 
void print (HYP &start, const char *filename, const bool sort=true)
 
void add_sample (const float v)
 
virtual generator< HYP & > run_thread (Control &ctl, HYP h0) override
 
virtual void process_evaluable (HYP &current)
 If we can evaluate this current node (usually: compute a posterior and add_sample) More...
 
virtual void add_children (HYP &current)
 This gets called before descending the tree if we don't have all of our children. NOTE: This could add all the children (default) or be overwritten to add one, or none. More...
 
virtual int sample_child_index (HYP &current)
 
virtual this_t * descend_to_childless (HYP &current)
 This goes down the tree to a node with no children (OR evaluable) More...
 
virtual this_t * descend_to_evaluable (HYP &current)
 This goes down the tree, sampling children until it finds an evaluable (building a full tree) More...
 
virtual generator< HYP & > search_one (HYP &current)=0
 This is not implemented in MCTSBase because it is different in Partial and Full (below). So, subclasses must implement this. More...
 
- Public Member Functions inherited from ThreadedInferenceInterface< HYP, HYP >
virtual generator< HYP &> run_thread (Control &ctl, Args... args)=0
 
 ThreadedInferenceInterface ()
 
unsigned long next_index ()
 Return the next index to operate on (in a thread-safe way). More...
 
size_t nthreads ()
 How many threads are currently run in this interface? More...
 
void run_thread_generator_wrapper (size_t thr, Control &ctl, Args... args)
 We have to wrap run_thread in something that manages the sync with main. This really just synchronizes the output of run_thread with run below. NOTE this makes a copy of x into the local next_x, so that when the thread keeps running, it doesn't mess anything up. We may in the future block the thread and return a reference, but its not clear that's faster. More...
 
generator< HYP &> run (Control ctl, Args... args)
 Set up the multiple threads and actually run, calling run_thread_generator_wrapper. More...
 
generator< HYP &> unthreaded_run (Control ctl, Args... args)
 
- Public Member Functions inherited from BaseNode< this_t >
 BaseNode (size_t n=0, this_t *p=nullptr, size_t i=0)
 Constructor of basenode – sizes children to n. More...
 
 BaseNode (const this_t &n)
 
 BaseNode (this_t &&n)
 
void operator= (const this_t &t)
 
void operator= (const this_t &&t)
 
void make_root ()
 Make a node root – just nulls the parent. More...
 
virtual ~BaseNode ()
 
virtual std::string string (bool usedot=true) const
 
virtual std::string my_string () const
 
virtual bool operator== (const this_t &n) const
 
NodeIterator begin () const
 
NodeIterator end () const
 
virtual bool operator!= (const this_t &n) const
 
void reserve_children (const size_t n)
 
decltype(children) & get_children ()
 
decltype(children) const & get_children () const
 
this_t & child (const size_t i)
 
const this_t & child (const size_t i) const
 
template<typename... Args>
void fill (size_t n, Args... args)
 
size_t nchildren () const
 
this_t * left_descend () const
 
size_t depth () const
 
void fix_child_info ()
 
void check_child_info () const
 
this_t & operator[] (const size_t i)
 
const this_t & operator[] (const size_t i) const
 
void set_child (const size_t i, this_t &n)
 
void set_child (const size_t i, this_t &&n)
 
void push_back (this_t &n)
 
void push_back (this_t &&n)
 
virtual bool is_root () const
 Am I a root node? I am if my parent is nullptr. More...
 
this_t * root ()
 Find the root of this node by walking up the tree. More...
 
this_t * get_via (std::function< bool(this_t &)> &f)
 Return a pointer to the first node satisfying predicate f, in standard traversal; nullptr otherwise. More...
 
virtual size_t count () const
 How many nodes total are below me? More...
 
virtual size_t count (const this_t &n) const
 How many nodes below me are equal to n? More...
 
virtual bool is_terminal () const
 Am I a terminal? I am if I have no children. More...
 
virtual size_t count_terminals () const
 
virtual this_t * get_nth (int n, std::function< int(const this_t &)> &f)
 
virtual this_t * get_nth (int n)
 
template<typename T >
sum (std::function< T(const this_t &)> &f) const
 
template<typename T >
sum (T(*f)(const this_t &)) const
 
bool all (std::function< bool(const this_t &)> &f) const
 
void map (const std::function< void(this_t &)> &f)
 
void show (size_t t=0) const
 

Public Attributes

bool open
 
SpinLock mylock
 
int which_expansion
 
std::atomic< unsigned int > nvisits
 
StreamingStatistics statistics
 
- Public Attributes inherited from ThreadedInferenceInterface< HYP, HYP >
std::atomic< size_t > index
 
size_t __nthreads
 
std::atomic< size_t > __nrunning
 
ConcurrentQueueRing< HYP > to_yield
 
- Public Attributes inherited from BaseNode< this_t >
this_t * parent
 
size_t pi
 

Static Public Attributes

static double explore = 1.0
 
static data_tdata = nullptr
 
- Static Public Attributes inherited from BaseNode< this_t >
static NodeIterator EndNodeIterator = NodeIterator(nullptr)
 

Friends

class BaseNode< this_t >
 

Additional Inherited Members

- Protected Attributes inherited from BaseNode< this_t >
std::vector< this_t > children
 

Detailed Description

template<typename this_t, typename HYP>
class MCTSBase< this_t, HYP >

Author
piantado
Date
03/06/20

Member Typedef Documentation

◆ data_t

template<typename this_t, typename HYP>
using MCTSBase< this_t, HYP >::data_t = typename HYP::data_t

Constructor & Destructor Documentation

◆ MCTSBase() [1/5]

template<typename this_t, typename HYP>
MCTSBase< this_t, HYP >::MCTSBase ( )
inline

◆ MCTSBase() [2/5]

template<typename this_t, typename HYP>
MCTSBase< this_t, HYP >::MCTSBase ( HYP &  start,
this_t *  par,
size_t  w 
)
inline

◆ MCTSBase() [3/5]

template<typename this_t, typename HYP>
MCTSBase< this_t, HYP >::MCTSBase ( HYP &  start,
double  ex,
data_t d 
)
inline

◆ MCTSBase() [4/5]

template<typename this_t, typename HYP>
MCTSBase< this_t, HYP >::MCTSBase ( const this_t &  m)
inline

◆ MCTSBase() [5/5]

template<typename this_t, typename HYP>
MCTSBase< this_t, HYP >::MCTSBase ( this_t &&  m)
inline

Member Function Documentation

◆ add_children()

template<typename this_t, typename HYP>
virtual void MCTSBase< this_t, HYP >::add_children ( HYP &  current)
inlinevirtual

This gets called before descending the tree if we don't have all of our children. NOTE: This could add all the children (default) or be overwritten to add one, or none.

Parameters
current

◆ add_sample()

template<typename this_t, typename HYP>
void MCTSBase< this_t, HYP >::add_sample ( const float  v)
inline

◆ descend_to_childless()

template<typename this_t, typename HYP>
virtual this_t* MCTSBase< this_t, HYP >::descend_to_childless ( HYP &  current)
inlinevirtual

This goes down the tree to a node with no children (OR evaluable)

Parameters
current

◆ descend_to_evaluable()

template<typename this_t, typename HYP>
virtual this_t* MCTSBase< this_t, HYP >::descend_to_evaluable ( HYP &  current)
inlinevirtual

This goes down the tree, sampling children until it finds an evaluable (building a full tree)

Parameters
current

◆ operator=() [1/2]

template<typename this_t, typename HYP>
void MCTSBase< this_t, HYP >::operator= ( const MCTSBase< this_t, HYP > &  m)
inline

◆ operator=() [2/2]

template<typename this_t, typename HYP>
void MCTSBase< this_t, HYP >::operator= ( MCTSBase< this_t, HYP > &&  m)
inline

◆ print() [1/3]

template<typename this_t, typename HYP>
void MCTSBase< this_t, HYP >::print ( HYP  from,
std::ostream &  o,
const int  depth,
const bool  sort 
)
inline

◆ print() [2/3]

template<typename this_t, typename HYP>
void MCTSBase< this_t, HYP >::print ( HYP &  start,
const bool  sort = true 
)
inline

◆ print() [3/3]

template<typename this_t, typename HYP>
void MCTSBase< this_t, HYP >::print ( HYP &  start,
const char *  filename,
const bool  sort = true 
)
inline

◆ process_evaluable()

template<typename this_t, typename HYP>
virtual void MCTSBase< this_t, HYP >::process_evaluable ( HYP &  current)
inlinevirtual

If we can evaluate this current node (usually: compute a posterior and add_sample)

Parameters
current

◆ run_thread()

template<typename this_t, typename HYP>
virtual generator<HYP&> MCTSBase< this_t, HYP >::run_thread ( Control ctl,
HYP  h0 
)
inlineoverridevirtual

◆ sample_child_index()

template<typename this_t, typename HYP>
virtual int MCTSBase< this_t, HYP >::sample_child_index ( HYP &  current)
inlinevirtual

◆ search_one()

template<typename this_t, typename HYP>
virtual generator<HYP&> MCTSBase< this_t, HYP >::search_one ( HYP &  current)
pure virtual

This is not implemented in MCTSBase because it is different in Partial and Full (below). So, subclasses must implement this.

Parameters
current

Friends And Related Function Documentation

◆ BaseNode< this_t >

template<typename this_t, typename HYP>
friend class BaseNode< this_t >
friend

Member Data Documentation

◆ data

template<typename this_t, typename HYP>
HYP::data_t * MCTSBase< this_t, HYP >::data = nullptr
static

◆ explore

template<typename this_t, typename HYP>
double MCTSBase< this_t, HYP >::explore = 1.0
static

◆ mylock

template<typename this_t, typename HYP>
SpinLock MCTSBase< this_t, HYP >::mylock

◆ nvisits

template<typename this_t, typename HYP>
std::atomic<unsigned int> MCTSBase< this_t, HYP >::nvisits

◆ open

template<typename this_t, typename HYP>
bool MCTSBase< this_t, HYP >::open

◆ statistics

template<typename this_t, typename HYP>
StreamingStatistics MCTSBase< this_t, HYP >::statistics

◆ which_expansion

template<typename this_t, typename HYP>
int MCTSBase< this_t, HYP >::which_expansion

The documentation for this class was generated from the following file: