hops
LinearProgramGurobiImpl.hpp
Go to the documentation of this file.
1 #ifndef HOPS_LINEARPROGRAMGUROBIIMPL_HPP
2 #define HOPS_LINEARPROGRAMGUROBIIMPL_HPP
3 
4 #include "LinearProgram.hpp"
5 #include <Eigen/Core>
6 
7 #ifdef HOPS_GUROBI_FOUND
8 
9 #include <gurobi_c++.h>
10 #include <memory>
11 
12 namespace hops {
13  class LinearProgramGurobiImpl : public LinearProgram {
14  public:
15  LinearProgramGurobiImpl(const Eigen::MatrixXd &A, const Eigen::VectorXd &b);
16 
18 
19  LinearProgramGurobiImpl &operator=(const LinearProgramGurobiImpl &other);
20 
21  [[nodiscard]] LinearProgramSolution solve(const Eigen::VectorXd &objective) const override;
22 
23  std::tuple<Eigen::MatrixXd, Eigen::VectorXd> removeRedundantConstraints(double tolerance) override;
24 
25  [[nodiscard]] LinearProgramSolution computeChebyshevCenter() const override;
26 
27  [[nodiscard]] std::vector<long> computeUnconstrainedDimensions() const override;
28 
29  std::tuple<Eigen::MatrixXd, Eigen::VectorXd>
30  addBoxConstraintsToUnconstrainedDimensions(double lb, double ub) override;
31 
32  private:
33  std::unique_ptr<GRBModel> model;
34  std::vector<GRBVar> variables;
35  };
36 }
37 
38 #else //HOPS_GUROBI_FOUND
39 
40 namespace hops {
42  public:
43  LinearProgramGurobiImpl(const Eigen::MatrixXd &A, const Eigen::VectorXd &b) : LinearProgram(A, b) {
44  throw std::runtime_error("HOPS did not find gurobi during compilation.");
45  }
46 
47  [[nodiscard]] LinearProgramSolution solve(const Eigen::VectorXd &) const override {
48  throw std::runtime_error("HOPS did not find gurobi during compilation.");
49  }
50 
51  std::tuple<Eigen::MatrixXd, Eigen::VectorXd> removeRedundantConstraints(double) override {
52  throw std::runtime_error("HOPS did not find gurobi during compilation.");
53  }
54 
55  [[nodiscard]] LinearProgramSolution computeChebyshevCenter() const override {
56  throw std::runtime_error("HOPS did not find gurobi during compilation.");
57  }
58 
59  [[nodiscard]] std::vector<long> computeUnconstrainedDimensions() const override {
60  throw std::runtime_error("HOPS did not find gurobi during compilation.");
61  }
62 
63  std::tuple<Eigen::MatrixXd, Eigen::VectorXd>
64  addBoxConstraintsToUnconstrainedDimensions(double, double) override {
65  throw std::runtime_error("HOPS did not find gurobi during compilation.");
66  }
67  };
68 }
69 
70 #endif //HOPS_GUROBI_FOUND
71 #endif //HOPS_LINEARPROGRAMGUROBIIMPL_HPP
hops::LinearProgramGurobiImpl::addBoxConstraintsToUnconstrainedDimensions
std::tuple< Eigen::MatrixXd, Eigen::VectorXd > addBoxConstraintsToUnconstrainedDimensions(double, double) override
Adds box constraints to unconstrained dimensions and returns system matrices. Changes to the system m...
Definition: LinearProgramGurobiImpl.hpp:64
hops::LinearProgram
Definition: LinearProgram.hpp:9
hops::LinearProgram::b
Eigen::VectorXd b
Definition: LinearProgram.hpp:54
hops::LinearProgramSolution
Definition: LinearProgramSolution.hpp:9
hops::LinearProgramGurobiImpl::solve
LinearProgramSolution solve(const Eigen::VectorXd &) const override
Definition: LinearProgramGurobiImpl.hpp:47
hops::LinearProgramGurobiImpl::computeUnconstrainedDimensions
std::vector< long > computeUnconstrainedDimensions() const override
Definition: LinearProgramGurobiImpl.hpp:59
hops::LinearProgramGurobiImpl::LinearProgramGurobiImpl
LinearProgramGurobiImpl(const Eigen::MatrixXd &A, const Eigen::VectorXd &b)
Definition: LinearProgramGurobiImpl.hpp:43
hops::LinearProgramGurobiImpl::computeChebyshevCenter
LinearProgramSolution computeChebyshevCenter() const override
Definition: LinearProgramGurobiImpl.hpp:55
hops::LinearProgramGurobiImpl::removeRedundantConstraints
std::tuple< Eigen::MatrixXd, Eigen::VectorXd > removeRedundantConstraints(double) override
Removes redundant constraints and returns system matrices. Changes to the system matrices are reflect...
Definition: LinearProgramGurobiImpl.hpp:51
hops::LinearProgram::A
Eigen::MatrixXd A
Definition: LinearProgram.hpp:53
hops
Definition: CsvReader.hpp:8
LinearProgram.hpp
hops::LinearProgramGurobiImpl
Definition: LinearProgramGurobiImpl.hpp:41