2014-12-09 19:13:57 +08:00
|
|
|
/* ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
* GTSAM Copyright 2010, Georgia Tech Research Corporation,
|
|
|
|
* Atlanta, Georgia 30332-0415
|
|
|
|
* All Rights Reserved
|
|
|
|
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
|
|
|
|
|
|
|
|
* See LICENSE for the license information
|
|
|
|
|
|
|
|
* -------------------------------------------------------------------------- */
|
|
|
|
|
2015-02-25 11:15:41 +08:00
|
|
|
/**
|
2015-02-25 22:09:33 +08:00
|
|
|
* @file EqualityFactorGraph.h
|
|
|
|
* @brief Factor graph of all LinearEquality factors
|
|
|
|
* @date Dec 8, 2014
|
|
|
|
* @author Duy-Nguyen Ta
|
2014-12-09 19:13:57 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <gtsam/inference/FactorGraph.h>
|
|
|
|
#include <gtsam_unstable/linear/LinearEquality.h>
|
|
|
|
|
|
|
|
namespace gtsam {
|
2016-06-18 12:28:49 +08:00
|
|
|
|
2016-02-12 12:33:33 +08:00
|
|
|
/**
|
2016-06-18 12:28:49 +08:00
|
|
|
* Collection of all Linear Equality constraints Ax=b of
|
|
|
|
* a Programming problem as a Factor Graph
|
2016-02-12 12:33:33 +08:00
|
|
|
*/
|
2016-06-14 10:58:36 +08:00
|
|
|
class EqualityFactorGraph: public FactorGraph<LinearEquality> {
|
2014-12-09 19:13:57 +08:00
|
|
|
public:
|
2023-01-18 06:05:12 +08:00
|
|
|
typedef std::shared_ptr<EqualityFactorGraph> shared_ptr;
|
2015-05-15 20:45:47 +08:00
|
|
|
|
2020-10-01 03:38:25 +08:00
|
|
|
/// Add a linear inequality, forwards arguments to LinearInequality.
|
|
|
|
template <class... Args> void add(Args &&... args) {
|
|
|
|
emplace_shared<LinearEquality>(std::forward<Args>(args)...);
|
|
|
|
}
|
|
|
|
|
2016-06-18 12:28:49 +08:00
|
|
|
/// Compute error of a guess.
|
2015-05-15 20:45:47 +08:00
|
|
|
double error(const VectorValues& x) const {
|
|
|
|
double total_error = 0.;
|
2016-06-14 10:58:36 +08:00
|
|
|
for (const sharedFactor& factor : *this) {
|
|
|
|
if (factor)
|
2015-05-15 20:45:47 +08:00
|
|
|
total_error += factor->error(x);
|
|
|
|
}
|
|
|
|
return total_error;
|
|
|
|
}
|
2014-12-09 19:13:57 +08:00
|
|
|
};
|
|
|
|
|
2014-12-22 05:02:06 +08:00
|
|
|
/// traits
|
2015-02-25 11:25:26 +08:00
|
|
|
template<> struct traits<EqualityFactorGraph> : public Testable<
|
|
|
|
EqualityFactorGraph> {
|
2014-12-22 05:02:06 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // \ namespace gtsam
|
2014-12-09 19:13:57 +08:00
|
|
|
|