Hermes  0.9.5-beta
Hierarchical Distributed I/O Buffering System
hermes::LinearProgram Class Reference

#include <linprog.h>

Public Member Functions

 LinearProgram (const char *name)
 
 ~LinearProgram ()
 
void DefineDimension (int num_vars, int num_constraints)
 
void AddConstraint (const std::string &base_name, int op_type, double lb, double ub)
 
void SetConstraintCoeff (int var, double val)
 
void SetVariableBounds (const std::string &base_name, int var, int op_type, double lb, double ub)
 
void SetObjective (int objective)
 
void SetObjectiveCoeff (int var, double val)
 
void Solve ()
 
bool IsOptimal ()
 
double GetSolution ()
 
double GetVariable (int var)
 
std::vector< double > ToVector ()
 

Private Attributes

int num_vars_
 
int num_constraints_
 
glp_prob * lp_
 
std::vector< int > ia_
 
std::vector< int > ja_
 
std::vector< double > ar_
 
size_t cur_constraint_
 
size_t result_
 

Detailed Description

A structure to represent linear program

Constructor & Destructor Documentation

◆ LinearProgram()

hermes::LinearProgram::LinearProgram ( const char *  name)
inlineexplicit

Initialize linear program solver with name.

◆ ~LinearProgram()

hermes::LinearProgram::~LinearProgram ( )
inline

Clean up resources used by the GLPK solver.

Member Function Documentation

◆ DefineDimension()

void hermes::LinearProgram::DefineDimension ( int  num_vars,
int  num_constraints 
)
inline

Define the problem size using num_vars and num_constraints.

Here is the caller graph for this function:

◆ AddConstraint()

void hermes::LinearProgram::AddConstraint ( const std::string &  base_name,
int  op_type,
double  lb,
double  ub 
)
inline

Add a constraint to the GLPK solver.

Here is the caller graph for this function:

◆ SetConstraintCoeff()

void hermes::LinearProgram::SetConstraintCoeff ( int  var,
double  val 
)
inline

Set coefficient value as val for the var variable.

Here is the caller graph for this function:

◆ SetVariableBounds()

void hermes::LinearProgram::SetVariableBounds ( const std::string &  base_name,
int  var,
int  op_type,
double  lb,
double  ub 
)
inline

Set the upper and lower bound for var variable.

Here is the caller graph for this function:

◆ SetObjective()

void hermes::LinearProgram::SetObjective ( int  objective)
inline

Set the objective function to optimize.

Here is the caller graph for this function:

◆ SetObjectiveCoeff()

void hermes::LinearProgram::SetObjectiveCoeff ( int  var,
double  val 
)
inline

Set the coefficients of objective function.

Here is the caller graph for this function:

◆ Solve()

void hermes::LinearProgram::Solve ( )
inline

Solve the problem.

Here is the caller graph for this function:

◆ IsOptimal()

bool hermes::LinearProgram::IsOptimal ( )
inline

Check if optimal solution exists.

Here is the caller graph for this function:

◆ GetSolution()

double hermes::LinearProgram::GetSolution ( )
inline

Get solution.

◆ GetVariable()

double hermes::LinearProgram::GetVariable ( int  var)
inline

Get the values for optimal solution.

Here is the caller graph for this function:

◆ ToVector()

std::vector<double> hermes::LinearProgram::ToVector ( )
inline

Collect the values as a vector.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ num_vars_

int hermes::LinearProgram::num_vars_
private

number of variables

◆ num_constraints_

int hermes::LinearProgram::num_constraints_
private

number of constraints

◆ lp_

glp_prob* hermes::LinearProgram::lp_
private

pointer to GLPK problem solver

◆ ia_

std::vector<int> hermes::LinearProgram::ia_
private

The "i" in A[i][j]

◆ ja_

std::vector<int> hermes::LinearProgram::ja_
private

The "j" in A[i][j]

◆ ar_

std::vector<double> hermes::LinearProgram::ar_
private

values for A[i][j]

◆ cur_constraint_

size_t hermes::LinearProgram::cur_constraint_
private

current constraint

◆ result_

size_t hermes::LinearProgram::result_
private

result of solver


The documentation for this class was generated from the following file: