lpinterface
 All Classes Namespaces Files Functions Variables Enumerations Enumerator
lphandle_soplex.hpp
1 #ifndef LPINTERFACE_LPHANDLE_SOPLEX_H
2 #define LPINTERFACE_LPHANDLE_SOPLEX_H
3 
4 #include <memory>
5 #include <numeric>
6 #include <unordered_map>
7 #include <vector>
8 
9 #include "soplex.h"
10 
11 #include "lpinterface/badge.hpp"
12 #include "lpinterface/detail/util.hpp"
13 #include "lpinterface/lp.hpp"
14 
15 namespace lpint {
16 
17 class SoplexSolver;
18 
20  public:
22  std::shared_ptr<soplex::SoPlex> soplex)
23  : soplex_(soplex) {
24  std::iota(permutation_.begin(), permutation_.end(), 0);
25  inverse_permutation_ = detail::inverse_permutation(permutation_);
26  std::iota(permutation_vars_.begin(), permutation_vars_.end(), 0);
27  inverse_permutation_vars_ = detail::inverse_permutation(permutation_vars_);
28  }
29 
30  Variable variable(std::size_t i) const override;
31 
32  std::vector<Variable> variables() const override;
33 
34  void add_variables(const std::vector<Variable>& vars) override;
35 
36  void add_variables(std::size_t num_vars) override;
37 
38  void add_constraints(
39  const std::vector<Constraint<double>>& constraints) override;
40 
41  void remove_variable(const std::size_t i) override;
42 
43  void remove_constraint(std::size_t i) override;
44 
45  std::size_t num_vars() const override;
46 
47  std::size_t num_constraints() const override;
48 
49  void set_objective_sense(const OptimizationType objsense) override;
50 
51  void set_objective(const Objective<double>& objective) override;
52 
53  OptimizationType optimization_type() const override;
54 
55  Constraint<double> constraint(std::size_t i) const override;
56 
57  std::vector<Constraint<double>> constraints() const override;
58 
59  Objective<double> objective() const override;
60 
61  std::shared_ptr<soplex::SoPlex> soplex(detail::Badge<SoplexSolver>) {
62  return soplex_;
63  }
64 
65  private:
66  std::vector<std::size_t> permutation_;
67  std::vector<std::size_t> inverse_permutation_;
68 
69  std::vector<std::size_t> permutation_vars_;
70  std::vector<std::size_t> inverse_permutation_vars_;
71 
72  std::shared_ptr<soplex::SoPlex> soplex_;
73 
75 };
76 
77 } // namespace lpint
78 
79 #endif // LPINTERFACE_LPHANDLE_SOPLEX_H
Struct to represent right-hand side of LP constraints. In linear programming, we have constraints of ...
Definition: data_objects.hpp:192
void set_objective(const Objective< double > &objective) override
Set the objective function to be used. This method must be called before calling add_constraints().
std::vector< Variable > variables() const override
Retrieve the variables from the internal LP solver.
OptimizationType
Objective sense for an LP.
Definition: lp.hpp:17
Interface representing linear program formulation. This interface represents linear programs of the f...
Definition: lp.hpp:53
std::size_t num_constraints() const override
Get the number of cosntraints in the LP.
Objective< double > objective() const override
Retrieve the objective function of the internal LP. This method requests the objective function value...
Minimize the objective function value.
Variable variable(std::size_t i) const override
Retrieve variable i from the internal LP solver.
std::size_t num_vars() const override
Get the number of variables in the LP.
Definition: lphandle_soplex.hpp:19
Definition: badge.hpp:9
void add_variables(const std::vector< Variable > &vars) override
Add variables to the LP.
void set_objective_sense(const OptimizationType objsense) override
Set the objective sense of this ILinearProgramHandle. The Optimization type can be either Optimizatio...
Class representing a variable in the LP.
Definition: data_objects.hpp:253
Struct representing the objective vector. A linear program has the canonical form This structure rep...
Definition: data_objects.hpp:223
std::vector< Constraint< double > > constraints() const override
Retrieve the constraints of the internal LP. This method requests the constraints from the internal L...
Constraint< double > constraint(std::size_t i) const override
Retrieve constraint i of the internal LP. This method requests a constraint from the internal LP solv...
void add_constraints(const std::vector< Constraint< double >> &constraints) override
Add a set of constraints to the LP formulation. This can only be called after calling set_objective()...
void remove_variable(const std::size_t i) override
Remove a variable from the LP.
void remove_constraint(std::size_t i) override
Remove a constraint from the LP.
OptimizationType optimization_type() const override
Retrieve the objective sense of this ILinearProgramHandle. The Optimization type can be either Optimi...