#include <OsiCpxSolverInterface.hpp>
Inheritance diagram for OsiCpxSolverInterface:
CPLEX specific public interfaces | |
enum | keepCachedFlag { KEEPCACHED_NONE = 0, KEEPCACHED_COLUMN = 1, KEEPCACHED_ROW = 2, KEEPCACHED_MATRIX = 4, KEEPCACHED_RESULTS = 8, KEEPCACHED_PROBLEM = KEEPCACHED_COLUMN | KEEPCACHED_ROW | KEEPCACHED_MATRIX, KEEPCACHED_ALL = KEEPCACHED_PROBLEM | KEEPCACHED_RESULTS, FREECACHED_COLUMN = KEEPCACHED_PROBLEM & !KEEPCACHED_COLUMN, FREECACHED_ROW = KEEPCACHED_PROBLEM & !KEEPCACHED_ROW, FREECACHED_MATRIX = KEEPCACHED_PROBLEM & !KEEPCACHED_MATRIX, FREECACHED_RESULTS = KEEPCACHED_ALL & !KEEPCACHED_RESULTS } |
CPXLPptr | getLpPtr (int keepCached=KEEPCACHED_NONE) |
Public Types | |
Public Member Functions | |
virtual void | setObjSense (double s) |
Set objective function sense (1 for min (default), -1 for max,). | |
virtual void | setColSolution (const double *colsol) |
virtual void | setRowPrice (const double *rowprice) |
const char * | getCtype () const |
return a vector of variable types (continous, binary, integer) | |
Solve methods | |
virtual void | initialSolve () |
Solve initial LP relaxation. | |
virtual void | resolve () |
Resolve an LP relaxation after problem modification. | |
virtual void | branchAndBound () |
Invoke solver's built-in enumeration algorithm. | |
Parameter set/get methods | |
The set methods return true if the parameter was set to the given value, false otherwise. There can be various reasons for failure: the given parameter is not applicable for the solver (e.g., refactorization frequency for the volume algorithm), the parameter is not yet implemented for the solver or simply the value of the parameter is out of the range the solver accepts. If a parameter setting call returns false check the details of your solver.
The get methods return true if the given parameter is applicable for the solver and is implemented. In this case the value of the parameter is returned in the second argument. Otherwise they return false. | |
bool | setIntParam (OsiIntParam key, int value) |
bool | setDblParam (OsiDblParam key, double value) |
bool | setStrParam (OsiStrParam key, const std::string &value) |
bool | getIntParam (OsiIntParam key, int &value) const |
bool | getDblParam (OsiDblParam key, double &value) const |
bool | getStrParam (OsiStrParam key, std::string &value) const |
Methods returning info on how the solution process terminated | |
virtual bool | isAbandoned () const |
Are there a numerical difficulties? | |
virtual bool | isProvenOptimal () const |
Is optimality proven? | |
virtual bool | isProvenPrimalInfeasible () const |
Is primal infeasiblity proven? | |
virtual bool | isProvenDualInfeasible () const |
Is dual infeasiblity proven? | |
virtual bool | isPrimalObjectiveLimitReached () const |
Is the given primal objective limit reached? | |
virtual bool | isDualObjectiveLimitReached () const |
Is the given dual objective limit reached? | |
virtual bool | isIterationLimitReached () const |
Iteration limit reached? | |
WarmStart related methods | |
CoinWarmStart * | getEmptyWarmStart () const |
Get an empty warm start object. | |
virtual CoinWarmStart * | getWarmStart () const |
Get warmstarting information. | |
virtual bool | setWarmStart (const CoinWarmStart *warmstart) |
Hotstart related methods (primarily used in strong branching). <br> | |
The user can create a hotstart (a snapshot) of the optimization process then reoptimize over and over again always starting from there. NOTE: between hotstarted optimizations only bound changes are allowed. | |
virtual void | markHotStart () |
Create a hotstart point of the optimization process. | |
virtual void | solveFromHotStart () |
Optimize starting from the hotstart. | |
virtual void | unmarkHotStart () |
Delete the snapshot. | |
Methods related to querying the input data | |
virtual int | getNumCols () const |
Get number of columns. | |
virtual int | getNumRows () const |
Get number of rows. | |
virtual int | getNumElements () const |
Get number of nonzero elements. | |
virtual const double * | getColLower () const |
Get pointer to array[getNumCols()] of column lower bounds. | |
virtual const double * | getColUpper () const |
Get pointer to array[getNumCols()] of column upper bounds. | |
virtual const char * | getRowSense () const |
virtual const double * | getRightHandSide () const |
virtual const double * | getRowRange () const |
virtual const double * | getRowLower () const |
Get pointer to array[getNumRows()] of row lower bounds. | |
virtual const double * | getRowUpper () const |
Get pointer to array[getNumRows()] of row upper bounds. | |
virtual const double * | getObjCoefficients () const |
Get pointer to array[getNumCols()] of objective function coefficients. | |
virtual double | getObjSense () const |
Get objective function sense (1 for min (default), -1 for max). | |
virtual bool | isContinuous (int colNumber) const |
Return true if column is continuous. | |
virtual const CoinPackedMatrix * | getMatrixByRow () const |
Get pointer to row-wise copy of matrix. | |
virtual const CoinPackedMatrix * | getMatrixByCol () const |
Get pointer to column-wise copy of matrix. | |
virtual double | getInfinity () const |
Get solver's value for infinity. | |
Methods related to querying the solution | |
virtual const double * | getColSolution () const |
Get pointer to array[getNumCols()] of primal solution vector. | |
virtual const double * | getRowPrice () const |
Get pointer to array[getNumRows()] of dual prices. | |
virtual const double * | getReducedCost () const |
Get a pointer to array[getNumCols()] of reduced costs. | |
virtual const double * | getRowActivity () const |
virtual double | getObjValue () const |
Get objective function value. | |
virtual int | getIterationCount () const |
virtual std::vector< double * > | getDualRays (int maxNumRays) const |
virtual std::vector< double * > | getPrimalRays (int maxNumRays) const |
Changing bounds on variables and constraints | |
virtual void | setObjCoeff (int elementIndex, double elementValue) |
virtual void | setObjCoeffSet (const int *indexFirst, const int *indexLast, const double *coeffList) |
virtual void | setColLower (int elementIndex, double elementValue) |
virtual void | setColUpper (int elementIndex, double elementValue) |
virtual void | setColBounds (int elementIndex, double lower, double upper) |
virtual void | setColSetBounds (const int *indexFirst, const int *indexLast, const double *boundList) |
virtual void | setRowLower (int elementIndex, double elementValue) |
virtual void | setRowUpper (int elementIndex, double elementValue) |
virtual void | setRowBounds (int elementIndex, double lower, double upper) |
virtual void | setRowType (int index, char sense, double rightHandSide, double range) |
virtual void | setRowSetBounds (const int *indexFirst, const int *indexLast, const double *boundList) |
virtual void | setRowSetTypes (const int *indexFirst, const int *indexLast, const char *senseList, const double *rhsList, const double *rangeList) |
Integrality related changing methods | |
virtual void | setContinuous (int index) |
virtual void | setInteger (int index) |
virtual void | setContinuous (const int *indices, int len) |
virtual void | setInteger (const int *indices, int len) |
Methods to expand a problem.<br> | |
Note that if a column is added then by default it will correspond to a continuous variable. | |
virtual void | addCol (const CoinPackedVectorBase &vec, const double collb, const double colub, const double obj) |
virtual void | addCols (const int numcols, const CoinPackedVectorBase *const *cols, const double *collb, const double *colub, const double *obj) |
virtual void | deleteCols (const int num, const int *colIndices) |
virtual void | addRow (const CoinPackedVectorBase &vec, const double rowlb, const double rowub) |
virtual void | addRow (const CoinPackedVectorBase &vec, const char rowsen, const double rowrhs, const double rowrng) |
virtual void | addRows (const int numrows, const CoinPackedVectorBase *const *rows, const double *rowlb, const double *rowub) |
virtual void | addRows (const int numrows, const CoinPackedVectorBase *const *rows, const char *rowsen, const double *rowrhs, const double *rowrng) |
virtual void | deleteRows (const int num, const int *rowIndices) |
Methods to input a problem | |
virtual void | loadProblem (const CoinPackedMatrix &matrix, const double *collb, const double *colub, const double *obj, const double *rowlb, const double *rowub) |
virtual void | assignProblem (CoinPackedMatrix *&matrix, double *&collb, double *&colub, double *&obj, double *&rowlb, double *&rowub) |
virtual void | loadProblem (const CoinPackedMatrix &matrix, const double *collb, const double *colub, const double *obj, const char *rowsen, const double *rowrhs, const double *rowrng) |
virtual void | assignProblem (CoinPackedMatrix *&matrix, double *&collb, double *&colub, double *&obj, char *&rowsen, double *&rowrhs, double *&rowrng) |
virtual void | loadProblem (const int numcols, const int numrows, const int *start, const int *index, const double *value, const double *collb, const double *colub, const double *obj, const double *rowlb, const double *rowub) |
virtual void | loadProblem (const int numcols, const int numrows, const int *start, const int *index, const double *value, const double *collb, const double *colub, const double *obj, const char *rowsen, const double *rowrhs, const double *rowrng) |
virtual int | readMps (const char *filename, const char *extension="mps") |
virtual void | writeMps (const char *filename, const char *extension="mps", double objSense=0.0) const |
CPLEX specific public interfaces | |
CPXENVptr | getEnvironmentPtr () |
Method to access CPLEX environment pointer. | |
Constructors and destructor | |
OsiCpxSolverInterface () | |
Default Constructor. | |
virtual OsiSolverInterface * | clone (bool copyData=true) const |
Clone. | |
OsiCpxSolverInterface (const OsiCpxSolverInterface &) | |
Copy constructor. | |
OsiCpxSolverInterface & | operator= (const OsiCpxSolverInterface &rhs) |
Assignment operator. | |
virtual | ~OsiCpxSolverInterface () |
Destructor. | |
virtual void | reset () |
Resets as if default constructor. | |
Static Public Member Functions | |
Static instance counter methods | |
void | incrementInstanceCounter () |
void | decrementInstanceCounter () |
unsigned int | getNumInstances () |
Return the number of instances of instantiated objects using CPLEX services. | |
Protected Member Functions | |
Protected methods | |
virtual void | applyRowCut (const OsiRowCut &rc) |
Apply a row cut. Return true if cut was applied. | |
virtual void | applyColCut (const OsiColCut &cc) |
Private Member Functions | |
Private static class functions | |
void | switchToLP () |
switches CPLEX to prob type LP | |
void | switchToMIP () |
switches CPLEX to prob type MIP | |
void | resizeColType (int minsize) |
resizes coltype_ vector to be able to store at least minsize elements | |
void | freeColType () |
frees colsize_ vector | |
Private methods | |
CPXLPptr | getMutableLpPtr () const |
Get LP Pointer for const methods. | |
void | gutsOfCopy (const OsiCpxSolverInterface &source) |
The real work of a copy constructor (used by copy and assignment). | |
void | gutsOfConstructor () |
The real work of the constructor. | |
void | gutsOfDestructor () |
The real work of the destructor. | |
void | freeCachedColRim () |
free cached column rim vectors | |
void | freeCachedRowRim () |
free cached row rim vectors | |
void | freeCachedResults () |
free cached result vectors | |
void | freeCachedMatrix () |
free cached matrices | |
void | freeCachedData (int keepCached=KEEPCACHED_NONE) |
free all cached data (except specified entries, see getLpPtr()) | |
void | freeAllMemory () |
free all allocated memory | |
void | printBounds () |
Just for testing purposes. | |
Private Attributes | |
Private member data | |
CPXLPptr | lp_ |
CPLEX model represented by this class instance. | |
int * | hotStartCStat_ |
Hotstart information. | |
int | hotStartCStatSize_ |
int * | hotStartRStat_ |
int | hotStartRStatSize_ |
int | hotStartMaxIteration_ |
Cached information derived from the CPLEX model | |
double * | obj_ |
Pointer to objective vector. | |
double * | collower_ |
Pointer to dense vector of variable lower bounds. | |
double * | colupper_ |
Pointer to dense vector of variable lower bounds. | |
char * | rowsense_ |
Pointer to dense vector of row sense indicators. | |
double * | rhs_ |
Pointer to dense vector of row right-hand side values. | |
double * | rowrange_ |
Pointer to dense vector of slack upper bounds for range constraints (undefined for non-range rows). | |
double * | rowlower_ |
Pointer to dense vector of row lower bounds. | |
double * | rowupper_ |
Pointer to dense vector of row upper bounds. | |
double * | colsol_ |
Pointer to primal solution vector. | |
double * | rowsol_ |
Pointer to dual solution vector. | |
double * | redcost_ |
Pointer to reduced cost vector. | |
double * | rowact_ |
Pointer to row activity (slack) vector. | |
CoinPackedMatrix * | matrixByRow_ |
Pointer to row-wise copy of problem matrix coefficients. | |
CoinPackedMatrix * | matrixByCol_ |
Pointer to row-wise copy of problem matrix coefficients. | |
Additional information needed for storing MIP problems | |
char * | coltype_ |
Pointer to dense vector of variable types (continous, binary, integer). | |
int | coltypesize_ |
Size of allocated memory for coltype_. | |
bool | probtypemip_ |
Stores whether CPLEX' prob type is currently set to MIP. | |
Static Private Attributes | |
Private static class data | |
CPXENVptr | env_ = NULL |
CPLEX environment pointer. | |
int | cpxVersionMajor_ = 0 |
CPLEX version. | |
int | cpxVersionMinor_ = 0 |
int | cpxVersionMinorMinor_ = 0 |
unsigned int | numInstances_ = 0 |
Number of live problem instances. | |
Friends | |
void | OsiCpxSolverInterfaceUnitTest (const std::string &mpsDir, const std::string &netlibDir) |
Instantiation of OsiCpxSolverInterface for CPLEX
Definition at line 28 of file OsiCpxSolverInterface.hpp.
|
Get pointer to CPLEX model and free all specified cached data entries (combined with logical or-operator '|' ):
Definition at line 583 of file OsiCpxSolverInterface.hpp.
00584 { 00586 KEEPCACHED_NONE = 0, 00588 KEEPCACHED_COLUMN = 1, 00590 KEEPCACHED_ROW = 2, 00592 KEEPCACHED_MATRIX = 4, 00594 KEEPCACHED_RESULTS = 8, 00596 KEEPCACHED_PROBLEM = KEEPCACHED_COLUMN | KEEPCACHED_ROW | KEEPCACHED_MATRIX, 00598 KEEPCACHED_ALL = KEEPCACHED_PROBLEM | KEEPCACHED_RESULTS, 00600 FREECACHED_COLUMN = KEEPCACHED_PROBLEM & !KEEPCACHED_COLUMN, 00602 FREECACHED_ROW = KEEPCACHED_PROBLEM & !KEEPCACHED_ROW, 00604 FREECACHED_MATRIX = KEEPCACHED_PROBLEM & !KEEPCACHED_MATRIX, 00606 FREECACHED_RESULTS = KEEPCACHED_ALL & !KEEPCACHED_RESULTS 00607 }; |
|
Add a column (primal variable) to the problem. Implements OsiSolverInterface. Definition at line 1691 of file OsiCpxSolverInterface.cpp. References coltype_, coltypesize_, env_, CoinPackedVectorBase::getElements(), CoinPackedVectorBase::getIndices(), getNumCols(), CoinPackedVectorBase::getNumElements(), KEEPCACHED_ROW, and resizeColType().
01694 { 01695 debugMessage("OsiCpxSolverInterface::addCol(%p, %g, %g, %g)\n", &vec, collb, colub, obj); 01696 01697 int nc = getNumCols(); 01698 assert(coltypesize_ >= nc); 01699 01700 resizeColType(nc + 1); 01701 coltype_[nc] = 'C'; 01702 01703 int err; 01704 int cmatbeg[2] = {0, vec.getNumElements()}; 01705 01706 err = CPXaddcols( env_, getLpPtr( OsiCpxSolverInterface::KEEPCACHED_ROW ), 01707 1, vec.getNumElements(), const_cast<double*>(&obj), 01708 cmatbeg, 01709 const_cast<int*>(vec.getIndices()), 01710 const_cast<double*>(vec.getElements()), 01711 const_cast<double*>(&collb), 01712 const_cast<double*>(&colub), NULL ); 01713 checkCPXerror( err, "CPXaddcols", "addCol" ); 01714 } |
|
Add a set of columns (primal variables) to the problem. The default implementation simply makes repeated calls to addCol(). Reimplemented from OsiSolverInterface. Definition at line 1717 of file OsiCpxSolverInterface.cpp. References coltype_, coltypesize_, env_, CoinPackedVectorBase::getElements(), CoinPackedVectorBase::getIndices(), getNumCols(), CoinPackedVectorBase::getNumElements(), KEEPCACHED_ROW, and resizeColType(). Referenced by getDualRays().
01721 { 01722 debugMessage("OsiCpxSolverInterface::addCols(%d, %p, %p, %p, %p)\n", numcols, cols, collb, colub, obj); 01723 01724 int nc = getNumCols(); 01725 assert(coltypesize_ >= nc); 01726 01727 resizeColType(nc + numcols); 01728 CoinFillN(&coltype_[nc], numcols, 'C'); 01729 01730 int i; 01731 int nz = 0; 01732 for (i = 0; i < numcols; ++i) 01733 nz += cols[i]->getNumElements(); 01734 01735 int* index = new int[nz]; 01736 double* elem = new double[nz]; 01737 int* start = new int[numcols+1]; 01738 01739 nz = 0; 01740 start[0] = 0; 01741 for (i = 0; i < numcols; ++i) { 01742 const CoinPackedVectorBase* col = cols[i]; 01743 const int len = col->getNumElements(); 01744 CoinDisjointCopyN(col->getIndices(), len, index+nz); 01745 CoinDisjointCopyN(col->getElements(), len, elem+nz); 01746 nz += len; 01747 start[i+1] = nz; 01748 } 01749 int err = CPXaddcols(env_, getLpPtr(OsiCpxSolverInterface::KEEPCACHED_ROW), 01750 numcols, nz, const_cast<double*>(obj), 01751 start, index, elem, 01752 const_cast<double*>(collb), 01753 const_cast<double*>(colub), NULL ); 01754 checkCPXerror( err, "CPXaddcols", "addCols" ); 01755 01756 delete[] start; 01757 delete[] elem; 01758 delete[] index; 01759 01760 // int i; 01761 // for( i = 0; i < numcols; ++i ) 01762 // addCol( *(cols[i]), collb[i], colub[i], obj[i] ); 01763 } |
|
Add a row (constraint) to the problem. Implements OsiSolverInterface. Definition at line 1791 of file OsiCpxSolverInterface.cpp. References OsiSolverInterface::convertBoundToSense(). Referenced by addRows().
01793 { 01794 debugMessage("OsiCpxSolverInterface::addRow(%p, %g, %g)\n", &vec, rowlb, rowub); 01795 01796 char sense; 01797 double rhs, range; 01798 01799 convertBoundToSense( rowlb, rowub, sense, rhs, range ); 01800 addRow( vec, sense, rhs, range ); 01801 } |
|
Add a set of rows (constraints) to the problem. The default implementation simply makes repeated calls to addRow(). Reimplemented from OsiSolverInterface. Definition at line 1863 of file OsiCpxSolverInterface.cpp. References addRow().
01867 { 01868 debugMessage("OsiCpxSolverInterface::addRows(%d, %p, %p, %p, %p)\n", numrows, rows, rowsen, rowrhs, rowrng); 01869 01870 int i; 01871 01872 for( i = 0; i < numrows; ++i ) 01873 addRow( *(rows[i]), rowsen[i], rowrhs[i], rowrng[i] ); 01874 } |
|
Add a set of rows (constraints) to the problem. The default implementation simply makes repeated calls to addRow(). Reimplemented from OsiSolverInterface. Definition at line 1850 of file OsiCpxSolverInterface.cpp. References addRow().
01853 { 01854 debugMessage("OsiCpxSolverInterface::addRows(%d, %p, %p, %p)\n", numrows, rows, rowlb, rowub); 01855 01856 int i; 01857 01858 for( i = 0; i < numrows; ++i ) 01859 addRow( *(rows[i]), rowlb[i], rowub[i] ); 01860 } |
|
Apply a column cut (bound adjustment). Return true if cut was applied. Implements OsiSolverInterface. Definition at line 2467 of file OsiCpxSolverInterface.cpp. References getColLower(), getColUpper(), CoinPackedVector::getElements(), CoinPackedVector::getIndices(), CoinPackedVector::getNumElements(), OsiColCut::lbs(), setColLower(), setColUpper(), and OsiColCut::ubs().
02468 { 02469 debugMessage("OsiCpxSolverInterface::applyColCut(%p)\n", &cc); 02470 02471 const double * cplexColLB = getColLower(); 02472 const double * cplexColUB = getColUpper(); 02473 const CoinPackedVector & lbs = cc.lbs(); 02474 const CoinPackedVector & ubs = cc.ubs(); 02475 int i; 02476 02477 for( i = 0; i < lbs.getNumElements(); ++i ) 02478 if ( lbs.getElements()[i] > cplexColLB[lbs.getIndices()[i]] ) 02479 setColLower( lbs.getIndices()[i], lbs.getElements()[i] ); 02480 for( i = 0; i < ubs.getNumElements(); ++i ) 02481 if ( ubs.getElements()[i] < cplexColUB[ubs.getIndices()[i]] ) 02482 setColUpper( ubs.getIndices()[i], ubs.getElements()[i] ); 02483 } |
|
Load in an problem by assuming ownership of the arguments (the constraints on the rows are given by sense/rhs/range triplets). For default values see the previous method. Implements OsiSolverInterface. Definition at line 2080 of file OsiCpxSolverInterface.cpp. References loadProblem().
02085 { 02086 debugMessage("OsiCpxSolverInterface::assignProblem()\n"); 02087 02088 loadProblem( *matrix, collb, colub, obj, rowsen, rowrhs, rowrng ); 02089 delete matrix; matrix = 0; 02090 delete[] collb; collb = 0; 02091 delete[] colub; colub = 0; 02092 delete[] obj; obj = 0; 02093 delete[] rowsen; rowsen = 0; 02094 delete[] rowrhs; rowrhs = 0; 02095 delete[] rowrng; rowrng = 0; 02096 } |
|
Load in an problem by assuming ownership of the arguments (the constraints on the rows are given by lower and upper bounds). For default values see the previous method. Implements OsiSolverInterface. Definition at line 1929 of file OsiCpxSolverInterface.cpp. References loadProblem().
01933 { 01934 debugMessage("OsiCpxSolverInterface::assignProblem()\n"); 01935 01936 loadProblem( *matrix, collb, colub, obj, rowlb, rowub ); 01937 delete matrix; matrix = 0; 01938 delete[] collb; collb = 0; 01939 delete[] colub; colub = 0; 01940 delete[] obj; obj = 0; 01941 delete[] rowlb; rowlb = 0; 01942 delete[] rowub; rowub = 0; 01943 } |
|
CPLEX has a context which should be deleted after CPLEX calls. This method:
Definition at line 2328 of file OsiCpxSolverInterface.cpp. References env_, and numInstances_. Referenced by ~OsiCpxSolverInterface().
02329 { 02330 assert( numInstances_ != 0 ); 02331 numInstances_--; 02332 if ( numInstances_ == 0 ) 02333 { 02334 int err = CPXcloseCPLEX( &env_ ); 02335 checkCPXerror( err, "CPXcloseCPLEX", "decrementInstanceCounter" ); 02336 env_ = NULL; 02337 } 02338 } |
|
Remove a set of columns (primal variables) from the problem. Implements OsiSolverInterface. Definition at line 1766 of file OsiCpxSolverInterface.cpp. References coltype_, env_, getNumCols(), and KEEPCACHED_ROW.
01767 { 01768 debugMessage("OsiCpxSolverInterface::deleteCols(%d, %p)\n", num, columnIndices); 01769 01770 int ncols = getNumCols(); 01771 int *delstat = new int[ncols]; 01772 int i, err; 01773 01774 CoinFillN(delstat, ncols, 0); 01775 for( i = 0; i < num; ++i ) 01776 delstat[columnIndices[i]] = 1; 01777 err = CPXdelsetcols( env_, getLpPtr( OsiCpxSolverInterface::KEEPCACHED_ROW ), delstat ); 01778 checkCPXerror( err, "CPXdelsetcols", "deleteCols" ); 01779 01780 for( i = 0; i < ncols; ++i ) 01781 { 01782 assert(delstat[i] <= i); 01783 if( delstat[i] != -1 ) 01784 coltype_[delstat[i]] = coltype_[i]; 01785 } 01786 01787 delete[] delstat; 01788 } |
|
Delete a set of rows (constraints) from the problem. Implements OsiSolverInterface. Definition at line 1877 of file OsiCpxSolverInterface.cpp. References env_, getNumRows(), and KEEPCACHED_COLUMN.
01878 { 01879 debugMessage("OsiCpxSolverInterface::deleteRows(%d, %p)\n", num, rowIndices); 01880 01881 int nrows = getNumRows(); 01882 int *delstat = new int[nrows]; 01883 int i, err; 01884 01885 CoinFillN( delstat, nrows, 0 ); 01886 for( i = 0; i < num; ++i ) 01887 delstat[rowIndices[i]] = 1; 01888 err = CPXdelsetrows( env_, getLpPtr( OsiCpxSolverInterface::KEEPCACHED_COLUMN ), delstat ); 01889 checkCPXerror( err, "CPXdelsetrows", "deleteRows" ); 01890 delete[] delstat; 01891 } |
|
Get as many dual rays as the solver can provide. (In case of proven primal infeasibility there should be at least one.)
NOTE for implementers of solver interfaces:
NOTE for users of solver interfaces: Implements OsiSolverInterface. Definition at line 1229 of file OsiCpxSolverInterface.cpp. References addCols(), getInfinity(), getNumCols(), getNumRows(), getRowPrice(), getRowSense(), initialSolve(), setObjCoeffSet(), and setObjSense().
01230 { 01231 debugMessage("OsiCpxSolverInterface::getDualRays(%d)\n", maxNumRays); 01232 01233 OsiCpxSolverInterface solver(*this); 01234 01235 const int numcols = getNumCols(); 01236 const int numrows = getNumRows(); 01237 int* index = new int[CoinMax(numcols,numrows)]; 01238 int i; 01239 for ( i = CoinMax(numcols,numrows)-1; i >= 0; --i) { 01240 index[i] = i; 01241 } 01242 double* obj = new double[CoinMax(numcols,2*numrows)]; 01243 CoinFillN(obj, numcols, 0.0); 01244 solver.setObjCoeffSet(index, index+numcols, obj); 01245 01246 double* clb = new double[2*numrows]; 01247 double* cub = new double[2*numrows]; 01248 01249 const double plusone = 1.0; 01250 const double minusone = -1.0; 01251 const char* sense = getRowSense(); 01252 01253 const CoinPackedVectorBase** cols = 01254 new const CoinPackedVectorBase*[2*numrows]; 01255 int newcols = 0; 01256 for (i = 0; i < numrows; ++i) { 01257 switch (sense[i]) { 01258 case 'L': 01259 cols[newcols++] = 01260 new CoinShallowPackedVector(1, &index[i], &minusone, false); 01261 break; 01262 case 'G': 01263 cols[newcols++] = 01264 new CoinShallowPackedVector(1, &index[i], &plusone, false); 01265 break; 01266 case 'R': 01267 cols[newcols++] = 01268 new CoinShallowPackedVector(1, &index[i], &minusone, false); 01269 cols[newcols++] = 01270 new CoinShallowPackedVector(1, &index[i], &plusone, false); 01271 break; 01272 case 'N': 01273 break; 01274 } 01275 } 01276 01277 CoinFillN(obj, newcols, 1.0); 01278 CoinFillN(clb, newcols, 0.0); 01279 CoinFillN(cub, newcols, getInfinity()); 01280 01281 solver.addCols(newcols, cols, clb, cub, obj+numcols); 01282 delete[] index; 01283 delete[] cols; 01284 delete[] clb; 01285 delete[] cub; 01286 delete[] obj; 01287 01288 solver.setObjSense(1.0); // minimize 01289 solver.initialSolve(); 01290 01291 const double* solverpi = getRowPrice(); 01292 double* pi = new double[numrows]; 01293 for ( i = numrows - 1; i >= 0; --i) { 01294 pi[i] = -solverpi[i]; 01295 } 01296 return std::vector<double*>(1, pi); 01297 } |
|
Get an empty warm start object. This routine returns an empty CoinWarmStartBasis object. Its purpose is to provide a way to give a client a warm start basis object of the appropriate type, which can resized and modified as desired. Implements OsiSolverInterface. Definition at line 105 of file OsiCpxSolverInterface.hpp.
00106 { return (dynamic_cast<CoinWarmStart *>(new CoinWarmStartBasis())) ; } |
|
Get how many iterations it took to solve the problem (whatever "iteration" mean to the solver. Implements OsiSolverInterface. Definition at line 1222 of file OsiCpxSolverInterface.cpp. References env_, and getMutableLpPtr().
01223 { 01224 debugMessage("OsiCpxSolverInterface::getIterationCount()\n"); 01225 01226 return CPXgetitcnt( env_, getMutableLpPtr() ); 01227 } |
|
Get as many primal rays as the solver can provide. (In case of proven dual infeasibility there should be at least one.)
NOTE for implementers of solver interfaces:
NOTE for users of solver interfaces: Implements OsiSolverInterface. Definition at line 1300 of file OsiCpxSolverInterface.cpp.
01301 { 01302 debugMessage("OsiCpxSolverInterface::getPrimalRays(%d)\n", maxNumRays); 01303 01304 // *FIXME* : must write the method -LL 01305 throw CoinError("method is not yet written", "getPrimalRays", 01306 "OsiCpxSolverInterface"); 01307 return std::vector<double*>(); 01308 } |
|
Get pointer to array[getNumRows()] of rows right-hand sides
Implements OsiSolverInterface. Definition at line 823 of file OsiCpxSolverInterface.cpp. References env_, getInfinity(), getMutableLpPtr(), getNumRows(), rhs_, rowrange_, and rowsense_. Referenced by getRowActivity(), getRowLower(), getRowRange(), getRowSense(), getRowUpper(), gutsOfCopy(), printBounds(), setRowLower(), and setRowUpper().
00824 { 00825 debugMessage("OsiCpxSolverInterface::getRightHandSide()\n"); 00826 00827 if ( rhs_==NULL ) 00828 { 00829 CPXLPptr lp = getMutableLpPtr(); 00830 int nrows = getNumRows(); 00831 if( nrows > 0 ) 00832 { 00833 rhs_ = new double[nrows]; 00834 CPXgetrhs( env_, lp, rhs_, 0, nrows-1 ); 00835 00836 assert( rowrange_ == NULL ); 00837 rowrange_ = new double[nrows]; 00838 CPXgetrngval( env_, lp, rowrange_, 0, nrows-1 ); 00839 00840 assert( rowsense_ == NULL ); 00841 rowsense_ = new char[nrows]; 00842 CPXgetsense( env_, lp, rowsense_, 0, nrows-1 ); 00843 00844 double inf = getInfinity(); 00845 int i; 00846 for ( i = 0; i < nrows; ++i ) 00847 { 00848 if ( rowsense_[i] != 'R' ) 00849 rowrange_[i]=0.0; 00850 else 00851 { 00852 if ( rhs_[i] <= -inf ) 00853 { 00854 rowsense_[i] = 'N'; 00855 rowrange_[i] = 0.0; 00856 rhs_[i] = 0.0; 00857 } 00858 else 00859 { 00860 if( rowrange_[i] >= 0.0 ) 00861 rhs_[i] = rhs_[i] + rowrange_[i]; 00862 else 00863 rowrange_[i] = -rowrange_[i]; 00864 } 00865 } 00866 } 00867 } 00868 } 00869 return rhs_; 00870 } |
|
Get pointer to array[getNumRows()] of row activity levels (constraint matrix times the solution vector Implements OsiSolverInterface. Definition at line 1153 of file OsiCpxSolverInterface.cpp. References env_, getMutableLpPtr(), getNumRows(), getRightHandSide(), probtypemip_, and rowact_.
01154 { 01155 debugMessage("OsiCpxSolverInterface::getRowActivity()\n"); 01156 01157 if( rowact_==NULL ) 01158 { 01159 int nrows = getNumRows(); 01160 if( nrows > 0 ) 01161 { 01162 rowact_ = new double[nrows]; 01163 if( probtypemip_ ) 01164 { 01165 double *rowslack = new double[nrows]; 01166 int err = CPXgetmipslack( env_, getMutableLpPtr(), rowslack, 0, nrows-1 ); 01167 if ( err == CPXERR_NO_SOLN || err == CPXERR_NO_INT_SOLN ) 01168 CoinFillN( rowact_, nrows, 0.0 ); 01169 else 01170 { 01171 checkCPXerror( err, "CPXgetmipslack", "getRowActivity" ); 01172 for( int r = 0; r < nrows; ++r ) 01173 rowact_[r] = getRightHandSide()[r] + rowslack[r]; 01174 } 01175 delete [] rowslack; 01176 } 01177 else 01178 { 01179 int err = CPXgetax( env_, getMutableLpPtr(), rowact_, 0, nrows-1 ); 01180 if ( err == CPXERR_NO_SOLN ) 01181 CoinFillN( rowact_, nrows, 0.0 ); 01182 else 01183 checkCPXerror( err, "CPXgetax", "getRowActivity" ); 01184 } 01185 } 01186 } 01187 return rowact_; 01188 } |
|
Get pointer to array[getNumRows()] of row ranges.
Implements OsiSolverInterface. Definition at line 872 of file OsiCpxSolverInterface.cpp. References getNumRows(), getRightHandSide(), and rowrange_. Referenced by getRowLower(), getRowUpper(), gutsOfCopy(), printBounds(), setRowLower(), and setRowUpper().
00873 { 00874 debugMessage("OsiCpxSolverInterface::getRowRange()\n"); 00875 00876 if ( rowrange_==NULL ) 00877 { 00878 // rowrange is determined with rhs, so invoke rhs 00879 getRightHandSide(); 00880 assert( rowrange_!=NULL || getNumRows() == 0 ); 00881 } 00882 return rowrange_; 00883 } |
|
Get pointer to array[getNumRows()] of row constraint senses.
Implements OsiSolverInterface. Definition at line 810 of file OsiCpxSolverInterface.cpp. References getNumRows(), getRightHandSide(), and rowsense_. Referenced by getDualRays(), getRowLower(), getRowUpper(), gutsOfCopy(), printBounds(), setRowLower(), and setRowUpper().
00811 { 00812 debugMessage("OsiCpxSolverInterface::getRowSense()\n"); 00813 00814 if ( rowsense_==NULL ) 00815 { 00816 // rowsense is determined with rhs, so invoke rhs 00817 getRightHandSide(); 00818 assert( rowsense_!=NULL || getNumRows() == 0 ); 00819 } 00820 return rowsense_; 00821 } |
|
CPLEX has a context which must be created prior to all other CPLEX calls. This method:
Definition at line 2299 of file OsiCpxSolverInterface.cpp. References cpxVersionMajor_, env_, and numInstances_. Referenced by OsiCpxSolverInterface().
02300 { 02301 if ( numInstances_ == 0 ) 02302 { 02303 int err; 02304 02305 #if CPX_VERSION >= 800 02306 env_ = CPXopenCPLEX( &err ); 02307 #else 02308 env_ = CPXopenCPLEXdevelop( &err ); 02309 #endif 02310 02311 checkCPXerror( err, "CPXopenCPLEXdevelop", "incrementInstanceCounter" ); 02312 assert( env_ != NULL ); 02313 #ifndef NDEBUG 02314 CPXsetintparam( env_, CPX_PARAM_SCRIND, CPX_ON ); // for testing purposes 02315 #endif 02316 //char logfileName[]="cplex.log"; 02317 //char filemode[]="a+"; 02318 //CPXFILEptr fp = CPXfopen( logfileName, filemode ); 02319 //CPXsetlogfile( env_, fp ); 02320 err = sscanf( CPXversion( env_ ), "%d.%d.%d", &cpxVersionMajor_, &cpxVersionMinor_, &cpxVersionMinorMinor_ ); 02321 assert( err == 3 ); 02322 } 02323 numInstances_++; 02324 } |
|
Just like the other loadProblem() methods except that the matrix is given in a standard column major ordered format (without gaps). Implements OsiSolverInterface. Definition at line 2133 of file OsiCpxSolverInterface.cpp. References coltype_, env_, getInfinity(), getMutableLpPtr(), gutsOfDestructor(), and resizeColType().
02140 { 02141 debugMessage("OsiCpxSolverInterface::loadProblem(%d, %d, %p, %p, %p, %p, %p, %p, %p, %p, %p)\n", 02142 numcols, numrows, start, index, value, collb, colub, obj, rowsen, rowrhs, rowrng); 02143 02144 const int nc = numcols; 02145 const int nr = numrows; 02146 02147 if( nr == 0 || nc == 0 ) { 02148 // empty LP? -> kill old LP 02149 gutsOfDestructor(); 02150 return; 02151 } 02152 02153 assert( rowsen != NULL ); 02154 assert( rowrhs != NULL ); 02155 02156 int i; 02157 02158 // Set column values to defaults if NULL pointer passed 02159 int * len = new int[nc]; 02160 double * clb = new double[nc]; 02161 double * cub = new double[nc]; 02162 double * ob = new double[nc]; 02163 double * rr = new double[nr]; 02164 double * rhs = new double[nr]; 02165 char * sen = new char[nr]; 02166 02167 for (i = 0; i < nc; ++i) { 02168 len[i] = start[i+1] - start[i]; 02169 } 02170 02171 if ( collb != NULL ) 02172 CoinDisjointCopyN(collb, nc, clb); 02173 else 02174 CoinFillN(clb, nc, 0.0); 02175 02176 if ( colub!=NULL ) 02177 CoinDisjointCopyN(colub, nc, cub); 02178 else 02179 CoinFillN(cub, nc, getInfinity()); 02180 02181 if ( obj!=NULL ) 02182 CoinDisjointCopyN(obj, nc, ob); 02183 else 02184 CoinFillN(ob, nc, 0.0); 02185 02186 if ( rowrng != NULL ) { 02187 for ( i=0; i<nr; i++ ) { 02188 if (rowsen[i] == 'R') { 02189 if ( rowrng[i] >= 0 ) { 02190 rhs[i] = rowrhs[i] - rowrng[i]; 02191 rr[i] = rowrng[i]; 02192 } else { 02193 rhs[i] = rowrhs[i]; 02194 rr[i] = -rowrng[i]; 02195 } 02196 } else { 02197 rhs[i] = rowrhs[i]; 02198 rr[i] = 0.0; 02199 } 02200 } 02201 } else { 02202 CoinDisjointCopyN(rowrhs, nr, rhs); 02203 } 02204 02205 CoinDisjointCopyN(rowsen, nr, sen); 02206 02207 int objDirection = CPXgetobjsen( env_, getMutableLpPtr() ); 02208 02209 int err = CPXcopylp( env_, getLpPtr(), 02210 nc, nr, 02211 // Leave ObjSense alone(set to current value). 02212 objDirection, ob, rhs, sen, 02213 const_cast<int *>(start), 02214 len, const_cast<int *>(index), 02215 const_cast<double *>(value), 02216 clb, cub, rr); 02217 02218 checkCPXerror( err, "CPXcopylp", "loadProblem" ); 02219 02220 delete[] len; 02221 delete[] clb; 02222 delete[] cub; 02223 delete[] ob; 02224 delete[] rr; 02225 delete[] rhs; 02226 delete[] sen; 02227 02228 resizeColType(nc); 02229 CoinFillN(coltype_, nc, 'C'); 02230 } |
|
Just like the other loadProblem() methods except that the matrix is given in a standard column major ordered format (without gaps). Implements OsiSolverInterface. Definition at line 2101 of file OsiCpxSolverInterface.cpp. References OsiSolverInterface::convertBoundToSense(), getInfinity(), and loadProblem().
02107 { 02108 debugMessage("OsiCpxSolverInterface::loadProblem()\n"); 02109 02110 const double inf = getInfinity(); 02111 02112 char * rowSense = new char [numrows]; 02113 double * rowRhs = new double[numrows]; 02114 double * rowRange = new double[numrows]; 02115 02116 for ( int i = numrows - 1; i >= 0; --i ) { 02117 const double lower = rowlb ? rowlb[i] : -inf; 02118 const double upper = rowub ? rowub[i] : inf; 02119 convertBoundToSense( lower, upper, rowSense[i], rowRhs[i], rowRange[i] ); 02120 } 02121 02122 loadProblem(numcols, numrows, start, index, value, collb, colub, obj, 02123 rowSense, rowRhs, rowRange); 02124 delete [] rowSense; 02125 delete [] rowRhs; 02126 delete [] rowRange; 02127 02128 } |
|
Load in an problem by copying the arguments (the constraints on the rows are given by sense/rhs/range triplets). If a pointer is 0 then the following values are the default:
Implements OsiSolverInterface. Definition at line 1948 of file OsiCpxSolverInterface.cpp. References coltype_, env_, getInfinity(), getMutableLpPtr(), gutsOfDestructor(), and resizeColType().
01953 { 01954 debugMessage("OsiCpxSolverInterface::loadProblem(%p, %p, %p, %p, %p, %p, %p)\n", 01955 &matrix, collb, colub, obj, rowsen, rowrhs, rowrng); 01956 01957 int nc=matrix.getNumCols(); 01958 int nr=matrix.getNumRows(); 01959 01960 if( nr == 0 || nc == 0 ) // empty LP? 01961 gutsOfDestructor(); // -> kill old LP 01962 else 01963 { 01964 assert( rowsen != NULL ); 01965 assert( rowrhs != NULL ); 01966 01967 int i; 01968 01969 // Set column values to defaults if NULL pointer passed 01970 double * clb; 01971 double * cub; 01972 double * ob; 01973 double * rr = NULL; 01974 double * rhs; 01975 if ( collb!=NULL ) 01976 clb=const_cast<double*>(collb); 01977 else 01978 { 01979 clb = new double[nc]; 01980 CoinFillN(clb, nc, 0.0); 01981 } 01982 if ( colub!=NULL ) 01983 cub=const_cast<double*>(colub); 01984 else 01985 { 01986 cub = new double[nc]; 01987 CoinFillN(cub, nc, getInfinity()); 01988 } 01989 if ( obj!=NULL ) 01990 ob=const_cast<double*>(obj); 01991 else 01992 { 01993 ob = new double[nc]; 01994 CoinFillN(ob, nc, 0.0); 01995 } 01996 if ( rowrng != NULL ) 01997 { 01998 rhs = new double[nr]; 01999 rr = new double[nr]; 02000 for ( i=0; i<nr; i++ ) 02001 { 02002 if (rowsen[i] == 'R') 02003 { 02004 if( rowrng[i] >= 0 ) 02005 { 02006 rhs[i] = rowrhs[i] - rowrng[i]; 02007 rr[i] = rowrng[i]; 02008 } 02009 else 02010 { 02011 rhs[i] = rowrhs[i]; 02012 rr[i] = -rowrng[i]; 02013 } 02014 } 02015 else 02016 { 02017 rhs[i] = rowrhs[i]; 02018 rr[i] = 0.0; 02019 } 02020 } 02021 } 02022 else 02023 rhs = const_cast<double*>(rowrhs); 02024 02025 bool freeMatrixRequired = false; 02026 CoinPackedMatrix * m = NULL; 02027 if ( !matrix.isColOrdered() ) 02028 { 02029 m = new CoinPackedMatrix(); 02030 m->reverseOrderedCopyOf(matrix); 02031 freeMatrixRequired = true; 02032 } 02033 else 02034 m = const_cast<CoinPackedMatrix *>(&matrix); 02035 02036 assert( nc == m->getNumCols() ); 02037 assert( nr == m->getNumRows() ); 02038 assert( m->isColOrdered() ); 02039 02040 int objDirection = CPXgetobjsen( env_, getMutableLpPtr() ); 02041 02042 int err = CPXcopylp( env_, getLpPtr(), 02043 nc, nr, 02044 // Leave ObjSense alone(set to current value). 02045 objDirection, 02046 ob, 02047 rhs, 02048 const_cast<char *>(rowsen), 02049 const_cast<int *>(m->getVectorStarts()), 02050 const_cast<int *>(m->getVectorLengths()), 02051 const_cast<int *>(m->getIndices()), 02052 const_cast<double *>(m->getElements()), 02053 const_cast<double *>(clb), 02054 const_cast<double *>(cub), 02055 rr ); 02056 checkCPXerror( err, "CPXcopylp", "loadProblem" ); 02057 02058 if ( collb == NULL ) 02059 delete[] clb; 02060 if ( colub == NULL ) 02061 delete[] cub; 02062 if ( obj == NULL ) 02063 delete[] ob; 02064 if ( rowrng != NULL ) { 02065 delete[] rr; 02066 delete[] rhs; 02067 } 02068 02069 if ( freeMatrixRequired ) 02070 delete m; 02071 02072 resizeColType(nc); 02073 CoinFillN(coltype_, nc, 'C'); 02074 } 02075 } |
|
Load in an problem by copying the arguments (the constraints on the rows are given by lower and upper bounds). If a pointer is 0 then the following values are the default:
Implements OsiSolverInterface. Definition at line 1898 of file OsiCpxSolverInterface.cpp. References OsiSolverInterface::convertBoundToSense(), and getInfinity(). Referenced by assignProblem(), gutsOfCopy(), and loadProblem().
01902 { 01903 debugMessage("OsiCpxSolverInterface::loadProblem(%p, %p, %p, %p, %p, %p)\n", &matrix, collb, colub, obj, rowlb, rowub); 01904 01905 const double inf = getInfinity(); 01906 01907 int nrows = matrix.getNumRows(); 01908 char * rowSense = new char [nrows]; 01909 double * rowRhs = new double[nrows]; 01910 double * rowRange = new double[nrows]; 01911 01912 int i; 01913 for ( i = nrows - 1; i >= 0; --i ) 01914 { 01915 const double lower = rowlb ? rowlb[i] : -inf; 01916 const double upper = rowub ? rowub[i] : inf; 01917 convertBoundToSense( lower, upper, rowSense[i], rowRhs[i], rowRange[i] ); 01918 } 01919 01920 loadProblem( matrix, collb, colub, obj, rowSense, rowRhs, rowRange ); 01921 delete [] rowSense; 01922 delete [] rowRhs; 01923 delete [] rowRange; 01924 } |
|
Read an mps file from the given filename Reimplemented from OsiSolverInterface. Definition at line 2235 of file OsiCpxSolverInterface.cpp. References env_, and OsiSolverInterface::readMps().
02237 { 02238 debugMessage("OsiCpxSolverInterface::readMps(%s, %s)\n", filename, extension); 02239 02240 #if 0 02241 std::string f(filename); 02242 std::string e(extension); 02243 std::string fullname = f + "." + e; 02244 int err = CPXreadcopyprob( env_, getLpPtr(), const_cast<char*>( fullname.c_str() ), NULL ); 02245 checkCPXerror( err, "CPXreadcopyprob", "readMps" ); 02246 #endif 02247 // just call base class method 02248 return OsiSolverInterface::readMps(filename,extension); 02249 } |
|
Set a single column lower and upper bound Reimplemented from OsiSolverInterface. Definition at line 1354 of file OsiCpxSolverInterface.cpp. References env_, and FREECACHED_COLUMN.
01355 { 01356 debugMessage("OsiCpxSolverInterface::setColBounds(%d, %g, %g)\n", elementIndex, lower, upper); 01357 01358 char c[2] = { 'L', 'U' }; 01359 int ind[2]; 01360 double bd[2]; 01361 int err; 01362 01363 ind[0] = elementIndex; 01364 ind[1] = elementIndex; 01365 bd[0] = lower; 01366 bd[1] = upper; 01367 err = CPXchgbds( env_, getLpPtr( OsiCpxSolverInterface::FREECACHED_COLUMN ), 2, ind, c, bd ); 01368 checkCPXerror( err, "CPXchgbds", "setColBounds" ); 01369 } |
|
Set a single column lower bound Implements OsiSolverInterface. Definition at line 1336 of file OsiCpxSolverInterface.cpp. References env_, and FREECACHED_COLUMN. Referenced by applyColCut().
01337 { 01338 debugMessage("OsiCpxSolverInterface::setColLower(%d, %g)\n", elementIndex, elementValue); 01339 01340 char c = 'L'; 01341 int err = CPXchgbds( env_, getLpPtr( OsiCpxSolverInterface::FREECACHED_COLUMN ), 1, &elementIndex, &c, &elementValue ); 01342 checkCPXerror( err, "CPXchgbds", "setColLower" ); 01343 } |
|
Set the bounds on a number of columns simultaneously
Reimplemented from OsiSolverInterface. Definition at line 1371 of file OsiCpxSolverInterface.cpp. References env_, and FREECACHED_COLUMN.
01374 { 01375 debugMessage("OsiCpxSolverInterface::setColSetBounds(%p, %p, %p)\n", indexFirst, indexLast, boundList); 01376 01377 const int cnt = indexLast - indexFirst; 01378 if (cnt <= 0) 01379 return; 01380 01381 char* c = new char[2*cnt]; 01382 int* ind = new int[2*cnt]; 01383 for (int i = 0; i < cnt; ++i) { 01384 register const int j = 2 * i; 01385 c[j] = 'L'; 01386 c[j+1] = 'U'; 01387 ind[j] = indexFirst[i]; 01388 ind[j+1] = indexFirst[i]; 01389 } 01390 int err = CPXchgbds( env_, 01391 getLpPtr(OsiCpxSolverInterface::FREECACHED_COLUMN), 01392 2*cnt, ind, c, const_cast<double*>(boundList) ); 01393 checkCPXerror( err, "CPXchgbds", "setColSetBounds" ); 01394 delete[] ind; 01395 delete[] c; 01396 // OsiSolverInterface::setColSetBounds( indexFirst, indexLast, boundList ); 01397 } |
|
Set the primal solution column values colsol[numcols()] is an array of values of the problem column variables. These values are copied to memory owned by the solver object or the solver. They will be returned as the result of colsol() until changed by another call to setColsol() or by a call to any solver routine. Whether the solver makes use of the solution in any way is solver-dependent. Implements OsiSolverInterface. Definition at line 1626 of file OsiCpxSolverInterface.cpp. References colsol_, cpxVersionMajor_, env_, freeCachedResults(), getMutableLpPtr(), getNumCols(), and rowsol_. Referenced by gutsOfCopy().
01627 { 01628 debugMessage("OsiCpxSolverInterface::setColSolution(%p)\n", cs); 01629 01630 int nc = getNumCols(); 01631 01632 if( cs == NULL ) 01633 freeCachedResults(); 01634 else if( nc > 0 ) 01635 { 01636 // If colsol isn't allocated, then allocate it 01637 if ( colsol_ == NULL ) 01638 colsol_ = new double[nc]; 01639 01640 // Copy in new col solution. 01641 CoinDisjointCopyN( cs, nc, colsol_ ); 01642 01643 // CPLEX < 7.0 doesn't support setting a col solution without a row solution 01644 // -> if a row solution exists or CPLEX version >= 7, then pass into CPLEX 01645 if ( rowsol_ != NULL || cpxVersionMajor_ >= 7 ) 01646 { 01647 int err = CPXcopystart( env_, getMutableLpPtr(), NULL, NULL, 01648 const_cast<double*>( colsol_ ), 01649 const_cast<double*>( rowsol_ ), 01650 NULL, NULL ); 01651 checkCPXerror( err, "CPXcopystart", "setColSolution" ); 01652 } 01653 } 01654 } |
|
Set a single column upper bound Implements OsiSolverInterface. Definition at line 1345 of file OsiCpxSolverInterface.cpp. References env_, and FREECACHED_COLUMN. Referenced by applyColCut().
01346 { 01347 debugMessage("OsiCpxSolverInterface::setColUpper(%d, %g)\n", elementIndex, elementValue); 01348 01349 char c = 'U'; 01350 int err = CPXchgbds( env_, getLpPtr( OsiCpxSolverInterface::FREECACHED_COLUMN ), 1, &elementIndex, &c, &elementValue ); 01351 checkCPXerror( err, "CPXchgbds", "setColUpper" ); 01352 } |
|
Set the variables listed in indices (which is of length len) to be continuous variables Reimplemented from OsiSolverInterface. Definition at line 1596 of file OsiCpxSolverInterface.cpp. References setContinuous().
01597 { 01598 debugMessage("OsiCpxSolverInterface::setContinuous(%p, %d)\n", indices, len); 01599 01600 for( int i = 0; i < len; ++i ) 01601 setContinuous(indices[i]); 01602 } |
|
Set the index-th variable to be a continuous variable Implements OsiSolverInterface. Definition at line 1555 of file OsiCpxSolverInterface.cpp. References coltype_, coltypesize_, env_, getMutableLpPtr(), getNumCols(), and probtypemip_. Referenced by setContinuous().
01556 { 01557 debugMessage("OsiCpxSolverInterface::setContinuous(%d)\n", index); 01558 01559 assert(coltype_ != NULL); 01560 assert(coltypesize_ >= getNumCols()); 01561 01562 coltype_[index] = 'C'; 01563 01564 if ( probtypemip_ ) 01565 { 01566 CPXLPptr lp = getMutableLpPtr(); 01567 int err; 01568 err = CPXchgctype( env_, lp, 1, &index, &coltype_[index] ); 01569 checkCPXerror( err, "CPXchgctype", "setContinuous" ); 01570 } 01571 } |
|
Set the variables listed in indices (which is of length len) to be integer variables Reimplemented from OsiSolverInterface. Definition at line 1605 of file OsiCpxSolverInterface.cpp. References setInteger().
01606 { 01607 debugMessage("OsiCpxSolverInterface::setInteger(%p, %d)\n", indices, len); 01608 01609 for( int i = 0; i < len; ++i ) 01610 setInteger(indices[i]); 01611 } |
|
Set the index-th variable to be an integer variable Implements OsiSolverInterface. Definition at line 1574 of file OsiCpxSolverInterface.cpp. References coltype_, coltypesize_, env_, getColLower(), getColUpper(), getMutableLpPtr(), getNumCols(), and probtypemip_. Referenced by setInteger().
01575 { 01576 debugMessage("OsiCpxSolverInterface::setInteger(%d)\n", index); 01577 01578 assert(coltype_ != NULL); 01579 assert(coltypesize_ >= getNumCols()); 01580 01581 if( getColLower()[index] == 0.0 && getColUpper()[index] == 1.0 ) 01582 coltype_[index] = 'B'; 01583 else 01584 coltype_[index] = 'I'; 01585 01586 if ( probtypemip_ ) 01587 { 01588 CPXLPptr lp = getMutableLpPtr(); 01589 int err; 01590 err = CPXchgctype( env_, lp, 1, &index, &coltype_[index] ); 01591 checkCPXerror( err, "CPXchgctype", "setInteger" ); 01592 } 01593 } |
|
Set an objective function coefficient Implements OsiSolverInterface. Definition at line 1314 of file OsiCpxSolverInterface.cpp. References env_, and FREECACHED_COLUMN.
01315 { 01316 debugMessage("OsiCpxSolverInterface::setObjCoeff(%d, %g)\n", elementIndex, elementValue); 01317 01318 int err = CPXchgobj(env_, getLpPtr( OsiCpxSolverInterface::FREECACHED_COLUMN ), 1, &elementIndex, &elementValue); 01319 checkCPXerror(err, "CPXchgobj", "setObjCoeff"); 01320 } |
|
Set a a set of objective function coefficients Reimplemented from OsiSolverInterface. Definition at line 1322 of file OsiCpxSolverInterface.cpp. References env_, and FREECACHED_COLUMN. Referenced by getDualRays().
01325 { 01326 debugMessage("OsiCpxSolverInterface::setObjCoeffSet(%p, %p, %p)\n", indexFirst, indexLast, coeffList); 01327 01328 const int cnt = indexLast - indexFirst; 01329 int err = CPXchgobj(env_, 01330 getLpPtr(OsiCpxSolverInterface::FREECACHED_COLUMN), cnt, 01331 const_cast<int*>(indexFirst), 01332 const_cast<double*>(coeffList)); 01333 checkCPXerror(err, "CPXchgobj", "setObjCoeffSet"); 01334 } |
|
Set a single row lower and upper bound Reimplemented from OsiSolverInterface. Definition at line 1434 of file OsiCpxSolverInterface.cpp. References OsiSolverInterface::convertBoundToSense(), and setRowType().
01435 { 01436 debugMessage("OsiCpxSolverInterface::setRowBounds(%d, %g, %g)\n", elementIndex, lower, upper); 01437 01438 double rhs, range; 01439 char sense; 01440 01441 convertBoundToSense( lower, upper, sense, rhs, range ); 01442 setRowType( elementIndex, sense, rhs, range ); 01443 } |
|
Set a single row lower bound Implements OsiSolverInterface. Definition at line 1400 of file OsiCpxSolverInterface.cpp. References OsiSolverInterface::convertBoundToSense(), OsiSolverInterface::convertSenseToBound(), getRightHandSide(), getRowRange(), getRowSense(), and setRowType().
01401 { 01402 debugMessage("OsiCpxSolverInterface::setRowLower(%d, %g)\n", i, elementValue); 01403 01404 double rhs = getRightHandSide()[i]; 01405 double range = getRowRange()[i]; 01406 char sense = getRowSense()[i]; 01407 double lower, upper; 01408 01409 convertSenseToBound( sense, rhs, range, lower, upper ); 01410 if( lower != elementValue ) { 01411 convertBoundToSense( elementValue, upper, sense, rhs, range ); 01412 setRowType( i, sense, rhs, range ); 01413 } 01414 } |
|
Set dual solution vector rowprice[numrows()] is an array of values of the problem row dual variables. These values are copied to memory owned by the solver object or the solver. They will be returned as the result of rowprice() until changed by another call to setRowprice() or by a call to any solver routine. Whether the solver makes use of the solution in any way is solver-dependent. Implements OsiSolverInterface. Definition at line 1658 of file OsiCpxSolverInterface.cpp. References colsol_, env_, freeCachedResults(), getMutableLpPtr(), getNumRows(), and rowsol_. Referenced by gutsOfCopy().
01659 { 01660 debugMessage("OsiCpxSolverInterface::setRowPrice(%p)\n", rs); 01661 01662 int nr = getNumRows(); 01663 01664 if( rs == NULL ) 01665 freeCachedResults(); 01666 else if( nr > 0 ) 01667 { 01668 // If rowsol isn't allocated, then allocate it 01669 if ( rowsol_ == NULL ) 01670 rowsol_ = new double[nr]; 01671 01672 // Copy in new row solution. 01673 CoinDisjointCopyN( rs, nr, rowsol_ ); 01674 01675 // if a col solution exists, then pass into CPLEX 01676 if ( colsol_ != NULL ) 01677 { 01678 int err = CPXcopystart( env_, getMutableLpPtr(), NULL, NULL, 01679 const_cast<double*>( colsol_ ), 01680 const_cast<double*>( rowsol_ ), 01681 NULL, NULL ); 01682 checkCPXerror( err, "CPXcopystart", "setRowPrice" ); 01683 } 01684 } 01685 } |
|
Set the bounds on a number of rows simultaneously
Reimplemented from OsiSolverInterface. Definition at line 1473 of file OsiCpxSolverInterface.cpp. References OsiSolverInterface::convertBoundToSense(), and setRowSetTypes().
01476 { 01477 debugMessage("OsiCpxSolverInterface::setRowSetBounds(%p, %p, %p)\n", indexFirst, indexLast, boundList); 01478 01479 const int cnt = indexLast - indexFirst; 01480 if (cnt <= 0) 01481 return; 01482 01483 char* sense = new char[cnt]; 01484 double* rhs = new double[cnt]; 01485 double* range = new double[cnt]; 01486 for (int i = 0; i < cnt; ++i) { 01487 convertBoundToSense(boundList[2*i], boundList[2*i+1], 01488 sense[i], rhs[i], range[i]); 01489 } 01490 setRowSetTypes(indexFirst, indexLast, sense, rhs, range); 01491 delete[] range; 01492 delete[] rhs; 01493 delete[] sense; 01494 01495 // OsiSolverInterface::setRowSetBounds( indexFirst, indexLast, boundList ); 01496 } |
|
Set the type of a number of rows simultaneously
Reimplemented from OsiSolverInterface. Definition at line 1499 of file OsiCpxSolverInterface.cpp. References env_, FREECACHED_ROW, and getInfinity(). Referenced by setRowSetBounds().
01504 { 01505 debugMessage("OsiCpxSolverInterface::setRowSetTypes(%p, %p, %p, %p, %p)\n", 01506 indexFirst, indexLast, senseList, rhsList, rangeList); 01507 01508 const int cnt = indexLast - indexFirst; 01509 if (cnt <= 0) 01510 return; 01511 01512 char* sense = new char[cnt]; 01513 double* rhs = new double[cnt]; 01514 double* range = new double[cnt]; 01515 int* rangeind = new int[cnt]; 01516 int rangecnt = 0; 01517 for (int i = 0; i < cnt; ++i) { 01518 sense[i] = senseList[i]; 01519 rhs[i] = rhsList[i]; 01520 if (sense[i] == 'R') { 01521 assert(rangeList[i] >= 0.0); 01522 rhs[i] -= rangeList[i]; 01523 rangeind[rangecnt] = indexFirst[i]; 01524 range[rangecnt] = rangeList[i]; 01525 ++rangecnt; 01526 } 01527 if (sense[i] == 'N') { 01528 sense[i] = 'R'; 01529 rhs[i] = -getInfinity(); 01530 rangeind[rangecnt] = indexFirst[i]; 01531 range[rangecnt] = 2*getInfinity(); 01532 ++rangecnt; 01533 } 01534 } 01535 int err; 01536 err = CPXchgsense(env_, getLpPtr(OsiCpxSolverInterface::FREECACHED_ROW), 01537 cnt, const_cast<int*>(indexFirst), sense); 01538 checkCPXerror( err, "CPXchgsense", "setRowSetTypes" ); 01539 err = CPXchgrhs(env_, getLpPtr(OsiCpxSolverInterface::FREECACHED_ROW), 01540 cnt, const_cast<int*>(indexFirst), rhs); 01541 checkCPXerror( err, "CPXchgrhs", "setRowSetTypes" ); 01542 err = CPXchgrngval(env_, getLpPtr(OsiCpxSolverInterface::FREECACHED_ROW), 01543 rangecnt, rangeind, range); 01544 checkCPXerror( err, "CPXchgrngval", "setRowSetTypes" ); 01545 01546 delete[] rangeind; 01547 delete[] range; 01548 delete[] rhs; 01549 delete[] sense; 01550 // OsiSolverInterface::setRowSetTypes( indexFirst, indexLast, senseList, 01551 // rhsList, rangeList ); 01552 } |
|
Set the type of a single row Implements OsiSolverInterface. Definition at line 1446 of file OsiCpxSolverInterface.cpp. References env_, FREECACHED_ROW, and getInfinity(). Referenced by setRowBounds(), setRowLower(), and setRowUpper().
01448 { 01449 debugMessage("OsiCpxSolverInterface::setRowType(%d, %c, %g, %g)\n", i, sense, rightHandSide, range); 01450 01451 int err; 01452 01453 if (sense == 'R') { 01454 assert( range >= 0.0 ); 01455 rightHandSide -= range; 01456 } 01457 if (sense == 'N') { 01458 sense = 'R'; 01459 rightHandSide = -getInfinity(); 01460 range = 2*getInfinity(); 01461 } 01462 err = CPXchgsense( env_, getLpPtr( OsiCpxSolverInterface::FREECACHED_ROW ), 01463 1, &i, &sense ); 01464 checkCPXerror( err, "CPXchgsense", "setRowType" ); 01465 err = CPXchgrhs( env_, getLpPtr( OsiCpxSolverInterface::FREECACHED_ROW ), 01466 1, &i, &rightHandSide ); 01467 checkCPXerror( err, "CPXchgrhs", "setRowType" ); 01468 err = CPXchgrngval( env_, getLpPtr( OsiCpxSolverInterface::FREECACHED_ROW ), 01469 1, &i, &range ); 01470 checkCPXerror( err, "CPXchgrngval", "setRowType" ); 01471 } |
|
Set a single row upper bound Implements OsiSolverInterface. Definition at line 1417 of file OsiCpxSolverInterface.cpp. References OsiSolverInterface::convertBoundToSense(), OsiSolverInterface::convertSenseToBound(), getRightHandSide(), getRowRange(), getRowSense(), and setRowType().
01418 { 01419 debugMessage("OsiCpxSolverInterface::setRowUpper(%d, %g)\n", i, elementValue); 01420 01421 double rhs = getRightHandSide()[i]; 01422 double range = getRowRange()[i]; 01423 char sense = getRowSense()[i]; 01424 double lower, upper; 01425 01426 convertSenseToBound( sense, rhs, range, lower, upper ); 01427 if( upper != elementValue ) { 01428 convertBoundToSense( lower, elementValue, sense, rhs, range ); 01429 setRowType( i, sense, rhs, range ); 01430 } 01431 } |
|
Set warmstarting information. Return true/false depending on whether the warmstart information was accepted or not. Implements OsiSolverInterface. Definition at line 611 of file OsiCpxSolverInterface.cpp. References env_, FREECACHED_RESULTS, CoinWarmStartBasis::getArtifStatus(), CoinWarmStartBasis::getNumArtificial(), getNumCols(), getNumRows(), CoinWarmStartBasis::getNumStructural(), CoinWarmStartBasis::getStructStatus(), and switchToLP().
00612 { 00613 debugMessage("OsiCpxSolverInterface::setWarmStart(%p)\n", warmstart); 00614 00615 const CoinWarmStartBasis* ws = dynamic_cast<const CoinWarmStartBasis*>(warmstart); 00616 int numcols, numrows, i, restat; 00617 int *cstat, *rstat; 00618 bool retval = false; 00619 00620 if( !ws ) 00621 return false; 00622 00623 numcols = ws->getNumStructural(); 00624 numrows = ws->getNumArtificial(); 00625 00626 if( numcols != getNumCols() || numrows != getNumRows() ) 00627 return false; 00628 00629 switchToLP(); 00630 00631 cstat = new int[numcols]; 00632 rstat = new int[numrows]; 00633 for( i = 0; i < numrows; ++i ) 00634 { 00635 switch( ws->getArtifStatus( i ) ) 00636 { 00637 case CoinWarmStartBasis::basic: 00638 rstat[i] = CPX_BASIC; 00639 break; 00640 case CoinWarmStartBasis::atLowerBound: 00641 rstat[i] = CPX_AT_LOWER; 00642 break; 00643 case CoinWarmStartBasis::atUpperBound: 00644 rstat[i] = CPX_AT_UPPER; 00645 break; 00646 default: // unknown row status 00647 retval = false; 00648 goto TERMINATE; 00649 } 00650 } 00651 for( i = 0; i < numcols; ++i ) 00652 { 00653 switch( ws->getStructStatus( i ) ) 00654 { 00655 case CoinWarmStartBasis::basic: 00656 cstat[i] = CPX_BASIC; 00657 break; 00658 case CoinWarmStartBasis::atLowerBound: 00659 cstat[i] = CPX_AT_LOWER; 00660 break; 00661 case CoinWarmStartBasis::atUpperBound: 00662 cstat[i] = CPX_AT_UPPER; 00663 break; 00664 case CoinWarmStartBasis::isFree: 00665 cstat[i] = CPX_FREE_SUPER; 00666 break; 00667 default: // unknown row status 00668 retval = false; 00669 goto TERMINATE; 00670 } 00671 } 00672 00673 // *FIXME* : can this be getMutableLpPtr() ? Does any cached data change by 00674 // *FIXME* : setting warmstart? Or at least wouldn't it be sufficient to 00675 // *FIXME* : clear the cached results but not the problem data? 00676 // -> is fixed by using FREECACHED_RESULTS; only cached solution will be discarded 00677 restat = CPXcopybase( env_, getLpPtr( OsiCpxSolverInterface::FREECACHED_RESULTS ), cstat, rstat ); 00678 retval = (restat == 0); 00679 TERMINATE: 00680 delete[] cstat; 00681 delete[] rstat; 00682 return retval; 00683 } |
|
Write the problem into an mps file of the given filename. If objSense is non zero then -1.0 forces the code to write a maximization objective and +1.0 to write a minimization one. If 0.0 then solver can do what it wants Implements OsiSolverInterface. Definition at line 2255 of file OsiCpxSolverInterface.cpp. References env_, and getMutableLpPtr().
02258 { 02259 debugMessage("OsiCpxSolverInterface::writeMps(%s, %s, %g)\n", filename, extension, objSense); 02260 02261 // *FIXME* : this will not output ctype information to the MPS file 02262 char filetype[4] = "MPS"; 02263 std::string f(filename); 02264 std::string e(extension); 02265 std::string fullname = f + "." + e; 02266 int err = CPXwriteprob( env_, getMutableLpPtr(), const_cast<char*>( fullname.c_str() ), filetype ); 02267 checkCPXerror( err, "CPXwriteprob", "writeMps" ); 02268 } |
|
A function that tests the methods in the OsiOslSolverInterface class. The only reason for it not to be a member method is that this way it doesn't have to be compiled into the library. And that's a gain, because the library should be compiled with optimization on, but this method should be compiled with debugging. Definition at line 72 of file OsiCpxSolverInterfaceTest.cpp.
00073 { 00074 // Test default constructor 00075 { 00076 assert( OsiCpxSolverInterface::getNumInstances()==0 ); 00077 OsiCpxSolverInterface m; 00078 assert( m.obj_==NULL ); 00079 assert( m.collower_==NULL ); 00080 assert( m.colupper_==NULL ); 00081 assert( m.coltype_==NULL ); 00082 assert( m.rowsense_==NULL ); 00083 assert( m.rhs_==NULL ); 00084 assert( m.rowrange_==NULL ); 00085 assert( m.rowlower_==NULL ); 00086 assert( m.rowupper_==NULL ); 00087 assert( m.colsol_==NULL ); 00088 assert( m.rowsol_==NULL ); 00089 assert( m.matrixByRow_==NULL ); 00090 assert( m.matrixByCol_==NULL ); 00091 assert( m.coltype_==NULL ); 00092 assert( m.coltypesize_==0 ); 00093 assert( OsiCpxSolverInterface::getNumInstances()==1 ); 00094 assert( m.getApplicationData() == NULL ); 00095 int i=2346; 00096 m.setApplicationData(&i); 00097 assert( *((int *)(m.getApplicationData())) == i ); 00098 } 00099 assert( OsiCpxSolverInterface::getNumInstances()==0 ); 00100 00101 { 00102 CoinRelFltEq eq; 00103 OsiCpxSolverInterface m; 00104 assert( OsiCpxSolverInterface::getNumInstances()==1 ); 00105 std::string fn = mpsDir+"exmip1"; 00106 m.readMps(fn.c_str(),"mps"); 00107 int ad = 13579; 00108 m.setApplicationData(&ad); 00109 assert( *((int *)(m.getApplicationData())) == ad ); 00110 00111 { 00112 assert( m.getNumCols()==8 ); 00113 const CoinPackedMatrix * colCopy = m.getMatrixByCol(); 00114 assert( colCopy->getNumCols() == 8 ); 00115 assert( colCopy->getMajorDim() == 8 ); 00116 assert( colCopy->getNumRows() == 5 ); 00117 assert( colCopy->getMinorDim() == 5 ); 00118 assert (colCopy->getVectorLengths()[7] == 2 ); 00119 CoinPackedMatrix revColCopy; 00120 revColCopy.reverseOrderedCopyOf(*colCopy); 00121 CoinPackedMatrix rev2ColCopy; 00122 rev2ColCopy.reverseOrderedCopyOf(revColCopy); 00123 assert( rev2ColCopy.getNumCols() == 8 ); 00124 assert( rev2ColCopy.getMajorDim() == 8 ); 00125 assert( rev2ColCopy.getNumRows() == 5 ); 00126 assert( rev2ColCopy.getMinorDim() == 5 ); 00127 assert( rev2ColCopy.getVectorLengths()[7] == 2 ); 00128 } 00129 00130 { 00131 OsiCpxSolverInterface im; 00132 assert( im.getNumCols() == 0 ); 00133 } 00134 00135 // Test copy constructor and assignment operator 00136 { 00137 OsiCpxSolverInterface lhs; 00138 { 00139 assert( *((int *)(m.getApplicationData())) == ad ); 00140 OsiCpxSolverInterface im(m); 00141 assert( *((int *)(im.getApplicationData())) == ad ); 00142 00143 OsiCpxSolverInterface imC1(im); 00144 assert( imC1.lp_ != im.lp_ ); 00145 assert( imC1.getNumCols() == im.getNumCols() ); 00146 assert( imC1.getNumRows() == im.getNumRows() ); 00147 assert( *((int *)(imC1.getApplicationData())) == ad ); 00148 00149 //im.setModelPtr(m); 00150 00151 OsiCpxSolverInterface imC2(im); 00152 assert( imC2.lp_ != im.lp_ ); 00153 assert( imC2.getNumCols() == im.getNumCols() ); 00154 assert( imC2.getNumRows() == im.getNumRows() ); 00155 assert( *((int *)(imC2.getApplicationData())) == ad ); 00156 00157 assert( imC2.lp_ != imC1.lp_ ); 00158 00159 lhs=imC2; 00160 } 00161 // Test that lhs has correct values even though rhs has gone out of scope 00162 00163 assert( lhs.lp_ != m.lp_ ); 00164 assert( lhs.getNumCols() == m.getNumCols() ); 00165 assert( lhs.getNumRows() == m.getNumRows() ); 00166 assert( *((int *)(lhs.getApplicationData())) == ad ); 00167 } 00168 00169 // Test clone 00170 { 00171 OsiCpxSolverInterface cplexSi(m); 00172 OsiSolverInterface * siPtr = &cplexSi; 00173 OsiSolverInterface * siClone = siPtr->clone(); 00174 OsiCpxSolverInterface * cplexClone = dynamic_cast<OsiCpxSolverInterface*>(siClone); 00175 assert( cplexClone != NULL ); 00176 assert( cplexClone->lp_ != cplexSi.lp_ ); 00177 assert( cplexClone->getNumRows() == cplexSi.getNumRows() ); 00178 assert( cplexClone->getNumCols() == m.getNumCols() ); 00179 00180 assert( *((int *)(cplexClone->getApplicationData())) == ad ); 00181 delete siClone; 00182 } 00183 00184 // test infinity 00185 { 00186 OsiCpxSolverInterface si; 00187 assert( eq( si.getInfinity(), CPX_INFBOUND ) ); 00188 } 00189 00190 // Test setting solution 00191 { 00192 OsiCpxSolverInterface m1(m); 00193 int i; 00194 00195 double * cs = new double[m1.getNumCols()]; 00196 for ( i = 0; i < m1.getNumCols(); i++ ) 00197 cs[i] = i + .5; 00198 m1.setColSolution(cs); 00199 for ( i = 0; i < m1.getNumCols(); i++ ) 00200 assert(m1.getColSolution()[i] == i + .5); 00201 00202 double * rs = new double[m1.getNumRows()]; 00203 for ( i = 0; i < m1.getNumRows(); i++ ) 00204 rs[i] = i - .5; 00205 m1.setRowPrice(rs); 00206 for ( i = 0; i < m1.getNumRows(); i++ ) 00207 assert(m1.getRowPrice()[i] == i - .5); 00208 00209 delete [] cs; 00210 delete [] rs; 00211 } 00212 00213 00214 // Test fraction Indices 00215 { 00216 OsiCpxSolverInterface fim; 00217 std::string fn = mpsDir+"exmip1"; 00218 fim.readMps(fn.c_str(),"mps"); 00219 //fim.setModelPtr(m); 00220 // exmip1.mps has 2 integer variables with index 2 & 3 00221 assert( fim.isContinuous(0) ); 00222 assert( fim.isContinuous(1) ); 00223 assert( !fim.isContinuous(2) ); 00224 assert( !fim.isContinuous(3) ); 00225 assert( fim.isContinuous(4) ); 00226 00227 assert( !fim.isInteger(0) ); 00228 assert( !fim.isInteger(1) ); 00229 assert( fim.isInteger(2) ); 00230 assert( fim.isInteger(3) ); 00231 assert( !fim.isInteger(4) ); 00232 00233 assert( !fim.isBinary(0) ); 00234 assert( !fim.isBinary(1) ); 00235 assert( fim.isBinary(2) ); 00236 assert( fim.isBinary(3) ); 00237 assert( !fim.isBinary(4) ); 00238 00239 assert( !fim.isIntegerNonBinary(0) ); 00240 assert( !fim.isIntegerNonBinary(1) ); 00241 assert( !fim.isIntegerNonBinary(2) ); 00242 assert( !fim.isIntegerNonBinary(3) ); 00243 assert( !fim.isIntegerNonBinary(4) ); 00244 00245 00246 // Test fractionalIndices 00247 { 00248 // Set a solution vector 00249 double * cs = new double[fim.getNumCols()]; 00250 for ( int i = 0; i < fim.getNumCols(); cs[i++] = 0.0 ); 00251 cs[2] = 2.9; 00252 cs[3] = 3.0; 00253 fim.setColSolution(cs); 00254 00255 OsiVectorInt fi = fim.getFractionalIndices(); 00256 assert( fi.size() == 1 ); 00257 assert( fi[0]==2 ); 00258 00259 // Set integer variables very close to integer values 00260 cs[2] = 5 + .00001/2.; 00261 cs[3] = 8 - .00001/2.; 00262 fim.setColSolution(cs); 00263 fi = fim.getFractionalIndices(1e-5); 00264 assert( fi.size() == 0 ); 00265 00266 // Set integer variables close, but beyond tolerances 00267 cs[2] = 5 + .00001*2.; 00268 cs[3] = 8 - .00001*2.; 00269 fim.setColSolution(cs); 00270 fi = fim.getFractionalIndices(1e-5); 00271 assert( fi.size() == 2 ); 00272 assert( fi[0]==2 ); 00273 assert( fi[1]==3 ); 00274 00275 delete [] cs; 00276 } 00277 00278 // Change data so column 2 & 3 are integerNonBinary 00279 fim.setColUpper(2, 5); 00280 fim.setColUpper(3, 6.0); 00281 assert( !fim.isBinary(0) ); 00282 assert( !fim.isBinary(1) ); 00283 assert( !fim.isBinary(2) ); 00284 assert( !fim.isBinary(3) ); 00285 assert( !fim.isBinary(4) ); 00286 00287 assert( !fim.isIntegerNonBinary(0) ); 00288 assert( !fim.isIntegerNonBinary(1) ); 00289 assert( fim.isIntegerNonBinary(2) ); 00290 assert( fim.isIntegerNonBinary(3) ); 00291 assert( !fim.isIntegerNonBinary(4) ); 00292 } 00293 00294 // Test apply cuts method 00295 { 00296 OsiCpxSolverInterface im(m); 00297 OsiCuts cuts; 00298 00299 // Generate some cuts 00300 { 00301 // Get number of rows and columns in model 00302 int nr=im.getNumRows(); 00303 int nc=im.getNumCols(); 00304 assert( nr == 5 ); 00305 assert( nc == 8 ); 00306 00307 // Generate a valid row cut from thin air 00308 int c; 00309 { 00310 int *inx = new int[nc]; 00311 for (c=0;c<nc;c++) inx[c]=c; 00312 double *el = new double[nc]; 00313 for (c=0;c<nc;c++) el[c]=((double)c)*((double)c); 00314 00315 OsiRowCut rc; 00316 rc.setRow(nc,inx,el); 00317 rc.setLb(-100.); 00318 rc.setUb(100.); 00319 rc.setEffectiveness(22); 00320 00321 cuts.insert(rc); 00322 delete[]el; 00323 delete[]inx; 00324 } 00325 00326 // Generate valid col cut from thin air 00327 { 00328 const double * cplexColLB = im.getColLower(); 00329 const double * cplexColUB = im.getColUpper(); 00330 int *inx = new int[nc]; 00331 for (c=0;c<nc;c++) inx[c]=c; 00332 double *lb = new double[nc]; 00333 double *ub = new double[nc]; 00334 for (c=0;c<nc;c++) lb[c]=cplexColLB[c]+0.001; 00335 for (c=0;c<nc;c++) ub[c]=cplexColUB[c]-0.001; 00336 00337 OsiColCut cc; 00338 cc.setLbs(nc,inx,lb); 00339 cc.setUbs(nc,inx,ub); 00340 00341 cuts.insert(cc); 00342 delete [] ub; 00343 delete [] lb; 00344 delete [] inx; 00345 } 00346 00347 { 00348 // Generate a row and column cut which have are ineffective 00349 OsiRowCut * rcP= new OsiRowCut; 00350 rcP->setEffectiveness(-1.); 00351 cuts.insert(rcP); 00352 assert(rcP==NULL); 00353 00354 OsiColCut * ccP= new OsiColCut; 00355 ccP->setEffectiveness(-12.); 00356 cuts.insert(ccP); 00357 assert(ccP==NULL); 00358 } 00359 { 00360 //Generate inconsistent Row cut 00361 OsiRowCut rc; 00362 const int ne=1; 00363 int inx[ne]={-10}; 00364 double el[ne]={2.5}; 00365 rc.setRow(ne,inx,el); 00366 rc.setLb(3.); 00367 rc.setUb(4.); 00368 assert(!rc.consistent()); 00369 cuts.insert(rc); 00370 } 00371 { 00372 //Generate inconsistent col cut 00373 OsiColCut cc; 00374 const int ne=1; 00375 int inx[ne]={-10}; 00376 double el[ne]={2.5}; 00377 cc.setUbs(ne,inx,el); 00378 assert(!cc.consistent()); 00379 cuts.insert(cc); 00380 } 00381 { 00382 // Generate row cut which is inconsistent for model m 00383 OsiRowCut rc; 00384 const int ne=1; 00385 int inx[ne]={10}; 00386 double el[ne]={2.5}; 00387 rc.setRow(ne,inx,el); 00388 assert(rc.consistent()); 00389 assert(!rc.consistent(im)); 00390 cuts.insert(rc); 00391 } 00392 { 00393 // Generate col cut which is inconsistent for model m 00394 OsiColCut cc; 00395 const int ne=1; 00396 int inx[ne]={30}; 00397 double el[ne]={2.0}; 00398 cc.setLbs(ne,inx,el); 00399 assert(cc.consistent()); 00400 assert(!cc.consistent(im)); 00401 cuts.insert(cc); 00402 } 00403 { 00404 // Generate col cut which is infeasible 00405 OsiColCut cc; 00406 const int ne=1; 00407 int inx[ne]={0}; 00408 double el[ne]={2.0}; 00409 cc.setUbs(ne,inx,el); 00410 cc.setEffectiveness(1000.); 00411 assert(cc.consistent()); 00412 assert(cc.consistent(im)); 00413 assert(cc.infeasible(im)); 00414 cuts.insert(cc); 00415 } 00416 } 00417 assert(cuts.sizeRowCuts()==4); 00418 assert(cuts.sizeColCuts()==5); 00419 00420 OsiSolverInterface::ApplyCutsReturnCode rc = im.applyCuts(cuts); 00421 assert( rc.getNumIneffective() == 2 ); 00422 assert( rc.getNumApplied() == 2 ); 00423 assert( rc.getNumInfeasible() == 1 ); 00424 assert( rc.getNumInconsistentWrtIntegerModel() == 2 ); 00425 assert( rc.getNumInconsistent() == 2 ); 00426 assert( cuts.sizeCuts() == rc.getNumIneffective() + 00427 rc.getNumApplied() + 00428 rc.getNumInfeasible() + 00429 rc.getNumInconsistentWrtIntegerModel() + 00430 rc.getNumInconsistent() ); 00431 } 00432 { 00433 OsiCpxSolverInterface cplexSi(m); 00434 int nc = cplexSi.getNumCols(); 00435 int nr = cplexSi.getNumRows(); 00436 const double * cl = cplexSi.getColLower(); 00437 const double * cu = cplexSi.getColUpper(); 00438 const double * rl = cplexSi.getRowLower(); 00439 const double * ru = cplexSi.getRowUpper(); 00440 00441 assert( nc == 8 ); 00442 assert( nr == 5 ); 00443 assert( eq(cl[0],2.5) ); 00444 assert( eq(cl[1],0.0) ); 00445 assert( eq(cu[1],4.1) ); 00446 assert( eq(cu[2],1.0) ); 00447 00448 assert( eq(rl[0],2.5) ); 00449 assert( eq(rl[4],3.0) ); 00450 assert( eq(ru[1],2.1) ); 00451 assert( eq(ru[4],15.0) ); 00452 00453 double newCs[8] = {1., 2., 3., 4., 5., 6., 7., 8.}; 00454 cplexSi.setColSolution(newCs); 00455 const double * cs = cplexSi.getColSolution(); 00456 assert( eq(cs[0],1.0) ); 00457 assert( eq(cs[7],8.0) ); 00458 { 00459 OsiCpxSolverInterface solnSi(cplexSi); 00460 const double * cs = solnSi.getColSolution(); 00461 assert( eq(cs[0],1.0) ); 00462 assert( eq(cs[7],8.0) ); 00463 } 00464 00465 assert( !eq(cl[3],1.2345) ); 00466 cplexSi.setColLower( 3, 1.2345 ); 00467 assert( eq(cplexSi.getColLower()[3],1.2345) ); 00468 00469 assert( !eq(cu[4],10.2345) ); 00470 cplexSi.setColUpper( 4, 10.2345 ); 00471 assert( eq(cplexSi.getColUpper()[4],10.2345) ); 00472 00473 assert( eq(cplexSi.getObjValue(),0.0) ); 00474 00475 assert( eq( cplexSi.getObjCoefficients()[0], 1.0) ); 00476 assert( eq( cplexSi.getObjCoefficients()[1], 0.0) ); 00477 assert( eq( cplexSi.getObjCoefficients()[2], 0.0) ); 00478 assert( eq( cplexSi.getObjCoefficients()[3], 0.0) ); 00479 assert( eq( cplexSi.getObjCoefficients()[4], 2.0) ); 00480 assert( eq( cplexSi.getObjCoefficients()[5], 0.0) ); 00481 assert( eq( cplexSi.getObjCoefficients()[6], 0.0) ); 00482 assert( eq( cplexSi.getObjCoefficients()[7], -1.0) ); 00483 } 00484 00485 // Test getMatrixByRow method 00486 { 00487 const OsiCpxSolverInterface si(m); 00488 const CoinPackedMatrix * smP = si.getMatrixByRow(); 00489 //const CoinPackedMatrix * osmP = dynamic_cast(const OsiCpxPackedMatrix*)(smP); 00490 //assert( osmP!=NULL ); 00491 00492 CoinRelFltEq eq; 00493 const double * ev = smP->getElements(); 00494 assert( eq(ev[0], 3.0) ); 00495 assert( eq(ev[1], 1.0) ); 00496 assert( eq(ev[2], -2.0) ); 00497 assert( eq(ev[3], -1.0) ); 00498 assert( eq(ev[4], -1.0) ); 00499 assert( eq(ev[5], 2.0) ); 00500 assert( eq(ev[6], 1.1) ); 00501 assert( eq(ev[7], 1.0) ); 00502 assert( eq(ev[8], 1.0) ); 00503 assert( eq(ev[9], 2.8) ); 00504 assert( eq(ev[10], -1.2) ); 00505 assert( eq(ev[11], 5.6) ); 00506 assert( eq(ev[12], 1.0) ); 00507 assert( eq(ev[13], 1.9) ); 00508 00509 const int * mi = smP->getVectorStarts(); 00510 assert( mi[0]==0 ); 00511 assert( mi[1]==5 ); 00512 assert( mi[2]==7 ); 00513 assert( mi[3]==9 ); 00514 assert( mi[4]==11 ); 00515 assert( mi[5]==14 ); 00516 00517 const int * ei = smP->getIndices(); 00518 assert( ei[0] == 0 ); 00519 assert( ei[1] == 1 ); 00520 assert( ei[2] == 3 ); 00521 assert( ei[3] == 4 ); 00522 assert( ei[4] == 7 ); 00523 assert( ei[5] == 1 ); 00524 assert( ei[6] == 2 ); 00525 assert( ei[7] == 2 ); 00526 assert( ei[8] == 5 ); 00527 assert( ei[9] == 3 ); 00528 assert( ei[10] == 6 ); 00529 assert( ei[11] == 0 ); 00530 assert( ei[12] == 4 ); 00531 assert( ei[13] == 7 ); 00532 00533 assert( smP->getMajorDim() == 5 ); 00534 assert( smP->getNumElements() == 14 ); 00535 00536 } 00537 //-------------- 00538 // Test rowsense, rhs, rowrange, getMatrixByRow 00539 { 00540 OsiCpxSolverInterface lhs; 00541 { 00542 #if 0 00543 assert( m.obj_==NULL ); 00544 assert( m.collower_==NULL ); 00545 assert( m.colupper_==NULL ); 00546 assert( m.rowrange_==NULL ); 00547 assert( m.rowsense_==NULL ); 00548 assert( m.rhs_==NULL ); 00549 assert( m.rowlower_==NULL ); 00550 assert( m.rowupper_==NULL ); 00551 assert( m.colsol_==NULL ); 00552 assert( m.rowsol_==NULL ); 00553 assert( m.getMatrixByRow_==NULL ); 00554 #endif 00555 00556 OsiCpxSolverInterface siC1(m); 00557 assert( siC1.obj_==NULL ); 00558 assert( siC1.collower_==NULL ); 00559 assert( siC1.colupper_==NULL ); 00560 // assert( siC1.coltype_==NULL ); 00561 assert( siC1.rowrange_==NULL ); 00562 assert( siC1.rowsense_==NULL ); 00563 assert( siC1.rhs_==NULL ); 00564 assert( siC1.rowlower_==NULL ); 00565 assert( siC1.rowupper_==NULL ); 00566 assert( siC1.colsol_!=NULL ); 00567 assert( siC1.rowsol_!=NULL ); 00568 assert( siC1.matrixByRow_==NULL ); 00569 00570 const char * siC1rs = siC1.getRowSense(); 00571 assert( siC1rs[0]=='G' ); 00572 assert( siC1rs[1]=='L' ); 00573 assert( siC1rs[2]=='E' ); 00574 assert( siC1rs[3]=='R' ); 00575 assert( siC1rs[4]=='R' ); 00576 00577 const double * siC1rhs = siC1.getRightHandSide(); 00578 assert( eq(siC1rhs[0],2.5) ); 00579 assert( eq(siC1rhs[1],2.1) ); 00580 assert( eq(siC1rhs[2],4.0) ); 00581 assert( eq(siC1rhs[3],5.0) ); 00582 assert( eq(siC1rhs[4],15.) ); 00583 00584 const double * siC1rr = siC1.getRowRange(); 00585 assert( eq(siC1rr[0],0.0) ); 00586 assert( eq(siC1rr[1],0.0) ); 00587 assert( eq(siC1rr[2],0.0) ); 00588 assert( eq(siC1rr[3],5.0-1.8) ); 00589 assert( eq(siC1rr[4],15.0-3.0) ); 00590 00591 const CoinPackedMatrix * siC1mbr = siC1.getMatrixByRow(); 00592 assert( siC1mbr != NULL ); 00593 00594 const double * ev = siC1mbr->getElements(); 00595 assert( eq(ev[0], 3.0) ); 00596 assert( eq(ev[1], 1.0) ); 00597 assert( eq(ev[2], -2.0) ); 00598 assert( eq(ev[3], -1.0) ); 00599 assert( eq(ev[4], -1.0) ); 00600 assert( eq(ev[5], 2.0) ); 00601 assert( eq(ev[6], 1.1) ); 00602 assert( eq(ev[7], 1.0) ); 00603 assert( eq(ev[8], 1.0) ); 00604 assert( eq(ev[9], 2.8) ); 00605 assert( eq(ev[10], -1.2) ); 00606 assert( eq(ev[11], 5.6) ); 00607 assert( eq(ev[12], 1.0) ); 00608 assert( eq(ev[13], 1.9) ); 00609 00610 const int * mi = siC1mbr->getVectorStarts(); 00611 assert( mi[0]==0 ); 00612 assert( mi[1]==5 ); 00613 assert( mi[2]==7 ); 00614 assert( mi[3]==9 ); 00615 assert( mi[4]==11 ); 00616 assert( mi[5]==14 ); 00617 00618 const int * ei = siC1mbr->getIndices(); 00619 assert( ei[0] == 0 ); 00620 assert( ei[1] == 1 ); 00621 assert( ei[2] == 3 ); 00622 assert( ei[3] == 4 ); 00623 assert( ei[4] == 7 ); 00624 assert( ei[5] == 1 ); 00625 assert( ei[6] == 2 ); 00626 assert( ei[7] == 2 ); 00627 assert( ei[8] == 5 ); 00628 assert( ei[9] == 3 ); 00629 assert( ei[10] == 6 ); 00630 assert( ei[11] == 0 ); 00631 assert( ei[12] == 4 ); 00632 assert( ei[13] == 7 ); 00633 00634 assert( siC1mbr->getMajorDim() == 5 ); 00635 assert( siC1mbr->getNumElements() == 14 ); 00636 00637 00638 assert( siC1rs == siC1.getRowSense() ); 00639 assert( siC1rhs == siC1.getRightHandSide() ); 00640 assert( siC1rr == siC1.getRowRange() ); 00641 00642 // Change CPLEX Model by adding free row 00643 OsiRowCut rc; 00644 rc.setLb(-DBL_MAX); 00645 rc.setUb( DBL_MAX); 00646 OsiCuts cuts; 00647 cuts.insert(rc); 00648 siC1.applyCuts(cuts); 00649 00650 // Since model was changed, test that cached 00651 // data is now freed. 00652 assert( siC1.obj_==NULL ); 00653 assert( siC1.collower_==NULL ); 00654 assert( siC1.colupper_==NULL ); 00655 // assert( siC1.coltype_==NULL ); 00656 assert( siC1.rowrange_==NULL ); 00657 assert( siC1.rowsense_==NULL ); 00658 assert( siC1.rhs_==NULL ); 00659 assert( siC1.rowlower_==NULL ); 00660 assert( siC1.rowupper_==NULL ); 00661 assert( siC1.colsol_==NULL ); 00662 assert( siC1.rowsol_==NULL ); 00663 assert( siC1.matrixByRow_==NULL ); 00664 00665 siC1rs = siC1.getRowSense(); 00666 siC1rhs = siC1.getRightHandSide(); 00667 siC1rr = siC1.getRowRange(); 00668 00669 assert( siC1rs[0]=='G' ); 00670 assert( siC1rs[1]=='L' ); 00671 assert( siC1rs[2]=='E' ); 00672 assert( siC1rs[3]=='R' ); 00673 assert( siC1rs[4]=='R' ); 00674 assert( siC1rs[5]=='N' ); 00675 00676 assert( eq(siC1rhs[0],2.5) ); 00677 assert( eq(siC1rhs[1],2.1) ); 00678 assert( eq(siC1rhs[2],4.0) ); 00679 assert( eq(siC1rhs[3],5.0) ); 00680 assert( eq(siC1rhs[4],15.) ); 00681 assert( eq(siC1rhs[5],0.0) ); 00682 00683 assert( eq(siC1rr[0],0.0) ); 00684 assert( eq(siC1rr[1],0.0) ); 00685 assert( eq(siC1rr[2],0.0) ); 00686 assert( eq(siC1rr[3],5.0-1.8) ); 00687 assert( eq(siC1rr[4],15.0-3.0) ); 00688 assert( eq(siC1rr[5],0.0) ); 00689 00690 lhs=siC1; 00691 } 00692 // Test that lhs has correct values even though siC1 has gone out of scope 00693 assert( lhs.obj_==NULL ); 00694 assert( lhs.collower_==NULL ); 00695 assert( lhs.colupper_==NULL ); 00696 // assert( lhs.coltype_==NULL ); 00697 assert( lhs.rowrange_==NULL ); 00698 assert( lhs.rowsense_==NULL ); 00699 assert( lhs.rhs_==NULL ); 00700 assert( lhs.rowlower_==NULL ); 00701 assert( lhs.rowupper_==NULL ); 00702 assert( lhs.colsol_!=NULL ); 00703 assert( lhs.rowsol_!=NULL ); 00704 assert( lhs.matrixByRow_==NULL ); 00705 00706 const char * lhsrs = lhs.getRowSense(); 00707 assert( lhsrs[0]=='G' ); 00708 assert( lhsrs[1]=='L' ); 00709 assert( lhsrs[2]=='E' ); 00710 assert( lhsrs[3]=='R' ); 00711 assert( lhsrs[4]=='R' ); 00712 assert( lhsrs[5]=='N' ); 00713 00714 const double * lhsrhs = lhs.getRightHandSide(); 00715 assert( eq(lhsrhs[0],2.5) ); 00716 assert( eq(lhsrhs[1],2.1) ); 00717 assert( eq(lhsrhs[2],4.0) ); 00718 assert( eq(lhsrhs[3],5.0) ); 00719 assert( eq(lhsrhs[4],15.) ); 00720 assert( eq(lhsrhs[5],0.0) ); 00721 00722 const double *lhsrr = lhs.getRowRange(); 00723 assert( eq(lhsrr[0],0.0) ); 00724 assert( eq(lhsrr[1],0.0) ); 00725 assert( eq(lhsrr[2],0.0) ); 00726 assert( eq(lhsrr[3],5.0-1.8) ); 00727 assert( eq(lhsrr[4],15.0-3.0) ); 00728 assert( eq(lhsrr[5],0.0) ); 00729 00730 const CoinPackedMatrix * lhsmbr = lhs.getMatrixByRow(); 00731 assert( lhsmbr != NULL ); 00732 const double * ev = lhsmbr->getElements(); 00733 assert( eq(ev[0], 3.0) ); 00734 assert( eq(ev[1], 1.0) ); 00735 assert( eq(ev[2], -2.0) ); 00736 assert( eq(ev[3], -1.0) ); 00737 assert( eq(ev[4], -1.0) ); 00738 assert( eq(ev[5], 2.0) ); 00739 assert( eq(ev[6], 1.1) ); 00740 assert( eq(ev[7], 1.0) ); 00741 assert( eq(ev[8], 1.0) ); 00742 assert( eq(ev[9], 2.8) ); 00743 assert( eq(ev[10], -1.2) ); 00744 assert( eq(ev[11], 5.6) ); 00745 assert( eq(ev[12], 1.0) ); 00746 assert( eq(ev[13], 1.9) ); 00747 00748 const int * mi = lhsmbr->getVectorStarts(); 00749 assert( mi[0]==0 ); 00750 assert( mi[1]==5 ); 00751 assert( mi[2]==7 ); 00752 assert( mi[3]==9 ); 00753 assert( mi[4]==11 ); 00754 assert( mi[5]==14 ); 00755 00756 const int * ei = lhsmbr->getIndices(); 00757 assert( ei[0] == 0 ); 00758 assert( ei[1] == 1 ); 00759 assert( ei[2] == 3 ); 00760 assert( ei[3] == 4 ); 00761 assert( ei[4] == 7 ); 00762 assert( ei[5] == 1 ); 00763 assert( ei[6] == 2 ); 00764 assert( ei[7] == 2 ); 00765 assert( ei[8] == 5 ); 00766 assert( ei[9] == 3 ); 00767 assert( ei[10] == 6 ); 00768 assert( ei[11] == 0 ); 00769 assert( ei[12] == 4 ); 00770 assert( ei[13] == 7 ); 00771 00772 int md = lhsmbr->getMajorDim(); 00773 assert( md == 6 ); 00774 assert( lhsmbr->getNumElements() == 14 ); 00775 } 00776 00777 //-------------- 00778 00779 assert(OsiCpxSolverInterface::getNumInstances()==1); 00780 } 00781 assert(OsiCpxSolverInterface::getNumInstances()==0); 00782 00783 00784 // Do common solverInterface testing by calling the 00785 // base class testing method. 00786 { 00787 OsiCpxSolverInterface m; 00788 OsiSolverInterfaceCommonUnitTest(&m, mpsDir,netlibDir); 00789 } 00790 } |