simplex.h
Go to the documentation of this file.
1 #ifndef SIMPLEXH
2 #define SIMPLEXH
3 
4 #include "box.h"
5 #include "interval.h"
6 #include "linear_constraint.h"
7 #include "equation.h"
8 
9 #if (_SIMPLEX_ENGINE==_GLPK)
10  #include <glpk.h>
15  #define SimplexType LPX
16 #endif
17 
18 #if (_SIMPLEX_ENGINE==_CLP)
19  #include <coin/Clp_C_Interface.h>
24  #define SimplexType __attribute__ ((aligned(8))) Clp_Simplex
25 #endif
26 
27 #if (_SIMPLEX_ENGINE==_LP_SOLVE)
28  #include <lp_solve/lp_lib.h>
33  #define SimplexType lprec
34 #endif
35 
55 /************************************************************************************/
63 #define SIMPLEX_TIMEOUT 10
64 /************************************************************************************/
65 
73 typedef struct {
74 
77  #if (_SIMPLEX_ENGINE==_CLP)
78  unsigned int fakeRows;
80  double *lower;
81  double *upper;
82  double *obj;
83  #endif
84 
85  #if (_SIMPLEX_ENGINE==_LP_SOLVE)
86  double inf;
88  #endif
89 
90 } TSimplex;
91 
92 /* Functions implemented in particular for each simplex engine
93  (GLPK,CLP,...) in simplex_glpk.c simplex_clp.c,.... */
94 
106 void SimplexCreate(double epsilon,unsigned int ncols,TSimplex *s);
107 
108 
116 void ResetSimplex(TSimplex *s);
117 
127 unsigned int SimplexNColumns(TSimplex *s);
128 
129 
139 unsigned int SimplexNRows(TSimplex *s);
140 
150 void SimplexSetColBounds(unsigned int ncol,Tinterval *i,TSimplex *s);
151 
161 void SimplexGetColBounds(unsigned int ncol,Tinterval *i,TSimplex *s);
162 
172 void SimplexGetColConstraint(unsigned int ncol,TLinearConstraint *lc,TSimplex *s);
173 
184 boolean SimplexColEmpty(unsigned int ncol,TSimplex *s);
185 
196 double SimplexGetColPrimal(unsigned int ncol,TSimplex *s);
197 
198 
209 double SimplexGetColDual(unsigned int ncol,TSimplex *s);
210 
220 void SimplexSetRowBounds(unsigned int nrow,Tinterval *i,TSimplex *s);
221 
231 void SimplexGetRowBounds(unsigned int nrow,Tinterval *i,TSimplex *s);
232 
242 void SimplexGetRowConstraint(unsigned int nrow,TLinearConstraint *lc,TSimplex *s);
243 
254 double SimplexGetRowPrimal(unsigned int nrow,TSimplex *s);
255 
266 double SimplexGetRowDual(unsigned int nrow,TSimplex *s);
267 
283  TSimplex *s);
284 
298 
308 
324 
336 unsigned int SimplexSolve(TSimplex *s);
337 
338 
346 void SimplexDelete(TSimplex *s);
347 
348 
368 void SimplexExpandBounds(unsigned int eq_type,Tinterval *b);
369 
370 
380 void SetSimplexBounds(Tbox *b,TSimplex *lp);
381 
406 boolean SimplexAddNewConstraint(double epsilon,
407  unsigned int safeSimplex,
408  TLinearConstraint *lc,
409  unsigned int eq_type,
410  Tinterval *is,
411  TSimplex *s);
412 
434 double SimplexGetOptimalValue(unsigned int safeSimplex,double m,Tbox *b,TSimplex *s);
435 
461 unsigned int ReduceRange(double epsilon,unsigned int safeSimplex,unsigned int nv,Tbox *b,TSimplex *lp);
462 #endif
unsigned int SimplexNRows(TSimplex *s)
Gets the number of rows (i.e., constraints) of the simplex structure.
Definition: simplex_clp.c:107
boolean SimplexAddNewConstraint(double epsilon, unsigned int safeSimplex, TLinearConstraint *lc, unsigned int eq_type, Tinterval *is, TSimplex *s)
Adds a row (i.e., a constraint) to the simplex.
Definition: simplex.c:67
void SimplexGetColConstraint(unsigned int ncol, TLinearConstraint *lc, TSimplex *s)
Gets a column from the simplex in the form of a linear constraint.
Definition: simplex_clp.c:133
Definition of the Tequation type and the associated functions.
double inf
Definition: simplex.h:86
void SetSimplexBounds(Tbox *b, TSimplex *lp)
Sets the columns bounds for the simplex.
Definition: simplex.c:40
double SimplexGetRowPrimal(unsigned int nrow, TSimplex *s)
Gets a row primal value after solving the simplex.
Definition: simplex_clp.c:241
void SimplexSetColBounds(unsigned int ncol, Tinterval *i, TSimplex *s)
Sets the bounds for a given column (i.e., variable).
Definition: simplex_clp.c:113
A linear constraint with an associated error.
#define SimplexType
The simples tableau type when using Glpk.
Definition: simplex.h:33
void SimplexGetRowConstraint(unsigned int nrow, TLinearConstraint *lc, TSimplex *s)
Gets a row constraint from the simplex.
Definition: simplex_clp.c:203
SimplexType * lp
Definition: simplex.h:75
void SimplexExpandBounds(unsigned int eq_type, Tinterval *b)
Expands an interval according to the equation type.
Definition: simplex.c:19
A simplex tableau structure.
Definition: simplex.h:73
void SimplexCreate(double epsilon, unsigned int ncols, TSimplex *s)
Constructor.
Definition: simplex_clp.c:22
double SimplexGetRowDual(unsigned int nrow, TSimplex *s)
Gets a row dual value after solving the simplex.
Definition: simplex_clp.c:250
unsigned int fakeRows
Definition: simplex.h:78
unsigned int SimplexSolve(TSimplex *s)
Determines an optimal value.
Definition: simplex_clp.c:332
void ResetSimplex(TSimplex *s)
Resets the simplex structure.
Definition: simplex_clp.c:96
unsigned int ReduceRange(double epsilon, unsigned int safeSimplex, unsigned int nv, Tbox *b, TSimplex *lp)
Reduces a variable range using the simplex.
Definition: simplex.c:329
Definition of the Tbox type and the associated functions.
double SimplexGetColDual(unsigned int ncol, TSimplex *s)
Gets a column dual value after solving the simplex.
Definition: simplex_clp.c:177
double * upper
Definition: simplex.h:81
unsigned int SimplexNColumns(TSimplex *s)
Gets the number of columns (i.e., variables) of the simplex structure.
Definition: simplex_clp.c:102
double SimplexGetColPrimal(unsigned int ncol, TSimplex *s)
Gets a column primal value after solving the simplex.
Definition: simplex_clp.c:168
void SimplexAddNewConstraintRaw(TLinearConstraint *lc, TSimplex *s)
Adds a row (i.e., a constraint) to the simplex.
Definition: simplex_clp.c:259
double SimplexGetOptimalValueRaw(TSimplex *s)
Gets the optimal value after optimizing the problem.
Definition: simplex_clp.c:327
void SimplexGetRowBounds(unsigned int nrow, Tinterval *i, TSimplex *s)
Gets the bounds for a given row (i.e., constraint).
Definition: simplex_clp.c:193
A box.
Definition: box.h:83
void SimplexSetRowBounds(unsigned int nrow, Tinterval *i, TSimplex *s)
Sets the bounds for a given row (i.e., constraint).
Definition: simplex_clp.c:187
void SimplexSetOptimizationFunction(TLinearConstraint *obj, TSimplex *s)
Sets a new objective function.
Definition: simplex_clp.c:286
void SimplexGetColBounds(unsigned int ncol, Tinterval *i, TSimplex *s)
Gets the bounds for a given column (i.e., variable).
Definition: simplex_clp.c:123
boolean SimplexColEmpty(unsigned int ncol, TSimplex *s)
Checks if a simplex column is empty.
Definition: simplex_clp.c:159
double SimplexGetOptimalValue(unsigned int safeSimplex, double m, Tbox *b, TSimplex *s)
Returns the optimal value determined by the simplex corrected to compensate for possible rounding eff...
Definition: simplex.c:215
double * obj
Definition: simplex.h:82
void SimplexGetOptimizationFunction(TLinearConstraint *obj, TSimplex *s)
Gets a current objective function.
Definition: simplex_clp.c:312
double * lower
Definition: simplex.h:80
Defines a interval.
Definition: interval.h:33
Definition of the TLinearConstraint type and the associated functions.
void SimplexDelete(TSimplex *s)
Destructor.
Definition: simplex_clp.c:367
Definition of the Tinterval type and the associated functions.