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.
const gtsam::Symbol key('X', 0)
void print(const string &s="") const
print
bool equals(const This &fg, double tol=1e-9) const
Check equality up to tolerance.
bool isFeasible(const VectorValues &x) const
check feasibility
std::shared_ptr< LP > shared_ptr
InequalityFactorGraph inequalities
Linear inequality constraints: cI(x) <= 0.
void print(const std::string &s="", const KeyFormatter &formatter=DefaultKeyFormatter) const override
Factor graph of all LinearInequality factors.
bool equals(const InequalityFactorGraph &other, double tol=1e-9) const
KeyDimMap cachedConstrainedKeyDimMap_
cached key-dim map of all variables in the constraints
virtual void print(const std::string &s="FactorGraph", const KeyFormatter &formatter=DefaultKeyFormatter) const
Print out graph to std::cout, with optional key formatter.
Factor graph of all LinearEquality factors.
void g(const string &key, int i)
const_iterator find(Key key) const
find
bool equals(const GaussianFactor &lf, double tol=1e-9) const override
const_iterator end() const
KeyDimMap collectKeyDim(const LinearGraph &linearGraph)
bool equals(const LP &other, double tol=1e-9) const
equals
LinearCost cost
Linear cost factor.
Vector costGradient(Key key, const VectorValues &delta) const
double error(const VectorValues &x) const
Array< double, 1, 3 > e(1./3., 0.5, 2.)
void print(const std::string &str="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
const KeyDimMap & constrainedKeyDimMap() const
std::map< Key, size_t > KeyDimMap
Mapping between variable's key and its corresponding dimensionality.
KeyVector::const_iterator const_iterator
Const iterator over keys.
double error(const VectorValues &x) const
Compute error of a guess.
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.
constABlock getA(const_iterator variable) const