23 #include <boost/range/adaptor/map.hpp> 36 template <
class PROBLEM,
class POLICY,
class INITSOLVER>
90 std::pair<VectorValues, VectorValues>
optimize(
93 bool useWarmStart =
false)
const;
99 std::pair<VectorValues, VectorValues>
optimize()
const;
125 template<
typename FACTOR>
134 if (variableIndex.
find(key) != variableIndex.
end()) {
135 for (
size_t factorIx : variableIndex[key]) {
136 typename FACTOR::shared_ptr factor = graph.at(factorIx);
137 if (!factor->active())
139 Matrix Ai = factor->getA(factor->find(key)).transpose();
140 Aterms.push_back(std::make_pair(factor->dualKey(), Ai));
172 State
iterate(
const State& state)
const;
179 bool useWarmStart =
false)
const;
191 template <
class PROBLEM>
193 auto keys = problem.cost.keys();
194 Key maxKey = *std::max_element(keys.begin(), keys.end());
195 if (!problem.equalities.empty())
196 maxKey = std::max(
maxKey, *problem.equalities.keys().rbegin());
197 if (!problem.inequalities.empty())
198 maxKey = std::max(
maxKey, *problem.inequalities.keys().rbegin());
boost::tuple< double, int > computeStepSize(const InequalityFactorGraph &workingSet, const VectorValues &xk, const VectorValues &p, const double &maxAlpha) const
Compute minimum step size alpha to move from the current point xk to the next feasible point along a ...
size_t iterations
Definition: ActiveSetSolver.h:46
bool converged
True if the algorithm has converged to a solution.
Definition: ActiveSetSolver.h:45
boost::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition: JacobianFactor.h:93
TermsContainer collectDualJacobians(Key key, const FactorGraph< FACTOR > &graph, const VariableIndex &variableIndex) const
Finds the active constraints in the given factor graph and returns the Dual Jacobians used to build a...
Definition: ActiveSetSolver.h:126
VectorValues values
current best values at each step
Definition: ActiveSetSolver.h:41
boost::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition: GaussianFactorGraph.h:74
Key maxKey(const PROBLEM &problem)
Find the max key in a problem.
Definition: ActiveSetSolver.h:192
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:57
const_iterator find(Key key) const
Find the iterator for the requested variable entry.
Definition: VariableIndex.h:152
The VariableIndex class computes and stores the block column structure of a factor graph.
Definition: VariableIndex.h:43
Collection of all Linear Inequality constraints Ax-b <= 0 of a Programming problem as a Factor Graph.
Definition: InequalityFactorGraph.h:32
A Linear Factor Graph is a factor graph where all factors are Gaussian, i.e.
Definition: GaussianFactorGraph.h:65
This struct contains the state information for a single iteration.
Definition: ActiveSetSolver.h:40
InequalityFactorGraph workingSet
Definition: ActiveSetSolver.h:43
int identifyLeavingConstraint(const InequalityFactorGraph &workingSet, const VectorValues &lambdas) const
Identifies active constraints that shouldn't be active anymore.
State()
Default constructor.
Definition: ActiveSetSolver.h:50
std::vector< std::pair< Key, Matrix > > TermsContainer
Vector of key matrix pairs. Matrices are usually the A term for a factor.
Definition: ActiveSetSolver.h:73
This class implements the active set algorithm for solving convex Programming problems.
Definition: ActiveSetSolver.h:37
This class represents a collection of vector-valued variables associated each with a unique integer i...
Definition: VectorValues.h:73
A factor graph is a bipartite graph with factor nodes connected to variable nodes.
Definition: BayesTree.h:32
KeySet constrainedKeys_
Definition: ActiveSetSolver.h:69
State(const VectorValues &initialValues, const VectorValues &initialDuals, const InequalityFactorGraph &initialWorkingSet, bool _converged, size_t _iterations)
Constructor with initial values.
Definition: ActiveSetSolver.h:54
const PROBLEM & problem_
the particular [convex] problem to solve
Definition: ActiveSetSolver.h:65
const_iterator end() const
Iterator to the first variable entry.
Definition: VariableIndex.h:149
GaussianFactorGraph buildWorkingGraph(const InequalityFactorGraph &workingSet, const VectorValues &xk=VectorValues()) const
Build a working graph of cost, equality and active inequality constraints to solve at each iteration.
VariableIndex inequalityVariableIndex_
Definition: ActiveSetSolver.h:66
void merge(const FastSet &other)
insert another set: handy for MATLAB access
Definition: FastSet.h:121
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
Factor graph of all LinearInequality factors.
ActiveSetSolver(const PROBLEM &problem)
Constructor.
Definition: ActiveSetSolver.h:77
Linear Factor Graph where all factors are Gaussians.
GaussianFactorGraph::shared_ptr buildDualGraph(const InequalityFactorGraph &workingSet, const VectorValues &delta) const
Just for testing...
State iterate(const State &state) const
Iterate 1 step, return a new state with a new workingSet and values.
std::pair< VectorValues, VectorValues > optimize() const
For this version the caller will not have to provide an initial value.
JacobianFactor::shared_ptr createDualFactor(Key key, const InequalityFactorGraph &workingSet, const VectorValues &delta) const
Creates a dual factor from the current workingSet and the key of the the variable used to created the...
Implmentation of ActiveSetSolver.
VectorValues duals
current values of dual variables at each step
Definition: ActiveSetSolver.h:42
InequalityFactorGraph identifyActiveConstraints(const InequalityFactorGraph &inequalities, const VectorValues &initialValues, const VectorValues &duals=VectorValues(), bool useWarmStart=false) const
Identify active constraints based on initial values.