(9)

To solve a linear programming problem. More...

Public Types

enum  Setting {
  OBJECTIVE = 0,
  LE_CONSTRAINT = 1,
  GE_CONSTRAINT = 2,
  EQ_CONSTRAINT = 3
}
 

Public Member Functions

 LPSolver ()
 Default constructor.
 
 LPSolver (int nv, int nb_le, int nb_ge, int nb_eq)
 Constructor using Linear Program data. More...
 
 ~LPSolver ()
 Destructor.
 
void setSize (int nv, int nb_le, int nb_ge, int nb_eq)
 Set optimization parameters. More...
 
void set (Vect< real_t > &x)
 vector of optimization variables More...
 
void set (Setting opt, const Vect< real_t > &a, real_t b=0.0)
 Set optimization data. More...
 
int run ()
 Run the linear program solver. More...
 
real_t getObjective () const
 Return objective. More...
 

Friends

ostream & operator<< (ostream &s, const LPSolver &os)
 Output class information.
 

Detailed Description

To solve a linear programming problem.

The Linear Program reads:

Minimise: d(1)*x(1) + ... + d(n)*x(n) + e
Subject to the constraints:
       A(i,1)*x(1) + ... + A(i,n)*x(n) <= a(i)  i=1,...,n_le
       B(i,1)*x(1) + ... + B(i,n)*x(n) >= b(i)  i=1,...,n_ge
       C(i,1)*x(1) + ... + C(i,n)*x(n) =  c(i)  i=1,...,n_eq
       x(i) >= 0, 1<=i<=n

Solution is held by the Simplex method Reference: "Numerical Recipes By W.H. Press, B. P. Flannery, S.A. Teukolsky and W.T. Vetterling, Cambridge University Press, 1986"

C-implementation copied from J-P Moreau, Paris

Author
Rachid Touzani

Member Enumeration Documentation

◆ Setting

enum Setting

Selects setting option: Objective or Constraints

Enumerator
OBJECTIVE 

Objective function coefficients

LE_CONSTRAINT 

'Less or Equal' constraint coefficients

GE_CONSTRAINT 

'Greater or Equal' constraint coefficients

EQ_CONSTRAINT 

'Equality' constraint coefficients

Constructor & Destructor Documentation

◆ LPSolver()

LPSolver ( int  nv,
int  nb_le,
int  nb_ge,
int  nb_eq 
)

Constructor using Linear Program data.

Parameters
[in]nvNumber of optimization variables
[in]nb_leNumber of '<=' inequality constraints
[in]nb_geNumber of '>=' inequality constraints
[in]nb_eqNumber of '=' equality constraints

Member Function Documentation

◆ getObjective()

real_t getObjective ( ) const

Return objective.

Once execution is complete, this function returns optimal value of objective

◆ run()

int run ( )

Run the linear program solver.

This function runs the linear programming solver using the Simplex algorithm

Returns
0 if process is complete, >0 otherwise

◆ set() [1/2]

void set ( Vect< real_t > &  x)

vector of optimization variables

Parameters
[in]xVector of optimization variables. Its size must be at least equal to number of optimization variables

◆ set() [2/2]

void set ( Setting  opt,
const Vect< real_t > &  a,
real_t  b = 0.0 
)

Set optimization data.

This function enables providing all optimization data. It has to be used for the objectice function and once for each constraint.

Parameters
[in]optOption for data, to choose among enumerated values:
  • OBJECTIVE To set objective function to minimize
  • LE_CONSTRAINT To set a '<=' inequality constraint
  • GE_CONSTRAINT To set a '>=' inequality constraint
  • EQ_CONSTRAINT To set an equality constraint
[in]aVector coefficients if the chosen function. If opt==OBJECTIVE, vector components are the coefficients multiplying the variables in the objective function. if xx_CONSTRAINT, vector components are the coefficients multiplying the variables in the corresponding constraint.
[in]bConstant value in the objective function or in a constraint. Its default value is 0.0

◆ setSize()

void setSize ( int  nv,
int  nb_le,
int  nb_ge,
int  nb_eq 
)

Set optimization parameters.

Parameters
[in]nvNumber of optimization variables
[in]nb_leNumber of '<=' inequality constraints
[in]nb_geNumber of '>=' inequality constraints
[in]nb_eqNumber of '=' equality constraints