20 cout << s <<
"SingleValue on " 21 <<
"j=" <<
formatter(keys_[0]) <<
" with value " << value_ << endl;
26 return (
double)(values.at(keys_[0]) == value_);
33 for (
size_t i1 = 0; i1 < cardinality_; i1++) table.push_back(i1 == value_);
41 return toDecisionTreeFactor() *
f;
47 throw invalid_argument(
"SingleValue check on wrong domain");
50 if (D.
firstValue() != value_)
throw runtime_error(
"Unsatisfiable");
53 D =
Domain(discreteKey(), value_);
59 DiscreteValues::const_iterator it = values.find(keys_[0]);
60 if (it != values.end() && it->second != value_)
61 throw runtime_error(
"SingleValue::partiallyApply: unsatisfiable");
62 return std::make_shared<SingleValue>(keys_[0], cardinality_, value_);
68 const Domain& Dk = domains.at(keys_[0]);
70 throw runtime_error(
"SingleValue::partiallyApply: unsatisfiable");
71 return std::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.
std::shared_ptr< Constraint > shared_ptr
bool ensureArcConsistency(Key j, Domains *domains) const override
size_t firstValue() const
const KeyFormatter & formatter
std::map< Key, Domain > Domains
Constraint::shared_ptr partiallyApply(const DiscreteValues &values) const override
Partially apply known values.
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
bool contains(size_t value) const
void print(const std::string &s="", const KeyFormatter &formatter=DefaultKeyFormatter) const override
print
DecisionTreeFactor toDecisionTreeFactor() const override
Convert into a decisiontree.
std::pair< Key, size_t > DiscreteKey
std::uint64_t Key
Integer nonlinear key type.
double operator()(const DiscreteValues &values) const override
Calculate value.
DiscreteKeys is a set of keys that can be assembled using the & operator.