21 std::set<size_t> values_;
29 Constraint(dkey.first), cardinality_(dkey.second) {
30 for (
size_t v = 0; v < cardinality_; v++)
37 Constraint(dkey.first), cardinality_(dkey.second) {
43 Constraint(other.keys_[0]), values_(other.values_) {
48 values_.insert(value);
56 size_t nrValues()
const {
57 return values_.size();
60 bool isSingleton()
const {
61 return nrValues() == 1;
64 size_t firstValue()
const {
65 return *values_.begin();
69 virtual void print(
const std::string& s =
"",
70 const KeyFormatter& formatter = DefaultKeyFormatter)
const;
74 if(!dynamic_cast<const Domain*>(&other))
77 const Domain& f(static_cast<const Domain&>(other));
78 return (cardinality_==f.cardinality_) && (values_==f.values_);
82 bool contains(
size_t value)
const {
83 return values_.count(value)>0;
87 virtual double operator()(
const Values& values)
const;
90 virtual DecisionTreeFactor toDecisionTreeFactor()
const;
93 virtual DecisionTreeFactor
operator*(
const DecisionTreeFactor& f)
const;
100 bool ensureArcConsistency(
size_t j, std::vector<Domain>& domains)
const;
107 bool checkAllDiff(
const KeyVector keys, std::vector<Domain>& domains);
110 virtual Constraint::shared_ptr partiallyApply(
111 const Values& values)
const;
114 virtual Constraint::shared_ptr partiallyApply(
115 const std::vector<Domain>& domains)
const;
Base class for discrete probabilistic factors The most general one is the derived DecisionTreeFactor.
Definition: Constraint.h:32
specialized key for discrete variables
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition: Matrix.cpp:141
Domain restriction constraint.
Definition: Domain.h:18
boost::shared_ptr< Domain > shared_ptr
allowed values
Definition: Domain.h:25
Base class for discrete probabilistic factors The most general one is the derived DecisionTreeFactor.
Definition: DiscreteFactor.h:34
boost::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: Key.h:33
void insert(size_t value)
insert a value, non const :-(
Definition: Domain.h:47
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition: Key.h:56
std::pair< Key, size_t > DiscreteKey
Key type for discrete conditionals Includes name and cardinality.
Definition: DiscreteKey.h:34
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
Domain(const Domain &other)
Constructor.
Definition: Domain.h:42
bool equals(const DiscreteFactor &other, double tol) const
equals
Definition: Domain.h:73
void erase(size_t value)
erase a value, non const :-(
Definition: Domain.h:52
Point2 operator *(double s, const Point2 &p)
multiply with scalar
Definition: Point2.h:170