23 std::cout << s <<
"AllDiff on ";
25 std::cout << std::endl;
30 std::set<size_t> taken;
32 size_t value = values.at(dkey);
33 if (taken.count(value))
return 0.0;
45 for (
size_t i1 = 0; i1 <
nrKeys; i1++)
46 for (
size_t i2 = i1 + 1; i2 <
nrKeys; i2++) {
61 Domain& Dj = domains->at(j);
78 const Domain& Dk = domains->at(k);
95 if (values.find(k) == values.end()) {
98 return std::make_shared<AllDiff>(newKeys);
103 const Domains& domains)
const {
106 const Domain& Dk = domains.at(k);
DiscreteKey discreteKey(size_t i) const
Constraint::shared_ptr partiallyApply(const DiscreteValues &) const override
Partially apply known values.
Concept check for values that can be used in unit tests.
std::optional< Domain > checkAllDiff(const KeyVector keys, const Domains &domains) const
std::shared_ptr< Constraint > shared_ptr
DecisionTreeFactor toDecisionTreeFactor() const override
Convert into a decisiontree, can be very expensive !
KeyVector keys_
The keys involved in this factor.
DecisionTreeFactor operator*(const DecisionTreeFactor &f) const override
Multiply into a decisiontree.
size_t firstValue() const
AllDiff(const DiscreteKeys &dkeys)
Construct from keys.
const KeyFormatter & formatter
static const size_t nrKeys
std::map< Key, Domain > Domains
std::map< Key, size_t > cardinalities_
double operator()(const DiscreteValues &values) const override
Calculate value = expensive !
void print(const std::string &s="", const KeyFormatter &formatter=DefaultKeyFormatter) const override
print
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.
DecisionTreeFactor toDecisionTreeFactor() const override
Convert into a decisiontree.
bool contains(size_t value) const
std::pair< Key, size_t > DiscreteKey
std::pair< iterator, bool > insert(const value_type &value)
bool ensureArcConsistency(Key j, Domains *domains) const override
std::uint64_t Key
Integer nonlinear key type.
DiscreteKeys is a set of keys that can be assembled using the & operator.
void erase(size_t value)
Erase a value, non const :-(.