Simplex
-
template<class T>
class Simplex - #include <simplex.hpp>
Solves a linear problem with the simplex algorithm. The variables are x_0, …, x_{n-1} For now, all the variables are supposed non-negative. If the preprocessor variable SIMPLEX_VERBOSE is defined, detailed informations about the resolution of the problem are printed on stderr.
Public Types
Public Functions
-
Simplex(const int variables_count)
Initializes the simplex algorithm to solve a problem with the given number of variables.
-
int variables_count() const
Returns the number of variables that the problem contains.
-
void maximize(const std::vector<T> &coefs)
Runs the simplex algorithm to maximize Σ a_j x_j subject to the previously given constraints.
-
void minimize(const std::vector<T> &coefs)
Runs the simplex algorithm to minimize Σ a_j x_j subject to the previously given constraints.
Private Functions
-
int choose_entering_variable() const
Returns the next entering variable (-1 if the solution is optimal)
-
int choose_leaving_variable(const int entering) const
Returns the next leaving variable (-1 if the problem is unbounded).
- Parameters:
entering – The entering variable choosen before
-
void make_exchange(const int entering, const int leaving)
Executes a transformation of the problem.
-
void print_constraints()
Prints the current state of the simplex on stderr.
-
void resize_constraints()
Add null coefficients at the end of each constraint to take into account the new variables.
Private Members
-
int m_variables_count
-
std::vector<Constraint> m_constraints
-
Constraint m_to_optimize
-
struct Constraint
-
Simplex(const int variables_count)