#include <OsiXprSolverInterface.hpp>
Inheritance diagram for OsiXprSolverInterface:
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) |
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 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 colIndex) const |
Return true if variable 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 | 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> | |
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 |
Constructors and destructors | |
OsiXprSolverInterface (int newrows=50, int newnz=100) | |
Default Constructor. | |
virtual OsiSolverInterface * | clone (bool copyData=true) const |
Clone. | |
OsiXprSolverInterface (const OsiXprSolverInterface &) | |
Copy constructor. | |
OsiXprSolverInterface & | operator= (const OsiXprSolverInterface &rhs) |
Assignment operator. | |
virtual | ~OsiXprSolverInterface () |
Destructor. | |
Static Public Member Functions | |
int | version () |
Return XPRESS-MP Version number. | |
Static instance counter methods | |
void | incrementInstanceCounter () |
void | decrementInstanceCounter () |
unsigned int | getNumInstances () |
Log File | |
FILE * | getLogFilePtr () |
Get logfile FILE *. | |
void | setLogFileName (const char *filename) |
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 methods | |
void | gutsOfCopy (const OsiXprSolverInterface &source) |
The real work of a copy constructor (used by copy and assignment). | |
void | gutsOfDestructor () |
The real work of a destructor (used by copy and assignment). | |
void | freeSolution () |
Destroy cached copy of solution data (whenever it changes). | |
void | freeCachedResults () |
int | getNumIntVars () const |
Number of integer variables in the problem. | |
Methods to support for XPRESS-MP multiple matrix facility | |
void | getVarTypes () const |
Build cached copy of variable types. | |
void | activateMe () const |
bool | isDataLoaded () const |
Private Attributes | |
Data to suupport for XPRESS-MP multiple matrix facility | |
bool | xprSaved_ |
Flag indicating that XPRESS has a saved copy of this problem. | |
int | xprMatrixId_ |
XPRESS matrix number for this saved problem. | |
std::string | xprProbname_ |
XPRESS problem name (should be unique for each saved problem). | |
Cached copies of XPRESS-MP problem data | |
CoinPackedMatrix * | matrixByRow_ |
CoinPackedMatrix * | matrixByCol_ |
double * | colupper_ |
Pointer to dense vector of structural variable upper bounds. | |
double * | collower_ |
Pointer to dense vector of structural variable lower bounds. | |
double * | rowupper_ |
Pointer to dense vector of slack variable upper bounds. | |
double * | rowlower_ |
Pointer to dense vector of slack 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_ |
double * | objcoeffs_ |
Pointer to dense vector of objective coefficients. | |
double | objsense_ |
Sense of objective (1 for min; -1 for max). | |
double * | colsol_ |
Pointer to dense vector of primal structural variable values. | |
double * | rowsol_ |
Pointer to dense vector of primal slack variable values. | |
double * | rowact_ |
Pointer to dense vector of primal slack variable values. | |
double * | rowprice_ |
Pointer to dense vector of dual row variable values. | |
double * | colprice_ |
Pointer to dense vector of dual column variable values. | |
int * | ivarind_ |
Pointer to list of indices of XPRESS "global" variables. | |
char * | ivartype_ |
char * | vartype_ |
Static Private Attributes | |
Private static class data | |
const char * | logFileName_ = NULL |
Name of the logfile. | |
FILE * | logFilePtr_ = NULL |
The FILE* to the logfile. | |
unsigned int | numInstances_ = 0 |
Number of live problem instances. | |
unsigned int | osiSerial_ = 0 |
Counts calls to incrementInstanceCounter(). | |
const OsiXprSolverInterface * | xprCurrentProblem_ = NULL |
Pointer to solver object for the active problem. | |
Friends | |
void | OsiXprSolverInterfaceUnitTest (const std::string &mpsDir, const std::string &netlibDir) |
Instantiation of OsiSolverInterface for XPRESS-MP
Definition at line 22 of file OsiXprSolverInterface.hpp.
|
Save the current problem in XPRESS (if necessary) and make this problem current (restore if necessary). Definition at line 2701 of file OsiXprSolverInterface.cpp. References getLogFilePtr(), xprCurrentProblem_, xprMatrixId_, xprProbname_, and xprSaved_. Referenced by addCol(), applyColCut(), applyRowCut(), branchAndBound(), deleteCols(), deleteRows(), getColLower(), getColSolution(), getColUpper(), getMatrixByRow(), getNumCols(), getNumElements(), getNumIntVars(), getNumRows(), getObjCoefficients(), getObjValue(), getReducedCost(), getRightHandSide(), getRowActivity(), getRowPrice(), getRowRange(), getRowSense(), getVarTypes(), getWarmStart(), gutsOfCopy(), initialSolve(), isAbandoned(), isDualObjectiveLimitReached(), isIterationLimitReached(), isPrimalObjectiveLimitReached(), isProvenDualInfeasible(), isProvenOptimal(), isProvenPrimalInfeasible(), loadProblem(), readMps(), resolve(), setColBounds(), setColLower(), setColSolution(), setColUpper(), setContinuous(), setInteger(), setObjCoeff(), setRowPrice(), setRowType(), setWarmStart(), and writeMps().
02702 { 02703 if ( xprCurrentProblem_ == this ) return; // we're already active 02704 02705 if ( xprCurrentProblem_ ) { // someone else is active... 02706 if ( xprCurrentProblem_->xprProbname_ != "" ) { // ...and has data 02707 02708 if ( getLogFilePtr()!=NULL ) { 02709 fprintf(getLogFilePtr(),"{\n"); 02710 fprintf(getLogFilePtr()," int matrixId;\n"); 02711 fprintf(getLogFilePtr()," int iret = savmat(& matrixId);\n"); 02712 } 02713 02714 // cout << "Problem " << xprCurrentProblem_->xprProbname_ 02715 // << " saved as matrix "; 02716 int iret = savmat(& xprCurrentProblem_->xprMatrixId_); 02717 if ( iret != 0 ) getipv(N_ERRNO, &iret); 02718 assert( iret == 0 ); 02719 // cout << xprCurrentProblem_->xprMatrixId_ << "." << endl; 02720 xprCurrentProblem_->xprSaved_ = true; 02721 02722 if ( getLogFilePtr()!=NULL ) { 02723 fprintf(getLogFilePtr()," // matrixId returned was %d;\n",xprCurrentProblem_->xprMatrixId_); 02724 fprintf(getLogFilePtr(),"}\n"); 02725 } 02726 02727 } 02728 } 02729 02730 if ( xprSaved_ ) { // we were saved before 02731 // cout << "Problem " << xprProbname_ << " restored from matrix " 02732 // << xprMatrixId_ << "." << endl; 02733 02734 if ( getLogFilePtr()!=NULL ) { 02735 fprintf(getLogFilePtr(),"{\n"); 02736 fprintf(getLogFilePtr()," int iret = resmat(%d);\n",xprMatrixId_); 02737 fprintf(getLogFilePtr(),"}\n"); 02738 } 02739 02740 int iret = resmat(xprMatrixId_); 02741 if ( iret != 0 ) getipv(N_ERRNO, &iret); 02742 assert( iret == 0 ); 02743 xprSaved_ = false; 02744 } 02745 02746 xprCurrentProblem_ = this; 02747 } |
|
Add a column (primal variable) to the problem. Implements OsiSolverInterface. Definition at line 1509 of file OsiXprSolverInterface.cpp. References activateMe(), freeCachedResults(), CoinPackedVectorBase::getElements(), CoinPackedVectorBase::getIndices(), CoinPackedVectorBase::getNumElements(), and isDataLoaded(). Referenced by addCols().
01512 { 01513 activateMe(); 01514 01515 if ( isDataLoaded() ) { 01516 freeCachedResults(); 01517 01518 int mstart = 0; 01519 01520 addcols(1, vec.getNumElements(), const_cast<double*>(&obj), 01521 &mstart, 01522 const_cast<int*>(vec.getIndices()), 01523 const_cast<double*>(vec.getElements()), 01524 const_cast<double*>(&collb), 01525 const_cast<double*>(&colub)); 01526 } 01527 } |
|
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 1530 of file OsiXprSolverInterface.cpp. References addCol().
01534 { 01535 // activateMe(); 01536 // freeCachedResults(); 01537 01538 for( int i = 0; i < numcols; i++ ) 01539 addCol( *(cols[i]), collb[i], colub[i], obj[i] ); 01540 } |
|
Add a row (constraint) to the problem. Implements OsiSolverInterface. Definition at line 1551 of file OsiXprSolverInterface.cpp. References OsiSolverInterface::convertBoundToSense().
01553 { 01554 // activateMe(); -- will be invoked 01555 // freeCachedResults(); -- will be invoked 01556 01557 char sense; 01558 double rhs, range; 01559 01560 convertBoundToSense(rowlb, rowub, sense, rhs, range); 01561 addRow(vec, sense, rhs, range); 01562 } |
|
Add a set of rows (constraints) to the problem. The default implementation simply makes repeated calls to addRow(). Reimplemented from OsiSolverInterface. Definition at line 1592 of file OsiXprSolverInterface.cpp.
01596 { 01597 // *FIXME* : must write the method -LL 01598 throw CoinError("method is not yet written", "addRows", 01599 "OsiXprSolverInterface"); 01600 } |
|
Add a set of rows (constraints) to the problem. The default implementation simply makes repeated calls to addRow(). Reimplemented from OsiSolverInterface. Definition at line 1582 of file OsiXprSolverInterface.cpp.
01585 { 01586 // *FIXME* : must write the method -LL 01587 throw CoinError("method is not yet written", "addRows", 01588 "OsiXprSolverInterface"); 01589 } |
|
Apply a column cut (bound adjustment). Return true if cut was applied. Implements OsiSolverInterface. Definition at line 2427 of file OsiXprSolverInterface.cpp. References activateMe(), freeCachedResults(), getColLower(), getColUpper(), CoinPackedVector::getElements(), CoinPackedVector::getIndices(), getLogFilePtr(), CoinPackedVector::getNumElements(), OsiColCut::lbs(), and OsiColCut::ubs().
02428 { 02429 activateMe(); 02430 02431 const double *collower = getColLower(); 02432 const double *colupper = getColUpper(); 02433 const CoinPackedVector & lbs = cc.lbs(); 02434 const CoinPackedVector & ubs = cc.ubs(); 02435 02436 int *index = new int [lbs.getNumElements() + ubs.getNumElements()]; 02437 char *btype = new char [lbs.getNumElements() + ubs.getNumElements()]; 02438 double *value = new double[lbs.getNumElements() + ubs.getNumElements()]; 02439 02440 int i, nbds; 02441 02442 for ( i = nbds = 0; i < lbs.getNumElements(); i++, nbds++ ) { 02443 index[nbds] = lbs.getIndices()[i]; 02444 btype[nbds] = 'L'; 02445 value[nbds] = (collower[index[nbds]] > lbs.getElements()[i]) ? 02446 collower[index[nbds]] : lbs.getElements()[i]; 02447 } 02448 02449 for ( i = 0; i < ubs.getNumElements(); i++, nbds++ ) { 02450 index[nbds] = ubs.getIndices()[i]; 02451 btype[nbds] = 'U'; 02452 value[nbds] = (colupper[index[nbds]] < ubs.getElements()[i]) ? 02453 colupper[index[nbds]] : ubs.getElements()[i]; 02454 } 02455 02456 if (getLogFilePtr()!=NULL) { 02457 fprintf(getLogFilePtr(),"{\n"); 02458 fprintf(getLogFilePtr()," int index[%d];\n",nbds); 02459 fprintf(getLogFilePtr()," char btype[%d];\n",nbds); 02460 fprintf(getLogFilePtr()," double value[%d];\n",nbds); 02461 for ( i=0; i<nbds; i++ ) { 02462 fprintf(getLogFilePtr()," index[%d]=%d;\n",i,index[i]); 02463 fprintf(getLogFilePtr()," btype[%d]='%c';\n",i,btype[i]); 02464 fprintf(getLogFilePtr()," value[%d]=%f;\n",i,value[i]); 02465 } 02466 fprintf(getLogFilePtr()," chgbds(%d, index, btype, value);\n",nbds); 02467 fprintf(getLogFilePtr(),"}\n"); 02468 } 02469 02470 chgbds(nbds, index, btype, value); 02471 02472 delete [] index; 02473 delete [] btype; 02474 delete [] value; 02475 02476 freeCachedResults(); 02477 // delete [] colupper_; colupper_ = NULL; 02478 // delete [] collower_; collower_ = NULL; 02479 } |
|
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 1865 of file OsiXprSolverInterface.cpp. References loadProblem().
01870 { 01871 loadProblem(*matrix, collb, colub, obj, rowsen, rowrhs, rowrng); 01872 delete matrix; matrix = 0; 01873 delete[] collb; collb = 0; 01874 delete[] colub; colub = 0; 01875 delete[] obj; obj = 0; 01876 delete[] rowsen; rowsen = 0; 01877 delete[] rowrhs; rowrhs = 0; 01878 delete[] rowrng; rowrng = 0; 01879 } |
|
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 1687 of file OsiXprSolverInterface.cpp. References loadProblem().
01691 { 01692 loadProblem(*matrix, collb, colub, obj, rowlb, rowub); 01693 delete matrix; matrix = 0; 01694 delete[] collb; collb = 0; 01695 delete[] colub; colub = 0; 01696 delete[] obj; obj = 0; 01697 delete[] rowlb; rowlb = 0; 01698 delete[] rowub; rowub = 0; 01699 } |
|
XPRESS has a context that should be deleted after XPRESS calls. This method:
Definition at line 2226 of file OsiXprSolverInterface.cpp. References getLogFilePtr(), and numInstances_. Referenced by ~OsiXprSolverInterface().
02227 { 02228 assert( numInstances_ != 0 ); 02229 numInstances_--; 02230 02231 // cout << "Instances = " << numInstances_ << endl; 02232 02233 if ( numInstances_ == 0 ) { 02234 02235 if ( getLogFilePtr()!=NULL ) { 02236 fprintf(getLogFilePtr(),"{\n"); 02237 fprintf(getLogFilePtr()," freexo();\n"); 02238 fprintf(getLogFilePtr(),"}\n"); 02239 } 02240 02241 freexo(); 02242 } 02243 } |
|
Remove a set of columns (primal variables) from the problem. Implements OsiSolverInterface. Definition at line 1543 of file OsiXprSolverInterface.cpp. References activateMe(), and freeCachedResults().
01544 { 01545 activateMe(); 01546 freeCachedResults(); 01547 delcols(num, const_cast<int *>(columnIndices)); 01548 } |
|
Delete a set of rows (constraints) from the problem. Implements OsiSolverInterface. Definition at line 1603 of file OsiXprSolverInterface.cpp. References activateMe(), and freeCachedResults().
01604 { 01605 activateMe(); 01606 freeCachedResults(); 01607 01608 delrows(num, const_cast<int *>(rowIndices)); 01609 } |
|
Destroy cached copies of problem and solution data (whenever they change) Definition at line 2606 of file OsiXprSolverInterface.cpp. References collower_, colupper_, freeSolution(), ivarind_, ivartype_, matrixByRow_, objcoeffs_, rhs_, rowlower_, rowrange_, rowsense_, rowupper_, and vartype_. Referenced by addCol(), applyColCut(), applyRowCut(), deleteCols(), deleteRows(), gutsOfDestructor(), loadProblem(), setColBounds(), setColLower(), setColUpper(), setContinuous(), setInteger(), setObjCoeff(), and setRowType().
02607 { 02608 delete matrixByRow_; matrixByRow_ = NULL; 02609 delete matrixByCol_; matrixByCol_ = NULL; 02610 delete [] colupper_; colupper_ = NULL; 02611 delete [] collower_; collower_ = NULL; 02612 delete [] rowupper_; rowupper_ = NULL; 02613 delete [] rowlower_; rowlower_ = NULL; 02614 02615 delete [] rowsense_; rowsense_ = NULL; 02616 delete [] rhs_; rhs_ = NULL; 02617 delete [] rowrange_; rowrange_ = NULL; 02618 02619 delete [] objcoeffs_; objcoeffs_ = NULL; 02620 02621 freeSolution(); 02622 02623 delete [] ivarind_; ivarind_ = NULL; 02624 delete [] ivartype_; ivartype_ = NULL; 02625 delete [] vartype_; vartype_ = NULL; 02626 } |
|
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 1040 of file OsiXprSolverInterface.cpp.
01041 { 01042 // *FIXME* : must write the method -LL 01043 throw CoinError("method is not yet written", "getDualRays", 01044 "OsiXprSolverInterface"); 01045 return std::vector<double*>(); 01046 } |
|
Get how many iterations it took to solve the problem (whatever "iteration" mean to the solver. Implements OsiSolverInterface. Definition at line 1029 of file OsiXprSolverInterface.cpp.
01030 { 01031 int itcnt; 01032 01033 getipv(N_ITCNT, &itcnt); 01034 01035 return itcnt; 01036 } |
|
Return the number of instances of instantiated objects using XPRESS services. Definition at line 2248 of file OsiXprSolverInterface.cpp. References numInstances_.
02249 { 02250 return numInstances_; 02251 } |
|
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 1050 of file OsiXprSolverInterface.cpp. References getNumCols(), and getNumRows().
01051 { 01052 #if 0 01053 // *FIXME* : Still need to expand column into full ncols-length vector 01054 01055 const int nrows = getNumRows(); 01056 int nrspar; 01057 getipv(N_NRSPAR, &nrspar); 01058 int junb; 01059 int retcode; 01060 01061 retcode = getunb(&junb); 01062 01063 if ( retcode != 0 ) 01064 return std::vector<double *>(0, (double *) NULL);; 01065 01066 double *ray = new double[nrows]; 01067 01068 01069 if ( junb < nrows ) { // it's a slack 01070 int i; 01071 01072 for ( i = 0; i < nrows; i++ ) ray[i] = 0.0; 01073 ray[junb] = 1.0; 01074 retcode = ftran(ray); 01075 } else if ( junb >= nrows + nrspar && 01076 junb < nrows + nrspar + getNumCols() ){ 01077 // it's a structural variable 01078 int *mstart = new int[nrows]; 01079 int *mrowind = new int[nrows]; 01080 double *dmatval = new double[nrows]; 01081 int nelt; 01082 int jcol = junb - nrows - nrspar; 01083 01084 retcode = getcols(mstart, mrowind, dmatval, nrows, &nelt, 01085 jcol, jcol); 01086 /* Unpack into the zeroed array y */ 01087 int i, ielt; 01088 01089 for ( i = 0; i < nrows; i++ ) ray[i] = 0.0; 01090 for ( ielt = 0; ielt < nelt; ielt++ ) 01091 ray[mrowind[ielt]] = dmatval[ielt]; 01092 retcode = ftran(ray); 01093 01094 delete [] mstart; 01095 delete [] mrowind; 01096 delete [] dmatval; 01097 } else { // it's an error 01098 retcode = 1; 01099 } 01100 01101 if ( retcode == 0 ) return std::vector<double *>(1, ray); 01102 else { 01103 delete ray; 01104 return std::vector<double *>(0, (double *) NULL); 01105 } 01106 #endif 01107 01108 // *FIXME* : must write the method -LL 01109 throw CoinError("method is not yet written", "getPrimalRays", 01110 "OsiXprSolverInterface"); 01111 return std::vector<double*>(); 01112 } |
|
Get pointer to array[getNumRows()] of rows right-hand sides
Implements OsiSolverInterface. Definition at line 629 of file OsiXprSolverInterface.cpp. References activateMe(), getLogFilePtr(), getNumRows(), getRowSense(), isDataLoaded(), and rhs_. Referenced by getRowActivity(), getRowLower(), getRowUpper(), setRowLower(), and setRowUpper().
00630 { 00631 if ( rhs_ == NULL ) { 00632 activateMe(); 00633 00634 if ( isDataLoaded() ) { 00635 int nrows = getNumRows(); 00636 00637 if (getLogFilePtr()!=NULL) { 00638 fprintf(getLogFilePtr(),"{\n"); 00639 fprintf(getLogFilePtr()," double rhs[%d];\n",nrows); 00640 fprintf(getLogFilePtr()," getrhs(rhs, 0, %d);\n",nrows-1); 00641 fprintf(getLogFilePtr(),"}\n"); 00642 } 00643 00644 rhs_ = new double[nrows]; 00645 getrhs(rhs_, 0, nrows - 1); 00646 00647 // Make sure free rows have rhs of zero 00648 const char * rs = getRowSense(); 00649 int nr = getNumRows(); 00650 int i; 00651 for ( i = 0; i < nr; i++ ) { 00652 if ( rs[i] == 'N' ) rhs_[i]=0.0; 00653 } 00654 } 00655 } 00656 00657 return rhs_; 00658 } |
|
Get pointer to array[getNumRows()] of row activity levels (constraint matrix times the solution vector Implements OsiSolverInterface. Definition at line 974 of file OsiXprSolverInterface.cpp. References activateMe(), getNumRows(), getRightHandSide(), isDataLoaded(), and rowact_.
00975 { 00976 if( rowact_ == NULL ) { 00977 activateMe(); 00978 00979 if ( isDataLoaded() ) { 00980 int nrows = getNumRows(); 00981 const double *rhs = getRightHandSide(); 00982 if( nrows > 0 ) { 00983 int status; 00984 00985 rowact_ = new double[nrows]; 00986 00987 getipv(N_PSTAT, &status); 00988 00989 if ( status == 7 ) { 00990 int i; 00991 00992 solution(NULL, rowact_, NULL, NULL); 00993 00994 for ( i = 0; i < nrows; i++ ) 00995 rowact_[i] = rhs[i] - rowact_[i]; 00996 } else { 00997 CoinFillN(rowact_, nrows, 0.0); 00998 } 00999 } 01000 } 01001 } 01002 return rowact_; 01003 } |
|
Get pointer to array[getNumRows()] of row ranges.
Implements OsiSolverInterface. Definition at line 661 of file OsiXprSolverInterface.cpp. References activateMe(), getLogFilePtr(), getNumRows(), getRowSense(), isDataLoaded(), and rowrange_. Referenced by getRowLower(), getRowUpper(), setRowLower(), and setRowUpper().
00662 { 00663 if ( rowrange_ == NULL ) { 00664 activateMe(); 00665 00666 if ( isDataLoaded() ) { 00667 int nrows = getNumRows(); 00668 00669 if (getLogFilePtr()!=NULL) { 00670 fprintf(getLogFilePtr(),"{\n"); 00671 fprintf(getLogFilePtr()," double rowrange[%d];\n",nrows); 00672 fprintf(getLogFilePtr()," getrng(rowrange, 0, %d);\n",nrows-1); 00673 fprintf(getLogFilePtr(),"}\n"); 00674 } 00675 rowrange_ = new double[nrows]; 00676 getrng(rowrange_, 0, nrows - 1); 00677 00678 // Make sure non-R rows have range of 0.0 00679 // XPRESS seems to set N and L rows to a range of Infinity 00680 const char * rs = getRowSense(); 00681 int nr = getNumRows(); 00682 int i; 00683 for ( i = 0; i < nr; i++ ) { 00684 if ( rs[i] != 'R' ) rowrange_[i] = 0.0; 00685 } 00686 } 00687 } 00688 00689 return rowrange_; 00690 } |
|
Get pointer to array[getNumRows()] of row constraint senses.
Implements OsiSolverInterface. Definition at line 606 of file OsiXprSolverInterface.cpp. References activateMe(), getLogFilePtr(), getNumRows(), isDataLoaded(), and rowsense_. Referenced by getRightHandSide(), getRowLower(), getRowRange(), getRowUpper(), setRowLower(), and setRowUpper().
00607 { 00608 if ( rowsense_ == NULL ) { 00609 activateMe(); 00610 00611 if ( isDataLoaded() ) { 00612 int nrows = getNumRows(); 00613 00614 if (getLogFilePtr()!=NULL) { 00615 fprintf(getLogFilePtr(),"{\n"); 00616 fprintf(getLogFilePtr()," char rowsense[%d];\n",nrows); 00617 fprintf(getLogFilePtr()," getrowtype(rowsense, 0, %d);\n",nrows-1); 00618 fprintf(getLogFilePtr(),"}\n"); 00619 } 00620 rowsense_ = new char[nrows]; 00621 getrowtype(rowsense_, 0, nrows - 1); 00622 } 00623 } 00624 00625 return rowsense_; 00626 } |
|
XPRESS has a context that must be created prior to all other XPRESS calls. This method:
Definition at line 2197 of file OsiXprSolverInterface.cpp. References getLogFilePtr(), numInstances_, and osiSerial_. Referenced by OsiXprSolverInterface().
02198 { 02199 if ( numInstances_ == 0 ) { 02200 if ( getLogFilePtr()!=NULL ) { 02201 fprintf(getLogFilePtr(),"{\n"); 02202 fprintf(getLogFilePtr()," setoptlog(\"xpress.log\");\n"); 02203 fprintf(getLogFilePtr()," initlz(NULL,0);\n"); 02204 fprintf(getLogFilePtr(),"}\n"); 02205 } 02206 const char *logfile = "xpress.log"; 02207 setoptlog(logfile); 02208 int iret = initlz(NULL, 0); 02209 02210 // Student Version returns 32 02211 if ( iret != 32 ) { 02212 if ( iret != 0 ) getipv(N_ERRNO, &iret); 02213 assert(iret == 0); 02214 } 02215 } 02216 02217 numInstances_++; 02218 osiSerial_++; 02219 02220 // cout << "Instances = " << numInstances_ << "; Serial = " << osiSerial_ << endl; 02221 } |
|
Save and restore are necessary if there is data associated with this problem. Also, queries to a problem with no data should respond sensibly; XPRESS query results are undefined. Definition at line 2752 of file OsiXprSolverInterface.cpp. References xprProbname_. Referenced by addCol(), getColLower(), getColSolution(), getColUpper(), getMatrixByRow(), getNumCols(), getNumElements(), getNumIntVars(), getNumRows(), getObjCoefficients(), getObjValue(), getReducedCost(), getRightHandSide(), getRowActivity(), getRowPrice(), getRowRange(), getRowSense(), setColBounds(), setColLower(), setColUpper(), setContinuous(), setInteger(), setObjCoeff(), and setRowType().
02753 { 02754 return xprProbname_ != ""; 02755 } |
|
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 1914 of file OsiXprSolverInterface.cpp. References activateMe(), freeCachedResults(), getLogFilePtr(), osiSerial_, and xprProbname_.
01921 { 01922 assert( rowsen != NULL ); 01923 assert( rowrhs != NULL ); 01924 01925 activateMe(); 01926 freeCachedResults(); 01927 int i; 01928 01929 // Set column values to defaults if NULL pointer passed 01930 int nc = numcols; 01931 int nr = numrows; 01932 int * len = new int[nc]; 01933 double * clb; 01934 double * cub; 01935 double * ob; 01936 01937 std::adjacent_difference(start, start + (nc+1), len); 01938 01939 if ( collb!=NULL ) { 01940 clb=const_cast<double*>(collb); 01941 } 01942 else { 01943 clb = new double[nc]; 01944 for( i=0; i<nc; i++ ) clb[i]=0.0; 01945 } 01946 if ( colub!=NULL ) 01947 cub=const_cast<double*>(colub); 01948 else { 01949 cub = new double[nc]; 01950 for( i=0; i<nc; i++ ) cub[i]=DPLINF; 01951 } 01952 if ( obj!=NULL ) 01953 ob=const_cast<double*>(obj); 01954 else { 01955 ob = new double[nc]; 01956 for( i=0; i<nc; i++ ) ob[i]=0.0; 01957 } 01958 01959 // Generate a problem name 01960 char probName[256]; 01961 sprintf(probName, "Prob%i", osiSerial_); 01962 01963 if ( getLogFilePtr()!=NULL ) { 01964 fprintf(getLogFilePtr(),"{\n"); 01965 01966 fprintf(getLogFilePtr()," char rowsen[%d];\n",nr); 01967 for ( i=0; i<nr; i++ ) 01968 fprintf(getLogFilePtr()," rowsen[%d]='%c';\n",i,rowsen[i]); 01969 01970 fprintf(getLogFilePtr()," double rowrhs[%d];\n",nr); 01971 for ( i=0; i<nr; i++ ) 01972 fprintf(getLogFilePtr()," rowrhs[%d]=%f;\n",i,rowrhs[i]); 01973 01974 fprintf(getLogFilePtr()," double rowrng[%d];\n",nr); 01975 for ( i=0; i<nr; i++ ) 01976 fprintf(getLogFilePtr()," rowrng[%d]=%f;\n",i,rowrng[i]); 01977 01978 fprintf(getLogFilePtr()," double ob[%d];\n",nc); 01979 for ( i=0; i<nc; i++ ) 01980 fprintf(getLogFilePtr()," ob[%d]=%f;\n",i,ob[i]); 01981 01982 fprintf(getLogFilePtr()," double clb[%d];\n",nc); 01983 for ( i=0; i<nc; i++ ) 01984 fprintf(getLogFilePtr()," clb[%d]=%f;\n",i,clb[i]); 01985 01986 fprintf(getLogFilePtr()," double cub[%d];\n",nc); 01987 for ( i=0; i<nc; i++ ) 01988 fprintf(getLogFilePtr()," cub[%d]=%f;\n",i,cub[i]); 01989 01990 fprintf(getLogFilePtr()," int vectorStarts[%d];\n",nc+1); 01991 for ( i=0; i<=nc; i++ ) 01992 fprintf(getLogFilePtr()," vectorStarts[%d]=%d;\n",i,start[i]); 01993 01994 fprintf(getLogFilePtr()," int vectorLengths[%d];\n",nc); 01995 for ( i=0; i<nc; i++ ) 01996 fprintf(getLogFilePtr()," vectorLengths[%d]=%d;\n",i,len[i]); 01997 01998 fprintf(getLogFilePtr()," int indices[%d];\n",start[nc]); 01999 for ( i=0; i<start[nc]; i++ ) 02000 fprintf(getLogFilePtr()," indices[%d]=%d;\n",i,index[i]); 02001 02002 fprintf(getLogFilePtr()," double elements[%d];\n",start[nc]); 02003 for ( i=0; i<start[nc]; i++ ) 02004 fprintf(getLogFilePtr()," elements[%d]=%f;\n",i,value[i]); 02005 02006 fprintf(getLogFilePtr(), 02007 " int iret = loadprob(\"%s\",\n" 02008 " %d,\n" 02009 " %d,\n" 02010 " rowsen,\n" 02011 " rowrhs,\n" 02012 " rowrng,\n" 02013 " ob,\n" 02014 " vectorStarts,\n" 02015 " vectorLengths,\n" 02016 " indices,\n" 02017 " elements,\n" 02018 " clb,\n" 02019 " cub );\n",probName,nc,nr ); 02020 fprintf(getLogFilePtr(),"}\n"); 02021 } 02022 // Need to cast away const'ness 02023 int iret = loadprob(probName, 02024 nc, 02025 nr, 02026 rowsen, 02027 const_cast<double*>(rowrhs), 02028 const_cast<double*>(rowrng), 02029 ob, 02030 const_cast<int*>(start), 02031 const_cast<int*>(len), 02032 const_cast<int*>(index), 02033 const_cast<double*>(value), 02034 clb, 02035 cub ); 02036 setStrParam(OsiProbName,probName); 02037 02038 if ( iret != 0 ) 02039 getipv(N_ERRNO, &iret); 02040 assert( iret == 0 ); 02041 02042 02043 if (getLogFilePtr()!=NULL) { 02044 fprintf(getLogFilePtr(),"{\n"); 02045 fprintf(getLogFilePtr()," char pname[256];\n"); 02046 fprintf(getLogFilePtr()," getprob(pname);\n"); 02047 fprintf(getLogFilePtr(),"}\n"); 02048 } 02049 02050 char pname[256]; // Problem names can be 200 chars in XPRESS 12 02051 getprob(pname); 02052 xprProbname_ = pname; 02053 02054 if ( collb == NULL ) delete[] clb; 02055 if ( colub == NULL ) delete[] cub; 02056 if ( obj == NULL ) delete[] ob; 02057 delete[] len; 02058 } |
|
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 1884 of file OsiXprSolverInterface.cpp. References OsiSolverInterface::convertBoundToSense(), getInfinity(), and loadProblem().
01890 { 01891 const double inf = getInfinity(); 01892 01893 char * rowSense = new char [numrows]; 01894 double * rowRhs = new double[numrows]; 01895 double * rowRange = new double[numrows]; 01896 01897 for ( int i = numrows - 1; i >= 0; --i ) { 01898 const double lower = rowlb ? rowlb[i] : -inf; 01899 const double upper = rowub ? rowub[i] : inf; 01900 convertBoundToSense( lower, upper, rowSense[i], rowRhs[i], rowRange[i] ); 01901 } 01902 01903 loadProblem(numcols, numrows, start, index, value, collb, colub, obj, 01904 rowSense, rowRhs, rowRange); 01905 delete [] rowSense; 01906 delete [] rowRhs; 01907 delete [] rowRange; 01908 01909 } |
|
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 1706 of file OsiXprSolverInterface.cpp. References activateMe(), freeCachedResults(), getLogFilePtr(), osiSerial_, and xprProbname_.
01711 { 01712 assert( rowsen != NULL ); 01713 assert( rowrhs != NULL ); 01714 01715 activateMe(); 01716 freeCachedResults(); 01717 int i; 01718 01719 // Set column values to defaults if NULL pointer passed 01720 int nc=matrix.getNumCols(); 01721 double * clb; 01722 double * cub; 01723 double * ob; 01724 if ( collb!=NULL ) { 01725 clb=const_cast<double*>(collb); 01726 } 01727 else { 01728 clb = new double[nc]; 01729 for( i=0; i<nc; i++ ) clb[i]=0.0; 01730 } 01731 if ( colub!=NULL ) 01732 cub=const_cast<double*>(colub); 01733 else { 01734 cub = new double[nc]; 01735 for( i=0; i<nc; i++ ) cub[i]=DPLINF; 01736 } 01737 if ( obj!=NULL ) 01738 ob=const_cast<double*>(obj); 01739 else { 01740 ob = new double[nc]; 01741 for( i=0; i<nc; i++ ) ob[i]=0.0; 01742 } 01743 01744 bool freeMatrixRequired = false; 01745 CoinPackedMatrix * m = NULL; 01746 if ( !matrix.isColOrdered() ) { 01747 m = new CoinPackedMatrix(); 01748 m->reverseOrderedCopyOf(matrix); 01749 freeMatrixRequired = true; 01750 } else { 01751 m = const_cast<CoinPackedMatrix *>(&matrix); 01752 } 01753 01754 // Generate a problem name 01755 char probName[256]; 01756 sprintf(probName, "Prob%i", osiSerial_); 01757 01758 01759 nc = m->getNumCols(); 01760 int nr = m->getNumRows(); 01761 01762 if ( getLogFilePtr()!=NULL ) { 01763 fprintf(getLogFilePtr(),"{\n"); 01764 01765 fprintf(getLogFilePtr()," char rowsen[%d];\n",nr); 01766 for ( i=0; i<nr; i++ ) 01767 fprintf(getLogFilePtr()," rowsen[%d]='%c';\n",i,rowsen[i]); 01768 01769 fprintf(getLogFilePtr()," double rowrhs[%d];\n",nr); 01770 for ( i=0; i<nr; i++ ) 01771 fprintf(getLogFilePtr()," rowrhs[%d]=%f;\n",i,rowrhs[i]); 01772 01773 fprintf(getLogFilePtr()," double rowrng[%d];\n",nr); 01774 for ( i=0; i<nr; i++ ) 01775 fprintf(getLogFilePtr()," rowrng[%d]=%f;\n",i,rowrng[i]); 01776 01777 fprintf(getLogFilePtr()," double ob[%d];\n",nc); 01778 for ( i=0; i<nc; i++ ) 01779 fprintf(getLogFilePtr()," ob[%d]=%f;\n",i,ob[i]); 01780 01781 fprintf(getLogFilePtr()," double clb[%d];\n",nc); 01782 for ( i=0; i<nc; i++ ) 01783 fprintf(getLogFilePtr()," clb[%d]=%f;\n",i,clb[i]); 01784 01785 fprintf(getLogFilePtr()," double cub[%d];\n",nc); 01786 for ( i=0; i<nc; i++ ) 01787 fprintf(getLogFilePtr()," cub[%d]=%f;\n",i,cub[i]); 01788 01789 fprintf(getLogFilePtr()," int vectorStarts[%d];\n",nc+1); 01790 for ( i=0; i<=nc; i++ ) 01791 fprintf(getLogFilePtr()," vectorStarts[%d]=%d;\n",i,m->getVectorStarts()[i]); 01792 01793 fprintf(getLogFilePtr()," int vectorLengths[%d];\n",nc); 01794 for ( i=0; i<nc; i++ ) 01795 fprintf(getLogFilePtr()," vectorLengths[%d]=%d;\n",i,m->getVectorLengths()[i]); 01796 01797 fprintf(getLogFilePtr()," int indices[%d];\n",m->getVectorStarts()[nc]); 01798 for ( i=0; i<m->getVectorStarts()[nc]; i++ ) 01799 fprintf(getLogFilePtr()," indices[%d]=%d;\n",i,m->getIndices()[i]); 01800 01801 fprintf(getLogFilePtr()," double elements[%d];\n",m->getVectorStarts()[nc]); 01802 for ( i=0; i<m->getVectorStarts()[nc]; i++ ) 01803 fprintf(getLogFilePtr()," elements[%d]=%f;\n",i,m->getElements()[i]); 01804 01805 fprintf(getLogFilePtr(), 01806 " int iret = loadprob(\"%s\",\n" 01807 " %d,\n" 01808 " %d,\n" 01809 " rowsen,\n" 01810 " rowrhs,\n" 01811 " rowrng,\n" 01812 " ob,\n" 01813 " vectorStarts,\n" 01814 " vectorLengths,\n" 01815 " indices,\n" 01816 " elements,\n" 01817 " clb,\n" 01818 " cub );\n",probName,nc,nr ); 01819 fprintf(getLogFilePtr(),"}\n"); 01820 } 01821 // Need to cast away const'ness 01822 int iret = loadprob(probName, 01823 nc, 01824 nr, 01825 rowsen, 01826 const_cast<double*>(rowrhs), 01827 const_cast<double*>(rowrng), 01828 ob, 01829 const_cast<int*>(m->getVectorStarts()), 01830 const_cast<int*>(m->getVectorLengths()), 01831 const_cast<int*>(m->getIndices()), 01832 const_cast<double*>(m->getElements()), 01833 clb, 01834 cub ); 01835 setStrParam(OsiProbName,probName); 01836 01837 if ( iret != 0 ) 01838 getipv(N_ERRNO, &iret); 01839 assert( iret == 0 ); 01840 01841 01842 if (getLogFilePtr()!=NULL) { 01843 fprintf(getLogFilePtr(),"{\n"); 01844 fprintf(getLogFilePtr()," char pname[256];\n"); 01845 fprintf(getLogFilePtr()," getprob(pname);\n"); 01846 fprintf(getLogFilePtr(),"}\n"); 01847 } 01848 01849 char pname[256]; // Problem names can be 200 chars in XPRESS 12 01850 getprob(pname); 01851 xprProbname_ = pname; 01852 01853 if ( collb==NULL ) delete[] clb; 01854 if ( colub==NULL ) delete[] cub; 01855 if ( obj ==NULL ) delete[] ob; 01856 01857 if (freeMatrixRequired) { 01858 delete m; 01859 } 01860 } |
|
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 1616 of file OsiXprSolverInterface.cpp. References OsiSolverInterface::convertBoundToSense(), and getInfinity(). Referenced by assignProblem(), and loadProblem().
01620 { 01621 const double inf = getInfinity(); 01622 01623 char * rowSense = new char [matrix.getNumRows()]; 01624 double * rowRhs = new double[matrix.getNumRows()]; 01625 double * rowRange = new double[matrix.getNumRows()]; 01626 01627 int i; 01628 for ( i = matrix.getNumRows() - 1; i >= 0; --i) { 01629 01630 double rlb; 01631 if ( rowlb!=NULL ) 01632 rlb = rowlb[i]; 01633 else 01634 rlb = -inf; 01635 01636 double rub; 01637 if ( rowub!=NULL ) 01638 rub = rowub[i]; 01639 else 01640 rub = inf; 01641 01642 convertBoundToSense(rlb,rub,rowSense[i],rowRhs[i],rowRange[i]); 01643 #if 0 01644 if ( rlb==rub ) { 01645 rowSense[i]='E'; 01646 rowRhs[i] =rlb; 01647 rowRange[i]=0.0; 01648 continue; 01649 } 01650 if ( rlb<=-inf && rub>=inf ) { 01651 rowSense[i]='N'; 01652 rowRhs[i] =inf; 01653 rowRange[i]=0.0; 01654 continue; 01655 } 01656 if ( rlb<=-inf && !(rub>=inf) ) { 01657 rowSense[i]='L'; 01658 rowRhs[i] =rub; 01659 rowRange[i]=0.0; 01660 continue; 01661 } 01662 if ( !(rlb<=-inf) && rub>=inf ) { 01663 rowSense[i]='G'; 01664 rowRhs[i] =rlb; 01665 rowRange[i]=0.0; 01666 continue; 01667 } 01668 if ( !(rlb<=-inf) && !(rub>=inf) ) { 01669 rowSense[i]='R'; 01670 rowRhs[i] =rub; 01671 rowRange[i]=rub-rlb; 01672 continue; 01673 } 01674 #endif 01675 } 01676 01677 loadProblem(matrix, collb, colub, obj, rowSense, rowRhs, rowRange ); 01678 01679 delete [] rowSense; 01680 delete [] rowRhs; 01681 delete [] rowRange; 01682 } |
|
Read an mps file from the given filename Reimplemented from OsiSolverInterface. Definition at line 2067 of file OsiXprSolverInterface.cpp. References activateMe(), getLogFilePtr(), OsiSolverInterface::readMps(), and xprProbname_.
02068 { 02069 activateMe(); 02070 02071 #if 0 02072 if (getLogFilePtr()!=NULL) { 02073 fprintf(getLogFilePtr(),"{\n"); 02074 fprintf(getLogFilePtr()," input(\"%s\");\n",filename); 02075 fprintf(getLogFilePtr()," int namlen;\n"); 02076 fprintf(getLogFilePtr()," geticv(N_NAMSIZ,&namlen);\n"); 02077 fprintf(getLogFilePtr()," namlen *= 8;\n"); 02078 } 02079 02080 // Read Mps file. 02081 // XPRESS generates its own file extensions, so we ignore any supplied. 02082 int iret = input(filename); 02083 if ( iret != 0 ) 02084 getipv(N_ERRNO, &iret); 02085 assert( iret == 0 ); 02086 02087 // Get length of Mps names 02088 int namlen; 02089 getipv(N_NAMSIZ, &namlen); 02090 namlen *= 8; 02091 02092 if (getLogFilePtr()!=NULL) { 02093 fprintf(getLogFilePtr()," char objRowName[%d],rowName[%d];\n",namlen,namlen); 02094 fprintf(getLogFilePtr()," getccv(N_OBJNAM, objRowName);\n"); 02095 fprintf(getLogFilePtr()," int nr;\n"); 02096 fprintf(getLogFilePtr()," seticv(N_NROW, &nr);"); 02097 } 02098 02099 // Allocate space to hold row names. 02100 char * objRowName = new char[namlen+1]; 02101 char * rowName = new char[namlen+1]; 02102 02103 // Get name of objective row. 02104 // If "" returned, then first N row is objective row 02105 getccv(N_OBJNAM,objRowName); 02106 02107 // Get number of rows 02108 int nr; 02109 getipv(N_NROW, &nr); 02110 02111 if (getLogFilePtr()!=NULL) { 02112 fprintf(getLogFilePtr()," char rs[%d];\n",nr); 02113 fprintf(getLogFilePtr()," getrowtype(rs, 0, %d);\n",nr-1); 02114 } 02115 02116 // Get row sense. 02117 char * rs = new char[nr]; 02118 getrowtype(rs, 0, nr - 1); 02119 02120 // Loop once for each row looking for objective row 02121 int i; 02122 for ( i=0; i<nr; i++ ) { 02123 02124 // Objective row must be an N row 02125 if ( rs[i]=='N' ) { 02126 02127 if (getLogFilePtr()!=NULL) { 02128 fprintf(getLogFilePtr()," getnames(1,rowName,%d,%d);\n",i,i); 02129 } 02130 02131 // Get name of this row 02132 getnames(1,rowName,i,i); 02133 02134 // Is this the objective row? 02135 if( strcmp(rowName,objRowName)==0 || 02136 strcmp("",objRowName) == 0 ) { 02137 02138 if (getLogFilePtr()!=NULL) { 02139 fprintf(getLogFilePtr()," int rowToDelete[1];\n"); 02140 fprintf(getLogFilePtr()," rowToDelete[0]=%d;\n",i); 02141 fprintf(getLogFilePtr()," delrows(1,rowToDelete);\n"); 02142 } 02143 02144 // found objective row. now delete it 02145 int rowToDelete[1]; 02146 rowToDelete[0] = i; 02147 delrows(1,rowToDelete); 02148 break; 02149 } 02150 } 02151 } 02152 02153 delete [] rs; 02154 delete [] rowName; 02155 delete [] objRowName; 02156 02157 if (getLogFilePtr()!=NULL) { 02158 fprintf(getLogFilePtr()," char pname[256];\n"); 02159 fprintf(getLogFilePtr()," getprob(pname);\n"); 02160 fprintf(getLogFilePtr(),"}\n"); 02161 } 02162 02163 char pname[256]; // Problem names can be 200 chars in XPRESS 12 02164 getprob(pname); 02165 xprProbname_ = pname; 02166 return 0; 02167 #else 02168 int retVal = OsiSolverInterface::readMps(filename,extension); 02169 getStrParam(OsiProbName,xprProbname_); 02170 return retVal; 02171 #endif 02172 } |
|
Set a single column lower and upper bound Reimplemented from OsiSolverInterface. Definition at line 1227 of file OsiXprSolverInterface.cpp. References activateMe(), freeCachedResults(), getLogFilePtr(), getVarTypes(), isDataLoaded(), and vartype_.
01228 { 01229 activateMe(); 01230 01231 if ( isDataLoaded() ) { 01232 char qbtype[2] = { 'L', 'U' }; 01233 int mindex[2]; 01234 double bnd[2]; 01235 01236 getVarTypes(); 01237 mindex[0] = elementIndex; 01238 mindex[1] = elementIndex; 01239 bnd[0] = lower; 01240 bnd[1] = upper; 01241 01242 if (getLogFilePtr()!=NULL) { 01243 fprintf(getLogFilePtr(),"chgbds(2, [%d %d], [%c %c], [%f %f]);\n", 01244 mindex[0], mindex[1], qbtype[0], qbtype[1], bnd[0], bnd[1]); 01245 } 01246 chgbds(2, mindex, qbtype, bnd); 01247 01248 if ( vartype_ && 01249 vartype_[mindex[0]] == 'B' && 01250 !((lower == 0.0 && upper == 0.0) || 01251 (lower == 1.0 && upper == 1.0) || 01252 (lower == 0.0 && upper == 1.0)) ) { 01253 char elementType = 'I'; 01254 01255 if (getLogFilePtr()!=NULL) { 01256 fprintf(getLogFilePtr(),"chgcoltype(1, %d, %c );\n", 01257 mindex[0], elementType); 01258 } 01259 01260 chgcoltype(1, &mindex[0], &elementType); 01261 } 01262 freeCachedResults(); 01263 // delete [] colupper_; 01264 // colupper_ = NULL; 01265 } 01266 } |
|
Set a single column lower bound Implements OsiSolverInterface. Definition at line 1158 of file OsiXprSolverInterface.cpp. References activateMe(), freeCachedResults(), getLogFilePtr(), getVarTypes(), isDataLoaded(), and vartype_.
01159 { 01160 activateMe(); 01161 01162 if ( isDataLoaded() ) { 01163 char boundType = 'L'; 01164 01165 getVarTypes(); 01166 01167 if (getLogFilePtr()!=NULL) { 01168 fprintf(getLogFilePtr(),"chgbds(1, %d, %c, %f );\n", 01169 elementIndex,boundType,elementValue); 01170 } 01171 01172 if ( vartype_ && 01173 vartype_[elementIndex] == 'B' && 01174 (elementValue != 0.0 && elementValue != 1.0) ) { 01175 char elementType = 'I'; 01176 01177 if (getLogFilePtr()!=NULL) { 01178 fprintf(getLogFilePtr(),"chgcoltype(1, %d, %c );\n", 01179 elementIndex,elementType); 01180 } 01181 chgcoltype(1, &elementIndex, &elementType); 01182 } 01183 chgbds(1, &elementIndex, &boundType, &elementValue); 01184 01185 freeCachedResults(); 01186 // delete [] collower_; 01187 // collower_ = NULL; 01188 } 01189 } |
|
Set the bounds on a number of columns simultaneously
Reimplemented from OsiSolverInterface. Definition at line 1270 of file OsiXprSolverInterface.cpp. References OsiSolverInterface::setColSetBounds().
01273 { 01274 OsiSolverInterface::setColSetBounds(indexFirst, indexLast, boundList); 01275 } |
|
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 1477 of file OsiXprSolverInterface.cpp. References activateMe(), colsol_, freeSolution(), and getNumCols().
01478 { 01479 activateMe(); 01480 01481 freeSolution(); 01482 01483 colsol_ = new double[getNumCols()]; 01484 01485 for ( int i = 0; i < getNumCols(); i++ ) 01486 colsol_[i] = colsol[i]; 01487 } |
|
Set a single column upper bound Implements OsiSolverInterface. Definition at line 1194 of file OsiXprSolverInterface.cpp. References activateMe(), freeCachedResults(), getLogFilePtr(), getVarTypes(), isDataLoaded(), and vartype_.
01195 { 01196 activateMe(); 01197 01198 if ( isDataLoaded() ) { 01199 char boundType = 'U'; 01200 01201 getVarTypes(); 01202 if (getLogFilePtr()!=NULL) { 01203 fprintf(getLogFilePtr(),"chgbds(1, %d, %c, %f );\n", 01204 elementIndex,boundType,elementValue); 01205 } 01206 chgbds(1, &elementIndex, &boundType, &elementValue); 01207 if ( vartype_ && 01208 vartype_[elementIndex] == 'B' && 01209 (elementValue != 0.0 && elementValue != 1.0) ) { 01210 char elementType = 'I'; 01211 01212 if (getLogFilePtr()!=NULL) { 01213 fprintf(getLogFilePtr(),"chgcoltype(1, %d, %c );\n", 01214 elementIndex,elementType); 01215 } 01216 01217 chgcoltype(1, &elementIndex, &elementType); 01218 } 01219 freeCachedResults(); 01220 // delete [] colupper_; 01221 // colupper_ = NULL; 01222 } 01223 } |
|
Set the variables listed in indices (which is of length len) to be continuous variables Reimplemented from OsiSolverInterface. Definition at line 1419 of file OsiXprSolverInterface.cpp. References activateMe(), freeCachedResults(), and isDataLoaded().
01420 { 01421 activateMe(); 01422 01423 if ( isDataLoaded() ) { 01424 int pstat; 01425 01426 getipv(N_PSTAT, &pstat); 01427 01428 if ( (pstat & 6) == 0 ) { // not presolved 01429 char *qctype = new char[len]; 01430 01431 CoinFillN(qctype, len, 'C'); 01432 chgcoltype(len, const_cast<int *>(indices), qctype); 01433 freeCachedResults(); 01434 } 01435 } 01436 } |
|
Set the index-th variable to be a continuous variable Implements OsiSolverInterface. Definition at line 1375 of file OsiXprSolverInterface.cpp. References activateMe(), freeCachedResults(), and isDataLoaded().
01376 { 01377 activateMe(); 01378 01379 if ( isDataLoaded() ) { 01380 int pstat; 01381 01382 getipv(N_PSTAT, &pstat); 01383 01384 if ( (pstat & 6) == 0 ) { // not presolved 01385 char qctype = 'C'; 01386 01387 chgcoltype(1, &index, &qctype); 01388 freeCachedResults(); 01389 } 01390 } 01391 } |
|
Set the variables listed in indices (which is of length len) to be integer variables Reimplemented from OsiSolverInterface. Definition at line 1439 of file OsiXprSolverInterface.cpp. References activateMe(), freeCachedResults(), getColLower(), getColUpper(), and isDataLoaded().
01440 { 01441 activateMe(); 01442 01443 if ( isDataLoaded() ) { 01444 int pstat; 01445 01446 getipv(N_PSTAT, &pstat); 01447 01448 if ( (pstat & 6) == 0 ) { // not presolved 01449 char *qctype = new char[len]; 01450 const double* clb = getColLower(); 01451 const double* cub = getColUpper(); 01452 01453 for ( int i = 0; i < len; i++ ) { 01454 if ( clb[indices[i]] == 0.0 && cub[indices[i]] == 1.0 ) 01455 qctype[i] = 'B'; 01456 else 01457 qctype[i] = 'I'; 01458 } 01459 01460 chgcoltype(len, const_cast<int *>(indices), qctype); 01461 freeCachedResults(); 01462 } 01463 } 01464 } |
|
Set the index-th variable to be an integer variable Implements OsiSolverInterface. Definition at line 1394 of file OsiXprSolverInterface.cpp. References activateMe(), freeCachedResults(), getColLower(), getColUpper(), and isDataLoaded().
01395 { 01396 activateMe(); 01397 01398 if ( isDataLoaded() ) { 01399 int pstat; 01400 01401 getipv(N_PSTAT, &pstat); 01402 01403 if ( (pstat & 6) == 0 ) { // not presolved 01404 char qctype; 01405 01406 if ( getColLower()[index] == 0.0 && 01407 getColUpper()[index] == 1.0 ) 01408 qctype = 'B'; 01409 else 01410 qctype = 'I'; 01411 01412 chgcoltype(1, &index, &qctype); 01413 freeCachedResults(); 01414 } 01415 } 01416 } |
|
Set logfile name. The logfile is an attempt to capture the calls to Xpress functions for debugging. Definition at line 2274 of file OsiXprSolverInterface.cpp. References logFileName_.
02275 { 02276 logFileName_ = filename; 02277 } |
|
Set an objective function coefficient Implements OsiSolverInterface. Definition at line 1145 of file OsiXprSolverInterface.cpp. References activateMe(), freeCachedResults(), and isDataLoaded().
01146 { 01147 activateMe(); 01148 01149 if ( isDataLoaded() ) { 01150 chgobj(1, &elementIndex, &elementValue); 01151 freeCachedResults(); 01152 } 01153 } |
|
Set a single row lower and upper bound Reimplemented from OsiSolverInterface. Definition at line 1320 of file OsiXprSolverInterface.cpp. References OsiSolverInterface::convertBoundToSense(), and setRowType().
01321 { 01322 double rhs, range; 01323 char sense; 01324 01325 convertBoundToSense( lower, upper, sense, rhs, range ); 01326 setRowType( elementIndex, sense, rhs, range ); 01327 // freeCachedRowRim(); --- invoked in setRowType() 01328 } |
|
Set a single row lower bound Implements OsiSolverInterface. Definition at line 1280 of file OsiXprSolverInterface.cpp. References OsiSolverInterface::convertBoundToSense(), OsiSolverInterface::convertSenseToBound(), getRightHandSide(), getRowRange(), getRowSense(), and setRowType().
01281 { 01282 // activateMe(); 01283 01284 double rhs = getRightHandSide()[elementIndex]; 01285 double range = getRowRange()[elementIndex]; 01286 char sense = getRowSense()[elementIndex]; 01287 double lower, upper; 01288 01289 convertSenseToBound(sense, rhs, range, lower, upper); 01290 if( lower != elementValue ) { 01291 convertBoundToSense(elementValue, upper, sense, rhs, range); 01292 setRowType(elementIndex, sense, rhs, range); 01293 // freeCachedResults(); --- invoked in setRowType() 01294 } 01295 } |
|
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 1492 of file OsiXprSolverInterface.cpp. References activateMe(), freeSolution(), getNumRows(), and rowprice_.
01493 { 01494 activateMe(); 01495 01496 freeSolution(); 01497 01498 rowprice_ = new double[getNumRows()]; 01499 01500 for ( int i = 0; i < getNumRows(); i++ ) 01501 rowprice_[i] = rowprice[i]; 01502 } |
|
Set the bounds on a number of rows simultaneously
Reimplemented from OsiSolverInterface. Definition at line 1354 of file OsiXprSolverInterface.cpp. References OsiSolverInterface::setRowSetBounds().
01357 { 01358 OsiSolverInterface::setRowSetBounds(indexFirst, indexLast, boundList); 01359 } |
|
Set the type of a number of rows simultaneously
Reimplemented from OsiSolverInterface. Definition at line 1364 of file OsiXprSolverInterface.cpp. References OsiSolverInterface::setRowSetTypes().
01369 { 01370 OsiSolverInterface::setRowSetTypes(indexFirst, indexLast, senseList, rhsList, rangeList); 01371 } |
|
Set the type of a single row Implements OsiSolverInterface. Definition at line 1333 of file OsiXprSolverInterface.cpp. References activateMe(), freeCachedResults(), and isDataLoaded(). Referenced by setRowBounds(), setRowLower(), and setRowUpper().
01335 { 01336 activateMe(); 01337 01338 if ( isDataLoaded() ) { 01339 int mindex[1] = {index}; 01340 char qrtype[1] = {sense}; 01341 double rhs[1] = {rightHandSide}; 01342 double rng[1] = {range}; 01343 01344 chgrowtype(1, mindex, qrtype); 01345 chgrhs(1, mindex, rhs); 01346 chgrng(1, mindex, rng); 01347 01348 freeCachedResults(); 01349 } 01350 } |
|
Set a single row upper bound Implements OsiSolverInterface. Definition at line 1300 of file OsiXprSolverInterface.cpp. References OsiSolverInterface::convertBoundToSense(), OsiSolverInterface::convertSenseToBound(), getRightHandSide(), getRowRange(), getRowSense(), and setRowType().
01301 { 01302 // activateMe(); 01303 01304 double rhs = getRightHandSide()[elementIndex]; 01305 double range = getRowRange()[elementIndex]; 01306 char sense = getRowSense()[elementIndex]; 01307 double lower, upper; 01308 01309 convertSenseToBound( sense, rhs, range, lower, upper ); 01310 if( upper != elementValue ) { 01311 convertBoundToSense(lower, elementValue, sense, rhs, range); 01312 setRowType(elementIndex, sense, rhs, range); 01313 // freeCachedResults(); --- invoked in setRowType() 01314 } 01315 } |
|
Set warmstarting information. Return true/false depending on whether the warmstart information was accepted or not. Implements OsiSolverInterface. Definition at line 397 of file OsiXprSolverInterface.cpp. References activateMe(), CoinWarmStartBasis::getArtifStatus(), CoinWarmStartBasis::getNumArtificial(), getNumCols(), getNumRows(), CoinWarmStartBasis::getNumStructural(), and CoinWarmStartBasis::getStructStatus().
00398 { 00399 const CoinWarmStartBasis* ws = dynamic_cast<const CoinWarmStartBasis*>(warmstart); 00400 00401 if ( !ws ) return false; 00402 00403 activateMe(); 00404 00405 int numcols = ws->getNumStructural(); 00406 int numrows = ws->getNumArtificial(); 00407 00408 if ( numcols != getNumCols() || numrows != getNumRows() ) 00409 return false; 00410 00411 bool retval; 00412 int retstat; 00413 int *cstatus = new int[numcols]; 00414 int *rstatus = new int[numrows]; 00415 int i; 00416 00417 for ( i = 0; i < numrows; i++ ) { 00418 switch( ws->getArtifStatus(i) ) { 00419 case CoinWarmStartBasis::atLowerBound: 00420 rstatus[i] = 0; 00421 break; 00422 case CoinWarmStartBasis::basic: 00423 rstatus[i] = 1; 00424 break; 00425 case CoinWarmStartBasis::atUpperBound: 00426 rstatus[i] = 2; 00427 break; 00428 default: // unknown row status 00429 retval = false; 00430 goto TERMINATE; 00431 } 00432 } 00433 00434 for( i = 0; i < numcols; i++ ) { 00435 switch( ws->getStructStatus(i) ) { 00436 case CoinWarmStartBasis::atLowerBound: 00437 case CoinWarmStartBasis::isFree: 00438 cstatus[i] = 0; 00439 break; 00440 case CoinWarmStartBasis::basic: 00441 cstatus[i] = 1; 00442 break; 00443 case CoinWarmStartBasis::atUpperBound: 00444 cstatus[i] = 2; 00445 break; 00446 default: // unknown row status 00447 retval = false; 00448 goto TERMINATE; 00449 } 00450 } 00451 00452 retstat = loadbasis(rstatus, cstatus); 00453 retval = (retstat == 0); 00454 00455 TERMINATE: 00456 delete[] cstatus; 00457 delete[] rstatus; 00458 return retval; 00459 00460 } |
|
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 2178 of file OsiXprSolverInterface.cpp. References activateMe().
02181 { 02182 activateMe(); 02183 02184 // Note: XPRESS insists on ignoring the extension and 02185 // adding ".mat" instead. Forewarned is forearmed. 02186 // Note: Passing an empty filename produces a file named after 02187 // the problem. 02188 02189 output(filename, ""); 02190 } |
|
A function that tests the methods in the OsiXprSolverInterface 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 32 of file OsiXprSolverInterfaceTest.cpp.
00033 { 00034 00035 #if 0 00036 // Test to at least see if licence managment is working 00037 { 00038 int iret = initlz(NULL, 0); 00039 if ( iret != 0 ) getipv(N_ERRNO, &iret); 00040 assert(iret == 0); 00041 } 00042 #endif 00043 00044 00045 // Test default constructor 00046 { 00047 assert( OsiXprSolverInterface::getNumInstances()==0 ); 00048 OsiXprSolverInterface m; 00049 assert( m.xprSaved_ == false ); 00050 assert( m.xprMatrixId_ = -1 ); 00051 assert( m.xprProbname_ == "" ); 00052 assert( m.matrixByRow_ == NULL ); 00053 assert( m.colupper_ == NULL ); 00054 assert( m.collower_ == NULL ); 00055 assert( m.rowupper_ == NULL ); 00056 assert( m.rowlower_ == NULL ); 00057 assert( m.rowsense_ == NULL ); 00058 assert( m.rhs_ == NULL ); 00059 assert( m.rowrange_ == NULL ); 00060 assert( m.colsol_ == NULL ); 00061 assert( m.rowprice_ == NULL ); 00062 assert( m.ivarind_ == NULL ); 00063 assert( m.ivartype_ == NULL ); 00064 assert( m.vartype_ == NULL ); 00065 assert( OsiXprSolverInterface::getNumInstances() == 1 ); 00066 assert( OsiXprSolverInterface::xprCurrentProblem_ == NULL ); 00067 assert( m.getApplicationData() == NULL ); 00068 int i = 2346; 00069 m.setApplicationData(&i); 00070 assert( *((int *)(m.getApplicationData())) == i ); 00071 } 00072 assert( OsiXprSolverInterface::getNumInstances() == 0 ); 00073 00074 { 00075 CoinRelFltEq eq; 00076 OsiXprSolverInterface m; 00077 assert( OsiXprSolverInterface::getNumInstances() == 1 ); 00078 std::string fn = mpsDir+"exmip1"; 00079 m.readMps(fn.c_str()); 00080 assert( OsiXprSolverInterface::xprCurrentProblem_ == &m ); 00081 // This assert fails on windows because fn is mixed case and xprProbname_is uppercase. 00082 //assert( m.xprProbname_ == fn ); 00083 int ad = 13579; 00084 m.setApplicationData(&ad); 00085 assert( *((int *)(m.getApplicationData())) == ad ); 00086 00087 { 00088 OsiXprSolverInterface im; 00089 // assert( im.modelPtr_==NULL ); 00090 00091 assert( im.getNumCols() == 0 ); 00092 00093 // assert( im.modelPtr()!=NULL ); 00094 // assert( im.mutableModelPtr()!=NULL ); 00095 // assert( im.modelPtr() == im.mutableModelPtr() ); 00096 } 00097 00098 // Test copy constructor and assignment operator 00099 { 00100 OsiXprSolverInterface lhs; 00101 { 00102 assert( *((int *)(m.getApplicationData())) == ad ); 00103 OsiXprSolverInterface im(m); 00104 assert( *((int *)(im.getApplicationData())) == ad ); 00105 00106 OsiXprSolverInterface imC1(im); 00107 // assert( imC1.mutableModelPtr()!=im.mutableModelPtr() ); 00108 // assert( imC1.modelPtr()!=im.modelPtr() ); 00109 assert( imC1.getNumCols() == im.getNumCols() ); 00110 assert( imC1.getNumRows() == im.getNumRows() ); 00111 assert( *((int *)(imC1.getApplicationData())) == ad ); 00112 00113 //im.setModelPtr(m); 00114 00115 00116 OsiXprSolverInterface imC2(im); 00117 // assert( imC2.mutableModelPtr()!=im.mutableModelPtr() ); 00118 // assert( imC2.modelPtr()!=im.modelPtr() ); 00119 assert( imC2.getNumCols() == im.getNumCols() ); 00120 assert( imC2.getNumRows() == im.getNumRows() ); 00121 assert( *((int *)(imC2.getApplicationData())) == ad ); 00122 00123 // assert( imC2.mutableModelPtr()!=imC1.mutableModelPtr() ); 00124 // assert( imC2.modelPtr()!=imC1.modelPtr() ); 00125 00126 lhs=imC2; 00127 } 00128 00129 // Test that lhs has correct values even though rhs has gone out of scope 00130 // assert( lhs.mutableModelPtr() != m.mutableModelPtr() ); 00131 // assert( lhs.modelPtr() != m.modelPtr() ); 00132 assert( lhs.getNumCols() == m.getNumCols() ); 00133 assert( lhs.getNumRows() == m.getNumRows() ); 00134 assert( *((int *)(lhs.getApplicationData())) == ad ); 00135 } 00136 00137 // Test clone 00138 { 00139 OsiXprSolverInterface xprSi(m); 00140 OsiSolverInterface * siPtr = &xprSi; 00141 OsiSolverInterface * siClone = siPtr->clone(); 00142 OsiXprSolverInterface * xprClone = dynamic_cast<OsiXprSolverInterface*>(siClone); 00143 assert( xprClone != NULL ); 00144 // assert( xprClone->modelPtr() != xprSi.modelPtr() ); 00145 // assert( xprClone->modelPtr() != m.modelPtr() ); 00146 assert( xprClone->getNumRows() == xprSi.getNumRows() ); 00147 assert( xprClone->getNumCols() == m.getNumCols() ); 00148 00149 assert( *((int *)(xprClone->getApplicationData())) == ad ); 00150 delete siClone; 00151 } 00152 00153 // Test infinity 00154 { 00155 OsiXprSolverInterface si; 00156 assert( eq(si.getInfinity(), DPLINF) ); 00157 } 00158 00159 // Test setting solution 00160 { 00161 OsiXprSolverInterface m1(m); 00162 int i; 00163 00164 double * cs = new double[m1.getNumCols()]; 00165 for ( i = 0; i < m1.getNumCols(); i++ ) 00166 cs[i] = i + .5; 00167 m1.setColSolution(cs); 00168 for ( i = 0; i < m1.getNumCols(); i++ ) 00169 assert(m1.getColSolution()[i] == i + .5); 00170 00171 double * rs = new double[m1.getNumRows()]; 00172 for ( i = 0; i < m1.getNumRows(); i++ ) 00173 rs[i] = i - .5; 00174 m1.setRowPrice(rs); 00175 for ( i = 0; i < m1.getNumRows(); i++ ) 00176 assert(m1.getRowPrice()[i] == i - .5); 00177 00178 delete [] cs; 00179 delete [] rs; 00180 } 00181 00182 // Test fraction Indices 00183 { 00184 OsiXprSolverInterface fim; 00185 std::string fn = mpsDir+"exmip1"; 00186 fim.readMps(fn.c_str()); 00187 //fim.setModelPtr(m); 00188 // exmip1.mps has 2 integer variables with index 2 & 3 00189 assert( fim.isContinuous(0) ); 00190 assert( fim.isContinuous(1) ); 00191 assert( !fim.isContinuous(2) ); 00192 assert( !fim.isContinuous(3) ); 00193 assert( fim.isContinuous(4) ); 00194 00195 assert( !fim.isInteger(0) ); 00196 assert( !fim.isInteger(1) ); 00197 assert( fim.isInteger(2) ); 00198 assert( fim.isInteger(3) ); 00199 assert( !fim.isInteger(4) ); 00200 00201 // XPRESS-MP incorrectly treats unbounded integer variables as 00202 // general integers instead of binary (as in MPSX standard) 00203 assert( !fim.isBinary(0) ); 00204 assert( !fim.isBinary(1) ); 00205 assert( fim.isBinary(2) ); 00206 assert( fim.isBinary(3) ); 00207 assert( !fim.isBinary(4) ); 00208 00209 assert( !fim.isIntegerNonBinary(0) ); 00210 assert( !fim.isIntegerNonBinary(1) ); 00211 assert( !fim.isIntegerNonBinary(2) ); 00212 assert( !fim.isIntegerNonBinary(3) ); 00213 assert( !fim.isIntegerNonBinary(4) ); 00214 00215 // Test fractionalIndices 00216 { 00217 // Set a solution vector 00218 double * cs = new double[fim.getNumCols()]; 00219 for ( int i = 0; i < fim.getNumCols(); cs[i++] = 0.0 ); 00220 cs[2] = 2.9; 00221 cs[3] = 3.0; 00222 fim.setColSolution(cs); 00223 00224 OsiVectorInt fi = fim.getFractionalIndices(); 00225 assert( fi.size() == 1 ); 00226 assert( fi[0]==2 ); 00227 00228 // Set integer variables very close to integer values 00229 cs[2] = 5 + .00001/2.; 00230 cs[3] = 8 - .00001/2.; 00231 fim.setColSolution(cs); 00232 fi = fim.getFractionalIndices(1e-5); 00233 assert( fi.size() == 0 ); 00234 00235 // Set integer variables close, but beyond tolerances 00236 cs[2] = 5 + .00001*2.; 00237 cs[3] = 8 - .00001*2.; 00238 fim.setColSolution(cs); 00239 fi = fim.getFractionalIndices(1e-5); 00240 assert( fi.size() == 2 ); 00241 assert( fi[0]==2 ); 00242 assert( fi[1]==3 ); 00243 00244 delete [] cs; 00245 } 00246 00247 // Change data so column 2 & 3 are integerNonBinary 00248 fim.setColUpper(2, 5); 00249 fim.setColUpper(3, 6.0); 00250 assert( !fim.isBinary(0) ); 00251 assert( !fim.isBinary(1) ); 00252 assert( !fim.isBinary(2) ); 00253 assert( !fim.isBinary(3) ); 00254 assert( !fim.isBinary(4) ); 00255 00256 assert( !fim.isIntegerNonBinary(0) ); 00257 assert( !fim.isIntegerNonBinary(1) ); 00258 assert( fim.isIntegerNonBinary(2) ); 00259 assert( fim.isIntegerNonBinary(3) ); 00260 assert( !fim.isIntegerNonBinary(4) ); 00261 } 00262 00263 // Test apply cut method 00264 { 00265 OsiXprSolverInterface im(m); 00266 OsiCuts cuts; 00267 00268 // Generate some cuts 00269 //cg.generateCuts(im,cuts); 00270 { 00271 // Get number of rows and columns in model 00272 int nr=im.getNumRows(); 00273 int nc=im.getNumCols(); 00274 assert ( nr == 5 ); 00275 assert ( nc == 8 ); 00276 00277 // Generate a valid row cut from thin air 00278 int c; 00279 { 00280 int *inx = new int[nc]; 00281 for (c=0;c<nc;c++) inx[c]=c; 00282 double *el = new double[nc]; 00283 for (c=0;c<nc;c++) el[c]=((double)c)*((double)c); 00284 00285 OsiRowCut rc; 00286 rc.setRow(nc,inx,el); 00287 rc.setLb(-100.); 00288 rc.setUb(100.); 00289 rc.setEffectiveness(22); 00290 00291 cuts.insert(rc); 00292 delete[]el; 00293 delete[]inx; 00294 } 00295 00296 // Generate valid col cut from thin air 00297 { 00298 const double * xprColLB = im.getColLower(); 00299 const double * xprColUB = im.getColUpper(); 00300 int *inx = new int[nc]; 00301 for (c=0;c<nc;c++) inx[c]=c; 00302 double *lb = new double[nc]; 00303 double *ub = new double[nc]; 00304 for (c=0;c<nc;c++) lb[c]=xprColLB[c]+0.001; 00305 for (c=0;c<nc;c++) ub[c]=xprColUB[c]-0.001; 00306 00307 OsiColCut cc; 00308 cc.setLbs(nc,inx,lb); 00309 cc.setUbs(nc,inx,ub); 00310 00311 cuts.insert(cc); 00312 delete [] ub; 00313 delete [] lb; 00314 delete [] inx; 00315 } 00316 00317 { 00318 // Generate a row and column cut which have are ineffective 00319 OsiRowCut * rcP= new OsiRowCut; 00320 rcP->setEffectiveness(-1.); 00321 cuts.insert(rcP); 00322 assert(rcP==NULL); 00323 00324 OsiColCut * ccP= new OsiColCut; 00325 ccP->setEffectiveness(-12.); 00326 cuts.insert(ccP); 00327 assert(ccP==NULL); 00328 } 00329 { 00330 //Generate inconsistent Row cut 00331 OsiRowCut rc; 00332 const int ne=1; 00333 int inx[ne]={-10}; 00334 double el[ne]={2.5}; 00335 rc.setRow(ne,inx,el); 00336 rc.setLb(3.); 00337 rc.setUb(4.); 00338 assert(!rc.consistent()); 00339 cuts.insert(rc); 00340 } 00341 { 00342 //Generate inconsistent col cut 00343 OsiColCut cc; 00344 const int ne=1; 00345 int inx[ne]={-10}; 00346 double el[ne]={2.5}; 00347 cc.setUbs(ne,inx,el); 00348 assert(!cc.consistent()); 00349 cuts.insert(cc); 00350 } 00351 { 00352 // Generate row cut which is inconsistent for model m 00353 OsiRowCut rc; 00354 const int ne=1; 00355 int inx[ne]={10}; 00356 double el[ne]={2.5}; 00357 rc.setRow(ne,inx,el); 00358 assert(rc.consistent()); 00359 assert(!rc.consistent(im)); 00360 cuts.insert(rc); 00361 } 00362 { 00363 // Generate col cut which is inconsistent for model m 00364 OsiColCut cc; 00365 const int ne=1; 00366 int inx[ne]={30}; 00367 double el[ne]={2.0}; 00368 cc.setLbs(ne,inx,el); 00369 assert(cc.consistent()); 00370 assert(!cc.consistent(im)); 00371 cuts.insert(cc); 00372 } 00373 { 00374 // Generate col cut which is infeasible 00375 OsiColCut cc; 00376 const int ne=1; 00377 int inx[ne]={0}; 00378 double el[ne]={2.0}; 00379 cc.setUbs(ne,inx,el); 00380 cc.setEffectiveness(1000.); 00381 assert(cc.consistent()); 00382 assert(cc.consistent(im)); 00383 assert(cc.infeasible(im)); 00384 cuts.insert(cc); 00385 } 00386 } 00387 assert(cuts.sizeRowCuts()==4); 00388 assert(cuts.sizeColCuts()==5); 00389 00390 OsiSolverInterface::ApplyCutsReturnCode rc = im.applyCuts(cuts); 00391 assert( rc.getNumIneffective() == 2 ); 00392 assert( rc.getNumApplied() == 2 ); 00393 assert( rc.getNumInfeasible() == 1 ); 00394 assert( rc.getNumInconsistentWrtIntegerModel() == 2 ); 00395 assert( rc.getNumInconsistent() == 2 ); 00396 assert( cuts.sizeCuts() == rc.getNumIneffective() + 00397 rc.getNumApplied() + 00398 rc.getNumInfeasible() + 00399 rc.getNumInconsistentWrtIntegerModel() + 00400 rc.getNumInconsistent() ); 00401 } 00402 00403 { 00404 OsiXprSolverInterface xprSi(m); 00405 int nc = xprSi.getNumCols(); 00406 int nr = xprSi.getNumRows(); 00407 assert( nc == 8 ); 00408 assert( nr == 5 ); 00409 assert( eq(xprSi.getColLower()[0],2.5) ); 00410 assert( eq(xprSi.getColLower()[1],0.0) ); 00411 assert( eq(xprSi.getColUpper()[1],4.1) ); 00412 assert( eq(xprSi.getRowLower()[0],2.5) ); 00413 assert( eq(xprSi.getRowLower()[4],3.0) ); 00414 assert( eq(xprSi.getRowUpper()[1],2.1) ); 00415 assert( eq(xprSi.getRowUpper()[4],15.0) ); 00416 00417 // const double * cs = xprSi.getColSolution(); 00418 // assert( eq(cs[0],2.5) ); 00419 // assert( eq(cs[7],0.0) ); 00420 00421 assert( !eq(xprSi.getColLower()[3],1.2345) ); 00422 xprSi.setColLower( 3, 1.2345 ); 00423 assert( eq(xprSi.getColLower()[3],1.2345) ); 00424 00425 assert( !eq(xprSi.getColUpper()[4],10.2345) ); 00426 xprSi.setColUpper( 4, 10.2345 ); 00427 assert( eq(xprSi.getColUpper()[4],10.2345) ); 00428 00429 //assert( eq(xprSi.getObjValue(),0.0) ); 00430 00431 assert( eq( xprSi.getObjCoefficients()[0], 1.0) ); 00432 assert( eq( xprSi.getObjCoefficients()[1], 0.0) ); 00433 assert( eq( xprSi.getObjCoefficients()[2], 0.0) ); 00434 assert( eq( xprSi.getObjCoefficients()[3], 0.0) ); 00435 assert( eq( xprSi.getObjCoefficients()[4], 2.0) ); 00436 assert( eq( xprSi.getObjCoefficients()[5], 0.0) ); 00437 assert( eq( xprSi.getObjCoefficients()[6], 0.0) ); 00438 assert( eq( xprSi.getObjCoefficients()[7], -1.0) ); 00439 } 00440 00441 // Test matrixByRow method 00442 { 00443 const OsiXprSolverInterface si(m); 00444 const CoinPackedMatrix * smP = si.getMatrixByRow(); 00445 00446 CoinRelFltEq eq; 00447 const double * ev = smP->getElements(); 00448 00449 assert( eq(ev[0], 3.0) ); 00450 assert( eq(ev[1], 1.0) ); 00451 assert( eq(ev[2], -2.0) ); 00452 assert( eq(ev[3], -1.0) ); 00453 assert( eq(ev[4], -1.0) ); 00454 assert( eq(ev[5], 2.0) ); 00455 assert( eq(ev[6], 1.1) ); 00456 assert( eq(ev[7], 1.0) ); 00457 assert( eq(ev[8], 1.0) ); 00458 assert( eq(ev[9], 2.8) ); 00459 assert( eq(ev[10], -1.2) ); 00460 assert( eq(ev[11], 5.6) ); 00461 assert( eq(ev[12], 1.0) ); 00462 assert( eq(ev[13], 1.9) ); 00463 00464 const int * mi = smP->getVectorStarts(); 00465 assert( mi[0]==0 ); 00466 assert( mi[1]==5 ); 00467 assert( mi[2]==7 ); 00468 assert( mi[3]==9 ); 00469 assert( mi[4]==11 ); 00470 assert( mi[5]==14 ); 00471 00472 const int * ei = smP->getIndices(); 00473 assert( ei[0] == 0 ); 00474 assert( ei[1] == 1 ); 00475 assert( ei[2] == 3 ); 00476 assert( ei[3] == 4 ); 00477 assert( ei[4] == 7 ); 00478 assert( ei[5] == 1 ); 00479 assert( ei[6] == 2 ); 00480 assert( ei[7] == 2 ); 00481 assert( ei[8] == 5 ); 00482 assert( ei[9] == 3 ); 00483 assert( ei[10] == 6 ); 00484 assert( ei[11] == 0 ); 00485 assert( ei[12] == 4 ); 00486 assert( ei[13] == 7 ); 00487 00488 assert( smP->getMajorDim() == 5 ); 00489 assert( smP->getMinorDim() == 8 ); 00490 assert( smP->getNumElements() == 14 ); 00491 assert( smP->getSizeVectorStarts()==6 ); 00492 00493 } 00494 00495 00496 //-------------- 00497 // Test rowsense, rhs, rowrange, matrixByRow 00498 { 00499 OsiXprSolverInterface lhs; 00500 { 00501 assert( m.rowrange_==NULL ); 00502 assert( m.rowsense_==NULL ); 00503 assert( m.rhs_==NULL ); 00504 00505 OsiXprSolverInterface siC1(m); 00506 assert( siC1.rowrange_==NULL ); 00507 assert( siC1.rowsense_==NULL ); 00508 assert( siC1.rhs_==NULL ); 00509 00510 const char * siC1rs = siC1.getRowSense(); 00511 assert( siC1rs[0] == 'G' ); 00512 assert( siC1rs[1] == 'L' ); 00513 assert( siC1rs[2] == 'E' ); 00514 assert( siC1rs[3] == 'R' ); 00515 assert( siC1rs[4] == 'R' ); 00516 00517 const double * siC1rhs = siC1.getRightHandSide(); 00518 assert( eq(siC1rhs[0], 2.5) ); 00519 assert( eq(siC1rhs[1], 2.1) ); 00520 assert( eq(siC1rhs[2], 4.0) ); 00521 assert( eq(siC1rhs[3], 5.0) ); 00522 assert( eq(siC1rhs[4], 15.0) ); 00523 00524 const double * siC1rr = siC1.getRowRange(); 00525 assert( eq(siC1rr[0], 0.0) ); 00526 assert( eq(siC1rr[1], 0.0) ); 00527 assert( eq(siC1rr[2], 0.0) ); 00528 assert( eq(siC1rr[3], 5.0 - 1.8) ); 00529 assert( eq(siC1rr[4], 15.0 - 3.0) ); 00530 00531 const CoinPackedMatrix * siC1mbr = siC1.getMatrixByRow(); 00532 assert( siC1mbr != NULL ); 00533 00534 const double * ev = siC1mbr->getElements(); 00535 assert( eq(ev[0], 3.0) ); 00536 assert( eq(ev[1], 1.0) ); 00537 assert( eq(ev[2], -2.0) ); 00538 assert( eq(ev[3], -1.0) ); 00539 assert( eq(ev[4], -1.0) ); 00540 assert( eq(ev[5], 2.0) ); 00541 assert( eq(ev[6], 1.1) ); 00542 assert( eq(ev[7], 1.0) ); 00543 assert( eq(ev[8], 1.0) ); 00544 assert( eq(ev[9], 2.8) ); 00545 assert( eq(ev[10], -1.2) ); 00546 assert( eq(ev[11], 5.6) ); 00547 assert( eq(ev[12], 1.0) ); 00548 assert( eq(ev[13], 1.9) ); 00549 00550 const int * mi = siC1mbr->getVectorStarts(); 00551 assert( mi[0]==0 ); 00552 assert( mi[1]==5 ); 00553 assert( mi[2]==7 ); 00554 assert( mi[3]==9 ); 00555 assert( mi[4]==11 ); 00556 assert( mi[5]==14 ); 00557 00558 const int * ei = siC1mbr->getIndices(); 00559 assert( ei[0] == 0 ); 00560 assert( ei[1] == 1 ); 00561 assert( ei[2] == 3 ); 00562 assert( ei[3] == 4 ); 00563 assert( ei[4] == 7 ); 00564 assert( ei[5] == 1 ); 00565 assert( ei[6] == 2 ); 00566 assert( ei[7 ] == 2 ); 00567 assert( ei[8 ] == 5 ); 00568 assert( ei[9 ] == 3 ); 00569 assert( ei[10] == 6 ); 00570 assert( ei[11] == 0 ); 00571 assert( ei[12] == 4 ); 00572 assert( ei[13] == 7 ); 00573 00574 assert( siC1mbr->getMajorDim() == 5 ); 00575 assert( siC1mbr->getMinorDim() == 8 ); 00576 assert( siC1mbr->getNumElements() == 14 ); 00577 assert( siC1mbr->getSizeVectorStarts()==6 ); 00578 00579 assert( siC1rs == siC1.getRowSense() ); 00580 assert( siC1rhs == siC1.getRightHandSide() ); 00581 assert( siC1rr == siC1.getRowRange() ); 00582 00583 // Change XPRESS Model by adding free row 00584 OsiRowCut rc; 00585 rc.setLb(-DBL_MAX); 00586 rc.setUb(DBL_MAX); 00587 OsiCuts cuts; 00588 cuts.insert(rc); 00589 siC1.applyCuts(cuts); 00590 00591 // Since model was changed, test that cached 00592 // data is now freed. 00593 assert( siC1.rowrange_ == NULL ); 00594 assert( siC1.rowsense_ == NULL ); 00595 assert( siC1.rhs_ == NULL ); 00596 assert( siC1.matrixByRow_ == NULL ); 00597 00598 siC1rs = siC1.getRowSense(); 00599 assert( siC1rs[0] == 'G' ); 00600 assert( siC1rs[1] == 'L' ); 00601 assert( siC1rs[2] == 'E' ); 00602 assert( siC1rs[3] == 'R' ); 00603 assert( siC1rs[4] == 'R' ); 00604 assert( siC1rs[5] == 'N' ); 00605 00606 siC1rhs = siC1.getRightHandSide(); 00607 assert( eq(siC1rhs[0],2.5) ); 00608 assert( eq(siC1rhs[1],2.1) ); 00609 assert( eq(siC1rhs[2],4.0) ); 00610 assert( eq(siC1rhs[3],5.0) ); 00611 assert( eq(siC1rhs[4],15.0) ); 00612 assert( eq(siC1rhs[5],0.0) ); 00613 00614 siC1rr = siC1.getRowRange(); 00615 assert( eq(siC1rr[0], 0.0) ); 00616 assert( eq(siC1rr[1], 0.0) ); 00617 assert( eq(siC1rr[2], 0.0) ); 00618 assert( eq(siC1rr[3], 5.0 - 1.8) ); 00619 assert( eq(siC1rr[4], 15.0 - 3.0) ); 00620 assert( eq(siC1rr[5], 0.0) ); 00621 lhs=siC1; 00622 } 00623 // Test that lhs has correct values even though siC1 has gone out of scope 00624 assert( lhs.rowrange_ == NULL ); 00625 assert( lhs.rowsense_ == NULL ); 00626 assert( lhs.rhs_ == NULL ); 00627 assert( lhs.matrixByRow_ == NULL ); 00628 00629 const char * lhsrs = lhs.getRowSense(); 00630 assert( lhsrs[0] == 'G' ); 00631 assert( lhsrs[1] == 'L' ); 00632 assert( lhsrs[2] == 'E' ); 00633 assert( lhsrs[3] == 'R' ); 00634 assert( lhsrs[4] == 'R' ); 00635 assert( lhsrs[5] == 'N' ); 00636 00637 00638 const double * lhsrhs = lhs.getRightHandSide(); 00639 assert( eq(lhsrhs[0], 2.5) ); 00640 assert( eq(lhsrhs[1], 2.1) ); 00641 assert( eq(lhsrhs[2], 4.0) ); 00642 assert( eq(lhsrhs[3], 5.0) ); 00643 assert( eq(lhsrhs[4], 15.0) ); 00644 assert( eq(lhsrhs[5], 0.0) ); 00645 00646 const double *lhsrr = lhs.getRowRange(); 00647 assert( eq(lhsrr[0], 0.0) ); 00648 assert( eq(lhsrr[1], 0.0) ); 00649 assert( eq(lhsrr[2], 0.0) ); 00650 assert( eq(lhsrr[3], 5.0 - 1.8) ); 00651 assert( eq(lhsrr[4], 15.0 - 3.0) ); 00652 assert( eq(lhsrr[5], 0.0) ); 00653 00654 const CoinPackedMatrix * lhsmbr = lhs.getMatrixByRow(); 00655 assert( lhsmbr != NULL ); 00656 00657 const double * ev = lhsmbr->getElements(); 00658 assert( eq(ev[0], 3.0) ); 00659 assert( eq(ev[1], 1.0) ); 00660 assert( eq(ev[2], -2.0) ); 00661 assert( eq(ev[3], -1.0) ); 00662 assert( eq(ev[4], -1.0) ); 00663 assert( eq(ev[5], 2.0) ); 00664 assert( eq(ev[6], 1.1) ); 00665 assert( eq(ev[7], 1.0) ); 00666 assert( eq(ev[8], 1.0) ); 00667 assert( eq(ev[9], 2.8) ); 00668 assert( eq(ev[10], -1.2) ); 00669 assert( eq(ev[11], 5.6) ); 00670 assert( eq(ev[12], 1.0) ); 00671 assert( eq(ev[13], 1.9) ); 00672 00673 const int * mi = lhsmbr->getVectorStarts(); 00674 assert( mi[0]==0 ); 00675 assert( mi[1]==5 ); 00676 assert( mi[2]==7 ); 00677 assert( mi[3]==9 ); 00678 assert( mi[4]==11 ); 00679 assert( mi[5]==14 ); 00680 00681 const int * ei = lhsmbr->getIndices(); 00682 assert( ei[0] == 0 ); 00683 assert( ei[1] == 1 ); 00684 assert( ei[2] == 3 ); 00685 assert( ei[3] == 4 ); 00686 assert( ei[4] == 7 ); 00687 assert( ei[5] == 1 ); 00688 assert( ei[6] == 2 ); 00689 assert( ei[7] == 2 ); 00690 assert( ei[8] == 5 ); 00691 assert( ei[9] == 3 ); 00692 assert( ei[10] == 6 ); 00693 assert( ei[11] == 0 ); 00694 assert( ei[12] == 4 ); 00695 assert( ei[13] == 7 ); 00696 00697 assert( lhsmbr->getMajorDim() == 6 ); 00698 assert( lhsmbr->getMinorDim() == 8 ); 00699 assert( lhsmbr->getNumElements() == 14 ); 00700 assert( lhsmbr->getSizeVectorStarts()==7 ); 00701 } 00702 00703 //-------------- 00704 00705 // Test load problem 00706 { 00707 OsiXprSolverInterface base(m); 00708 base.initialSolve(); 00709 assert(m.getNumRows() == base.getNumRows()); 00710 00711 OsiXprSolverInterface si1,si2,si3,si4; 00712 00713 si1.loadProblem( 00714 *base.getMatrixByCol(), 00715 base.getColLower(),base.getColUpper(),base.getObjCoefficients(), 00716 base.getRowSense(),base.getRightHandSide(),base.getRowRange()); 00717 si1.initialSolve(); 00718 assert(eq(base.getObjValue(), si1.getObjValue())); 00719 assert(m.getNumRows() == si1.getNumRows()); 00720 00721 si2.loadProblem( 00722 *base.getMatrixByRow(), 00723 base.getColLower(),base.getColUpper(),base.getObjCoefficients(), 00724 base.getRowSense(),base.getRightHandSide(),base.getRowRange()); 00725 si2.initialSolve(); 00726 assert(eq(base.getObjValue(), si2.getObjValue())); 00727 assert(m.getNumRows() == si2.getNumRows()); 00728 00729 si3.loadProblem( 00730 *base.getMatrixByCol(), 00731 base.getColLower(),base.getColUpper(),base.getObjCoefficients(), 00732 base.getRowLower(),base.getRowUpper() ); 00733 si3.initialSolve(); 00734 assert(eq(base.getObjValue(), si3.getObjValue())); 00735 assert(m.getNumRows() == si3.getNumRows()); 00736 00737 si4.loadProblem( 00738 *base.getMatrixByCol(), 00739 base.getColLower(),base.getColUpper(),base.getObjCoefficients(), 00740 base.getRowLower(),base.getRowUpper() ); 00741 si4.initialSolve(); 00742 assert(eq(base.getObjValue(), si4.getObjValue())); 00743 assert(m.getNumRows() == si4.getNumRows()); 00744 00745 base.initialSolve(); 00746 si1.initialSolve(); 00747 si2.initialSolve(); 00748 si3.initialSolve(); 00749 si4.initialSolve(); 00750 00751 // Create an indices vector 00752 assert(base.getNumCols()<10); 00753 assert(base.getNumRows()<10); 00754 int indices[10]; 00755 int i; 00756 for (i=0; i<10; i++) indices[i]=i; 00757 00758 // Test collower 00759 CoinPackedVector basePv,pv; 00760 basePv.setVector(base.getNumCols(),indices,base.getColLower()); 00761 pv.setVector( si1.getNumCols(),indices, si1.getColLower()); 00762 assert(basePv.isEquivalent(pv)); 00763 pv.setVector( si2.getNumCols(),indices, si2.getColLower()); 00764 assert(basePv.isEquivalent(pv)); 00765 pv.setVector( si3.getNumCols(),indices, si3.getColLower()); 00766 assert(basePv.isEquivalent(pv)); 00767 pv.setVector( si4.getNumCols(),indices, si4.getColLower()); 00768 assert(basePv.isEquivalent(pv)); 00769 00770 // Test colupper 00771 basePv.setVector(base.getNumCols(),indices,base.getColUpper()); 00772 pv.setVector( si1.getNumCols(),indices, si1.getColUpper()); 00773 assert(basePv.isEquivalent(pv)); 00774 pv.setVector( si2.getNumCols(),indices, si2.getColUpper()); 00775 assert(basePv.isEquivalent(pv)); 00776 pv.setVector( si3.getNumCols(),indices, si3.getColUpper()); 00777 assert(basePv.isEquivalent(pv)); 00778 pv.setVector( si4.getNumCols(),indices, si4.getColUpper()); 00779 assert(basePv.isEquivalent(pv)); 00780 00781 // Test getObjCoefficients 00782 basePv.setVector(base.getNumCols(),indices,base.getObjCoefficients()); 00783 pv.setVector( si1.getNumCols(),indices, si1.getObjCoefficients()); 00784 assert(basePv.isEquivalent(pv)); 00785 pv.setVector( si2.getNumCols(),indices, si2.getObjCoefficients()); 00786 assert(basePv.isEquivalent(pv)); 00787 pv.setVector( si3.getNumCols(),indices, si3.getObjCoefficients()); 00788 assert(basePv.isEquivalent(pv)); 00789 pv.setVector( si4.getNumCols(),indices, si4.getObjCoefficients()); 00790 assert(basePv.isEquivalent(pv)); 00791 00792 // Test rowlower 00793 basePv.setVector(base.getNumRows(),indices,base.getRowLower()); 00794 pv.setVector( si1.getNumRows(),indices, si1.getRowLower()); 00795 assert( eq(base.getRowLower()[3],si1.getRowLower()[3]) ); 00796 assert(basePv.isEquivalent(pv)); 00797 pv.setVector( si2.getNumRows(),indices, si2.getRowLower()); 00798 assert(basePv.isEquivalent(pv)); 00799 pv.setVector( si3.getNumRows(),indices, si3.getRowLower()); 00800 assert(basePv.isEquivalent(pv)); 00801 pv.setVector( si4.getNumRows(),indices, si4.getRowLower()); 00802 assert(basePv.isEquivalent(pv)); 00803 00804 // Test rowupper 00805 basePv.setVector(base.getNumRows(),indices,base.getRowUpper()); 00806 pv.setVector( si1.getNumRows(),indices, si1.getRowUpper()); 00807 assert(basePv.isEquivalent(pv)); 00808 pv.setVector( si2.getNumRows(),indices, si2.getRowUpper()); 00809 assert(basePv.isEquivalent(pv)); 00810 pv.setVector( si3.getNumRows(),indices, si3.getRowUpper()); 00811 assert(basePv.isEquivalent(pv)); 00812 pv.setVector( si4.getNumRows(),indices, si4.getRowUpper()); 00813 assert(basePv.isEquivalent(pv)); 00814 00815 // Test Constraint Matrix 00816 assert( base.getMatrixByCol()->isEquivalent(*si1.getMatrixByCol()) ); 00817 assert( base.getMatrixByRow()->isEquivalent(*si1.getMatrixByRow()) ); 00818 assert( base.getMatrixByCol()->isEquivalent(*si2.getMatrixByCol()) ); 00819 assert( base.getMatrixByRow()->isEquivalent(*si2.getMatrixByRow()) ); 00820 assert( base.getMatrixByCol()->isEquivalent(*si3.getMatrixByCol()) ); 00821 assert( base.getMatrixByRow()->isEquivalent(*si3.getMatrixByRow()) ); 00822 assert( base.getMatrixByCol()->isEquivalent(*si4.getMatrixByCol()) ); 00823 assert( base.getMatrixByRow()->isEquivalent(*si4.getMatrixByRow()) ); 00824 00825 // Test Objective Value 00826 assert( eq(base.getObjValue(),si1.getObjValue()) ); 00827 assert( eq(base.getObjValue(),si2.getObjValue()) ); 00828 assert( eq(base.getObjValue(),si3.getObjValue()) ); 00829 assert( eq(base.getObjValue(),si4.getObjValue()) ); 00830 } 00831 //-------------- 00832 00833 assert(OsiXprSolverInterface::getNumInstances()==1); 00834 } 00835 assert(OsiXprSolverInterface::getNumInstances()==0); 00836 00837 00838 // Do common solverInterface testing by calling the 00839 // base class testing method. 00840 { 00841 OsiXprSolverInterface m; 00842 OsiSolverInterfaceCommonUnitTest(&m, mpsDir,netlibDir); 00843 } 00844 } |
|
Pointer to list of global variable types:
Definition at line 768 of file OsiXprSolverInterface.hpp. Referenced by freeCachedResults(), and getVarTypes(). |
|
Pointer to row-wise copy of problem matrix coefficients. Definition at line 710 of file OsiXprSolverInterface.hpp. Referenced by freeCachedResults(), getMatrixByRow(), and gutsOfDestructor(). |
|
Pointer to dense vector of slack upper bounds for range constraints (undefined for non-range rows) Definition at line 734 of file OsiXprSolverInterface.hpp. Referenced by freeCachedResults(), getRowRange(), and gutsOfDestructor(). |
|
Pointer to dense vector of variable types (as above, or 'C' for continuous) Definition at line 773 of file OsiXprSolverInterface.hpp. Referenced by freeCachedResults(), getVarTypes(), gutsOfDestructor(), isContinuous(), setColBounds(), setColLower(), and setColUpper(). |