FMT 1.2.0
Forest management tools for forest planning
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
Models::FMTLpSolver Class Reference

Abstract class to ease the usage of the OsiSolverInterface in FMT for linear programming models. More...

#include <FMTLpSolver.h>

Inheritance diagram for Models::FMTLpSolver:
[legend]
Collaboration diagram for Models::FMTLpSolver:
[legend]

Public Member Functions

void swap (FMTLpSolver &rhs)
 Swap this FMTLpSolver with another one.
 
void passInLogger (const std::unique_ptr< Logging::FMTLogger > &logger) override
 Pass in the logger, overridden for the OsiSolverInterface.
 
void unmarkHotStart ()
 Clear all cached data in the OsiSolverInterface.
 
bool stockResolve ()
 Call the plain OsiSolverInterface resolve, synchronizing the matrix first.
 
 FMTLpSolver ()
 Default constructor for FMTLpSolver.
 
virtual ~FMTLpSolver ()=default
 Default virtual destructor for FMTLpSolver.
 
 FMTLpSolver (const FMTLpSolver &rhs)
 Default copy constructor for FMTLpSolver.
 
 FMTLpSolver (FMTLpSolver &&rhs)=default
 Default move constructor for FMTLpSolver.
 
FMTLpSolveroperator= (const FMTLpSolver &rhs)
 Copy assignment operator for FMTLpSolver.
 
FMTLpSolveroperator= (FMTLpSolver &&rhs)=default
 Default move assignment for FMTLpSolver.
 
 FMTLpSolver (FMTSolverInterface lsolvertype, const std::string &p_ColdStartParameters, const std::string &p_WarmStartParameters, const std::string &p_problemName)
 Main constructor for FMTLpSolver with a solver type, cold and warm start parameters and a problem name.
 
bool operator== (const FMTLpSolver &rhs) const
 Comparison operator for FMTLpSolver.
 
bool operator!= (const FMTLpSolver &rhs) const
 Inequality operator for FMTLpSolver.
 
virtual bool resolve ()
 Call solverinterface->resolve when some changes are done to the model, avoiding a full initialSolve.
 
virtual bool initialSolve ()
 Cold start of the LP solve of a simple LP model.
 
void setNumberOfThreads (const size_t &nthread)
 Set the maximum number of threads to be used by the solver.
 
void setMipGapTolerance (const double &gap)
 Set the tolerance between the relaxed optimal and the integer optimal.
 
void setOptimizerMaxTime (const double &time)
 Set the maximum amount of time the optimizer is allowed to spend on the optimization.
 
void mipParameters ()
 Set the mixed-integer optimizer parameters, including the way the feasibility pump heuristic is employed to improve solution quality.
 
double getObjValue () const
 Get the objective value of the solved matrix.
 
int getIterationCount () const
 Get the number of iterations done by the solver.
 
void passInSolver (const FMTLpSolver &solver)
 Share the solver interface pointer of another solver.
 
void passInMessageHandler (Logging::FMTLogger &logger)
 Pass the FMTLogger to the solver interface.
 
void setSolverType (FMTSolverInterface &lsolvertype) const
 Setter of the solver type of the serializable matrix.
 
bool gotLicense () const
 Return true if the license of the solver is available.
 
std::string getSolverName () const
 Return the name of the solver used.
 
int getNumCols () const
 Return the number of columns by looking in the solver interface and in the cache.
 
int getNumRows () const
 Return the number of rows by looking in the solver interface and in the cache.
 
const double * getObjCoefficients () const
 Return the objective coefficients of the matrix, synchronizing the solver interface with the cache first.
 
const double * getColLower () const
 Return the column lower bounds of the matrix, synchronizing the solver interface with the cache first.
 
const double * getColUpper () const
 Return the column upper bounds of the matrix, synchronizing the solver interface with the cache first.
 
const double * getColSolution () const
 Return the column solution of the solver interface, without synchronizing with the cache.
 
const double * getRowPrice () const
 Return the row price (dual solution) of the solver interface, without synchronizing with the cache.
 
const double * getRowActivity () const
 Return the row activity of the solver interface, without synchronizing with the cache.
 
const double * getRowUpper () const
 Return the row upper bounds of the solver interface, synchronizing with the cache first.
 
const double * getRowLower () const
 Return the row lower bounds of the solver interface, synchronizing with the cache first.
 
int getRow (int whichRow, double &rowLower, double &rowUpper, std::vector< int > &indices, std::vector< double > &elements) const
 Fill the bounds, indices and elements of a given row, trying to synchronize the matrix as little as possible.
 
int getCol (int whichCol, double &colLower, double &colUpper, double &objectiveValue, std::vector< int > &indices, std::vector< double > &elements) const
 Fill the bounds, objective, indices and elements of a given column, trying to synchronize the matrix as little as possible.
 
double getObjSense () const
 Return the objective sense of the solver interface, synchronizing with the cache first.
 
void setObjective (const double *objectivevalues)
 Set the objective values of the columns of the matrix.
 
void setObjSense (const double &newsense)
 Set the objective sense of the solver interface.
 
void addRow (int numberInRow, const int *columns, const double *elements, double rowLower=-std::numeric_limits< double >::max(), double rowUpper=std::numeric_limits< double >::max())
 Add a row with its columns, elements and bounds.
 
void addCol (int numberInColumn, const int *rows, const double *elements, double columnLower=0.0, double columnUpper=std::numeric_limits< double >::max(), double objectiveValue=0.0)
 Add a column with its rows, elements, bounds and objective value.
 
void addRows (const int numrows, const int *rowStarts, const int *columns, const double *elements, const double *rowlb, const double *rowub)
 Add multiple rows directly to the matrix, synchronizing the matrix with the cache first.
 
void addCols (const int numcols, const int *columnStarts, const int *rows, const double *elements, const double *collb, const double *colub, const double *obj)
 Add multiple columns directly to the matrix, synchronizing the matrix with the cache first.
 
bool isProvenOptimal () const
 Return true if the program is optimal, synchronizing the matrix with the cache first.
 
void deleteRow (const int &rowindex)
 Delete a given row; if the cache is used it is only deleted from the cache.
 
void deleteCol (const int &colindex)
 Delete a given column; if the cache is used it is only deleted from the cache.
 
void deleteRows (int numberofrows, const int *rowindexes)
 Delete multiple rows; if the cache is used the matrix is synchronized before deleting the rows.
 
void deleteCols (int numberofcols, const int *colindexes)
 Delete multiple columns; if the cache is used the matrix is synchronized before deleting the columns.
 
void setColSolution (const double *newsolution)
 Set a solution for all columns of the solver interface, synchronizing the matrix first.
 
void setRowPrice (const double *rowprice)
 Set a solution for all rows of the solver interface, synchronizing the matrix first.
 
void setColSetBounds (const int *indexFirst, const int *indexLast, const double *boundlist)
 Synchronize the matrix and set the lower and upper bounds of a set of columns.
 
void setRowSetBounds (const int *indexFirst, const int *indexLast, const double *boundlist)
 Synchronize the matrix and set the lower and upper bounds of a set of rows.
 
void setInteger (const int &colindex)
 Synchronize the matrix and set a given column as integer.
 
void setInteger (const int *indices, int len)
 Synchronize the matrix and set multiple columns as integer variables.
 
void setColName (const std::string &name, const int &columnid) const
 Update the constraints and variables names.
 
void setRowName (const std::string &name, const int &rowid) const
 Set a row name.
 
void writeLp (const std::string &location) const
 Write the solver interface matrix to a file using the LP formulation.
 
void writeMps (const std::string &location) const
 Write the solver interface matrix to a file using the MPS formulation.
 
void branchAndBound ()
 Synchronize the matrix cache and call the branch and bound MIP enumeration solver.
 
void enableMatrixCaching ()
 Enable the rows and columns caching when adding or deleting a variable to the solver interface, reducing the number of calls made to the OsiSolverInterface.
 
void disableMatrixCaching ()
 Synchronize the matrix cache with the solver interface and turn off the matrix caching.
 
FMTSolverInterface getSolverType () const
 Return the solver type of the solver.
 
void synchronize ()
 Update the OsiSolverInterface using the cached matrix information (new or deleted rows and columns) when constraints or variables have been added or deleted.
 
void sortDeletedCache ()
 Sort and remove duplicates in the rows and columns to delete in the matrix cache.
 
const std::vector< int > & getCacheDeletedConstraints () const
 Return the row ids that are in the cache and marked as deleted.
 
const std::vector< int > & getCacheDeletedVariables () const
 Return the column ids that are in the cache and marked as deleted.
 
std::string lowerNUpperToStr (const double &lower, const double &upper) const
 Convert double bounds to string bounds (-inf, inf).
 
std::string getCacheElements () const
 Return the constraints and variables sitting in the matrix cache to be added to the solver interface, for debugging.
 
void updateRowsAndColsNames (bool shortformat=true)
 Update the rows and columns names.
 
std::string getMskErrorDesc (int error) const
 Return the description of an error code from Mosek.
 
bool SupportsMultiThreading () const
 Return true if the solver support multithreading.
 
- Public Member Functions inherited from Core::FMTObject
 FMTObject ()
 Default constructor for FMTObject.
 
virtual ~FMTObject ()
 Default virtual destructor for FMTObject.
 
 FMTObject (const std::unique_ptr< Exception::FMTExceptionHandler > exhandler)
 Construct a FMTObject passing in the exception handler of another FMTObject.
 
 FMTObject (const FMTObject &rhs)
 Copy constructor for FMTObject.
 
FMTObjectoperator= (const FMTObject &rhs)
 Copy assignment operator for FMTObject.
 
virtual void passInLogger (const std::unique_ptr< Logging::FMTLogger > &logger)
 Pass in the logger of another FMTObject.
 
void passInExceptionHandler (const std::unique_ptr< Exception::FMTExceptionHandler > &exhandler)
 Pass in the exception handler of another FMTObject.
 
void redirectLogToFile (const std::string &location)
 Redirect the log to a specific file, appending to it.
 
virtual void setDefaultLogger ()
 Create and set a default logger to the FMTObject.
 
virtual void setQuietLogger ()
 Create and set a quiet logger to the FMTObject.
 
virtual void setTaskLogger ()
 Create and set a task logger to the FMTObject.
 
virtual void setDebugLogger ()
 Create and set a debug logger to the FMTObject.
 
void setDefaultExceptionHandler ()
 Create and set a default exception handler to the FMTObject.
 
void setQuietExceptionHandler ()
 Create and set a quiet exception handler to the FMTObject.
 
void setDebugExceptionHandler ()
 Create and set a debug exception handler to the FMTObject.
 
void setFreeExceptionHandler ()
 Create and set a free exception handler to the FMTObject.
 
void disableNestedExceptions ()
 Disable the nested exception throw of the exception handler.
 
void enableNestedExceptions ()
 Enable the nested exception throw of the exception handler.
 
void setErrorsToWarnings (const std::vector< Exception::FMTexc > &errors)
 Set a list of errors to be cast to warnings on the exception handler.
 
void setMaxWarningsBeforeSilenced (const size_t &maxwarningcount)
 Set the number of warnings raised before being silenced.
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Static Public Member Functions

static std::vector< Models::FMTSolverInterfacegetAvailableSolverInterface ()
 Return the available solver interfaces.
 
static std::string_view toString (Models::FMTSolverInterface p_solver)
 return the string value of the solver
 
- Static Public Member Functions inherited from Core::FMTObject
static Logging::FMTLoggergetLogger ()
 get a pointer to the actual logger.
 
static Exception::FMTExceptionHandlergetExceptionHandler ()
 get a pointer to the actual exception handler.
 
static std::string getRuntimeLocation ()
 Return the location of the FMT shared library.
 
static unsigned long long getAvailableMemory ()
 Return the available memory in bytes.
 
static void setTerminateStack ()
 will write the stack in the log when terminate called and raise a function failed.
 
static void setAbortStack ()
 will write the stack in the log when abort called with SIGABRT and raise a function failed.
 

Protected Member Functions

bool canUpdateSource () const
 Return true if the solver interface source can be updated.
 
std::shared_ptr< OsiSolverInterface > buildSolverInterface (const FMTSolverInterface &lsolvertype) const
 Build a shared pointer to a solver interface, passing the message handler to the pointer.
 
std::shared_ptr< OsiSolverInterface > copySolverInterface (const std::shared_ptr< OsiSolverInterface > &solver_ptr, const FMTSolverInterface &lsolvertype) const
 Copy a shared pointer to a solver interface into another shared pointer, passing the message handler to the pointer.
 
void clearRowCache ()
 Clear the row caching of the OsiSolverInterface if Mosek is used.
 
const CoinPackedMatrix * getMatrixByRow () const
 Return a CoinPackedMatrix by row of the problem, synchronizing the matrix first.
 
const CoinPackedMatrix * getMatrixByCol () const
 Return a CoinPackedMatrix by column of the problem, synchronizing the matrix first.
 
- Protected Member Functions inherited from Core::FMTObject
template<class Archive >
void forceSave (Archive &ar, const unsigned int version) const
 Force the serialization to save useful information, which the default FMTObject serialization does not.
 
template<class Archive >
void forceLoad (Archive &ar, const unsigned int version)
 Force the serialization to load useful information, which the default FMTObject serialization does not.
 
void checkSignals () const
 Check if the user has sent a ctrl-c signal using boost::python to FMT.
 
void setCplHandler ()
 Pass the FMT exception handler to the GDAL exception handler (GDAL only).
 

Protected Attributes

FMTMatrixBuild matrixcache
 The matrix cache follow the constraints or variables that need to be added or removed to the problem.
 
FMTSolverInterface solvertype
 Solver type used maybe usefull for initialSolve or resolve to know what solver we are using to speed-up the process.
 

Friends

class boost::serialization::access
 

Additional Inherited Members

- Static Protected Member Functions inherited from Core::FMTObject
static std::chrono::time_point< std::chrono::high_resolution_clock > getClock ()
 Return a clock of the current time.
 
template<class chrono >
static double getDuration (const std::chrono::time_point< std::chrono::high_resolution_clock > &startclock)
 Return the time elapsed since a start clock as a double.
 
static std::string getDurationInSeconds (const std::chrono::time_point< std::chrono::high_resolution_clock > &startclock)
 Return the time elapsed since a start clock in seconds as a string.
 
static void _logStack ()
 Log the stack trace...
 
static void _terminate ()
 Raise an error with the boost stacktrace.
 
static void _abort (int p_signal)
 Raise an error with the boost stacktrace on abort.
 
- Static Protected Attributes inherited from Core::FMTObject
static std::unique_ptr< Exception::FMTExceptionHandler_exhandler
 A shared pointer to the exception handler.
 
static std::unique_ptr< Logging::FMTLogger_logger
 A shared pointer to the logger.
 

Detailed Description

Abstract class to ease the usage of the OsiSolverInterface in FMT for linear programming models.

The FMTLpSolver reduces the overhead caused by the addRow and addCol calls of the OsiSolverInterface during recurrent calls. Calls related to adding or removing columns or rows, checking the primal or dual solution and getting the number of rows or columns do not need synchronization with the cache, so they are faster when the cache is used.

Constructor & Destructor Documentation

◆ FMTLpSolver() [1/4]

Models::FMTLpSolver::FMTLpSolver ( )

Default constructor for FMTLpSolver.

◆ ~FMTLpSolver()

virtual Models::FMTLpSolver::~FMTLpSolver ( )
virtualdefault

Default virtual destructor for FMTLpSolver.

◆ FMTLpSolver() [2/4]

Models::FMTLpSolver::FMTLpSolver ( const FMTLpSolver rhs)

Default copy constructor for FMTLpSolver.

Parameters
[in]rhsthe FMTLpSolver to copy.

◆ FMTLpSolver() [3/4]

Models::FMTLpSolver::FMTLpSolver ( FMTLpSolver &&  rhs)
default

Default move constructor for FMTLpSolver.

Parameters
[in,out]rhsthe FMTLpSolver to move from.

◆ FMTLpSolver() [4/4]

Models::FMTLpSolver::FMTLpSolver ( FMTSolverInterface  lsolvertype,
const std::string &  p_ColdStartParameters,
const std::string &  p_WarmStartParameters,
const std::string &  p_problemName 
)

Main constructor for FMTLpSolver with a solver type, cold and warm start parameters and a problem name.

Parameters
[in]lsolvertypethe solver type.
[in]p_ColdStartParametersthe cold start parameters on the form param_name param_value per line.
[in]p_WarmStartParametersthe warm start parameters on the form param_name param_value per line.
[in]p_problemNamethe name of the problem.

Member Function Documentation

◆ addCol()

void Models::FMTLpSolver::addCol ( int  numberInColumn,
const int *  rows,
const double *  elements,
double  columnLower = 0.0,
double  columnUpper = std::numeric_limits< double >::max(),
double  objectiveValue = 0.0 
)

Add a column with its rows, elements, bounds and objective value.

If the cache is used the column is only added to the matrix cache, otherwise it is added to the solver interface.

Parameters
[in]numberInColumnthe number of rows in the column.
[in]rowsthe row indexes.
[in]elementsthe elements.
[in]columnLowerthe column lower bound.
[in]columnUpperthe column upper bound.
[in]objectiveValuethe objective value.

◆ addCols()

void Models::FMTLpSolver::addCols ( const int  numcols,
const int *  columnStarts,
const int *  rows,
const double *  elements,
const double *  collb,
const double *  colub,
const double *  obj 
)

Add multiple columns directly to the matrix, synchronizing the matrix with the cache first.

Parameters
[in]numcolsthe number of columns.
[in]columnStartsthe column starts.
[in]rowsthe row indexes.
[in]elementsthe elements.
[in]collbthe column lower bounds.
[in]colubthe column upper bounds.
[in]objthe objective values.

◆ addRow()

void Models::FMTLpSolver::addRow ( int  numberInRow,
const int *  columns,
const double *  elements,
double  rowLower = -std::numeric_limits< double >::max(),
double  rowUpper = std::numeric_limits< double >::max() 
)

Add a row with its columns, elements and bounds.

If the cache is used the row is only added to the matrix cache, otherwise it is added to the solver interface.

Parameters
[in]numberInRowthe number of columns in the row.
[in]columnsthe column indexes.
[in]elementsthe elements.
[in]rowLowerthe row lower bound.
[in]rowUpperthe row upper bound.

◆ addRows()

void Models::FMTLpSolver::addRows ( const int  numrows,
const int *  rowStarts,
const int *  columns,
const double *  elements,
const double *  rowlb,
const double *  rowub 
)

Add multiple rows directly to the matrix, synchronizing the matrix with the cache first.

Parameters
[in]numrowsthe number of rows.
[in]rowStartsthe row starts.
[in]columnsthe column indexes.
[in]elementsthe elements.
[in]rowlbthe row lower bounds.
[in]rowubthe row upper bounds.

◆ branchAndBound()

void Models::FMTLpSolver::branchAndBound ( )

Synchronize the matrix cache and call the branch and bound MIP enumeration solver.

◆ buildSolverInterface()

std::shared_ptr< OsiSolverInterface > Models::FMTLpSolver::buildSolverInterface ( const FMTSolverInterface lsolvertype) const
protected

Build a shared pointer to a solver interface, passing the message handler to the pointer.

Parameters
[in]lsolvertypethe solver type.
Returns
a shared pointer to the solver interface.

◆ canUpdateSource()

bool Models::FMTLpSolver::canUpdateSource ( ) const
protected

Return true if the solver interface source can be updated.

Returns
true if the source can be updated else false.

◆ clearRowCache()

void Models::FMTLpSolver::clearRowCache ( )
protected

Clear the row caching of the OsiSolverInterface if Mosek is used.

◆ copySolverInterface()

std::shared_ptr< OsiSolverInterface > Models::FMTLpSolver::copySolverInterface ( const std::shared_ptr< OsiSolverInterface > &  solver_ptr,
const FMTSolverInterface lsolvertype 
) const
protected

Copy a shared pointer to a solver interface into another shared pointer, passing the message handler to the pointer.

Parameters
[in]solver_ptrthe solver interface to copy.
[in]lsolvertypethe solver type.
Returns
a shared pointer to the copied solver interface.

◆ deleteCol()

void Models::FMTLpSolver::deleteCol ( const int &  colindex)

Delete a given column; if the cache is used it is only deleted from the cache.

Parameters
[in]colindexthe column index.

◆ deleteCols()

void Models::FMTLpSolver::deleteCols ( int  numberofcols,
const int *  colindexes 
)

Delete multiple columns; if the cache is used the matrix is synchronized before deleting the columns.

Parameters
[in]numberofcolsthe number of columns.
[in]colindexesthe column indexes.

◆ deleteRow()

void Models::FMTLpSolver::deleteRow ( const int &  rowindex)

Delete a given row; if the cache is used it is only deleted from the cache.

Parameters
[in]rowindexthe row index.

◆ deleteRows()

void Models::FMTLpSolver::deleteRows ( int  numberofrows,
const int *  rowindexes 
)

Delete multiple rows; if the cache is used the matrix is synchronized before deleting the rows.

Parameters
[in]numberofrowsthe number of rows.
[in]rowindexesthe row indexes.

◆ disableMatrixCaching()

void Models::FMTLpSolver::disableMatrixCaching ( )

Synchronize the matrix cache with the solver interface and turn off the matrix caching.

◆ enableMatrixCaching()

void Models::FMTLpSolver::enableMatrixCaching ( )

Enable the rows and columns caching when adding or deleting a variable to the solver interface, reducing the number of calls made to the OsiSolverInterface.

◆ getAvailableSolverInterface()

static std::vector< Models::FMTSolverInterface > Models::FMTLpSolver::getAvailableSolverInterface ( )
static

Return the available solver interfaces.

Returns
the available solver interfaces.

◆ getCacheDeletedConstraints()

const std::vector< int > & Models::FMTLpSolver::getCacheDeletedConstraints ( ) const
inline

Return the row ids that are in the cache and marked as deleted.

Returns
the deleted constraint ids.

◆ getCacheDeletedVariables()

const std::vector< int > & Models::FMTLpSolver::getCacheDeletedVariables ( ) const
inline

Return the column ids that are in the cache and marked as deleted.

Returns
the deleted variable ids.

◆ getCacheElements()

std::string Models::FMTLpSolver::getCacheElements ( ) const

Return the constraints and variables sitting in the matrix cache to be added to the solver interface, for debugging.

Returns
the cache elements.

◆ getCol()

int Models::FMTLpSolver::getCol ( int  whichCol,
double &  colLower,
double &  colUpper,
double &  objectiveValue,
std::vector< int > &  indices,
std::vector< double > &  elements 
) const

Fill the bounds, objective, indices and elements of a given column, trying to synchronize the matrix as little as possible.

Parameters
[in]whichColthe column index.
[out]colLowerthe column lower bound.
[out]colUpperthe column upper bound.
[out]objectiveValuethe column objective value.
[out]indicesthe column indices.
[out]elementsthe column elements.
Returns
the number of elements in the column.

◆ getColLower()

const double * Models::FMTLpSolver::getColLower ( ) const

Return the column lower bounds of the matrix, synchronizing the solver interface with the cache first.

Returns
the column lower bounds.

◆ getColSolution()

const double * Models::FMTLpSolver::getColSolution ( ) const

Return the column solution of the solver interface, without synchronizing with the cache.

Returns
the column solution.

◆ getColUpper()

const double * Models::FMTLpSolver::getColUpper ( ) const

Return the column upper bounds of the matrix, synchronizing the solver interface with the cache first.

Returns
the column upper bounds.

◆ getIterationCount()

int Models::FMTLpSolver::getIterationCount ( ) const

Get the number of iterations done by the solver.

Returns
the iteration count.

◆ getMatrixByCol()

const CoinPackedMatrix * Models::FMTLpSolver::getMatrixByCol ( ) const
protected

Return a CoinPackedMatrix by column of the problem, synchronizing the matrix first.

Returns
the matrix by column.

◆ getMatrixByRow()

const CoinPackedMatrix * Models::FMTLpSolver::getMatrixByRow ( ) const
protected

Return a CoinPackedMatrix by row of the problem, synchronizing the matrix first.

Returns
the matrix by row.

◆ getMskErrorDesc()

std::string Models::FMTLpSolver::getMskErrorDesc ( int  error) const

Return the description of an error code from Mosek.

Parameters
[in]errorthe error code.
Returns
the error description.

◆ getNumCols()

int Models::FMTLpSolver::getNumCols ( ) const

Return the number of columns by looking in the solver interface and in the cache.

Returns
the number of columns.

◆ getNumRows()

int Models::FMTLpSolver::getNumRows ( ) const

Return the number of rows by looking in the solver interface and in the cache.

Returns
the number of rows.

◆ getObjCoefficients()

const double * Models::FMTLpSolver::getObjCoefficients ( ) const

Return the objective coefficients of the matrix, synchronizing the solver interface with the cache first.

Returns
the objective coefficients.

◆ getObjSense()

double Models::FMTLpSolver::getObjSense ( ) const

Return the objective sense of the solver interface, synchronizing with the cache first.

Returns
the objective sense.

◆ getObjValue()

double Models::FMTLpSolver::getObjValue ( ) const

Get the objective value of the solved matrix.

Returns
the objective value.

◆ getRow()

int Models::FMTLpSolver::getRow ( int  whichRow,
double &  rowLower,
double &  rowUpper,
std::vector< int > &  indices,
std::vector< double > &  elements 
) const

Fill the bounds, indices and elements of a given row, trying to synchronize the matrix as little as possible.

Parameters
[in]whichRowthe row index.
[out]rowLowerthe row lower bound.
[out]rowUpperthe row upper bound.
[out]indicesthe row indices.
[out]elementsthe row elements.
Returns
the number of variables in the row.

◆ getRowActivity()

const double * Models::FMTLpSolver::getRowActivity ( ) const

Return the row activity of the solver interface, without synchronizing with the cache.

Returns
the row activity.

◆ getRowLower()

const double * Models::FMTLpSolver::getRowLower ( ) const

Return the row lower bounds of the solver interface, synchronizing with the cache first.

Returns
the row lower bounds.

◆ getRowPrice()

const double * Models::FMTLpSolver::getRowPrice ( ) const

Return the row price (dual solution) of the solver interface, without synchronizing with the cache.

Returns
the row price.

◆ getRowUpper()

const double * Models::FMTLpSolver::getRowUpper ( ) const

Return the row upper bounds of the solver interface, synchronizing with the cache first.

Returns
the row upper bounds.

◆ getSolverName()

std::string Models::FMTLpSolver::getSolverName ( ) const

Return the name of the solver used.

Returns
the solver name.

◆ getSolverType()

FMTSolverInterface Models::FMTLpSolver::getSolverType ( ) const
inline

Return the solver type of the solver.

Returns
the solver type.

◆ gotLicense()

bool Models::FMTLpSolver::gotLicense ( ) const

Return true if the license of the solver is available.

Returns
true if the license is available else false.

◆ initialSolve()

virtual bool Models::FMTLpSolver::initialSolve ( )
virtual

Cold start of the LP solve of a simple LP model.

By default calls solverinterface->initialSolve, but based on the FMTSolverInterface it tries to use the best solver parameters for a type III forest planning model; interior point is considered the best algorithm for all solvers.

Returns
true if the initial solve succeeded else false.

Reimplemented in Heuristics::FMTOperatingAreaClusterer, and Heuristics::FMTOperatingAreaScheduler.

◆ isProvenOptimal()

bool Models::FMTLpSolver::isProvenOptimal ( ) const

Return true if the program is optimal, synchronizing the matrix with the cache first.

Returns
true if the program is proven optimal else false.

◆ lowerNUpperToStr()

std::string Models::FMTLpSolver::lowerNUpperToStr ( const double &  lower,
const double &  upper 
) const

Convert double bounds to string bounds (-inf, inf).

Parameters
[in]lowerthe lower bound.
[in]upperthe upper bound.
Returns
the string bounds.

◆ mipParameters()

void Models::FMTLpSolver::mipParameters ( )

Set the mixed-integer optimizer parameters, including the way the feasibility pump heuristic is employed to improve solution quality.

◆ operator!=()

bool Models::FMTLpSolver::operator!= ( const FMTLpSolver rhs) const

Inequality operator for FMTLpSolver.

Parameters
[in]rhsthe FMTLpSolver to compare to.
Returns
true if both solvers are different else false.

◆ operator=() [1/2]

FMTLpSolver & Models::FMTLpSolver::operator= ( const FMTLpSolver rhs)

Copy assignment operator for FMTLpSolver.

Parameters
[in]rhsthe FMTLpSolver to copy.
Returns
a reference to this FMTLpSolver.

◆ operator=() [2/2]

FMTLpSolver & Models::FMTLpSolver::operator= ( FMTLpSolver &&  rhs)
default

Default move assignment for FMTLpSolver.

Parameters
[in,out]rhsthe FMTLpSolver to move from.
Returns
a reference to this FMTLpSolver.

◆ operator==()

bool Models::FMTLpSolver::operator== ( const FMTLpSolver rhs) const

Comparison operator for FMTLpSolver.

Parameters
[in]rhsthe FMTLpSolver to compare to.
Returns
true if both solvers are equal else false.

◆ passInLogger()

void Models::FMTLpSolver::passInLogger ( const std::unique_ptr< Logging::FMTLogger > &  logger)
overridevirtual

Pass in the logger, overridden for the OsiSolverInterface.

Parameters
[in]loggerthe logger.

Reimplemented from Core::FMTObject.

◆ passInMessageHandler()

void Models::FMTLpSolver::passInMessageHandler ( Logging::FMTLogger logger)

Pass the FMTLogger to the solver interface.

Parameters
[in]loggerthe logger.

◆ passInSolver()

void Models::FMTLpSolver::passInSolver ( const FMTLpSolver solver)

Share the solver interface pointer of another solver.

Parameters
[in]solverthe solver to share the interface of.

◆ resolve()

virtual bool Models::FMTLpSolver::resolve ( )
virtual

Call solverinterface->resolve when some changes are done to the model, avoiding a full initialSolve.

Returns
true if the resolve succeeded else false.

◆ setColName()

void Models::FMTLpSolver::setColName ( const std::string &  name,
const int &  columnid 
) const

Update the constraints and variables names.

Set a column name.

Parameters
[in]namethe column name.
[in]columnidthe column index.

◆ setColSetBounds()

void Models::FMTLpSolver::setColSetBounds ( const int *  indexFirst,
const int *  indexLast,
const double *  boundlist 
)

Synchronize the matrix and set the lower and upper bounds of a set of columns.

Parameters
[in]indexFirstthe first column index.
[in]indexLastthe last column index.
[in]boundlistthe bounds.

◆ setColSolution()

void Models::FMTLpSolver::setColSolution ( const double *  newsolution)

Set a solution for all columns of the solver interface, synchronizing the matrix first.

Parameters
[in]newsolutionthe new column solution.

◆ setInteger() [1/2]

void Models::FMTLpSolver::setInteger ( const int &  colindex)

Synchronize the matrix and set a given column as integer.

Parameters
[in]colindexthe column index.

◆ setInteger() [2/2]

void Models::FMTLpSolver::setInteger ( const int *  indices,
int  len 
)

Synchronize the matrix and set multiple columns as integer variables.

Parameters
[in]indicesthe column indices.
[in]lenthe number of indices.

◆ setMipGapTolerance()

void Models::FMTLpSolver::setMipGapTolerance ( const double &  gap)

Set the tolerance between the relaxed optimal and the integer optimal.

The default is 1.0e-4; a larger gap such as 0.01 (1%) or even 5% may be better. Not all solvers can have the MIP gap set.

Parameters
[in]gapthe MIP gap tolerance.

◆ setNumberOfThreads()

void Models::FMTLpSolver::setNumberOfThreads ( const size_t &  nthread)

Set the maximum number of threads to be used by the solver.

Not all solvers can have the number of threads set.

Parameters
[in]nthreadthe number of threads.

◆ setObjective()

void Models::FMTLpSolver::setObjective ( const double *  objectivevalues)

Set the objective values of the columns of the matrix.

Parameters
[in]objectivevaluesthe objective values.

◆ setObjSense()

void Models::FMTLpSolver::setObjSense ( const double &  newsense)

Set the objective sense of the solver interface.

Parameters
[in]newsensethe new objective sense.

◆ setOptimizerMaxTime()

void Models::FMTLpSolver::setOptimizerMaxTime ( const double &  time)

Set the maximum amount of time the optimizer is allowed to spend on the optimization.

A negative number means infinity.

Parameters
[in]timethe maximum optimization time.

◆ setRowName()

void Models::FMTLpSolver::setRowName ( const std::string &  name,
const int &  rowid 
) const

Set a row name.

Parameters
[in]namethe row name.
[in]rowidthe row index.

◆ setRowPrice()

void Models::FMTLpSolver::setRowPrice ( const double *  rowprice)

Set a solution for all rows of the solver interface, synchronizing the matrix first.

Parameters
[in]rowpricethe new row price.

◆ setRowSetBounds()

void Models::FMTLpSolver::setRowSetBounds ( const int *  indexFirst,
const int *  indexLast,
const double *  boundlist 
)

Synchronize the matrix and set the lower and upper bounds of a set of rows.

Parameters
[in]indexFirstthe first row index.
[in]indexLastthe last row index.
[in]boundlistthe bounds.

◆ setSolverType()

void Models::FMTLpSolver::setSolverType ( FMTSolverInterface lsolvertype) const

Setter of the solver type of the serializable matrix.

Parameters
[in]lsolvertypethe solver type.

◆ sortDeletedCache()

void Models::FMTLpSolver::sortDeletedCache ( )

Sort and remove duplicates in the rows and columns to delete in the matrix cache.

◆ stockResolve()

bool Models::FMTLpSolver::stockResolve ( )

Call the plain OsiSolverInterface resolve, synchronizing the matrix first.

Returns
true if the solve results in an optimal solution else false.

◆ SupportsMultiThreading()

bool Models::FMTLpSolver::SupportsMultiThreading ( ) const

Return true if the solver support multithreading.

Returns
true if it support else false

◆ swap()

void Models::FMTLpSolver::swap ( FMTLpSolver rhs)

Swap this FMTLpSolver with another one.

Parameters
[in,out]rhsthe FMTLpSolver to swap with.

◆ synchronize()

void Models::FMTLpSolver::synchronize ( )

Update the OsiSolverInterface using the cached matrix information (new or deleted rows and columns) when constraints or variables have been added or deleted.

◆ toString()

static std::string_view Models::FMTLpSolver::toString ( Models::FMTSolverInterface  p_solver)
static

return the string value of the solver

Parameters
[in]p_solverthe solver
Returns
the solver string view

◆ unmarkHotStart()

void Models::FMTLpSolver::unmarkHotStart ( )

Clear all cached data in the OsiSolverInterface.

◆ updateRowsAndColsNames()

void Models::FMTLpSolver::updateRowsAndColsNames ( bool  shortformat = true)

Update the rows and columns names.

Parameters
[in]shortformatif true uses the short format.

◆ writeLp()

void Models::FMTLpSolver::writeLp ( const std::string &  location) const

Write the solver interface matrix to a file using the LP formulation.

Parameters
[in]locationthe file location.

◆ writeMps()

void Models::FMTLpSolver::writeMps ( const std::string &  location) const

Write the solver interface matrix to a file using the MPS formulation.

Parameters
[in]locationthe file location.

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Member Data Documentation

◆ matrixcache

FMTMatrixBuild Models::FMTLpSolver::matrixcache
mutableprotected

The matrix cache follow the constraints or variables that need to be added or removed to the problem.

◆ solvertype

FMTSolverInterface Models::FMTLpSolver::solvertype
protected

Solver type used maybe usefull for initialSolve or resolve to know what solver we are using to speed-up the process.


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