EigenOpt 1.0.0
Loading...
Searching...
No Matches
simplex_internal.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <Eigen/Dense>
4#include <string>
5#include <vector>
6
7namespace EigenOpt {
8
9namespace simplex {
10
11namespace internal {
12
14
28 bool non_negative = false;
29 bool non_positive = false;
30 int idx = -1;
31};
32
33
35
59template<class Scalar>
61 const Eigen::Matrix<Scalar,Eigen::Dynamic,Eigen::Dynamic>& C,
62 const Eigen::Matrix<Scalar,Eigen::Dynamic,1>& d,
63 const Scalar& small_number,
64 std::vector<VariableDomain>& domains,
65 std::string& halt_reason
66);
67
68
70
93template<class Scalar>
94Eigen::Matrix<Scalar,Eigen::Dynamic,Eigen::Dynamic> transformation_matrix_from_domains(
95 const std::vector<VariableDomain>& domains
96);
97
98
100
115template<class Scalar>
117 const Eigen::Matrix<Scalar,Eigen::Dynamic,Eigen::Dynamic>& C,
118 const Eigen::Matrix<Scalar,Eigen::Dynamic,1>& d,
119 const Scalar& small_number,
120 Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>& T,
121 std::string& halt_reason
122);
123
124
126
175template<class Scalar>
176void create_tableau(
177 const Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>& C,
178 const Eigen::Matrix<Scalar, Eigen::Dynamic, 1>& d,
179 Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>& tableau,
180 std::vector<int>& basic_variables
181);
182
183
185
196template<class Scalar>
198 Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>& tableau,
199 const std::vector<int>& basic_variables
200);
201
202
204
229template<class Scalar>
230void pivot(
231 Eigen::Matrix<Scalar,Eigen::Dynamic,Eigen::Dynamic>& tableau,
232 int entering_variable,
233 int leaving_variable
234);
235
236
238
274template<class Scalar>
275bool simplex(
276 Eigen::Matrix<Scalar,Eigen::Dynamic,Eigen::Dynamic>& tableau,
277 std::vector<int>& basic_variables,
278 const Scalar& small_number,
279 std::string& halt_reason
280);
281
282
284
321template<class Scalar>
323 const Eigen::Matrix<Scalar,Eigen::Dynamic,1>& objective,
324 Eigen::Matrix<Scalar,Eigen::Dynamic,Eigen::Dynamic>& tableau,
325 std::vector<int>& basic_variables,
326 unsigned int na,
327 const Scalar& small_number,
328 std::string& halt_reason
329);
330
331
333
365template<class Scalar>
366bool penalty_method(
367 const Eigen::Matrix<Scalar,Eigen::Dynamic,1>& objective,
368 Eigen::Matrix<Scalar,Eigen::Dynamic,Eigen::Dynamic>& tableau,
369 std::vector<int>& basic_variables,
370 unsigned int na,
371 const Scalar& small_number,
372 const Scalar& large_number,
373 std::string& halt_reason
374);
375
376} // namespace internal
377
378} // namespace simplex
379
380} // namespace EigenOpt
381
382#include "simplex_internal.hxx"
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > transformation_matrix_from_domains(const std::vector< VariableDomain > &domains)
Calculate a transformation matrix so that , .
void pivot(Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > &tableau, int entering_variable, int leaving_variable)
Perform a pivot operation between a basic and a non-basic variable.
bool deduce_variables_domains(const Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > &C, const Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > &d, const Scalar &small_number, std::vector< VariableDomain > &domains, std::string &halt_reason)
Given a set of inequality constraints, deduce the domain of the decision variables.
bool simplex(Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > &tableau, std::vector< int > &basic_variables, const Scalar &small_number, std::string &halt_reason)
Perform successive pivot operations until a termination condition is met.
bool transformation_matrix(const Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > &C, const Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > &d, const Scalar &small_number, Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > &T, std::string &halt_reason)
Calculate a transformation matrix so that , .
void create_tableau(const Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > &C, const Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > &d, Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > &tableau, std::vector< int > &basic_variables)
Create a Simplex Tableau given a set of inequality constraints.
bool two_steps_method(const Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > &objective, Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > &tableau, std::vector< int > &basic_variables, unsigned int na, const Scalar &small_number, std::string &halt_reason)
Solve a minimization problem using the two-steps Simplex method.
bool penalty_method(const Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > &objective, Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > &tableau, std::vector< int > &basic_variables, unsigned int na, const Scalar &small_number, const Scalar &large_number, std::string &halt_reason)
Solve a minimization problem using the penalty Simplex method.
void eliminate_objective(Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > &tableau, const std::vector< int > &basic_variables)
Use Gaussian elimination on the last row of the tableau.
Main namespace of this project, containing all utilities.
Auxiliay structure to store the domain of a variable.
int idx
Which constraint (if any) implies the given domain.