Infrared
Loading...
Searching...
No Matches
ired::Assignment Class Reference

A (partial) assignment of variables to values. More...

#include <assignment.hpp>

Public Types

using assignment_t = Assignment
 assignment type
 
using var_idx_t = int
 variable index type
 
using var_value_t = int
 variable value type
 

Public Member Functions

 Assignment (const FiniteDomainVector &domains)
 construct empty
 
const auto & operator[] (var_idx_t i) const
 get value of a variable (read only)
 
auto & operator[] (var_idx_t i)
 get value of a variable (read/write)
 
const auto & values () const
 get values (read only)
 
auto size () const
 get number of variables in assignment
 
auto is_det (var_idx_t i) const
 check whether variable is determined
 
void set_undet (var_idx_t i)
 set variables to undetermined
 
void set_undet (const std::vector< var_idx_t > &xs)
 set variables to undetermined
 
void inc (var_idx_t i)
 increment value of variable
 
template<class FeatureNetwork >
auto make_iterator (const std::vector< var_idx_t > &vars, const FeatureNetwork &cn, const std::vector< const typename FeatureNetwork::constraint_t * > &constraints, const std::vector< const typename FeatureNetwork::function_t * > &functions, const typename FeatureNetwork::fun_value_t &initial_value)
 make sub-assignment iterator
 
template<class Function , class EP >
auto eval_determined (const std::vector< const Function * > &functions, const EP &)
 evaluate constraints/functions where all variables are already determined
 
template<class CN >
auto make_iterator (const std::vector< var_idx_t > &vars, const CN &cn, const std::vector< const typename CN::constraint_t * > &constraints, const std::vector< const typename CN::function_t * > &functions, const typename CN::fun_value_t &initial_value)
 

Detailed Description

A (partial) assignment of variables to values.

An object of Assignment associates values to a series of /finite domain/ variables (indexed 0..n-1); typically the variables belong to a constraint network CN (

See also
FeatureNetwork).

In an assignment for the CN, variables are associated to values in their finite integer domain (according to CN) or are undetermined (encoded domain specifically!). Assignments are total, if no variable is undetermined.

Partial assignments can be enumerated using objects of class AssignmentIterator. Such iterators are generated for an assignment using make_iterator; typically they are used to iterate over a subset of the variables in the CN while evaluating functions and checking constraints.

An assignment is valid for a set of constraints, iff all the constraints are satisfied (evaluate to true). The value of an assignment for a set of functions is the product (as defined by the EvaluationPolicy) of the function values for the assignment. Only assignments with non-zero (zero def'd by EvaluationPolicy) evaluation are valid for the functions.

Member Typedef Documentation

◆ assignment_t

assignment type

◆ var_idx_t

variable index type

◆ var_value_t

variable value type

Constructor & Destructor Documentation

◆ Assignment()

ired::Assignment::Assignment ( const FiniteDomainVector domains)
inlineexplicit

construct empty

Parameters
domainsdomains of the variables; attention: domains must stay available

after construction, all variables are undetermined

Member Function Documentation

◆ eval_determined()

template<class Function , class EP >
auto ired::Assignment::eval_determined ( const std::vector< const Function * > &  functions,
const EP &   
)
inline

evaluate constraints/functions where all variables are already determined

Returns
product of determined function values

◆ inc()

void ired::Assignment::inc ( var_idx_t  i)
inline

increment value of variable

Parameters
iindex of variable

◆ is_det()

auto ired::Assignment::is_det ( var_idx_t  i) const
inline

check whether variable is determined

Parameters
ivariable index

◆ make_iterator() [1/2]

template<class CN >
auto ired::Assignment::make_iterator ( const std::vector< var_idx_t > &  vars,
const CN &  cn,
const std::vector< const typename CN::constraint_t * > &  constraints,
const std::vector< const typename CN::function_t * > &  functions,
const typename CN::fun_value_t &  initial_value 
)

◆ make_iterator() [2/2]

template<class FeatureNetwork >
auto ired::Assignment::make_iterator ( const std::vector< var_idx_t > &  vars,
const FeatureNetwork cn,
const std::vector< const typename FeatureNetwork::constraint_t * > &  constraints,
const std::vector< const typename FeatureNetwork::function_t * > &  functions,
const typename FeatureNetwork::fun_value_t initial_value 
)

make sub-assignment iterator

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

◆ operator[]() [1/2]

auto & ired::Assignment::operator[] ( var_idx_t  i)
inline

get value of a variable (read/write)

Parameters
ivariable index
Returns
value of variable i

◆ operator[]() [2/2]

const auto & ired::Assignment::operator[] ( var_idx_t  i) const
inline

get value of a variable (read only)

Parameters
ivariable index
Returns
value of variable i

◆ set_undet() [1/2]

void ired::Assignment::set_undet ( const std::vector< var_idx_t > &  xs)
inline

set variables to undetermined

Parameters
xsvector of variable indices

◆ set_undet() [2/2]

void ired::Assignment::set_undet ( var_idx_t  i)
inline

set variables to undetermined

Parameters
iindex of variable

◆ size()

auto ired::Assignment::size ( ) const
inline

get number of variables in assignment

◆ values()

const auto & ired::Assignment::values ( ) const
inline

get values (read only)


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