23 template<
typename HYP>
24 std::set<HYP>
get_partitions(
const HYP& h0,
const size_t max_depth,
const size_t max_size) {
25 assert(not (max_depth==0 and max_size==0));
27 std::set<HYP> cur = {h0};
30 for(
size_t dd=0;(max_depth==0 or dd<max_depth) and (max_size==0 or cur.size() < max_size);dd++) {
35 auto neigh = h.neighbors();
36 for(
int n=0;n<neigh;n++) {
38 newh.expand_to_neighbor(n);
43 if(not newh.is_evaluable()) {
50 if(max_size > 0 and nxt.size() > max_size){
70 template<
typename HYP>
82 PartitionMCMC(HYP& h0,
size_t max_depth,
typename HYP::data_t* data,
size_t max_size=0) {
84 assert(not h0.is_evaluable() &&
"*** You should not call PartitionMCMC on a complete node (usually you want it to be empty)");
92 for(
auto& n : x.get_value() ){
93 n.can_resample =
false;
101 #ifdef DEBUG_PARTITION_MCMC 102 print(
"Starting PartitionMCMC on ", h.string(),
"\t", x.string());
106 print(
"# Initialized ", this->
pool.size(),
" partitions");
Definition: PartitionMCMC.h:71
std::vector< MCMCChain< HYP > > pool
Definition: ChainPool.h:29
Definition: ChainPool.h:25
volatile sig_atomic_t CTRL_C
This manages multiple threads for running inference. This requires a subclass to define run_thread...
void print(FIRST f, ARGS... args)
Lock output_lock and print to std:cout.
Definition: IO.h:53
std::vector< RunningState > running
Definition: ChainPool.h:46
std::set< HYP > get_partitions(const HYP &h0, const size_t max_depth, const size_t max_size)
Compute "partitions" meaning trees with holes where we can run MCMC on the hole. This takes either a ...
Definition: PartitionMCMC.h:24
This represents an MCMC hain on a hypothesis of type HYP. It uses HYP::propose and HYP::compute_poste...
PartitionMCMC(HYP &h0, size_t max_depth, typename HYP::data_t *data, size_t max_size=0)
This specifies both a max_Size and a max_depth which are the most partitions we'll make...
Definition: PartitionMCMC.h:82