irafhy
Interval arithmetic based Reachability Analysis Framework for Hybrid Automaton
GLPKWrapper.h
Go to the documentation of this file.
1 #ifndef UTILITY_OPTIMIZER_LINEAR_PROG_GLPK_WRAPPER_H
2 #define UTILITY_OPTIMIZER_LINEAR_PROG_GLPK_WRAPPER_H
3 
4 #include <glpk.h>
5 #include <cassert>
6 #include <iostream>
7 #include <vector>
8 #include <capd/capdlib.h>
11 
12 namespace irafhy
13 {
15  {
16  private:
20  glp_prob* glpProb_ = nullptr;
24  glp_smcp param_;
28  int* ia_ = nullptr;
32  int* ja_ = nullptr;
36  std::size_t rowCnt_;
40  std::size_t colCnt_;
44  double* array_ = nullptr;
48  bool isExact_;
56  mutable bool isReady_;
60  mutable bool solved_;
64  mutable bool isArrayCreated_ = false;
65 
66  private:
71  void createArrays(std::size_t size);
80  void fillArrays(const Eigen::VectorXd& objectCoefficients,
81  double objectConstantTerm,
82  const Eigen::MatrixXd& constraintMatrix,
83  const std::vector<capd::interval>& constraintRowBounds,
84  const std::vector<capd::interval>& constraintColBounds);
88  void deleteArrays();
89 
90  public:
95  : glpProb_(nullptr)
96  , param_()
97  , ia_(nullptr)
98  , ja_(nullptr)
99  , rowCnt_(0)
100  , colCnt_(0)
101  , array_(nullptr)
102  , isExact_(true)
103  , direction_(LINEPROG_DIRECTION::MAX)
104  , isReady_(false)
105  , solved_(false)
106  {}
116  void init(const Eigen::VectorXd& objectCoefficients,
117  double objectConstantTerm,
118  const Eigen::MatrixXd& constraintMatrix,
119  const std::vector<capd::interval>& constraintRowBounds,
120  const std::vector<capd::interval>& constraintColBounds,
121  LINEPROG_DIRECTION direction);
125  ~GLPKWrapper();
130  void solve(bool isExact);
138  Evaluation result(const Eigen::VectorXd& objectCoefficients,
139  const Eigen::MatrixXd& constraintMatrix,
140  const std::vector<capd::interval>& constraintRowBounds) const;
141  };
142 } // namespace irafhy
143 #endif //UTILITY_OPTIMIZER_LINEAR_PROG_GLPK_WRAPPER_H
int * ia_
pointer to the ia array of GLPK problem
Definition: GLPKWrapper.h:28
LINEPROG_DIRECTION
optimization direction of the linear programming
Definition: enum.h:83
~GLPKWrapper()
destructor
Definition: GLPKWrapper.cpp:137
double * array_
GLPK data array.
Definition: GLPKWrapper.h:44
Evaluation result(const Eigen::VectorXd &objectCoefficients, const Eigen::MatrixXd &constraintMatrix, const std::vector< capd::interval > &constraintRowBounds) const
get the resulting of the solving
Definition: GLPKWrapper.cpp:193
Definition: enum.h:85
void createArrays(std::size_t size)
allocate memory for the GLPK array
Definition: GLPKWrapper.cpp:7
bool solved_
is the problem solved by GLPK
Definition: GLPKWrapper.h:60
Definition: evaluation.hpp:10
bool isReady_
is data prepared
Definition: GLPKWrapper.h:56
Definition: condition.cpp:3
LINEPROG_DIRECTION direction_
optimizing direction of the problem
Definition: GLPKWrapper.h:52
glp_prob * glpProb_
pointer to the GLPK problem
Definition: GLPKWrapper.h:20
void deleteArrays()
release the memory
Definition: GLPKWrapper.cpp:126
void fillArrays(const Eigen::VectorXd &objectCoefficients, double objectConstantTerm, const Eigen::MatrixXd &constraintMatrix, const std::vector< capd::interval > &constraintRowBounds, const std::vector< capd::interval > &constraintColBounds)
fill the GLPK array with given information
Definition: GLPKWrapper.cpp:17
Definition: GLPKWrapper.h:14
bool isExact_
solve LP problem in exact arithmetic or not
Definition: GLPKWrapper.h:48
void solve(bool isExact)
solve the problem with wrapped GLPK library
Definition: GLPKWrapper.cpp:178
void init(const Eigen::VectorXd &objectCoefficients, double objectConstantTerm, const Eigen::MatrixXd &constraintMatrix, const std::vector< capd::interval > &constraintRowBounds, const std::vector< capd::interval > &constraintColBounds, LINEPROG_DIRECTION direction)
initialize the problem with given information
Definition: GLPKWrapper.cpp:146
GLPKWrapper()
constructor
Definition: GLPKWrapper.h:94
std::size_t rowCnt_
number of the rows of constraints
Definition: GLPKWrapper.h:36
glp_smcp param_
GLPK related parameters.
Definition: GLPKWrapper.h:24
int * ja_
pointer to the ja array of GLPK problem
Definition: GLPKWrapper.h:32
bool isArrayCreated_
is the GLPK array created
Definition: GLPKWrapper.h:64
std::size_t colCnt_
number of the variables
Definition: GLPKWrapper.h:40