hpp-centroidal-dynamics: include/hpp/centroidal-dynamics/solver_LP_abstract.hh Source File

hpp-centroidal-dynamics 9.0.2 Utility classes for testing (robust) equilibrium of a system in contact with the environment, and other centroidal dynamics methods.

Loading...
Searching...
No Matches
solver_LP_abstract.hh
Go to the documentation of this file.
1/*
2 * Copyright 2015, LAAS-CNRS
3 * Author: Andrea Del Prete
4 */
5
6#ifndef HPP_CENTROIDAL_DYNAMICS_SOLVER_LP_ABSTRACT_HH
7#define HPP_CENTROIDAL_DYNAMICS_SOLVER_LP_ABSTRACT_HH
8
9#include <Eigen/Dense>
10#include <hpp/centroidal-dynamics/local_config.hh>
11#include <hpp/centroidal-dynamics/util.hh>
12
13namespace centroidal_dynamics {
14
18enum CENTROIDAL_DYNAMICS_DLLAPI SolverLP {
19 SOLVER_LP_QPOASES = 0,
20 SOLVER_LP_CLP = 1
21};
22
26enum CENTROIDAL_DYNAMICS_DLLAPI LP_status {
27 LP_STATUS_UNKNOWN = -1,
28 LP_STATUS_OPTIMAL = 0,
29 LP_STATUS_INFEASIBLE = 1,
30 LP_STATUS_UNBOUNDED = 2,
31 LP_STATUS_MAX_ITER_REACHED = 3,
32 LP_STATUS_ERROR = 4
33};
34
38 class CENTROIDAL_DYNAMICS_DLLAPI Solver_LP_abstract {
39 protected:
40 bool m_useWarmStart; // true if the solver is allowed to warm start
41 int m_maxIter; // max number of iterations
42 double m_maxTime; // max time to solve the LP [s]
43
44 public:
45 Solver_LP_abstract() {
46 m_maxIter = 1000;
47 m_maxTime = 100.0;
48 m_useWarmStart = true;
49 }
50
51 virtual ~Solver_LP_abstract() {}
52
58 static Solver_LP_abstract* getNewSolver(SolverLP solverType);
59
65 virtual LP_status solve(Cref_vectorX c, Cref_vectorX lb, Cref_vectorX ub,
66 Cref_matrixXX A, Cref_vectorX Alb, Cref_vectorX Aub,
67 Ref_vectorX sol) = 0;
68
75 virtual LP_status solve(const std::string& filename, Ref_vectorX sol);
76
91 virtual bool writeLpToFile(const std::string& filename, Cref_vectorX c,
92 Cref_vectorX lb, Cref_vectorX ub, Cref_matrixXX A,
93 Cref_vectorX Alb, Cref_vectorX Aub);
94
109 virtual bool readLpFromFile(const std::string& filename, VectorX& c,
110 VectorX& lb, VectorX& ub, MatrixXX& A,
111 VectorX& Alb, VectorX& Aub);
112
114 virtual LP_status getStatus() = 0;
115
117 virtual double getObjectiveValue() = 0;
118
120 virtual void getDualSolution(Ref_vectorX res) = 0;
121
123 virtual bool getUseWarmStart() { return m_useWarmStart; }
125 virtual void setUseWarmStart(bool useWarmStart) {
126 m_useWarmStart = useWarmStart;
127 }
128
130 virtual unsigned int getMaximumIterations() { return m_maxIter; }
132 virtual bool setMaximumIterations(unsigned int maxIter);
133
135 virtual double getMaximumTime() { return m_maxTime; }
137 virtual bool setMaximumTime(double seconds);
138};
139
140} // end namespace centroidal_dynamics
141
142#endif // HPP_CENTROIDAL_DYNAMICS_SOLVER_LP_ABSTRACT_HH
centroidal_dynamics::Solver_LP_abstract
Abstract interface for a Linear Program (LP) solver.
Definition solver_LP_abstract.hh:38
centroidal_dynamics::Solver_LP_abstract::getMaximumTime
virtual double getMaximumTime()
Definition solver_LP_abstract.hh:135
centroidal_dynamics::Solver_LP_abstract::m_maxTime
double m_maxTime
Definition solver_LP_abstract.hh:42
centroidal_dynamics::Solver_LP_abstract::setUseWarmStart
virtual void setUseWarmStart(bool useWarmStart)
Definition solver_LP_abstract.hh:125
centroidal_dynamics::Solver_LP_abstract::getMaximumIterations
virtual unsigned int getMaximumIterations()
Definition solver_LP_abstract.hh:130
centroidal_dynamics::Solver_LP_abstract::m_useWarmStart
bool m_useWarmStart
Definition solver_LP_abstract.hh:40
centroidal_dynamics::Solver_LP_abstract::getObjectiveValue
virtual double getObjectiveValue()=0
centroidal_dynamics::Solver_LP_abstract::getStatus
virtual LP_status getStatus()=0
centroidal_dynamics::Solver_LP_abstract::solve
virtual LP_status solve(Cref_vectorX c, Cref_vectorX lb, Cref_vectorX ub, Cref_matrixXX A, Cref_vectorX Alb, Cref_vectorX Aub, Ref_vectorX sol)=0
centroidal_dynamics::Solver_LP_abstract::m_maxIter
int m_maxIter
Definition solver_LP_abstract.hh:41
centroidal_dynamics::Solver_LP_abstract::Solver_LP_abstract
Solver_LP_abstract()
Definition solver_LP_abstract.hh:45
centroidal_dynamics::Solver_LP_abstract::getUseWarmStart
virtual bool getUseWarmStart()
Definition solver_LP_abstract.hh:123
centroidal_dynamics::Solver_LP_abstract::getDualSolution
virtual void getDualSolution(Ref_vectorX res)=0
centroidal_dynamics::Solver_LP_abstract::~Solver_LP_abstract
virtual ~Solver_LP_abstract()
Definition solver_LP_abstract.hh:51
local_config.hh
CENTROIDAL_DYNAMICS_DLLAPI
#define CENTROIDAL_DYNAMICS_DLLAPI
Definition local_config.hh:52
centroidal_dynamics
Definition centroidal_dynamics.hh:14
centroidal_dynamics::VectorX
Eigen::Matrix< value_type, Eigen::Dynamic, 1 > VectorX
Definition util.hh:35
centroidal_dynamics::Ref_vectorX
Eigen::Ref< VectorX > Ref_vectorX
Definition util.hh:53
centroidal_dynamics::Cref_vectorX
const Eigen::Ref< const VectorX > & Cref_vectorX
Definition util.hh:63
centroidal_dynamics::Cref_matrixXX
const Eigen::Ref< const MatrixXX > & Cref_matrixXX
Definition util.hh:69
centroidal_dynamics::MatrixXX
Eigen::Matrix< value_type, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > MatrixXX
Definition util.hh:49
LP_STATUS_INFEASIBLE
LP_STATUS_INFEASIBLE
Definition solver_LP_abstract.hh:29
SOLVER_LP_QPOASES
SOLVER_LP_QPOASES
Definition solver_LP_abstract.hh:19
LP_STATUS_OPTIMAL
LP_STATUS_OPTIMAL
Definition solver_LP_abstract.hh:28
LP_STATUS_UNKNOWN
LP_STATUS_UNKNOWN
Definition solver_LP_abstract.hh:27
LP_STATUS_MAX_ITER_REACHED
LP_STATUS_MAX_ITER_REACHED
Definition solver_LP_abstract.hh:31
LP_STATUS_UNBOUNDED
LP_STATUS_UNBOUNDED
Definition solver_LP_abstract.hh:30
util.hh