|
graph_analysis
|
#include <LPSolver.hpp>

Classes | |
| struct | KnownSolution |
Public Types | |
| 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 |
Public Member Functions | |
| LPSolver () | |
| virtual | ~LPSolver () |
| virtual LPSolver::Type | getSolverType () const =0 |
| bool | loadProblem (const std::string &filename, ProblemFormat format=CPLEX) |
| virtual void | saveProblem (const std::string &filename, ProblemFormat format=CPLEX) const =0 |
| virtual void | loadSolution (const std::string &filename, SolutionType format=BASIC_SOLUTION)=0 |
| std::string | saveProblemToTempfile (LPSolver::ProblemFormat format=CPLEX) const |
| std::string | saveSolutionToTempfile (LPSolver::SolutionType format=BASIC_SOLUTION) const |
| virtual void | saveSolution (const std::string &filename, LPSolver::SolutionType format=BASIC_SOLUTION) const =0 |
| virtual double | getObjectiveValue () const =0 |
| virtual double | getVariableValueByColumnIdx (uint32_t idx) const |
| std::string | getVariableNameByColumnIdx (uint32_t idx) const |
| uint32_t | getColumnIdxByVariableName (const std::string &varName) const |
| virtual Status | run ()=0 |
| virtual Status | run (const std::string &problemFilename, LPSolver::ProblemFormat problemFormat=CPLEX, bool useCaching=false)=0 |
| 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 LPSolver::Ptr | getInstance (LPSolver::Type solverType) |
| static ProblemFormat | getProblemFormatFromFileExtension (const std::string &extension) |
| static std::string | getTempFilename (const std::string &suffix=".lp") |
Static Public Attributes | |
| 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 | |
| typedef std::map< std::string, KnownSolution > | KnownSolutions |
Protected Member Functions | |
| virtual void | doLoadProblem (const std::string &filename, ProblemFormat format=CPLEX)=0 |
| 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 | |
| std::string | mProblemFile |
| LPSolver::ProblemFormat | mProblemFileFormat |
| std::string | mSolutionFile |
| LPSolver::SolutionType | mSolutionFileFormat |
| size_t | mSolutionCacheSize |
Static Protected Attributes | |
| static KnownSolutions | msKnownSolutions |
General interface to call linear problem solvers
|
protected |
| typedef shared_ptr<LPSolver> graph_analysis::algorithms::LPSolver::Ptr |
| graph_analysis::algorithms::LPSolver::LPSolver | ( | ) |
|
virtual |
|
protectedpure virtual |
| uint32_t graph_analysis::algorithms::LPSolver::getColumnIdxByVariableName | ( | const std::string & | varName | ) | const |
Get the column index for the canonize variable name
| varName | canonized variable name |
|
static |
|
pure virtual |
Retrieve the current objective value of the solution
Implemented in graph_analysis::algorithms::lp::embedded::GLPKSolver, graph_analysis::algorithms::lp::embedded::SoplexSolver, graph_analysis::algorithms::lp::CommandlineSolver, graph_analysis::algorithms::lp::CommandlineSolver, and graph_analysis::algorithms::lp::embedded::ScipSolver.
|
inline |
|
inline |
|
static |
Get the problem format from an extension
|
protected |
|
inline |
|
inline |
|
inline |
|
pure virtual |
Implemented in graph_analysis::algorithms::lp::embedded::GLPKSolver, graph_analysis::algorithms::lp::embedded::ScipSolver, graph_analysis::algorithms::lp::GLPKSolver, graph_analysis::algorithms::lp::CBCSolver, graph_analysis::algorithms::lp::CLPSolver, graph_analysis::algorithms::lp::ScipSolver, and graph_analysis::algorithms::lp::embedded::SoplexSolver.
|
static |
Get a temporary filename
| std::string graph_analysis::algorithms::LPSolver::getVariableNameByColumnIdx | ( | uint32_t | idx | ) | const |
Get the canonized variable name for the given column index
| idx | column index |
|
virtual |
Get the variable value by the column index
| idx | column index |
Reimplemented in graph_analysis::algorithms::lp::embedded::GLPKSolver, graph_analysis::algorithms::lp::embedded::SoplexSolver, graph_analysis::algorithms::lp::embedded::ScipSolver, and graph_analysis::algorithms::lp::CommandlineSolver.
|
inlinevirtual |
Allow to return the set of infeasible constraint by a list of indices in the final solution
Reimplemented in graph_analysis::algorithms::lp::embedded::SoplexSolver.
|
protected |
| bool graph_analysis::algorithms::LPSolver::loadProblem | ( | const std::string & | filename, |
| ProblemFormat | format = CPLEX |
||
| ) |
Load a problem based
| filename | filename of the problem file |
| format | format of the problem |
|
pure virtual |
Load a solution based
| filename | filename of the solution file |
| format | format of the solution |
Implemented in graph_analysis::algorithms::lp::embedded::GLPKSolver, graph_analysis::algorithms::lp::CommandlineSolver, graph_analysis::algorithms::lp::CommandlineSolver, graph_analysis::algorithms::lp::embedded::ScipSolver, and graph_analysis::algorithms::lp::embedded::SoplexSolver.
|
protected |
|
inline |
|
pure virtual |
Run the solver (after loadProblem) has been called
Implemented in graph_analysis::algorithms::lp::embedded::GLPKSolver, graph_analysis::algorithms::lp::embedded::SoplexSolver, graph_analysis::algorithms::lp::CommandlineSolver, graph_analysis::algorithms::lp::embedded::ScipSolver, and graph_analysis::algorithms::lp::CommandlineSolver.
|
pure virtual |
Run the solver with a given problem file
| problemFilename | filename of the problem to solve |
| problemFormat | format of the problem to solver |
| useCaching | To use caching of problem and respective solutions set to True, otherwise False |
Implemented in graph_analysis::algorithms::lp::embedded::GLPKSolver, graph_analysis::algorithms::lp::embedded::SoplexSolver, graph_analysis::algorithms::lp::embedded::ScipSolver, graph_analysis::algorithms::lp::CommandlineSolver, and graph_analysis::algorithms::lp::CommandlineSolver.
|
pure virtual |
Save the problem to file
| filename | filename of the problem file |
| format | format of the the problem |
Implemented in graph_analysis::algorithms::lp::embedded::GLPKSolver, graph_analysis::algorithms::lp::CommandlineSolver, graph_analysis::algorithms::lp::CommandlineSolver, graph_analysis::algorithms::lp::embedded::ScipSolver, and graph_analysis::algorithms::lp::embedded::SoplexSolver.
| std::string graph_analysis::algorithms::LPSolver::saveProblemToTempfile | ( | LPSolver::ProblemFormat | format = CPLEX | ) | const |
Save the problem in a temporary file
|
pure virtual |
Save the solution to file
| filename | filename of the solution file |
| format | format of the the solution |
Implemented in graph_analysis::algorithms::lp::embedded::GLPKSolver, graph_analysis::algorithms::lp::CommandlineSolver, graph_analysis::algorithms::lp::CommandlineSolver, graph_analysis::algorithms::lp::embedded::ScipSolver, and graph_analysis::algorithms::lp::embedded::SoplexSolver.
| std::string graph_analysis::algorithms::LPSolver::saveSolutionToTempfile | ( | LPSolver::SolutionType | format = BASIC_SOLUTION | ) | const |
Save the solution in a temporary file
|
inline |
Set the maximum size of the solution cache The cache will be cleared – if the size exceeds this cache size
|
mutableprotected |
Provide the current problem file and format after loadProblem has been called
|
mutableprotected |
|
staticprotected |
|
protected |
|
mutableprotected |
Provide the current solution file and format after loadSolution has been called
|
mutableprotected |
|
static |
|
static |
|
static |
|
static |
1.8.13