![]() |
FMT 1.2.0
Forest management tools for forest planning
|
Abstract class to ease the usage of the OsiSolverInterface in FMT for linear programming models. More...
#include <FMTLpSolver.h>
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. | |
| FMTLpSolver & | operator= (const FMTLpSolver &rhs) |
| Copy assignment operator for FMTLpSolver. | |
| FMTLpSolver & | operator= (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. | |
| FMTObject & | operator= (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::FMTSolverInterface > | getAvailableSolverInterface () |
| 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::FMTLogger * | getLogger () |
| get a pointer to the actual logger. | |
| static Exception::FMTExceptionHandler * | getExceptionHandler () |
| 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. | |
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.
| Models::FMTLpSolver::FMTLpSolver | ( | ) |
Default constructor for FMTLpSolver.
|
virtualdefault |
Default virtual destructor for FMTLpSolver.
| Models::FMTLpSolver::FMTLpSolver | ( | const FMTLpSolver & | rhs | ) |
Default copy constructor for FMTLpSolver.
| [in] | rhs | the FMTLpSolver to copy. |
|
default |
Default move constructor for FMTLpSolver.
| [in,out] | rhs | the FMTLpSolver to move from. |
| 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.
| [in] | lsolvertype | the solver type. |
| [in] | p_ColdStartParameters | the cold start parameters on the form param_name param_value per line. |
| [in] | p_WarmStartParameters | the warm start parameters on the form param_name param_value per line. |
| [in] | p_problemName | the name of the problem. |
| 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.
| [in] | numberInColumn | the number of rows in the column. |
| [in] | rows | the row indexes. |
| [in] | elements | the elements. |
| [in] | columnLower | the column lower bound. |
| [in] | columnUpper | the column upper bound. |
| [in] | objectiveValue | the objective value. |
| 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.
| [in] | numcols | the number of columns. |
| [in] | columnStarts | the column starts. |
| [in] | rows | the row indexes. |
| [in] | elements | the elements. |
| [in] | collb | the column lower bounds. |
| [in] | colub | the column upper bounds. |
| [in] | obj | the objective values. |
| 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.
| [in] | numberInRow | the number of columns in the row. |
| [in] | columns | the column indexes. |
| [in] | elements | the elements. |
| [in] | rowLower | the row lower bound. |
| [in] | rowUpper | the row upper bound. |
| 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.
| [in] | numrows | the number of rows. |
| [in] | rowStarts | the row starts. |
| [in] | columns | the column indexes. |
| [in] | elements | the elements. |
| [in] | rowlb | the row lower bounds. |
| [in] | rowub | the row upper bounds. |
| void Models::FMTLpSolver::branchAndBound | ( | ) |
Synchronize the matrix cache and call the branch and bound MIP enumeration solver.
|
protected |
Build a shared pointer to a solver interface, passing the message handler to the pointer.
| [in] | lsolvertype | the solver type. |
|
protected |
Return true if the solver interface source can be updated.
|
protected |
Clear the row caching of the OsiSolverInterface if Mosek is used.
|
protected |
Copy a shared pointer to a solver interface into another shared pointer, passing the message handler to the pointer.
| [in] | solver_ptr | the solver interface to copy. |
| [in] | lsolvertype | the solver type. |
| void Models::FMTLpSolver::deleteCol | ( | const int & | colindex | ) |
Delete a given column; if the cache is used it is only deleted from the cache.
| [in] | colindex | the column index. |
| 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.
| [in] | numberofcols | the number of columns. |
| [in] | colindexes | the column indexes. |
| void Models::FMTLpSolver::deleteRow | ( | const int & | rowindex | ) |
Delete a given row; if the cache is used it is only deleted from the cache.
| [in] | rowindex | the row index. |
| 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.
| [in] | numberofrows | the number of rows. |
| [in] | rowindexes | the row indexes. |
| void Models::FMTLpSolver::disableMatrixCaching | ( | ) |
Synchronize the matrix cache with the solver interface and turn off the matrix caching.
| 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.
|
static |
Return the available solver interfaces.
|
inline |
Return the row ids that are in the cache and marked as deleted.
|
inline |
Return the column ids that are in the cache and marked as deleted.
| 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.
| 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.
| [in] | whichCol | the column index. |
| [out] | colLower | the column lower bound. |
| [out] | colUpper | the column upper bound. |
| [out] | objectiveValue | the column objective value. |
| [out] | indices | the column indices. |
| [out] | elements | the column elements. |
| const double * Models::FMTLpSolver::getColLower | ( | ) | const |
Return the column lower bounds of the matrix, synchronizing the solver interface with the cache first.
| const double * Models::FMTLpSolver::getColSolution | ( | ) | const |
Return the column solution of the solver interface, without synchronizing with the cache.
| const double * Models::FMTLpSolver::getColUpper | ( | ) | const |
Return the column upper bounds of the matrix, synchronizing the solver interface with the cache first.
| int Models::FMTLpSolver::getIterationCount | ( | ) | const |
Get the number of iterations done by the solver.
|
protected |
Return a CoinPackedMatrix by column of the problem, synchronizing the matrix first.
|
protected |
Return a CoinPackedMatrix by row of the problem, synchronizing the matrix first.
| std::string Models::FMTLpSolver::getMskErrorDesc | ( | int | error | ) | const |
Return the description of an error code from Mosek.
| [in] | error | the error code. |
| int Models::FMTLpSolver::getNumCols | ( | ) | const |
Return the number of columns by looking in the solver interface and in the cache.
| int Models::FMTLpSolver::getNumRows | ( | ) | const |
Return the number of rows by looking in the solver interface and in the cache.
| const double * Models::FMTLpSolver::getObjCoefficients | ( | ) | const |
Return the objective coefficients of the matrix, synchronizing the solver interface with the cache first.
| double Models::FMTLpSolver::getObjSense | ( | ) | const |
Return the objective sense of the solver interface, synchronizing with the cache first.
| double Models::FMTLpSolver::getObjValue | ( | ) | const |
Get the objective value of the solved matrix.
| 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.
| [in] | whichRow | the row index. |
| [out] | rowLower | the row lower bound. |
| [out] | rowUpper | the row upper bound. |
| [out] | indices | the row indices. |
| [out] | elements | the row elements. |
| const double * Models::FMTLpSolver::getRowActivity | ( | ) | const |
Return the row activity of the solver interface, without synchronizing with the cache.
| const double * Models::FMTLpSolver::getRowLower | ( | ) | const |
Return the row lower bounds of the solver interface, synchronizing with the cache first.
| const double * Models::FMTLpSolver::getRowPrice | ( | ) | const |
Return the row price (dual solution) of the solver interface, without synchronizing with the cache.
| const double * Models::FMTLpSolver::getRowUpper | ( | ) | const |
Return the row upper bounds of the solver interface, synchronizing with the cache first.
| std::string Models::FMTLpSolver::getSolverName | ( | ) | const |
Return the name of the solver used.
|
inline |
Return the solver type of the solver.
| bool Models::FMTLpSolver::gotLicense | ( | ) | const |
Return true if the license of the solver is available.
|
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.
Reimplemented in Heuristics::FMTOperatingAreaClusterer, and Heuristics::FMTOperatingAreaScheduler.
| bool Models::FMTLpSolver::isProvenOptimal | ( | ) | const |
Return true if the program is optimal, synchronizing the matrix with the cache first.
| std::string Models::FMTLpSolver::lowerNUpperToStr | ( | const double & | lower, |
| const double & | upper | ||
| ) | const |
Convert double bounds to string bounds (-inf, inf).
| [in] | lower | the lower bound. |
| [in] | upper | the upper bound. |
| void Models::FMTLpSolver::mipParameters | ( | ) |
Set the mixed-integer optimizer parameters, including the way the feasibility pump heuristic is employed to improve solution quality.
| bool Models::FMTLpSolver::operator!= | ( | const FMTLpSolver & | rhs | ) | const |
Inequality operator for FMTLpSolver.
| [in] | rhs | the FMTLpSolver to compare to. |
| FMTLpSolver & Models::FMTLpSolver::operator= | ( | const FMTLpSolver & | rhs | ) |
Copy assignment operator for FMTLpSolver.
| [in] | rhs | the FMTLpSolver to copy. |
|
default |
Default move assignment for FMTLpSolver.
| [in,out] | rhs | the FMTLpSolver to move from. |
| bool Models::FMTLpSolver::operator== | ( | const FMTLpSolver & | rhs | ) | const |
Comparison operator for FMTLpSolver.
| [in] | rhs | the FMTLpSolver to compare to. |
|
overridevirtual |
Pass in the logger, overridden for the OsiSolverInterface.
| [in] | logger | the logger. |
Reimplemented from Core::FMTObject.
| void Models::FMTLpSolver::passInMessageHandler | ( | Logging::FMTLogger & | logger | ) |
Pass the FMTLogger to the solver interface.
| [in] | logger | the logger. |
| void Models::FMTLpSolver::passInSolver | ( | const FMTLpSolver & | solver | ) |
Share the solver interface pointer of another solver.
| [in] | solver | the solver to share the interface of. |
|
virtual |
Call solverinterface->resolve when some changes are done to the model, avoiding a full initialSolve.
| void Models::FMTLpSolver::setColName | ( | const std::string & | name, |
| const int & | columnid | ||
| ) | const |
Update the constraints and variables names.
Set a column name.
| [in] | name | the column name. |
| [in] | columnid | the column index. |
| 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.
| [in] | indexFirst | the first column index. |
| [in] | indexLast | the last column index. |
| [in] | boundlist | the bounds. |
| void Models::FMTLpSolver::setColSolution | ( | const double * | newsolution | ) |
Set a solution for all columns of the solver interface, synchronizing the matrix first.
| [in] | newsolution | the new column solution. |
| void Models::FMTLpSolver::setInteger | ( | const int & | colindex | ) |
Synchronize the matrix and set a given column as integer.
| [in] | colindex | the column index. |
| void Models::FMTLpSolver::setInteger | ( | const int * | indices, |
| int | len | ||
| ) |
Synchronize the matrix and set multiple columns as integer variables.
| [in] | indices | the column indices. |
| [in] | len | the number of indices. |
| 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.
| [in] | gap | the MIP gap tolerance. |
| 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.
| [in] | nthread | the number of threads. |
| void Models::FMTLpSolver::setObjective | ( | const double * | objectivevalues | ) |
Set the objective values of the columns of the matrix.
| [in] | objectivevalues | the objective values. |
| void Models::FMTLpSolver::setObjSense | ( | const double & | newsense | ) |
Set the objective sense of the solver interface.
| [in] | newsense | the new objective sense. |
| 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.
| [in] | time | the maximum optimization time. |
| void Models::FMTLpSolver::setRowName | ( | const std::string & | name, |
| const int & | rowid | ||
| ) | const |
Set a row name.
| [in] | name | the row name. |
| [in] | rowid | the row index. |
| void Models::FMTLpSolver::setRowPrice | ( | const double * | rowprice | ) |
Set a solution for all rows of the solver interface, synchronizing the matrix first.
| [in] | rowprice | the new row price. |
| 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.
| [in] | indexFirst | the first row index. |
| [in] | indexLast | the last row index. |
| [in] | boundlist | the bounds. |
| void Models::FMTLpSolver::setSolverType | ( | FMTSolverInterface & | lsolvertype | ) | const |
Setter of the solver type of the serializable matrix.
| [in] | lsolvertype | the solver type. |
| void Models::FMTLpSolver::sortDeletedCache | ( | ) |
Sort and remove duplicates in the rows and columns to delete in the matrix cache.
| bool Models::FMTLpSolver::stockResolve | ( | ) |
Call the plain OsiSolverInterface resolve, synchronizing the matrix first.
| bool Models::FMTLpSolver::SupportsMultiThreading | ( | ) | const |
Return true if the solver support multithreading.
| void Models::FMTLpSolver::swap | ( | FMTLpSolver & | rhs | ) |
Swap this FMTLpSolver with another one.
| [in,out] | rhs | the FMTLpSolver to swap with. |
| 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.
|
static |
return the string value of the solver
| [in] | p_solver | the solver |
| void Models::FMTLpSolver::unmarkHotStart | ( | ) |
Clear all cached data in the OsiSolverInterface.
| void Models::FMTLpSolver::updateRowsAndColsNames | ( | bool | shortformat = true | ) |
Update the rows and columns names.
| [in] | shortformat | if true uses the short format. |
| void Models::FMTLpSolver::writeLp | ( | const std::string & | location | ) | const |
Write the solver interface matrix to a file using the LP formulation.
| [in] | location | the file location. |
| void Models::FMTLpSolver::writeMps | ( | const std::string & | location | ) | const |
Write the solver interface matrix to a file using the MPS formulation.
| [in] | location | the file location. |
|
friend |
|
mutableprotected |
The matrix cache follow the constraints or variables that need to be added or removed to the problem.
|
protected |
Solver type used maybe usefull for initialSolve or resolve to know what solver we are using to speed-up the process.