In many cases it is natural to build a model by adding one row at a time. More...
#include <CoinBuild.hpp>
Public Member Functions | |
Useful methods | |
void | addRow (int numberInRow, const int *columns, const double *elements, double rowLower=-COIN_DBL_MAX, double rowUpper=COIN_DBL_MAX) |
add a row | |
void | addColumn (int numberInColumn, const int *rows, const double *elements, double columnLower=0.0, double columnUpper=COIN_DBL_MAX, double objectiveValue=0.0) |
add a column | |
void | addCol (int numberInColumn, const int *rows, const double *elements, double columnLower=0.0, double columnUpper=COIN_DBL_MAX, double objectiveValue=0.0) |
add a column | |
int | numberRows () const |
Return number of rows or maximum found so far. | |
int | numberColumns () const |
Return number of columns or maximum found so far. | |
CoinBigIndex | numberElements () const |
Return number of elements. | |
int | row (int whichRow, double &rowLower, double &rowUpper, const int *&indices, const double *&elements) const |
Returns number of elements in a row and information in row. | |
int | currentRow (double &rowLower, double &rowUpper, const int *&indices, const double *&elements) const |
Returns number of elements in current row and information in row Used as rows may be stored in a chain. | |
void | setCurrentRow (int whichRow) |
Set current row. | |
int | currentRow () const |
Returns current row number. | |
int | column (int whichColumn, double &columnLower, double &columnUpper, double &objectiveValue, const int *&indices, const double *&elements) const |
Returns number of elements in a column and information in column. | |
int | currentColumn (double &columnLower, double &columnUpper, double &objectiveValue, const int *&indices, const double *&elements) const |
Returns number of elements in current column and information in column Used as columns may be stored in a chain. | |
void | setCurrentColumn (int whichColumn) |
Set current column. | |
int | currentColumn () const |
Returns current column number. | |
int | type () const |
Returns type. | |
Constructors, destructor | |
CoinBuild () | |
Default constructor. | |
CoinBuild (int type) | |
Constructor with type 0==for addRow, 1== for addColumn. | |
~CoinBuild () | |
Destructor. | |
Copy method | |
CoinBuild (const CoinBuild &) | |
The copy constructor. | |
CoinBuild & | operator= (const CoinBuild &) |
= | |
Private Member Functions | |
void | setMutableCurrent (int which) const |
Set current. | |
void | addItem (int numberInItem, const int *indices, const double *elements, double itemLower, double itemUpper, double objectiveValue) |
add a item | |
int | item (int whichItem, double &itemLower, double &itemUpper, double &objectiveValue, const int *&indices, const double *&elements) const |
Returns number of elements in a item and information in item. | |
int | currentItem (double &itemLower, double &itemUpper, double &objectiveValue, const int *&indices, const double *&elements) const |
Returns number of elements in current item and information in item Used as items may be stored in a chain. | |
void | setCurrentItem (int whichItem) |
Set current item. | |
int | currentItem () const |
Returns current item number. | |
Private Attributes | |
Data members | |
int | numberItems_ |
Current number of items. | |
int | numberOther_ |
Current number of other dimension i.e. Columns if addRow (i.e. max). | |
CoinBigIndex | numberElements_ |
Current number of elements. | |
double * | currentItem_ |
Current item pointer. | |
double * | firstItem_ |
First item pointer. | |
double * | lastItem_ |
Last item pointer. | |
int | type_ |
Type of build - 0 for row, 1 for column, -1 unset. |
In many cases it is natural to build a model by adding one row at a time.
In Coin this is inefficient so this class gives some help. An instance of CoinBuild can be built up more efficiently and then added to the Clp/OsiModel in one go.
It may be more efficient to have fewer arrays and re-allocate them but this should give a large gain over addRow.
I have now extended it to columns.
Definition at line 23 of file CoinBuild.hpp.
CoinBuild::CoinBuild | ( | ) |
Default constructor.
CoinBuild::CoinBuild | ( | int | type | ) |
Constructor with type 0==for addRow, 1== for addColumn.
CoinBuild::~CoinBuild | ( | ) |
Destructor.
CoinBuild::CoinBuild | ( | const CoinBuild & | ) |
The copy constructor.
void CoinBuild::addRow | ( | int | numberInRow, | |
const int * | columns, | |||
const double * | elements, | |||
double | rowLower = -COIN_DBL_MAX , |
|||
double | rowUpper = COIN_DBL_MAX | |||
) |
add a row
void CoinBuild::addColumn | ( | int | numberInColumn, | |
const int * | rows, | |||
const double * | elements, | |||
double | columnLower = 0.0 , |
|||
double | columnUpper = COIN_DBL_MAX , |
|||
double | objectiveValue = 0.0 | |||
) |
add a column
void CoinBuild::addCol | ( | int | numberInColumn, | |
const int * | rows, | |||
const double * | elements, | |||
double | columnLower = 0.0 , |
|||
double | columnUpper = COIN_DBL_MAX , |
|||
double | objectiveValue = 0.0 | |||
) | [inline] |
add a column
Definition at line 38 of file CoinBuild.hpp.
int CoinBuild::numberRows | ( | ) | const [inline] |
Return number of rows or maximum found so far.
Definition at line 44 of file CoinBuild.hpp.
int CoinBuild::numberColumns | ( | ) | const [inline] |
Return number of columns or maximum found so far.
Definition at line 47 of file CoinBuild.hpp.
CoinBigIndex CoinBuild::numberElements | ( | ) | const [inline] |
Return number of elements.
Definition at line 50 of file CoinBuild.hpp.
int CoinBuild::row | ( | int | whichRow, | |
double & | rowLower, | |||
double & | rowUpper, | |||
const int *& | indices, | |||
const double *& | elements | |||
) | const |
Returns number of elements in a row and information in row.
int CoinBuild::currentRow | ( | double & | rowLower, | |
double & | rowUpper, | |||
const int *& | indices, | |||
const double *& | elements | |||
) | const |
Returns number of elements in current row and information in row Used as rows may be stored in a chain.
void CoinBuild::setCurrentRow | ( | int | whichRow | ) |
Set current row.
int CoinBuild::currentRow | ( | ) | const |
Returns current row number.
int CoinBuild::column | ( | int | whichColumn, | |
double & | columnLower, | |||
double & | columnUpper, | |||
double & | objectiveValue, | |||
const int *& | indices, | |||
const double *& | elements | |||
) | const |
Returns number of elements in a column and information in column.
int CoinBuild::currentColumn | ( | double & | columnLower, | |
double & | columnUpper, | |||
double & | objectiveValue, | |||
const int *& | indices, | |||
const double *& | elements | |||
) | const |
Returns number of elements in current column and information in column Used as columns may be stored in a chain.
void CoinBuild::setCurrentColumn | ( | int | whichColumn | ) |
Set current column.
int CoinBuild::currentColumn | ( | ) | const |
Returns current column number.
int CoinBuild::type | ( | ) | const [inline] |
Returns type.
Definition at line 80 of file CoinBuild.hpp.
void CoinBuild::setMutableCurrent | ( | int | which | ) | const [private] |
Set current.
void CoinBuild::addItem | ( | int | numberInItem, | |
const int * | indices, | |||
const double * | elements, | |||
double | itemLower, | |||
double | itemUpper, | |||
double | objectiveValue | |||
) | [private] |
add a item
int CoinBuild::item | ( | int | whichItem, | |
double & | itemLower, | |||
double & | itemUpper, | |||
double & | objectiveValue, | |||
const int *& | indices, | |||
const double *& | elements | |||
) | const [private] |
Returns number of elements in a item and information in item.
int CoinBuild::currentItem | ( | double & | itemLower, | |
double & | itemUpper, | |||
double & | objectiveValue, | |||
const int *& | indices, | |||
const double *& | elements | |||
) | const [private] |
Returns number of elements in current item and information in item Used as items may be stored in a chain.
void CoinBuild::setCurrentItem | ( | int | whichItem | ) | [private] |
Set current item.
int CoinBuild::currentItem | ( | ) | const [private] |
Returns current item number.
int CoinBuild::numberItems_ [private] |
Current number of items.
Definition at line 129 of file CoinBuild.hpp.
int CoinBuild::numberOther_ [private] |
Current number of other dimension i.e. Columns if addRow (i.e. max).
Definition at line 131 of file CoinBuild.hpp.
CoinBigIndex CoinBuild::numberElements_ [private] |
Current number of elements.
Definition at line 133 of file CoinBuild.hpp.
double* CoinBuild::currentItem_ [mutable, private] |
Current item pointer.
Definition at line 135 of file CoinBuild.hpp.
double* CoinBuild::firstItem_ [private] |
First item pointer.
Definition at line 137 of file CoinBuild.hpp.
double* CoinBuild::lastItem_ [private] |
Last item pointer.
Definition at line 139 of file CoinBuild.hpp.
int CoinBuild::type_ [private] |
Type of build - 0 for row, 1 for column, -1 unset.
Definition at line 141 of file CoinBuild.hpp.