| Line |
Branch |
Exec |
Source |
| 1 |
|
|
// |
| 2 |
|
|
// Copyright (c) 2017 CNRS |
| 3 |
|
|
// |
| 4 |
|
|
// This file is part of tsid |
| 5 |
|
|
// tsid is free software: you can redistribute it |
| 6 |
|
|
// and/or modify it under the terms of the GNU Lesser General Public |
| 7 |
|
|
// License as published by the Free Software Foundation, either version |
| 8 |
|
|
// 3 of the License, or (at your option) any later version. |
| 9 |
|
|
// tsid is distributed in the hope that it will be |
| 10 |
|
|
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty |
| 11 |
|
|
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 |
|
|
// General Lesser Public License for more details. You should have |
| 13 |
|
|
// received a copy of the GNU Lesser General Public License along with |
| 14 |
|
|
// tsid If not, see |
| 15 |
|
|
// <http://www.gnu.org/licenses/>. |
| 16 |
|
|
// |
| 17 |
|
|
|
| 18 |
|
|
#ifndef __invdyn_solvers_hqp_base_hpp__ |
| 19 |
|
|
#define __invdyn_solvers_hqp_base_hpp__ |
| 20 |
|
|
|
| 21 |
|
|
#include "tsid/solvers/fwd.hpp" |
| 22 |
|
|
#include "tsid/solvers/solver-HQP-output.hpp" |
| 23 |
|
|
#include "tsid/math/constraint-base.hpp" |
| 24 |
|
|
|
| 25 |
|
|
#include <vector> |
| 26 |
|
|
#include <utility> |
| 27 |
|
|
|
| 28 |
|
|
namespace tsid { |
| 29 |
|
|
namespace solvers { |
| 30 |
|
|
|
| 31 |
|
|
/** |
| 32 |
|
|
* @brief Abstract interface for a Quadratic Program (HQP) solver. |
| 33 |
|
|
*/ |
| 34 |
|
|
class TSID_DLLAPI SolverHQPBase { |
| 35 |
|
|
public: |
| 36 |
|
|
EIGEN_MAKE_ALIGNED_OPERATOR_NEW |
| 37 |
|
|
|
| 38 |
|
|
static std::string const HQP_status_string[5]; |
| 39 |
|
|
|
| 40 |
|
|
typedef math::RefVector RefVector; |
| 41 |
|
|
typedef math::ConstRefVector ConstRefVector; |
| 42 |
|
|
typedef math::ConstRefMatrix ConstRefMatrix; |
| 43 |
|
|
|
| 44 |
|
|
SolverHQPBase(const std::string& name); |
| 45 |
|
22 |
virtual ~SolverHQPBase() = default; |
| 46 |
|
|
|
| 47 |
|
✗ |
virtual const std::string& name() const { return m_name; } |
| 48 |
|
|
|
| 49 |
|
|
virtual void resize(unsigned int n, unsigned int neq, unsigned int nin) = 0; |
| 50 |
|
|
|
| 51 |
|
|
/** Solve the specified Hierarchical Quadratic Program. |
| 52 |
|
|
*/ |
| 53 |
|
|
virtual const HQPOutput& solve(const HQPData& problemData) = 0; |
| 54 |
|
|
|
| 55 |
|
|
/** Retrieve the matrices describing a QP problem from the problem data. */ |
| 56 |
|
|
virtual void retrieveQPData(const HQPData& problemData, |
| 57 |
|
|
const bool hessianRegularization) = 0; |
| 58 |
|
|
|
| 59 |
|
|
/** Get the objective value of the last solved problem. */ |
| 60 |
|
|
virtual double getObjectiveValue() = 0; |
| 61 |
|
|
|
| 62 |
|
|
/** Return true if the solver is allowed to warm start, false otherwise. */ |
| 63 |
|
✗ |
virtual bool getUseWarmStart() { return m_useWarmStart; } |
| 64 |
|
|
/** Specify whether the solver is allowed to use warm-start techniques. */ |
| 65 |
|
✗ |
virtual void setUseWarmStart(bool useWarmStart) { |
| 66 |
|
✗ |
m_useWarmStart = useWarmStart; |
| 67 |
|
|
} |
| 68 |
|
|
|
| 69 |
|
|
/** Get the current maximum number of iterations performed by the solver. */ |
| 70 |
|
✗ |
virtual unsigned int getMaximumIterations() { return m_maxIter; } |
| 71 |
|
|
/** Set the current maximum number of iterations performed by the solver. */ |
| 72 |
|
|
virtual bool setMaximumIterations(unsigned int maxIter); |
| 73 |
|
|
|
| 74 |
|
|
/** Get the maximum time allowed to solve a problem. */ |
| 75 |
|
✗ |
virtual double getMaximumTime() { return m_maxTime; } |
| 76 |
|
|
/** Set the maximum time allowed to solve a problem. */ |
| 77 |
|
|
virtual bool setMaximumTime(double seconds); |
| 78 |
|
|
|
| 79 |
|
|
protected: |
| 80 |
|
|
std::string m_name; |
| 81 |
|
|
bool m_useWarmStart; // true if the solver is allowed to warm start |
| 82 |
|
|
unsigned int m_maxIter; // max number of iterations |
| 83 |
|
|
double m_maxTime; // max time to solve the HQP [s] |
| 84 |
|
|
HQPOutput m_output; |
| 85 |
|
|
}; |
| 86 |
|
|
|
| 87 |
|
|
} // namespace solvers |
| 88 |
|
|
} // namespace tsid |
| 89 |
|
|
|
| 90 |
|
|
#endif // ifndef __invdyn_solvers_hqp_base_hpp__ |
| 91 |
|
|
|