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-02-12 12:33:33 +08:00
|
|
|
/**
|
|
|
|
* This class is used to represent an equality constraint on
|
|
|
|
* a Programming problem of the form Ax = b.
|
|
|
|
*/
|
2015-02-25 11:25:26 +08:00
|
|
|
class EqualityFactorGraph : public FactorGraph<LinearEquality> {
|
2014-12-09 19:13:57 +08:00
|
|
|
public:
|
2015-02-25 11:25:26 +08:00
|
|
|
typedef boost::shared_ptr<EqualityFactorGraph> shared_ptr;
|
2015-05-15 20:45:47 +08:00
|
|
|
|
|
|
|
/** compute error of a guess.
|
|
|
|
* TODO: This code is duplicated in GaussianFactorGraph and NonlinearFactorGraph!!
|
|
|
|
* Remove it!
|
|
|
|
*/
|
|
|
|
double error(const VectorValues& x) const {
|
|
|
|
double total_error = 0.;
|
2016-06-14 08:35:17 +08:00
|
|
|
for(const sharedFactor& factor: *this){
|
2015-05-15 20:45:47 +08:00
|
|
|
if(factor)
|
|
|
|
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
|
|
|
|