12 #include <boost/make_shared.hpp> 21 cout << s <<
"SingleValue on " <<
"j=" <<
formatter(keys_[0])
22 <<
" with value " << value_ << endl;
27 return (
double) (values.at(keys_[0]) == value_);
35 for (
size_t i1 = 0; i1 < cardinality_; i1++)
36 table.push_back(i1 == value_);
44 return toDecisionTreeFactor() *
f;
49 vector<Domain>& domains)
const {
50 if (j != keys_[0])
throw invalid_argument(
51 "SingleValue check on wrong domain");
54 if (D.
firstValue() != value_)
throw runtime_error(
"Unsatisfiable");
57 D =
Domain(discreteKey(),value_);
64 if (it != values.end() && it->second != value_)
throw runtime_error(
65 "SingleValue::partiallyApply: unsatisfiable");
66 return boost::make_shared < SingleValue > (keys_[0], cardinality_, value_);
71 const vector<Domain>& domains)
const {
72 const Domain& Dk = domains[keys_[0]];
74 "SingleValue::partiallyApply: unsatisfiable");
75 return boost::make_shared < SingleValue > (discreteKey(), value_);
DecisionTreeFactor operator*(const DecisionTreeFactor &f) const override
Multiply into a decisiontree.
Concept check for values that can be used in unit tests.
double operator()(const Values &values) const override
Calculate value.
Constraint::shared_ptr partiallyApply(const Values &values) const override
Partially apply known values.
const KeyFormatter & formatter
std::pair< Key, size_t > DiscreteKey
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
boost::transform_iterator< boost::function1< ConstKeyValuePair, const ConstKeyValuePtrPair & >, KeyValueMap::const_iterator > const_iterator
Const forward iterator, with value type ConstKeyValuePair.
size_t firstValue() const
void print(const std::string &s="", const KeyFormatter &formatter=DefaultKeyFormatter) const override
print
DecisionTreeFactor toDecisionTreeFactor() const override
Convert into a decisiontree.
bool contains(size_t value) const
bool ensureArcConsistency(size_t j, std::vector< Domain > &domains) const override
boost::shared_ptr< Constraint > shared_ptr
DiscreteKeys is a set of keys that can be assembled using the & operator.