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

Helper caching rows and columns to add to a solver matrix in batch for efficiency. More...

#include <FMTMatrixBuild.h>

Public Member Functions

void swap (FMTMatrixBuild &rhs)
 Swap this FMTMatrixBuild with another.
 
std::vector< std::string > & getColumnNames ()
 Return the cached column names.
 
std::vector< std::string > & getRowNames ()
 Return the cached row names.
 
void formatAllNames (bool shortformat)
 Format the cached row and column names.
 
void setColName (const std::string &name, const int &columnid)
 Set a column name.
 
void setRowName (const std::string &name, const int &rowid)
 Set a row name.
 
void synchronize (std::shared_ptr< OsiSolverInterface > solver)
 Synchronize the cached columns and rows with the solver matrix.
 
 FMTMatrixBuild ()
 Default constructor for FMTMatrixBuild.
 
 FMTMatrixBuild (const FMTMatrixBuild &rhs)
 Copy constructor for FMTMatrixBuild.
 
FMTMatrixBuildoperator= (const FMTMatrixBuild &rhs)
 Copy assignment operator for FMTMatrixBuild.
 
 ~FMTMatrixBuild ()
 Destructor for FMTMatrixBuild.
 
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 to the cache to potentially synchronize it later.
 
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 to the cache to potentially synchronize it later.
 
void deleteRow (const int &rowindex)
 Delete a row from the matrix cache.
 
void deleteCol (const int &colindex)
 Delete a column from the matrix cache.
 
int numberNewRows () const
 Return the number of newly added rows in the matrix cache.
 
int numberNewCols () const
 Return the number of newly added columns in the matrix cache.
 
int numberOfDeletedRows () const
 Return the number of newly deleted rows in the matrix cache.
 
int numberOfDeletedCols () const
 Return the number of newly deleted columns in the matrix cache.
 
const std::vector< int > & getDeletedConstraints () const
 Return the newly deleted rows in the matrix cache.
 
const std::vector< int > & getDeletedVariables () const
 Return the newly deleted columns in the matrix cache.
 
void sortAndCleanDeleted ()
 Remove duplicates from the deleted rows and columns and sort them.
 
std::string getRowsToSynchronize () const
 Return a string of all the rows in the matrix cache, mainly for debugging.
 
std::string getColsToSynchronize () const
 Return a string of all the columns in the matrix cache, mainly for debugging.
 
int getRow (int whichRow, double &rowLower, double &rowUpper, std::vector< int > &indices, std::vector< double > &elements) const
 Fill up the bounds, indices and elements of a given row present in the cache.
 
int getCol (int whichCol, double &colLower, double &colUpper, double &objectiveValue, std::vector< int > &indices, std::vector< double > &elements) const
 Fill up the bounds, objective, indices and elements of a given column present in the cache.
 

Detailed Description

Helper caching rows and columns to add to a solver matrix in batch for efficiency.

CoinBuild lets the user add rows or columns and then synchronize them with the matrix. This class keeps track of the last added columns and rows to let the user virtually add more to the matrix.

Constructor & Destructor Documentation

◆ FMTMatrixBuild() [1/2]

Models::FMTMatrixBuild::FMTMatrixBuild ( )

Default constructor for FMTMatrixBuild.

◆ FMTMatrixBuild() [2/2]

Models::FMTMatrixBuild::FMTMatrixBuild ( const FMTMatrixBuild rhs)

Copy constructor for FMTMatrixBuild.

Parameters
[in]rhsthe FMTMatrixBuild to copy.

◆ ~FMTMatrixBuild()

Models::FMTMatrixBuild::~FMTMatrixBuild ( )

Destructor for FMTMatrixBuild.

Member Function Documentation

◆ addCol()

void Models::FMTMatrixBuild::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 to the cache to potentially synchronize it later.

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

◆ addRow()

void Models::FMTMatrixBuild::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 to the cache to potentially synchronize it later.

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

◆ deleteCol()

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

Delete a column from the matrix cache.

Parameters
[in]colindexthe index of the column to delete.

◆ deleteRow()

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

Delete a row from the matrix cache.

Parameters
[in]rowindexthe index of the row to delete.

◆ formatAllNames()

void Models::FMTMatrixBuild::formatAllNames ( bool  shortformat)

Format the cached row and column names.

Parameters
[in]shortformatif true uses a short format.

◆ getCol()

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

Fill up the bounds, objective, indices and elements of a given column present in the cache.

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

◆ getColsToSynchronize()

std::string Models::FMTMatrixBuild::getColsToSynchronize ( ) const

Return a string of all the columns in the matrix cache, mainly for debugging.

Returns
the columns to synchronize.

◆ getColumnNames()

std::vector< std::string > & Models::FMTMatrixBuild::getColumnNames ( )
inline

Return the cached column names.

Returns
a reference to the cached column names.

◆ getDeletedConstraints()

const std::vector< int > & Models::FMTMatrixBuild::getDeletedConstraints ( ) const
inline

Return the newly deleted rows in the matrix cache.

Returns
the deleted constraints.

◆ getDeletedVariables()

const std::vector< int > & Models::FMTMatrixBuild::getDeletedVariables ( ) const
inline

Return the newly deleted columns in the matrix cache.

Returns
the deleted variables.

◆ getRow()

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

Fill up the bounds, indices and elements of a given row present in the cache.

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 elements in the row.

◆ getRowNames()

std::vector< std::string > & Models::FMTMatrixBuild::getRowNames ( )
inline

Return the cached row names.

Returns
a reference to the cached row names.

◆ getRowsToSynchronize()

std::string Models::FMTMatrixBuild::getRowsToSynchronize ( ) const

Return a string of all the rows in the matrix cache, mainly for debugging.

Returns
the rows to synchronize.

◆ numberNewCols()

int Models::FMTMatrixBuild::numberNewCols ( ) const
inline

Return the number of newly added columns in the matrix cache.

Returns
the number of newly added columns.

◆ numberNewRows()

int Models::FMTMatrixBuild::numberNewRows ( ) const
inline

Return the number of newly added rows in the matrix cache.

Returns
the number of newly added rows.

◆ numberOfDeletedCols()

int Models::FMTMatrixBuild::numberOfDeletedCols ( ) const
inline

Return the number of newly deleted columns in the matrix cache.

Returns
the number of newly deleted columns.

◆ numberOfDeletedRows()

int Models::FMTMatrixBuild::numberOfDeletedRows ( ) const
inline

Return the number of newly deleted rows in the matrix cache.

Returns
the number of newly deleted rows.

◆ operator=()

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

Copy assignment operator for FMTMatrixBuild.

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

◆ setColName()

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

Set a column name.

Parameters
[in]namethe name to set.
[in]columnidthe column id.

◆ setRowName()

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

Set a row name.

Parameters
[in]namethe name to set.
[in]rowidthe row id.

◆ sortAndCleanDeleted()

void Models::FMTMatrixBuild::sortAndCleanDeleted ( )

Remove duplicates from the deleted rows and columns and sort them.

◆ swap()

void Models::FMTMatrixBuild::swap ( FMTMatrixBuild rhs)

Swap this FMTMatrixBuild with another.

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

◆ synchronize()

void Models::FMTMatrixBuild::synchronize ( std::shared_ptr< OsiSolverInterface >  solver)

Synchronize the cached columns and rows with the solver matrix.

Parameters
[in]solverthe solver interface.

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