gtsam 4.1.1
gtsam
LinearEquality.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
23namespace gtsam {
24
30public:
33 typedef boost::shared_ptr<This> shared_ptr;
34
35private:
36 Key dualKey_;
37
38public:
41 Base() {
42 }
43
48 Base(jf), dualKey_(dualKey) {
49 if (!jf.isConstrained()) {
50 throw std::runtime_error(
51 "Cannot convert an unconstrained JacobianFactor to LinearEquality");
52 }
53 }
54
56 explicit LinearEquality(const HessianFactor& hf) {
57 throw std::runtime_error("Cannot convert HessianFactor to LinearEquality");
58 }
59
61 LinearEquality(Key i1, const Matrix& A1, const Vector& b, Key dualKey) :
62 Base(i1, A1, b, noiseModel::Constrained::All(b.rows())), dualKey_(dualKey) {
63 }
64
66 LinearEquality(Key i1, const Matrix& A1, Key i2, const Matrix& A2,
67 const Vector& b, Key dualKey) :
68 Base(i1, A1, i2, A2, b, noiseModel::Constrained::All(b.rows())), dualKey_(
69 dualKey) {
70 }
71
73 LinearEquality(Key i1, const Matrix& A1, Key i2, const Matrix& A2, Key i3,
74 const Matrix& A3, const Vector& b, Key dualKey) :
75 Base(i1, A1, i2, A2, i3, A3, b, noiseModel::Constrained::All(b.rows())), dualKey_(
76 dualKey) {
77 }
78
82 template<typename TERMS>
83 LinearEquality(const TERMS& terms, const Vector& b, Key dualKey) :
84 Base(terms, b, noiseModel::Constrained::All(b.rows())), dualKey_(dualKey) {
85 }
86
88 ~LinearEquality() override {
89 }
90
92 bool equals(const GaussianFactor& lf, double tol = 1e-9) const override {
93 return Base::equals(lf, tol);
94 }
95
97 void print(const std::string& s = "", const KeyFormatter& formatter =
98 DefaultKeyFormatter) const override {
99 Base::print(s, formatter);
100 }
101
104 return boost::static_pointer_cast < GaussianFactor
105 > (boost::make_shared < LinearEquality > (*this));
106 }
107
109 Key dualKey() const {
110 return dualKey_;
111 }
112
114 bool active() const {
115 return true;
116 }
117
119 Vector error_vector(const VectorValues& c) const {
120 return unweighted_error(c);
121 }
122
127 double error(const VectorValues& c) const override {
128 return 0.0;
129 }
130
131};
132// \ LinearEquality
133
135template<> struct traits<LinearEquality> : public Testable<LinearEquality> {
136};
137
138} // \ namespace gtsam
139
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:69
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
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition: concepts.h:30
A helper that implements the traits interface for GTSAM types.
Definition: Testable.h:151
This is the base class for all factor types.
Definition: Factor.h:56
An abstract virtual base class for JacobianFactor and HessianFactor.
Definition: GaussianFactor.h:39
boost::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition: GaussianFactor.h:42
A Gaussian factor using the canonical parameters (information form)
Definition: HessianFactor.h:101
A Gaussian factor in the squared-error form.
Definition: JacobianFactor.h:91
void print(const std::string &s="", const KeyFormatter &formatter=DefaultKeyFormatter) const override
print
Definition: JacobianFactor.cpp:414
bool isConstrained() const
is noise model constrained ?
Definition: JacobianFactor.h:267
bool equals(const GaussianFactor &lf, double tol=1e-9) const override
Equals for testable.
Definition: JacobianFactor.cpp:431
size_t rows() const
return the number of rows in the corresponding linear system
Definition: JacobianFactor.h:281
This class represents a collection of vector-valued variables associated each with a unique integer i...
Definition: VectorValues.h:74
This class defines a linear equality constraints, inheriting JacobianFactor with the special Constrai...
Definition: LinearEquality.h:29
Key dualKey() const
dual key
Definition: LinearEquality.h:109
LinearEquality(const HessianFactor &hf)
Conversion from HessianFactor (does Cholesky to obtain Jacobian matrix)
Definition: LinearEquality.h:56
bool active() const
for active set method: equality constraints are always active
Definition: LinearEquality.h:114
void print(const std::string &s="", const KeyFormatter &formatter=DefaultKeyFormatter) const override
print
Definition: LinearEquality.h:97
GaussianFactor::shared_ptr clone() const override
Clone this LinearEquality.
Definition: LinearEquality.h:103
bool equals(const GaussianFactor &lf, double tol=1e-9) const override
equals
Definition: LinearEquality.h:92
double error(const VectorValues &c) const override
Special error for constraints.
Definition: LinearEquality.h:127
LinearEquality(const TERMS &terms, const Vector &b, Key dualKey)
Construct an n-ary factor.
Definition: LinearEquality.h:83
boost::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition: LinearEquality.h:33
~LinearEquality() override
Virtual destructor.
Definition: LinearEquality.h:88
Vector error_vector(const VectorValues &c) const
Special error_vector for constraints (A*x-b)
Definition: LinearEquality.h:119
LinearEquality(const JacobianFactor &jf, Key dualKey)
Construct from a constrained noisemodel JacobianFactor with a dual key.
Definition: LinearEquality.h:47
LinearEquality This
Typedef to this class.
Definition: LinearEquality.h:31
LinearEquality(Key i1, const Matrix &A1, Key i2, const Matrix &A2, Key i3, const Matrix &A3, const Vector &b, Key dualKey)
Construct ternary factor.
Definition: LinearEquality.h:73
LinearEquality(Key i1, const Matrix &A1, Key i2, const Matrix &A2, const Vector &b, Key dualKey)
Construct binary factor.
Definition: LinearEquality.h:66
JacobianFactor Base
Typedef to base class.
Definition: LinearEquality.h:32
LinearEquality()
default constructor for I/O
Definition: LinearEquality.h:40
LinearEquality(Key i1, const Matrix &A1, const Vector &b, Key dualKey)
Construct unary factor.
Definition: LinearEquality.h:61