20 std::set<size_t> values_;
27 :
Constraint(dkey.first), cardinality_(dkey.second) {
28 for (
size_t v = 0; v < cardinality_; v++) values_.insert(v);
34 :
Constraint(dkey.first), cardinality_(dkey.second) {
40 :
Constraint(other.keys_[0]), values_(other.values_) {}
43 void insert(
size_t value) { values_.insert(value); }
46 void erase(
size_t value) { values_.erase(value); }
48 size_t nrValues()
const {
return values_.size(); }
50 bool isSingleton()
const {
return nrValues() == 1; }
52 size_t firstValue()
const {
return *values_.begin(); }
56 DefaultKeyFormatter)
const override;
60 if (!
dynamic_cast<const Domain*
>(&other))
64 return (cardinality_ == f.cardinality_) && (values_ == f.values_);
68 bool contains(
size_t value)
const {
return values_.count(value) > 0; }
71 double operator()(
const Values& values)
const override;
74 DecisionTreeFactor toDecisionTreeFactor()
const override;
77 DecisionTreeFactor
operator*(
const DecisionTreeFactor& f)
const override;
84 bool ensureArcConsistency(
size_t j,
85 std::vector<Domain>& domains)
const override;
93 bool checkAllDiff(
const KeyVector keys, std::vector<Domain>& domains);
96 Constraint::shared_ptr partiallyApply(
const Values& values)
const override;
99 Constraint::shared_ptr partiallyApply(
100 const std::vector<Domain>& domains)
const override;
specialized key for discrete variables
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition: Key.h:86
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition: Matrix.cpp:155
Point2 operator*(double s, const Point2 &p)
multiply with scalar
Definition: Point2.h:47
std::pair< Key, size_t > DiscreteKey
Key type for discrete conditionals Includes name and cardinality.
Definition: DiscreteKey.h:34
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: Key.h:35
Base class for discrete probabilistic factors The most general one is the derived DecisionTreeFactor.
Definition: DiscreteFactor.h:34
Base class for discrete probabilistic factors The most general one is the derived DecisionTreeFactor.
Definition: Constraint.h:33
Domain restriction constraint.
Definition: Domain.h:18
void erase(size_t value)
erase a value, non const :-(
Definition: Domain.h:46
bool equals(const DiscreteFactor &other, double tol) const override
equals
Definition: Domain.h:59
Domain(const Domain &other)
Constructor.
Definition: Domain.h:39
boost::shared_ptr< Domain > shared_ptr
allowed values
Definition: Domain.h:23
void insert(size_t value)
insert a value, non const :-(
Definition: Domain.h:43