AIToolbox
A library that offers tools for AI problem solving.
LP.hpp
Go to the documentation of this file.
1 #ifndef AI_TOOLBOX_LP_HEADER_FILE
2 #define AI_TOOLBOX_LP_HEADER_FILE
3 
4 #include <memory>
5 #include <optional>
6 
7 #include <AIToolbox/Types.hpp>
8 
9 namespace AIToolbox {
23  class LP {
24  private:
25  // Data concerning any specific library we use to solve LPs
26  struct LP_impl;
27  std::unique_ptr<LP_impl> pimpl_;
28 
29  public:
41  LP(size_t varNumber);
42 
51  ~LP();
52 
62  Eigen::Map<Vector> row;
63 
73  void setObjective(size_t n, bool maximize);
74 
83  void setObjective(bool maximize);
84 
97  void pushRow(Constraint c, double value);
98 
102  void popRow();
103 
115  size_t addColumn();
116 
133  std::optional<Vector> solve(size_t variables, double * objective = nullptr);
134 
152  void resize(size_t rows);
153 
162  void setUnbounded(size_t n);
163 
177  static double getPrecision();
178 
179  private:
180  size_t varNumber_;
181  bool maximize_;
182  };
183 }
184 
185 #endif
AIToolbox::LP::resize
void resize(size_t rows)
This function resizes the underlying LP.
AIToolbox::LP::Constraint::LessEqual
@ LessEqual
AIToolbox::LP::solve
std::optional< Vector > solve(size_t variables, double *objective=nullptr)
This function solves the LP associated with all constraints in the stack.
AIToolbox::LP::getPrecision
static double getPrecision()
This function returns the maximum precision obtainable from the solution.
AIToolbox::LP::LP
LP(size_t varNumber)
Basic constructor.
AIToolbox::LP
This class presents a common interface for solving Linear Programming problems.
Definition: LP.hpp:23
AIToolbox::LP::pushRow
void pushRow(Constraint c, double value)
This function adds a constraint to the LP.
AIToolbox
Definition: Experience.hpp:6
AIToolbox::LP::Constraint
Constraint
Definition: LP.hpp:30
AIToolbox::LP::Constraint::Equal
@ Equal
AIToolbox::LP::Constraint::GreaterEqual
@ GreaterEqual
Types.hpp
AIToolbox::LP::~LP
~LP()
Basic destructor to avoid problems with std::unique_ptr.
AIToolbox::LP::row
Eigen::Map< Vector > row
Editable vector containing column coefficients.
Definition: LP.hpp:62
AIToolbox::LP::setUnbounded
void setUnbounded(size_t n)
This function sets the specified variable as unbounded.
AIToolbox::LP::setObjective
void setObjective(size_t n, bool maximize)
This function selects the variable to use as objective.
AIToolbox::LP::popRow
void popRow()
This function removes the last pushed constraint.
AIToolbox::LP::addColumn
size_t addColumn()
This function adds a new column to the LP.