gtsam/gtsam_unstable/linear/QPSolver.h

80 lines
2.5 KiB
C
Raw Normal View History

2014-12-23 08:49:32 +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:09:31 +08:00
/**
2015-02-25 22:09:33 +08:00
* @file QPSolver.h
* @brief A quadratic programming solver implements the active set method
* @date Apr 15, 2014
* @author Duy-Nguyen Ta
2014-04-16 04:27:19 +08:00
*/
#pragma once
#include <gtsam/linear/VectorValues.h>
#include <gtsam_unstable/linear/QP.h>
#include <gtsam_unstable/linear/ActiveSetSolver.h>
#include <gtsam_unstable/linear/QPState.h>
2014-04-16 04:27:19 +08:00
2014-11-26 16:04:34 +08:00
#include <vector>
#include <set>
2014-04-16 04:27:19 +08:00
namespace gtsam {
/**
2015-02-25 11:09:31 +08:00
* This QPSolver uses the active set method to solve a quadratic programming problem
* defined in the QP struct.
* Note: This version of QPSolver only works with a feasible initial value.
2014-04-16 04:27:19 +08:00
*/
//TODO: Remove Vector Values
class QPSolver: public ActiveSetSolver {
const QP& qp_; //!< factor graphs of the QP problem, can't be modified!
2014-04-16 04:27:19 +08:00
public:
/// Constructor
QPSolver(const QP& qp);
/// Find solution with the current working set
VectorValues solveWithCurrentWorkingSet(
const InequalityFactorGraph& workingSet) const;
/// Create a dual factor
JacobianFactor::shared_ptr createDualFactor(Key key,
const InequalityFactorGraph& workingSet, const VectorValues& delta) const;
/// @}
2014-04-16 04:27:19 +08:00
boost::tuple<double, int> computeStepSize(
const InequalityFactorGraph& workingSet, const VectorValues& xk,
2014-11-26 16:04:34 +08:00
const VectorValues& p) const;
2014-04-16 04:27:19 +08:00
/** Iterate 1 step, return a new state with a new workingSet and values */
QPState iterate(const QPState& state) const;
2014-04-16 04:27:19 +08:00
2014-12-10 05:27:11 +08:00
/**
* Identify active constraints based on initial values.
*/
InequalityFactorGraph identifyActiveConstraints(
const InequalityFactorGraph& inequalities,
const VectorValues& initialValues, const VectorValues& duals =
VectorValues(), bool useWarmStart = true) const;
2014-12-10 05:27:11 +08:00
/** Optimize with a provided initial values
* For this version, it is the responsibility of the caller to provide
2015-02-25 11:09:31 +08:00
* a feasible initial value, otherwise, an exception will be thrown.
* @return a pair of <primal, dual> solutions
*/
2014-11-26 16:04:34 +08:00
std::pair<VectorValues, VectorValues> optimize(
const VectorValues& initialValues, const VectorValues& duals =
VectorValues(), bool useWarmStart = true) const;
2014-04-16 04:27:19 +08:00
};
2014-04-16 04:27:19 +08:00
} /* namespace gtsam */