graph_analysis
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
graph_analysis::algorithms::lp::embedded::GLPKSolver Class Reference

#include <GLPKSolver.hpp>

Inheritance diagram for graph_analysis::algorithms::lp::embedded::GLPKSolver:
Inheritance graph
[legend]
Collaboration diagram for graph_analysis::algorithms::lp::embedded::GLPKSolver:
Collaboration graph
[legend]

Public Member Functions

 GLPKSolver ()
 
 GLPKSolver (const std::string &problemName)
 
virtual ~GLPKSolver ()
 
LPSolver::Type getSolverType () const override
 
std::string getProblemName () const
 
void doLoadProblem (const std::string &filename, LPSolver::ProblemFormat format=CPLEX) override
 
void saveProblem (const std::string &filename, LPSolver::ProblemFormat format=CPLEX) const override
 
void loadSolution (const std::string &filename, LPSolver::SolutionType format=BASIC_SOLUTION) override
 
void saveSolution (const std::string &filename, LPSolver::SolutionType format=BASIC_SOLUTION) const override
 
double getObjectiveValue () const override
 
double getVariableValue (const std::string &varName) const
 
double getVariableValueByColumnIdx (uint32_t idx) const override
 
Status run () override
 
Status run (const std::string &problem, LPSolver::ProblemFormat problemFormat=CPLEX, bool useCaching=false) override
 
- Public Member Functions inherited from graph_analysis::algorithms::LPSolver
 LPSolver ()
 
virtual ~LPSolver ()
 
bool loadProblem (const std::string &filename, ProblemFormat format=CPLEX)
 
std::string saveProblemToTempfile (LPSolver::ProblemFormat format=CPLEX) const
 
std::string saveSolutionToTempfile (LPSolver::SolutionType format=BASIC_SOLUTION) const
 
std::string getVariableNameByColumnIdx (uint32_t idx) const
 
uint32_t getColumnIdxByVariableName (const std::string &varName) const
 
const std::string & getProblemFile () const
 
LPSolver::ProblemFormat getProblemFileFormat () const
 
const std::string & getSolutionFile () const
 
LPSolver::SolutionType getSolutionFileFormat () const
 
virtual std::vector< size_t > infeasibleConstraints () const
 
void setSolutionCacheSize (size_t size)
 
size_t getSolutionCacheSize () const
 
void resetSolutionCache ()
 

Static Public Member Functions

static int printHook (void *info, const char *s)
 
- Static Public Member Functions inherited from graph_analysis::algorithms::LPSolver
static LPSolver::Ptr getInstance (LPSolver::Type solverType)
 
static ProblemFormat getProblemFormatFromFileExtension (const std::string &extension)
 
static std::string getTempFilename (const std::string &suffix=".lp")
 

Protected Member Functions

Status translateSimplexReturnCode (int code)
 
Status translateIntoptReturnCode (int code)
 
- Protected Member Functions inherited from graph_analysis::algorithms::LPSolver
Status loadKnownSolution (const std::string &problemFilename)
 
void registerSolution (const std::string &problemFilename, const std::string &solutionFilename, Status status, SolutionType type)
 
const LPSolver::KnownSolutions::mapped_type & getRegisteredSolution (const std::string &problemFilename) const
 

Protected Attributes

glp_prob * mpProblem
 
- Protected Attributes inherited from graph_analysis::algorithms::LPSolver
std::string mProblemFile
 
LPSolver::ProblemFormat mProblemFileFormat
 
std::string mSolutionFile
 
LPSolver::SolutionType mSolutionFileFormat
 
size_t mSolutionCacheSize
 

Additional Inherited Members

- Public Types inherited from graph_analysis::algorithms::LPSolver
enum  Status {
  STATUS_UNKNOWN, STATUS_OPTIMAL, STATUS_INFEASIBLE, STATUS_UNBOUNDED,
  INVALID_PROBLEM_DEFINITION, NO_SOLUTION_FOUND, SOLUTION_FOUND
}
 
enum  Type {
  UNKNOWN_LP_SOLVER, CBC_SOLVER, CLP_SOLVER, GLPK_SOLVER,
  SCIP_SOLVER, SOPLEX_SOLVER, GLPK_SOLVER_EMBEDDED, SCIP_SOLVER_EMBEDDED,
  SOPLEX_SOLVER_EMBEDDED, LP_SOLVER_TYPE_END
}
 
enum  ProblemFormat {
  UNKNOWN_PROBLEM_FORMAT = 0, CPLEX, GLPK, MPS,
  LP_PROBLEM_FORMAT_END
}
 
enum  SolutionType {
  UNKNOWN_SOLUTION_TYPE = 0, BASIC_SOLUTION, IPT_SOLUTION, MIP_SOLUTION,
  LP_SOLUTION_TYPE_END
}
 Solution types: basic, IPT = interior point, MIP = mixed integer. More...
 
typedef shared_ptr< LPSolver > Ptr
 
- Static Public Attributes inherited from graph_analysis::algorithms::LPSolver
static std::map< Status, std::string > StatusTxt
 
static std::map< Type, std::string > TypeTxt
 
static std::map< ProblemFormat, std::string > ProblemFormatTxt
 
static std::map< LPSolver::ProblemFormat, std::vector< std::string > > ProblemFormatExtensions
 
- Protected Types inherited from graph_analysis::algorithms::LPSolver
typedef std::map< std::string, KnownSolution > KnownSolutions
 
- Static Protected Attributes inherited from graph_analysis::algorithms::LPSolver
static KnownSolutions msKnownSolutions
 

Detailed Description

General class to interface with the Gnu Linear Programming Kit

See also
http://kam.mff.cuni.cz/~elias/glpk.pdf

Constructor & Destructor Documentation

◆ GLPKSolver() [1/2]

graph_analysis::algorithms::lp::embedded::GLPKSolver::GLPKSolver ( )

◆ GLPKSolver() [2/2]

graph_analysis::algorithms::lp::embedded::GLPKSolver::GLPKSolver ( const std::string &  problemName)

◆ ~GLPKSolver()

graph_analysis::algorithms::lp::embedded::GLPKSolver::~GLPKSolver ( )
virtual

Member Function Documentation

◆ doLoadProblem()

void graph_analysis::algorithms::lp::embedded::GLPKSolver::doLoadProblem ( const std::string &  filename,
LPSolver::ProblemFormat  format = CPLEX 
)
overridevirtual

◆ getObjectiveValue()

double graph_analysis::algorithms::lp::embedded::GLPKSolver::getObjectiveValue ( ) const
inlineoverridevirtual

Retrieve the current objective value of the solution

Implements graph_analysis::algorithms::LPSolver.

◆ getProblemName()

std::string graph_analysis::algorithms::lp::embedded::GLPKSolver::getProblemName ( ) const
inline

◆ getSolverType()

LPSolver::Type graph_analysis::algorithms::lp::embedded::GLPKSolver::getSolverType ( ) const
inlineoverridevirtual

◆ getVariableValue()

double graph_analysis::algorithms::lp::embedded::GLPKSolver::getVariableValue ( const std::string &  varName) const

◆ getVariableValueByColumnIdx()

double graph_analysis::algorithms::lp::embedded::GLPKSolver::getVariableValueByColumnIdx ( uint32_t  idx) const
overridevirtual

Get the variable value by the column index

Parameters
idxcolumn index
Returns
the variable value

Reimplemented from graph_analysis::algorithms::LPSolver.

◆ loadSolution()

void graph_analysis::algorithms::lp::embedded::GLPKSolver::loadSolution ( const std::string &  filename,
LPSolver::SolutionType  format = BASIC_SOLUTION 
)
overridevirtual

Load a solution based

Parameters
filenamefilename of the solution file
formatformat of the solution

Implements graph_analysis::algorithms::LPSolver.

◆ printHook()

int graph_analysis::algorithms::lp::embedded::GLPKSolver::printHook ( void *  info,
const char *  s 
)
static

Hook function to redirect the output of glpk to the logger

◆ run() [1/2]

Status graph_analysis::algorithms::lp::embedded::GLPKSolver::run ( )
inlineoverridevirtual

Run the solver (after loadProblem) has been called

Implements graph_analysis::algorithms::LPSolver.

◆ run() [2/2]

GLPKSolver::Status graph_analysis::algorithms::lp::embedded::GLPKSolver::run ( const std::string &  problemFilename,
LPSolver::ProblemFormat  problemFormat = CPLEX,
bool  useCaching = false 
)
overridevirtual

Run the solver with a given problem file

Parameters
problemFilenamefilename of the problem to solve
problemFormatformat of the problem to solver
useCachingTo use caching of problem and respective solutions set to True, otherwise False

Implements graph_analysis::algorithms::LPSolver.

◆ saveProblem()

void graph_analysis::algorithms::lp::embedded::GLPKSolver::saveProblem ( const std::string &  filename,
LPSolver::ProblemFormat  format = CPLEX 
) const
overridevirtual

Save the problem to file

Parameters
filenamefilename of the problem file
formatformat of the the problem

Implements graph_analysis::algorithms::LPSolver.

◆ saveSolution()

void graph_analysis::algorithms::lp::embedded::GLPKSolver::saveSolution ( const std::string &  filename,
LPSolver::SolutionType  format = BASIC_SOLUTION 
) const
overridevirtual

Save the solution to file

Parameters
filenamefilename of the solution file
formatformat of the the solution

Implements graph_analysis::algorithms::LPSolver.

◆ translateIntoptReturnCode()

GLPKSolver::Status graph_analysis::algorithms::lp::embedded::GLPKSolver::translateIntoptReturnCode ( int  code)
protected

◆ translateSimplexReturnCode()

GLPKSolver::Status graph_analysis::algorithms::lp::embedded::GLPKSolver::translateSimplexReturnCode ( int  code)
protected

Member Data Documentation

◆ mpProblem

glp_prob* graph_analysis::algorithms::lp::embedded::GLPKSolver::mpProblem
protected

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