gtsam  4.1.0
gtsam
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 
22 #include <gtsam/inference/FactorGraph-inst.h>
25 
26 namespace gtsam {
27 
32 class InequalityFactorGraph: public FactorGraph<LinearInequality> {
33 private:
35 
36 public:
37  typedef boost::shared_ptr<InequalityFactorGraph> shared_ptr;
38 
40  void print(const std::string& str, const KeyFormatter& keyFormatter =
41  DefaultKeyFormatter) const {
42  Base::print(str, keyFormatter);
43  }
44 
46  bool equals(const InequalityFactorGraph& other, double tol = 1e-9) const {
47  return Base::equals(other, tol);
48  }
49 
51  template <class... Args> void add(Args &&... args) {
52  emplace_shared<LinearInequality>(std::forward<Args>(args)...);
53  }
54 
58  double error(const VectorValues& x) const {
59  for (const sharedFactor& factor : *this) {
60  if (factor)
61  if (factor->error(x) > 1e-7)
62  return std::numeric_limits<double>::infinity();
63  }
64  return 0.0;
65  }
66 };
67 
69 template<>
70 struct traits<InequalityFactorGraph> : public Testable<InequalityFactorGraph> {
71 };
72 
73 } // \ namespace gtsam
74 
LinearInequality.h
LinearInequality derived from Base with constrained noise model.
gtsam::traits
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition: concepts.h:30
gtsam::InequalityFactorGraph::equals
bool equals(const InequalityFactorGraph &other, double tol=1e-9) const
equals
Definition: InequalityFactorGraph.h:46
gtsam::VectorValues
This class represents a collection of vector-valued variables associated each with a unique integer i...
Definition: VectorValues.h:74
gtsam::FactorGraph< LinearInequality >::equals
bool equals(const This &fg, double tol=1e-9) const
Check equality.
Definition: FactorGraph-inst.h:51
FactorGraph.h
Factor Graph Base Class.
VectorValues.h
Factor Graph Values.
gtsam
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
gtsam::Testable
A helper that implements the traits interface for GTSAM types.
Definition: Testable.h:150
gtsam::InequalityFactorGraph::add
void add(Args &&... args)
Add a linear inequality, forwards arguments to LinearInequality.
Definition: InequalityFactorGraph.h:51
gtsam::FactorGraph
A factor graph is a bipartite graph with factor nodes connected to variable nodes.
Definition: FactorGraph.h:94
gtsam::InequalityFactorGraph
Collection of all Linear Inequality constraints Ax-b <= 0 of a Programming problem as a Factor Graph.
Definition: InequalityFactorGraph.h:32
gtsam::FactorGraph< LinearInequality >::sharedFactor
boost::shared_ptr< LinearInequality > sharedFactor
Shared pointer to a factor.
Definition: FactorGraph.h:98
gtsam::FactorGraph< LinearInequality >::print
void print(const std::string &s="FactorGraph", const KeyFormatter &formatter=DefaultKeyFormatter) const
print out graph
Definition: FactorGraph-inst.h:38
gtsam::KeyFormatter
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:35
gtsam::InequalityFactorGraph::error
double error(const VectorValues &x) const
Compute error of a guess.
Definition: InequalityFactorGraph.h:58
gtsam::InequalityFactorGraph::print
void print(const std::string &str, const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
print
Definition: InequalityFactorGraph.h:40