Infrared
Loading...
Searching...
No Matches
ired::AssignmentIterator< FeatureNetwork > Class Template Reference

Iterate over the assignments of a subset of variables. More...

#include <assignment.hpp>

Public Types

using assignment_t = Assignment
 
using var_idx_t = assignment_t::var_idx_t
 
using var_value_t = assignment_t::var_value_t
 
using ep = typename FeatureNetwork::evaluation_policy_t
 
using fun_value_t = typename ep::fun_value_t
 
using function_t = typename ep::function_t
 
using constraint_t = typename ep::constraint_t
 

Public Member Functions

 AssignmentIterator (assignment_t &a, const std::vector< var_idx_t > &vars, const FeatureNetwork &cn, const std::vector< const constraint_t * > &constraints, const std::vector< const function_t * > &functions, const fun_value_t &initial_value)
 constructor
 
void reset ()
 Reset iterator.
 
auto value ()
 get evaluation according to functions
 
void register_finish_stage2_hook (int stage1_size, const std::function< void()> &hook)
 register hook to run after finishing stage 2 enumeration
 
const auto & operator++ ()
 Next valid partial assignment.
 
bool finished ()
 Check for termination.
 

Detailed Description

template<class FeatureNetwork>
class ired::AssignmentIterator< FeatureNetwork >

Iterate over the assignments of a subset of variables.

Note
the assignment iterator works destructively on parent assignment!

The job of the assignment iterator goes beyond pure enumeration of the sub-assignments that are valid due to the domains of a subset of variables. It also checks validity due to constraints and functions and evaluates the functions.

Constraints and functions are evaluated as soon as all their variables are determined. For this purpose, the iterator precomputes tables ('boards'). Function values are combined via EvaluationPolicy::mul; partial products are tracked on the enumeration stack.

Member Typedef Documentation

◆ assignment_t

template<class FeatureNetwork >
using ired::AssignmentIterator< FeatureNetwork >::assignment_t = Assignment

◆ constraint_t

template<class FeatureNetwork >
using ired::AssignmentIterator< FeatureNetwork >::constraint_t = typename ep::constraint_t

◆ ep

◆ fun_value_t

template<class FeatureNetwork >
using ired::AssignmentIterator< FeatureNetwork >::fun_value_t = typename ep::fun_value_t

◆ function_t

template<class FeatureNetwork >
using ired::AssignmentIterator< FeatureNetwork >::function_t = typename ep::function_t

◆ var_idx_t

◆ var_value_t

Constructor & Destructor Documentation

◆ AssignmentIterator()

template<class FeatureNetwork >
ired::AssignmentIterator< FeatureNetwork >::AssignmentIterator ( assignment_t a,
const std::vector< var_idx_t > &  vars,
const FeatureNetwork cn,
const std::vector< const constraint_t * > &  constraints,
const std::vector< const function_t * > &  functions,
const fun_value_t initial_value 
)
inline

constructor

Parameters
varsvector of indices of the to-be-enumerated variables
cnconstraint network, where everything takes place
constraintscheck assignments
functionscheck and evaluate assignments

During the iteration, constraints and functions are evaluated. We evaluate only those constraints/functions that have at least on undetermined dependency on a variable in vars, where all dependencies outside of vars are already determined.

After construction with non-empty vars, the assignment is either set to the first valid assignment or finished() is true. After construction with empty vars, assignment is unchanged and finished() is false, but will be true immediately after a call to operator ++()!

Member Function Documentation

◆ finished()

template<class FeatureNetwork >
bool ired::AssignmentIterator< FeatureNetwork >::finished ( )
inline

Check for termination.

◆ operator++()

template<class FeatureNetwork >
const auto & ired::AssignmentIterator< FeatureNetwork >::operator++ ( )
inline

Next valid partial assignment.

Sets the assignment to the next valid assignment of vars_

◆ register_finish_stage2_hook()

template<class FeatureNetwork >
void ired::AssignmentIterator< FeatureNetwork >::register_finish_stage2_hook ( int  stage1_size,
const std::function< void()> &  hook 
)
inline

register hook to run after finishing stage 2 enumeration

Parameters
stage1_sizenumber of variables in stage 1
hookfunction to be called after finishing stage 2 enumeration

This is used in two-stage enumeration over two disjoint sets of variables; in the evaluation of a CN, this allows to marginalize over the second set and store the results as value of a function (the 'message') of the variables in the first set.

◆ reset()

template<class FeatureNetwork >
void ired::AssignmentIterator< FeatureNetwork >::reset ( )
inline

Reset iterator.

◆ value()

template<class FeatureNetwork >
auto ired::AssignmentIterator< FeatureNetwork >::value ( )
inline

get evaluation according to functions

after initialization or a call of operator++, this yields the product of all functions on enumerated variables, where at least one variable is determined only by the enumeration


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