Constraint.h
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
18 #pragma once
19 
22 #include <gtsam_unstable/dllexport.h>
23 
24 #include <map>
25 
26 namespace gtsam {
27 
28 class Domain;
29 using Domains = std::map<Key, Domain>;
30 
35 class GTSAM_UNSTABLE_EXPORT Constraint : public DiscreteFactor {
36  public:
37  typedef std::shared_ptr<Constraint> shared_ptr;
38 
39  protected:
42 
44  Constraint(Key j1, Key j2) : DiscreteFactor(KeyVector{j1, j2}) {}
45 
47  Constraint(const KeyVector& js) : DiscreteFactor(js) {}
48 
50  template <class KeyIterator>
51  Constraint(KeyIterator beginKey, KeyIterator endKey)
52  : DiscreteFactor(beginKey, endKey) {}
53 
54  public:
57 
59  Constraint();
60 
62  ~Constraint() override {}
63 
67 
68  /*
69  * Ensure Arc-consistency by checking every possible value of domain j.
70  * @param j domain to be checked
71  * @param (in/out) domains all domains, but only domains->at(j) will be checked.
72  * @return true if domains->at(j) was changed, false otherwise.
73  */
74  virtual bool ensureArcConsistency(Key j, Domains* domains) const = 0;
75 
77  virtual shared_ptr partiallyApply(const DiscreteValues&) const = 0;
78 
80  virtual shared_ptr partiallyApply(const Domains&) const = 0;
84 
86  std::string markdown(const KeyFormatter& keyFormatter = DefaultKeyFormatter,
87  const Names& names = {}) const override {
88  return "`Constraint` on " + std::to_string(size()) + " variables\n";
89  }
90 
92  std::string html(const KeyFormatter& keyFormatter = DefaultKeyFormatter,
93  const Names& names = {}) const override {
94  return "<p>Constraint on " + std::to_string(size()) + " variables</p>";
95  }
96 
98 };
99 // DiscreteFactor
100 
101 } // namespace gtsam
std::string html(const KeyFormatter &keyFormatter=DefaultKeyFormatter, const Names &names={}) const override
Render as html table.
Definition: Constraint.h:92
std::shared_ptr< Constraint > shared_ptr
Definition: Constraint.h:37
static const KeyFormatter DefaultKeyFormatter
Definition: Key.h:43
~Constraint() override
Virtual destructor.
Definition: Constraint.h:62
Constraint(Key j)
Construct unary constraint factor.
Definition: Constraint.h:41
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
std::map< Key, Domain > Domains
Definition: Constraint.h:29
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
DiscreteValues::Names Names
Translation table from values to strings.
traits
Definition: chartTesting.h:28
std::string markdown(const KeyFormatter &keyFormatter=DefaultKeyFormatter, const Names &names={}) const override
Render as markdown table.
Definition: Constraint.h:86
Constraint(const KeyVector &js)
Construct n-way constraint factor.
Definition: Constraint.h:47
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition: Key.h:86
Constraint(KeyIterator beginKey, KeyIterator endKey)
construct from container
Definition: Constraint.h:51
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:102
std::ptrdiff_t j
Constraint(Key j1, Key j2)
Construct binary constraint factor.
Definition: Constraint.h:44


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:03