35 template <
class PROBLEM,
class POLICY,
class INITSOLVER>
50 : values(), duals(), workingSet(), converged(false), iterations(0) {}
56 : values(initialValues),
58 workingSet(initialWorkingSet),
59 converged(_converged),
60 iterations(_iterations) {}
78 inequalityVariableIndex_ =
VariableIndex(problem_.inequalities);
79 constrainedKeys_ = problem_.equalities.keys();
80 constrainedKeys_.
merge(problem_.inequalities.keys());
89 std::pair<VectorValues, VectorValues>
optimize(
92 bool useWarmStart =
false)
const;
98 std::pair<VectorValues, VectorValues>
optimize()
const;
124 template<
typename FACTOR>
132 TermsContainer Aterms;
133 if (variableIndex.
find(key) != variableIndex.
end()) {
134 for (
size_t factorIx : variableIndex[key]) {
135 typename FACTOR::shared_ptr factor = graph.
at(factorIx);
136 if (!factor->active())
138 Matrix Ai = factor->getA(factor->find(key)).transpose();
139 Aterms.push_back(std::make_pair(factor->dualKey(), Ai));
178 bool useWarmStart =
false)
const;
190 template <
class PROBLEM>
192 auto keys = problem.cost.keys();
194 if (!problem.equalities.empty())
195 maxKey =
std::max(maxKey, *problem.equalities.keys().rbegin());
196 if (!problem.inequalities.empty())
197 maxKey =
std::max(maxKey, *problem.inequalities.keys().rbegin());
ActiveSetSolver(const PROBLEM &problem)
Constructor.
const gtsam::Symbol key('X', 0)
bool converged
True if the algorithm has converged to a solution.
const_iterator find(Key key) const
Find the iterator for the requested variable entry.
VectorValues values
current best values at each step
GaussianFactorGraph buildDualGraph(const InequalityFactorGraph &workingSet, const VectorValues &delta) const
Just for testing...
InequalityFactorGraph identifyActiveConstraints(const InequalityFactorGraph &inequalities, const VectorValues &initialValues, const VectorValues &duals=VectorValues(), bool useWarmStart=false) const
Identify active constraints based on initial values.
std::pair< VectorValues, VectorValues > optimize() const
void merge(const FastSet &other)
Factor graph of all LinearInequality factors.
NonlinearFactorGraph graph
Key maxKey(const PROBLEM &problem)
const_iterator end() const
Iterator to the first variable entry.
const PROBLEM & problem_
the particular [convex] problem to solve
State iterate(const State &state) const
Iterate 1 step, return a new state with a new workingSet and values.
TermsContainer collectDualJacobians(Key key, const FactorGraph< FACTOR > &graph, const VariableIndex &variableIndex) const
State()
Default constructor.
InequalityFactorGraph workingSet
GaussianFactorGraph buildWorkingGraph(const InequalityFactorGraph &workingSet, const VectorValues &xk=VectorValues()) const
std::tuple< double, int > computeStepSize(const InequalityFactorGraph &workingSet, const VectorValues &xk, const VectorValues &p, const double &maxAlpha) const
VariableIndex inequalityVariableIndex_
Linear Factor Graph where all factors are Gaussians.
int identifyLeavingConstraint(const InequalityFactorGraph &workingSet, const VectorValues &lambdas) const
Identifies active constraints that shouldn't be active anymore.
State(const VectorValues &initialValues, const VectorValues &initialDuals, const InequalityFactorGraph &initialWorkingSet, bool _converged, size_t _iterations)
Constructor with initial values.
std::shared_ptr< This > shared_ptr
shared_ptr to this class
const sharedFactor at(size_t i) const
This struct contains the state information for a single iteration.
JacobianFactor::shared_ptr createDualFactor(Key key, const InequalityFactorGraph &workingSet, const VectorValues &delta) const
VectorValues duals
current values of dual variables at each step
std::vector< std::pair< Key, Matrix > > TermsContainer
Vector of key matrix pairs. Matrices are usually the A term for a factor.
VariableIndex equalityVariableIndex_
std::uint64_t Key
Integer nonlinear key type.
Implmentation of ActiveSetSolver.