SingleValue.h
Go to the documentation of this file.
1 /*
2  * SingleValue.h
3  * @brief domain constraint
4  * @date Feb 6, 2012
5  * @author Frank Dellaert
6  */
7 
8 #pragma once
9 
12 
13 namespace gtsam {
14 
18  class GTSAM_UNSTABLE_EXPORT SingleValue: public Constraint {
19 
21  size_t cardinality_;
22 
24  size_t value_;
25 
27  return DiscreteKey(keys_[0],cardinality_);
28  }
29 
30  public:
31 
32  typedef boost::shared_ptr<SingleValue> shared_ptr;
33 
35  SingleValue(Key key, size_t n, size_t value) :
36  Constraint(key), cardinality_(n), value_(value) {
37  }
38 
40  SingleValue(const DiscreteKey& dkey, size_t value) :
41  Constraint(dkey.first), cardinality_(dkey.second), value_(value) {
42  }
43 
44  // print
45  void print(const std::string& s = "",
46  const KeyFormatter& formatter = DefaultKeyFormatter) const override;
47 
49  bool equals(const DiscreteFactor& other, double tol) const override {
50  if(!dynamic_cast<const SingleValue*>(&other))
51  return false;
52  else {
53  const SingleValue& f(static_cast<const SingleValue&>(other));
54  return (cardinality_==f.cardinality_) && (value_==f.value_);
55  }
56  }
57 
59  double operator()(const Values& values) const override;
60 
62  DecisionTreeFactor toDecisionTreeFactor() const override;
63 
65  DecisionTreeFactor operator*(const DecisionTreeFactor& f) const override;
66 
67  /*
68  * Ensure Arc-consistency
69  * @param j domain to be checked
70  * @param domains all other domains
71  */
72  bool ensureArcConsistency(size_t j, std::vector<Domain>& domains) const override;
73 
75  Constraint::shared_ptr partiallyApply(const Values& values) const override;
76 
78  Constraint::shared_ptr partiallyApply(
79  const std::vector<Domain>& domains) const override;
80  };
81 
82 } // namespace gtsam
void print(const Matrix &A, const string &s, ostream &stream)
Definition: Matrix.cpp:155
size_t value_
allowed value
Definition: SingleValue.h:24
SingleValue(Key key, size_t n, size_t value)
Constructor.
Definition: SingleValue.h:35
int n
leaf::MyValues values
Point2 operator*(double s, const Point2 &p)
multiply with scalar
Definition: Point2.h:45
static const KeyFormatter DefaultKeyFormatter
Definition: Key.h:43
const KeyFormatter & formatter
DiscreteKey discreteKey() const
Definition: SingleValue.h:26
constexpr int first(int i)
Implementation details for constexpr functions.
size_t cardinality_
Number of values.
Definition: SingleValue.h:21
std::pair< Key, size_t > DiscreteKey
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
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
RealScalar s
traits
Definition: chartTesting.h:28
specialized key for discrete variables
const G double tol
Definition: Group.h:83
bool equals(const DiscreteFactor &other, double tol) const override
equals
Definition: SingleValue.h:49
SingleValue(const DiscreteKey &dkey, size_t value)
Constructor.
Definition: SingleValue.h:40
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:61
boost::shared_ptr< SingleValue > shared_ptr
Definition: SingleValue.h:32
std::ptrdiff_t j
boost::shared_ptr< Constraint > shared_ptr
Definition: Constraint.h:36


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:44:12