Public Member Functions | Static Public Member Functions

lp_problem Class Reference

Brief description of lp_problem class. More...

List of all members.

Public Member Functions

 lp_problem (unsigned int nv=0)
 Constructor, equivalent to LP_Create.
void add_constraint (const ml_matrix &A, const ml_matrix &b, const ml_int_array &cType)
 Equivalent to LP_AddConstraint.m Add constraints to LP Object.
void add_vars (unsigned int nv, const ml_int_array *_vType=NULL, const ml_matrix *_lb=NULL, const ml_matrix *_ub=NULL, const ml_int_array *_absVal=NULL)
 Add variables to LP Object.
void set_cost (const ml_int_array &kv, const ml_matrix &c, const ml_int_array &absVal)
 Set the cost vector for a subset of variables in an LP Object.
void relax (const ml_int_array &kRelax, const ml_matrix &cRelax)
 Relax specified constraints in an LP object.
void var_bounds (ml_int_array kv, ml_matrix lb, ml_matrix ub)
 Set variable bounds for LP Object.
StatusReport solve (const char *solver="glpk")
 Solve a linear program defined by an LP object.
void display (const char *msg="") const
 Utility to display all internal matrices and values.
const ml_matrix & get_A () const
const ml_matrix & get_b () const
ml_int_array & set_kRelax (const ml_int_array &kRelax)
ml_matrix & set_cRelax (const ml_matrix &cRelax)

Static Public Member Functions

static void error (const char *str)
 print an error message (usage lp_problem::error(...);
static void msg (int num, const char *str)
 print an message (usage lp_problem::error(...);
static ml_matrix diff (const ml_matrix &a)
 Implements the MATLAB diff function (could be private)

Detailed Description

More description of class. Give general order in which functions are used. This is a general formulation of a linear programming problem. GLPK is used to solve the problem. PSS' SPEAR library, which provides the glpk interface, is required.

Constraint types are indicated with a character array. Elements can be: 'L' lower bound Ai*x >= bi 'U' lower bound Ai*x >= bi 'S' equality Ai*x = bi


Constructor & Destructor Documentation

lp_problem::lp_problem ( unsigned int  nv = 0 )
Parameters:
nvNumber of variables

References add_vars().


Member Function Documentation

void lp_problem::add_constraint ( const ml_matrix &  A,
const ml_matrix &  b,
const ml_int_array &  cType 
)

This appends rows to A and b.

MATLAB form: function p = LP_AddConstraint( p, A, b, cType )

Parameters:
A(m,n) New constraint matrix to append.
b(m,1) New constraint vector to append.
cType(m,1) Constraint types, (L|S|U) for lower bound/equality/upper bound.
void lp_problem::add_vars ( unsigned int  nv,
const ml_int_array *  vType = NULL,
const ml_matrix *  lb = NULL,
const ml_matrix *  ub = NULL,
const ml_int_array *  abs_val = NULL 
)

This appends columns to A and rows to c.

MATLAB Form: function p = LP_AddVars( p, nv, vType, lb, ub, absVal )

Parameters:
nv(1,1) Number of variables to add.
vType(n,1) Variable types. (B|I|C). Default 'C' continuous.
lb(n,1) Lower bounds for these variables.
ub(n,1) Upper bounds for these variables
absVal(v,1) Indices of these variables whose cost is proportional to the absolute value. v is a non-negative integer that is less than or equal to n

Referenced by lp_problem().

void lp_problem::set_cost ( const ml_int_array &  _kv,
const ml_matrix &  c,
const ml_int_array &  absVal 
)

MATLAB Form: p = LP_Cost( p, kv, c, absVal )

Parameters:
kv(n,1) Index of variables to set cost for.
c(n,1) Cost vector for these variables.
absVal(v,1) Indices of these variables whose cost is proportional to the absolute value.

References error().

void lp_problem::relax ( const ml_int_array &  kRelax,
const ml_matrix &  cRelax 
)

MATLAB Form: p = LP_Relax( p, kRelax, cRelax );

If cRelax is empty, will use: 100*max(abs(c)), where "c" is the cost coefficient vector, excluding other relaxation slack variables.

Parameters:
kRelax(n,1) Index of constraints to relax. If not provided, the "relax" field of the LP object will be used. If provided, it will overwrite the "relax" field.
cRelax(n,1) Cost coefficients for relaxation slack variables. %

Referenced by solve().

void lp_problem::var_bounds ( ml_int_array  kv,
ml_matrix  lb,
ml_matrix  ub 
)

MATLAB Form: p = LP_VarBounds( p, kv, lb, ub );

Parameters:
kv(n,1) Index of variables to set bounds for.
lb(n,1) Lower bounds for these variables.
ub(n,1) Upper bounds for these variables

References error().

StatusReport lp_problem::solve ( const char *  solver = "glpk" )

MATLAB Form: s = LP_Solve( p, solver );

Parameters:
solver(:) Desired solver. Optional. Default is "GLPK".

References StatusReport::err, StatusReport::fVal, relax(), StatusReport::x, and StatusReport::xRelSlack.

void lp_problem::display ( const char *  s = "" ) const
Parameters:
sAdditional string to display, i.e. problem name or identifier