Infrared
|
A tree of clusters (=variables, functions, constraints) More...
#include <cluster_tree.hpp>
Classes | |
struct | edge_info_t |
information at an edge of the tree More... | |
struct | vertex_info_t |
information at a vertex (=cluster/bag) of the tree More... | |
Public Types | |
using | feature_network_t = FeatureNetwork< FunValue, EvaluationPolicy > |
using | evaluation_policy_t = typename feature_network_t::evaluation_policy_t |
evaluation policy type | |
using | var_idx_t = typename feature_network_t::var_idx_t |
using | cluster_t = typename feature_network_t::cluster_t |
using | assignment_t = typename feature_network_t::assignment_t |
using | fun_value_t = typename feature_network_t::fun_value_t |
using | constraint_t = typename feature_network_t::constraint_t |
using | function_t = typename feature_network_t::function_t |
using | message_t = MaterializedFunction< fun_value_t > |
using | tree_t = graph::adjacency_list< vertex_info_t, edge_info_t > |
using | vertex_descriptor_t = typename tree_t::vertex_descriptor_t |
type of identifiers of vertices (typically 'long int') | |
Public Member Functions | |
ClusterTree () | |
construct empty | |
ClusterTree (const FiniteDomainVector &domains) | |
Construct with variable domains. | |
ClusterTree (std::vector< int > domsizes) | |
construct from vector of upper bounds | |
ClusterTree (int num_vars, const FiniteDomain &domain) | |
Construct with uniform domains. | |
ClusterTree (int num_vars, int domsize) | |
Construct with uniform domains. | |
~ClusterTree () | |
const auto & | feature_network () const |
read access to constraint network | |
auto | add_root_cluster (const std::vector< var_idx_t > &vars) |
add new root cluster to the tree | |
auto | add_child_cluster (vertex_descriptor_t parent, const std::vector< int > &vars) |
add new child cluster to the tree | |
void | add_constraint (vertex_descriptor_t node, const std::shared_ptr< constraint_t > &x) |
add new constraint to cluster | |
void | add_function (vertex_descriptor_t node, const std::shared_ptr< function_t > &x) |
add new function to cluster | |
auto | evaluate () |
Evaluate the cluster tree (by DP) | |
bool | is_consistent () |
Check consistency. | |
auto | traceback () |
Generate a traceback. | |
auto | restricted_traceback (const std::set< var_idx_t > &variables, const assignment_t &assignment) |
Generate a restricted traceback. | |
A tree of clusters (=variables, functions, constraints)
A cluster tree belongs to a constraint network and holds it. (The latter simplifies the usage in Infrared; however this means, we do not support several cluster trees for the same constraint network.)
The cluster tree supports evaluation and sampling. For this purpose, the cluster tree must satisfy the cluster tree properties
1) For each variable in the CN, there is one bag that contains the variable.
2) For each variable, the bags that contain this variable form a subtree.
3) For each function, there is exactly one bag that contains the function and its variables.
4) For each constraint, there is at least one bag that contains the function and its variables. Constraints are only assigned to bags that contain all of their variables.
Ensuring those properties is the job of the user of this class!
using ired::ClusterTree< FunValue, EvaluationPolicy >::assignment_t = typename feature_network_t::assignment_t |
using ired::ClusterTree< FunValue, EvaluationPolicy >::cluster_t = typename feature_network_t::cluster_t |
using ired::ClusterTree< FunValue, EvaluationPolicy >::constraint_t = typename feature_network_t::constraint_t |
using ired::ClusterTree< FunValue, EvaluationPolicy >::evaluation_policy_t = typename feature_network_t::evaluation_policy_t |
evaluation policy type
using ired::ClusterTree< FunValue, EvaluationPolicy >::feature_network_t = FeatureNetwork<FunValue, EvaluationPolicy> |
using ired::ClusterTree< FunValue, EvaluationPolicy >::fun_value_t = typename feature_network_t::fun_value_t |
using ired::ClusterTree< FunValue, EvaluationPolicy >::function_t = typename feature_network_t::function_t |
using ired::ClusterTree< FunValue, EvaluationPolicy >::message_t = MaterializedFunction<fun_value_t> |
using ired::ClusterTree< FunValue, EvaluationPolicy >::tree_t = graph::adjacency_list<vertex_info_t, edge_info_t> |
using ired::ClusterTree< FunValue, EvaluationPolicy >::var_idx_t = typename feature_network_t::var_idx_t |
using ired::ClusterTree< FunValue, EvaluationPolicy >::vertex_descriptor_t = typename tree_t::vertex_descriptor_t |
type of identifiers of vertices (typically 'long int')
|
inline |
construct empty
|
inlineexplicit |
Construct with variable domains.
domsizes | vector of domain sizes for each variable; its length specifies the number of variables |
|
inlineexplicit |
construct from vector of upper bounds
|
inline |
Construct with uniform domains.
num_vars | the number of variables in the underlying constraint network |
domsize | uniform domain size of each variable |
|
inline |
Construct with uniform domains.
num_vars | the number of variables in the underlying constraint network |
domsize | uniform domain size of each variable |
|
inline |
|
inline |
add new child cluster to the tree
parent | the parent of this child |
vars | variables of the new cluster |
Typically used when constructing the cluster tree. Typically, one adds functions and constraints to the new cluster that is created by this method (using the returned bag id).
|
inline |
add new constraint to cluster
id | identifier of cluster |
x | (shared pointer to) constraint |
Typically used when constructing the cluster tree.
|
inline |
add new function to cluster
id | identifier of cluster |
x | (shared pointer to) function |
Typically used when constructing the cluster tree.
|
inline |
add new root cluster to the tree
vars | variables of the new cluster |
Typically used when constructing the cluster tree. Typically, one adds functions and constraints to the new cluster that is created by this method (using the returned bag id).
auto ired::ClusterTree< FunValue, EvaluationPolicy >::evaluate |
Evaluate the cluster tree (by DP)
Call this once before generating tracebacks with traceback()
|
inline |
read access to constraint network
|
inline |
Check consistency.
auto ired::ClusterTree< FunValue, EvaluationPolicy >::restricted_traceback | ( | const std::set< var_idx_t > & | variables, |
const assignment_t & | assignment | ||
) |
Generate a restricted traceback.
variables | list of variables to which trace is restricted |
assignment | assignment of the other variables |
auto ired::ClusterTree< FunValue, EvaluationPolicy >::traceback |
Generate a traceback.
Generates one traceback assignment. Requires that the cluster tree was evaluated and is consistent. Arbitrarily many tracebacks can be generated after a single evaluation (which is of course mostly reasonable for non-det tb, like stochastic traceback)
Results are NOT defined if the cluster tree was never evaluated (due to a call to evaluate() or is_consistent()) or is not consistent. Calling traceback on an inconsistent tree may even result in termination.
On evaluated and consistent trees, stochastic traceback, samples from a distribution controlled by the functions and constraints. When the functions return Boltzmann weights, assignments are traced back from a Boltzmann distribution.