10 #include <gtsam_unstable/discrete/Domain.h> 25 size_t cardinality0_, cardinality1_;
32 cardinality0_(key1.second), cardinality1_(key2.second) {
36 virtual void print(
const std::string& s =
"",
37 const KeyFormatter& formatter = DefaultKeyFormatter)
const {
38 std::cout << s <<
"BinaryAllDiff on " << formatter(
keys_[0]) <<
" and " 39 << formatter(
keys_[1]) << std::endl;
44 if(!dynamic_cast<const BinaryAllDiff*>(&other))
47 const BinaryAllDiff& f(static_cast<const BinaryAllDiff&>(other));
48 return (cardinality0_==f.cardinality0_) && (cardinality1_==f.cardinality1_);
54 return (
double) (values.at(
keys_[0]) != values.at(
keys_[1]));
62 std::vector<double> table;
63 for (
size_t i1 = 0; i1 < cardinality0_; i1++)
64 for (
size_t i2 = 0; i2 < cardinality1_; i2++)
65 table.push_back(i1 != i2);
82 bool ensureArcConsistency(
size_t j, std::vector<Domain>& domains)
const {
90 throw std::runtime_error(
"BinaryAllDiff::partiallyApply not implemented");
95 const std::vector<Domain>&)
const {
96 throw std::runtime_error(
"BinaryAllDiff::partiallyApply not implemented");
virtual DecisionTreeFactor operator *(const DecisionTreeFactor &f) const
Multiply into a decisiontree.
Definition: BinaryAllDiff.h:71
Base class for discrete probabilistic factors The most general one is the derived DecisionTreeFactor.
Definition: Constraint.h:32
virtual Constraint::shared_ptr partiallyApply(const Values &) const
Partially apply known values.
Definition: BinaryAllDiff.h:89
virtual double operator()(const Values &values) const
Calculate value.
Definition: BinaryAllDiff.h:53
Binary AllDiff constraint Returns 1 if values for two keys are different, 0 otherwise DiscreteFactors...
Definition: BinaryAllDiff.h:23
BinaryAllDiff(const DiscreteKey &key1, const DiscreteKey &key2)
cardinality
Definition: BinaryAllDiff.h:30
Base class for discrete probabilistic factors The most general one is the derived DecisionTreeFactor.
Definition: DiscreteFactor.h:34
An assignment from labels to value index (size_t).
Definition: Assignment.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
A discrete probabilistic factor.
Definition: DecisionTreeFactor.h:38
std::pair< Key, size_t > DiscreteKey
Key type for discrete conditionals Includes name and cardinality.
Definition: DiscreteKey.h:34
const KeyVector & keys() const
Access the factor's involved variable keys.
Definition: Factor.h:118
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
KeyVector keys_
The keys involved in this factor.
Definition: Factor.h:72
virtual Constraint::shared_ptr partiallyApply(const std::vector< Domain > &) const
Partially apply known values, domain version.
Definition: BinaryAllDiff.h:94
virtual DecisionTreeFactor toDecisionTreeFactor() const
Convert into a decisiontree.
Definition: BinaryAllDiff.h:58
bool equals(const DiscreteFactor &other, double tol) const
equals
Definition: BinaryAllDiff.h:43
DiscreteKeys is a set of keys that can be assembled using the & operator.
Definition: DiscreteKey.h:37