graph_analysis
Public Member Functions | Protected Attributes | List of all members
graph_analysis::algorithms::lp::CommandlineSolver Class Referenceabstract

#include <CmdlineSolver.hpp>

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

Public Member Functions

 CommandlineSolver ()
 
virtual ~CommandlineSolver ()
 
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
 
Status run () override
 
Status run (const std::string &problem, LPSolver::ProblemFormat problemFormat=CPLEX, bool useCaching=false) override
 
virtual std::string createSolverCommand () const
 
virtual Solution readBasicSolution (const std::string &filename)=0
 
 CommandlineSolver ()
 
virtual ~CommandlineSolver ()
 
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 getVariableValueByColumnIdx (uint32_t idx) const override
 
double getVariableValue (const std::string &varName) const
 
Status run () override
 
Status run (const std::string &problem, LPSolver::ProblemFormat problemFormat=CPLEX, bool useCaching=false) override
 
virtual std::string createSolverCommand () const =0
 
virtual Solution readBasicSolution (const std::string &filename)=0
 
- Public Member Functions inherited from graph_analysis::algorithms::LPSolver
 LPSolver ()
 
virtual ~LPSolver ()
 
virtual LPSolver::Type getSolverType () const =0
 
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 ()
 

Protected Attributes

Solution mSolution
 
- 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 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")
 
- 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
 
- 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
 
- Static Protected Attributes inherited from graph_analysis::algorithms::LPSolver
static KnownSolutions msKnownSolutions
 

Detailed Description

General class to call the

Constructor & Destructor Documentation

◆ CommandlineSolver() [1/2]

graph_analysis::algorithms::lp::CommandlineSolver::CommandlineSolver ( )

◆ ~CommandlineSolver() [1/2]

graph_analysis::algorithms::lp::CommandlineSolver::~CommandlineSolver ( )
virtual

◆ CommandlineSolver() [2/2]

graph_analysis::algorithms::lp::CommandlineSolver::CommandlineSolver ( )

◆ ~CommandlineSolver() [2/2]

virtual graph_analysis::algorithms::lp::CommandlineSolver::~CommandlineSolver ( )
virtual

Member Function Documentation

◆ createSolverCommand() [1/2]

virtual std::string graph_analysis::algorithms::lp::CommandlineSolver::createSolverCommand ( ) const
inlinevirtual

◆ createSolverCommand() [2/2]

virtual std::string graph_analysis::algorithms::lp::CommandlineSolver::createSolverCommand ( ) const
pure virtual

◆ doLoadProblem() [1/2]

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

◆ doLoadProblem() [2/2]

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

◆ getObjectiveValue() [1/2]

double graph_analysis::algorithms::lp::CommandlineSolver::getObjectiveValue ( ) const
inlineoverridevirtual

Retrieve the current objective value of the solution

Implements graph_analysis::algorithms::LPSolver.

◆ getObjectiveValue() [2/2]

double graph_analysis::algorithms::lp::CommandlineSolver::getObjectiveValue ( ) const
inlineoverridevirtual

Retrieve the current objective value of the solution

Implements graph_analysis::algorithms::LPSolver.

◆ getProblemName() [1/2]

std::string graph_analysis::algorithms::lp::CommandlineSolver::getProblemName ( ) const
inline

◆ getProblemName() [2/2]

std::string graph_analysis::algorithms::lp::CommandlineSolver::getProblemName ( ) const
inline

◆ getVariableValue() [1/2]

double graph_analysis::algorithms::lp::CommandlineSolver::getVariableValue ( const std::string &  varName) const
inline

◆ getVariableValue() [2/2]

double graph_analysis::algorithms::lp::CommandlineSolver::getVariableValue ( const std::string &  varName) const
inline

◆ getVariableValueByColumnIdx()

double graph_analysis::algorithms::lp::CommandlineSolver::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() [1/2]

void graph_analysis::algorithms::lp::CommandlineSolver::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.

◆ loadSolution() [2/2]

void graph_analysis::algorithms::lp::CommandlineSolver::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.

◆ readBasicSolution() [1/2]

virtual Solution graph_analysis::algorithms::lp::CommandlineSolver::readBasicSolution ( const std::string &  filename)
pure virtual

◆ readBasicSolution() [2/2]

virtual Solution graph_analysis::algorithms::lp::CommandlineSolver::readBasicSolution ( const std::string &  filename)
pure virtual

◆ run() [1/4]

LPSolver::Status graph_analysis::algorithms::lp::CommandlineSolver::run ( )
overridevirtual

Run the solver (after loadProblem) has been called

Implements graph_analysis::algorithms::LPSolver.

◆ run() [2/4]

Status graph_analysis::algorithms::lp::CommandlineSolver::run ( )
overridevirtual

Run the solver (after loadProblem) has been called

Implements graph_analysis::algorithms::LPSolver.

◆ run() [3/4]

LPSolver::Status graph_analysis::algorithms::lp::CommandlineSolver::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.

◆ run() [4/4]

Status graph_analysis::algorithms::lp::CommandlineSolver::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() [1/2]

void graph_analysis::algorithms::lp::CommandlineSolver::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.

◆ saveProblem() [2/2]

void graph_analysis::algorithms::lp::CommandlineSolver::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() [1/2]

void graph_analysis::algorithms::lp::CommandlineSolver::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.

◆ saveSolution() [2/2]

void graph_analysis::algorithms::lp::CommandlineSolver::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.

Member Data Documentation

◆ mSolution

Solution graph_analysis::algorithms::lp::CommandlineSolver::mSolution
protected

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