GTSAM  4.0.2
C++ library for smoothing and mapping (SAM)
InequalityFactorGraph.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 
19 #pragma once
20 
25 
26 namespace gtsam {
27 
32 class InequalityFactorGraph: public FactorGraph<LinearInequality> {
33 private:
35 
36 public:
37  typedef std::shared_ptr<InequalityFactorGraph> shared_ptr;
38 
40  void print(
41  const std::string& str = "",
42  const KeyFormatter& keyFormatter = DefaultKeyFormatter) const override {
43  Base::print(str, keyFormatter);
44  }
45 
47  bool equals(const InequalityFactorGraph& other, double tol = 1e-9) const {
48  return Base::equals(other, tol);
49  }
50 
52  template <class... Args> void add(Args &&... args) {
53  emplace_shared<LinearInequality>(std::forward<Args>(args)...);
54  }
55 
59  double error(const VectorValues& x) const {
60  for (const sharedFactor& factor : *this) {
61  if (factor)
62  if (factor->error(x) > 1e-7)
63  return std::numeric_limits<double>::infinity();
64  }
65  return 0.0;
66  }
67 };
68 
70 template<>
71 struct traits<InequalityFactorGraph> : public Testable<InequalityFactorGraph> {
72 };
73 
74 } // \ namespace gtsam
75 
void add(Args &&... args)
Add a linear inequality, forwards arguments to LinearInequality.
Definition: InequalityFactorGraph.h:52
bool equals(const This &fg, double tol=1e-9) const
Check equality up to tolerance.
Definition: FactorGraph-inst.h:50
Definition: Testable.h:152
Definition: Group.h:43
Definition: BayesTree.h:34
Definition: InequalityFactorGraph.h:32
bool equals(const InequalityFactorGraph &other, double tol=1e-9) const
Definition: InequalityFactorGraph.h:47
virtual void print(const std::string &s="FactorGraph", const KeyFormatter &formatter=DefaultKeyFormatter) const
Print out graph to std::cout, with optional key formatter.
Definition: FactorGraph-inst.h:37
Definition: VectorValues.h:74
Factor Graph Values.
double error(const VectorValues &x) const
Definition: InequalityFactorGraph.h:59
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
Definition: chartTesting.h:28
void print(const std::string &str="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
Definition: InequalityFactorGraph.h:40
Factor Graph Base Class.
std::shared_ptr< LinearInequality > sharedFactor
Shared pointer to a factor.
Definition: FactorGraph.h:105
Factor Graph Base Class.
LinearInequality derived from Base with constrained noise model.