37 template <
class LinearGraph>
40 for (
const typename LinearGraph::sharedFactor& factor : linearGraph) {
41 if (!factor)
continue;
42 for (
Key key : factor->keys())
43 keyDimMap[
key] = factor->getDim(factor->find(
key));
63 return (equalities.
error(x) == 0 && inequalities.
error(x) == 0);
67 void print(
const string&
s =
"")
const {
68 std::cout <<
s << std::endl;
69 cost.
print(
"Linear cost: ");
70 equalities.
print(
"Linear equality factors: ");
71 inequalities.
print(
"Linear inequality factors: ");
81 if (!cachedConstrainedKeyDimMap_.empty())
82 return cachedConstrainedKeyDimMap_;
86 cachedConstrainedKeyDimMap_.insert(keysDim2.begin(), keysDim2.end());
87 return cachedConstrainedKeyDimMap_;
91 Vector g = Vector::Zero(delta.
at(key).size());
93 if (it != cost.
end()) g = cost.
getA(it).transpose();
EqualityFactorGraph equalities
Linear equality constraints: cE(x) = 0.
Vector costGradient(Key key, const VectorValues &delta) const
const_iterator find(Key key) const
find
bool equals(const InequalityFactorGraph &other, double tol=1e-9) const
InequalityFactorGraph inequalities
Linear inequality constraints: cI(x) <= 0.
void print(const std::string &s="", const KeyFormatter &formatter=DefaultKeyFormatter) const override
bool isFeasible(const VectorValues &x) const
check feasibility
const_iterator end() const
double error(const VectorValues &x) const
bool equals(const LP &other, double tol=1e-9) const
equals
Factor graph of all LinearInequality factors.
KeyDimMap cachedConstrainedKeyDimMap_
cached key-dim map of all variables in the constraints
Factor graph of all LinearEquality factors.
void g(const string &key, int i)
bool equals(const GaussianFactor &lf, double tol=1e-9) const override
bool equals(const This &fg, double tol=1e-9) const
KeyDimMap collectKeyDim(const LinearGraph &linearGraph)
const KeyDimMap & constrainedKeyDimMap() const
LinearCost cost
Linear cost factor.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
boost::shared_ptr< LP > shared_ptr
constABlock getA(const_iterator variable) const
double error(const VectorValues &x) const
Compute error of a guess.
void print(const std::string &str="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
virtual void print(const std::string &s="FactorGraph", const KeyFormatter &formatter=DefaultKeyFormatter) const
print out graph
void print(const string &s="") const
print
std::map< Key, size_t > KeyDimMap
Mapping between variable's key and its corresponding dimensionality.
KeyVector::const_iterator const_iterator
Const iterator over keys.
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
std::uint64_t Key
Integer nonlinear key type.
LinearCost derived from JacobianFactor to support linear cost functions c'x.