fix comments

release/4.3a0
thduynguyen 2015-02-24 22:09:31 -05:00
parent 95bb10d44a
commit 0c025f798c
3 changed files with 41 additions and 29 deletions

View File

@ -9,11 +9,11 @@
* -------------------------------------------------------------------------- */ * -------------------------------------------------------------------------- */
/* /**
* QP.h * @file: QP.h
* @brief: Factor graphs of a Quadratic Programming problem * @brief: Factor graphs of a Quadratic Programming problem
* @date: Dec 8, 2014 * @date: Dec 8, 2014
* @author: thduynguyen * @author: Duy-Nguyen Ta
*/ */
#pragma once #pragma once
@ -25,12 +25,12 @@
namespace gtsam { namespace gtsam {
/** /**
* struct contains factor graphs of a Quadratic Programming problem * Struct contains factor graphs of a Quadratic Programming problem
*/ */
struct QP { struct QP {
GaussianFactorGraph cost; //!< Quadratic cost factors GaussianFactorGraph cost; //!< Quadratic cost factors
LinearEqualityFactorGraph equalities; //!< linear equality constraints LinearEqualityFactorGraph equalities; //!< linear equality constraints: f(x) = 0
LinearInequalityFactorGraph inequalities; //!< linear inequality constraints LinearInequalityFactorGraph inequalities; //!< linear inequality constraints: g(x) <= 0
/** default constructor */ /** default constructor */
QP() : QP() :

View File

@ -1,8 +1,19 @@
/* /* ----------------------------------------------------------------------------
* QPSolver.cpp
* 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
* -------------------------------------------------------------------------- */
/**
* @file: QPSolver.cpp
* @brief: * @brief:
* @date: Apr 15, 2014 * @date: Apr 15, 2014
* @author: thduynguyen * @author: Duy-Nguyen Ta
*/ */
#include <gtsam/inference/Symbol.h> #include <gtsam/inference/Symbol.h>
@ -231,8 +242,8 @@ LinearInequalityFactorGraph QPSolver::identifyActiveConstraints(
workingFactor->inactivate(); workingFactor->inactivate();
} else { } else {
double error = workingFactor->error(initialValues); double error = workingFactor->error(initialValues);
// TODO: This version of QPSolver doesn't handle infeasible initial point // TODO: find a feasible initial point for QPSolver.
// since we haven't had an LPSolver yet // For now, we just throw an exception, since we don't have an LPSolver to do this yet
if (error > 0) if (error > 0)
throw InfeasibleInitialValues(); throw InfeasibleInitialValues();

View File

@ -8,11 +8,12 @@
* See LICENSE for the license information * See LICENSE for the license information
* -------------------------------------------------------------------------- */ * -------------------------------------------------------------------------- */
/*
* QPSolver.h /**
* @file: QPSolver.h
* @brief: A quadratic programming solver implements the active set method * @brief: A quadratic programming solver implements the active set method
* @date: Apr 15, 2014 * @date: Apr 15, 2014
* @author: thduynguyen * @author: Duy-Nguyen Ta
*/ */
#pragma once #pragma once
@ -47,19 +48,19 @@ struct QPState {
}; };
/** /**
* This class implements the active set method to solve quadratic programming problems * This QPSolver uses the active set method to solve a quadratic programming problem
* encoded in a GaussianFactorGraph with special mixed constrained noise models, in which * defined in the QP struct.
* a negative sigma denotes an inequality <=0 constraint, * Note: This version of QPSolver only works with a feasible initial value.
* a zero sigma denotes an equality =0 constraint,
* and a positive sigma denotes a normal Gaussian noise model.
*/ */
class QPSolver { class QPSolver {
const QP& qp_; //!< factor graphs of the QP problem, can't be modified! const QP& qp_; //!< factor graphs of the QP problem, can't be modified!
GaussianFactorGraph baseGraph_; //!< factor graphs of cost factors and linear equalities. The working set of inequalities will be added to this base graph in the process. GaussianFactorGraph baseGraph_; //!< factor graphs of cost factors and linear equalities.
//!< used to initialize the working set factor graph,
//!< to which active inequalities will be added
VariableIndex costVariableIndex_, equalityVariableIndex_, VariableIndex costVariableIndex_, equalityVariableIndex_,
inequalityVariableIndex_; inequalityVariableIndex_; //!< index to corresponding factors to build dual graphs
FastSet<Key> constrainedKeys_; //!< all constrained keys, will become factors in the dual graph FastSet<Key> constrainedKeys_; //!< all constrained keys, will become factors in dual graphs
public: public:
/// Constructor /// Constructor
@ -79,13 +80,13 @@ public:
const VariableIndex& variableIndex) const { const VariableIndex& variableIndex) const {
std::vector<std::pair<Key, Matrix> > Aterms; std::vector<std::pair<Key, Matrix> > Aterms;
if (variableIndex.find(key) != variableIndex.end()) { if (variableIndex.find(key) != variableIndex.end()) {
BOOST_FOREACH(size_t factorIx, variableIndex[key]){ BOOST_FOREACH(size_t factorIx, variableIndex[key]) {
typename FACTOR::shared_ptr factor = graph.at(factorIx); typename FACTOR::shared_ptr factor = graph.at(factorIx);
if (!factor->active()) continue; if (!factor->active()) continue;
Matrix Ai = factor->getA(factor->find(key)).transpose(); Matrix Ai = factor->getA(factor->find(key)).transpose();
Aterms.push_back(std::make_pair(factor->dualKey(), Ai)); Aterms.push_back(std::make_pair(factor->dualKey(), Ai));
}
} }
}
return Aterms; return Aterms;
} }
@ -189,7 +190,7 @@ public:
/** Optimize with a provided initial values /** Optimize with a provided initial values
* For this version, it is the responsibility of the caller to provide * For this version, it is the responsibility of the caller to provide
* a feasible initial value. * a feasible initial value, otherwise, an exception will be thrown.
* @return a pair of <primal, dual> solutions * @return a pair of <primal, dual> solutions
*/ */
std::pair<VectorValues, VectorValues> optimize( std::pair<VectorValues, VectorValues> optimize(