Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

OsiVolSolverInterface Class Reference

#include <OsiVolSolverInterface.hpp>

Inheritance diagram for OsiVolSolverInterface:

OsiSolverInterface List of all members.

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
virtual CoinWarmStartgetEmptyWarmStart () const
 Get an empty warm start object.

virtual CoinWarmStartgetWarmStart () 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 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
OSL specific public interfaces
VOL_problem * volprob ()
 Get pointer to Vol model.

Constructors and destructors
 OsiVolSolverInterface ()
 Default Constructor.

virtual OsiSolverInterfaceclone (bool copyData=true) const
 Clone.

 OsiVolSolverInterface (const OsiVolSolverInterface &)
 Copy constructor.

OsiVolSolverInterfaceoperator= (const OsiVolSolverInterface &rhs)
 Assignment operator.

virtual ~OsiVolSolverInterface ()
 Destructor.


Protected Member Functions

Helper methods for problem input
void initFromRlbRub (const int rownum, const double *rowlb, const double *rowub)
void initFromRhsSenseRange (const int rownum, const char *rowsen, const double *rowrhs, const double *rowrng)
void initFromClbCubObj (const int colnum, const double *collb, const double *colub, const double *obj)
Protected methods
virtual void applyRowCut (const OsiRowCut &rc)
virtual void applyColCut (const OsiColCut &cc)

Private Member Functions

Methods of <code>VOL_user_hooks</code>
virtual int compute_rc (const VOL_dvector &u, VOL_dvector &rc)
 compute reduced costs

virtual int solve_subproblem (const VOL_dvector &dual, const VOL_dvector &rc, double &lcost, VOL_dvector &x, VOL_dvector &v, double &pcost)
 Solve the subproblem for the subgradient step.

virtual int heuristics (const VOL_problem &p, const VOL_dvector &x, double &heur_val)
Private helper methods
void updateRowMatrix_ () const
void updateColMatrix_ () const
void checkData_ () const throw (CoinError)
void compute_rc_ (const double *u, double *rc) const
void gutsOfDestructor_ ()
void rowRimAllocator_ ()
void colRimAllocator_ ()
void rowRimResize_ (const int newSize)
void colRimResize_ (const int newSize)
void convertBoundsToSenses_ ()
void convertSensesToBounds_ ()
bool test_zero_one_minusone_ (const CoinPackedMatrix &m) const

Private Attributes

double objsense_
 Sense of objective (1 for min; -1 for max).

double * rowpriceHotStart_
int maxNumrows_
 allocated size of the row related rim vectors

int maxNumcols_
 allocated size of the column related rim vectors

VOL_problem volprob_
 The volume solver.

The problem matrix in row and column ordered forms <br>
Note that at least one of the matrices is always current.

bool rowMatrixCurrent_
 A flag indicating whether the row ordered matrix is up-to-date.

CoinPackedMatrix rowMatrix_
 The problem matrix in a row ordered form.

bool colMatrixCurrent_
 A flag indicating whether the column ordered matrix is up-to-date.

CoinPackedMatrix colMatrix_
 The problem matrix in a column ordered form.

Data members used when 0/1/-1 matrix is detected
bool isZeroOneMinusOne_
 An indicator whether the matrix is 0/1/-1.

OsiVolMatrixOneMinusOne_ * rowMatrixOneMinusOne_
 The row ordered matrix without the elements.

OsiVolMatrixOneMinusOne_ * colMatrixOneMinusOne_
 The column ordered matrix without the elements.

The rim vectors
double * colupper_
 Pointer to dense vector of structural variable upper bounds.

double * collower_
 Pointer to dense vector of structural variable lower bounds.

bool * continuous_
 Pointer to dense vector of bool to indicate if column is continuous.

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.

The solution
double * colsol_
 Pointer to dense vector of primal structural variable values.

double * rowprice_
 Pointer to dense vector of dual row variable values.

double * rc_
 Pointer to dense vector of reduced costs.

double * lhs_
 Pointer to dense vector of left hand sides (row activity levels).

double lagrangeanCost_
 The Lagrangean cost, a lower bound on the objective value.


Friends

void OsiVolSolverInterfaceUnitTest (const std::string &mpsDir, const std::string &netlibDir)

Detailed Description

Vol(ume) Solver Interface

Instantiation of OsiVolSolverInterface for the Volume Algorithm

Definition at line 24 of file OsiVolSolverInterface.hpp.


Member Function Documentation

void OsiVolSolverInterface::addCol const CoinPackedVectorBase vec,
const double  collb,
const double  colub,
const double  obj
[virtual]
 

Add a column (primal variable) to the problem.

Implements OsiSolverInterface.

Definition at line 985 of file OsiVolSolverInterface.cpp.

References collower_, colMatrix_, colRimResize_(), colsol_, colupper_, continuous_, getNumCols(), objcoeffs_, rc_, rowMatrixCurrent_, and updateColMatrix_().

00988 {
00989   const int colnum = getNumCols();
00990   colRimResize_(colnum + 1);
00991   collower_[colnum]   = collb;
00992   colupper_[colnum]   = colub;
00993   objcoeffs_[colnum]  = obj;
00994   continuous_[colnum] = true;
00995   colsol_[colnum]     = fabs(collb)<fabs(colub) ? collb : colub;
00996   rc_[colnum]         = 0.0;
00997 
00998   updateColMatrix_();
00999   colMatrix_.appendCol(vec);
01000   rowMatrixCurrent_ = false;
01001 }

void OsiVolSolverInterface::addCols const int  numcols,
const CoinPackedVectorBase *const *  cols,
const double *  collb,
const double *  colub,
const double *  obj
[virtual]
 

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 1006 of file OsiVolSolverInterface.cpp.

References collower_, colMatrix_, colRimResize_(), colsol_, colupper_, continuous_, getNumCols(), objcoeffs_, rc_, rowMatrixCurrent_, and updateColMatrix_().

01010 {
01011   if (numcols > 0) {
01012     const int colnum = getNumCols();
01013     colRimResize_(colnum + numcols);
01014     CoinDisjointCopyN(collb, numcols, collower_ + colnum);
01015     CoinDisjointCopyN(colub, numcols, colupper_ + colnum);
01016     CoinDisjointCopyN(obj, numcols, objcoeffs_ + colnum);
01017     CoinFillN(continuous_ + colnum, numcols, true);
01018     int c;
01019     for ( c=0; c<numcols; c++ ) {
01020       if ( fabs(collb[c]) < fabs(colub[c]) ) {
01021         colsol_[colnum+c] = collb[c];
01022       }
01023       else {
01024         colsol_[colnum+c] = colub[c];
01025       }
01026     }
01027     //CoinFillN(colsol_     + colnum, numcols, 0.0);
01028     CoinFillN(rc_         + colnum, numcols, 0.0);
01029 
01030     updateColMatrix_();
01031     colMatrix_.appendCols(numcols, cols);
01032     rowMatrixCurrent_ = false;
01033   }
01034 }

void OsiVolSolverInterface::addRow const CoinPackedVectorBase vec,
const double  rowlb,
const double  rowub
[virtual]
 

Add a row (constraint) to the problem.

Implements OsiSolverInterface.

Definition at line 1071 of file OsiVolSolverInterface.cpp.

References colMatrixCurrent_, OsiSolverInterface::convertBoundToSense(), getNumRows(), lhs_, rhs_, rowlower_, rowMatrix_, rowprice_, rowrange_, rowRimResize_(), rowsense_, rowupper_, and updateRowMatrix_().

01073 {
01074   const int rownum = getNumRows();
01075   rowRimResize_(rownum + 1);
01076   rowlower_[rownum] = rowlb;
01077   rowupper_[rownum] = rowub;
01078   convertBoundToSense(rowlb, rowub,
01079                       rowsense_[rownum], rhs_[rownum], rowrange_[rownum]);
01080   rowprice_[rownum] = 0.0;
01081   lhs_[rownum] = 0.0;
01082 
01083   updateRowMatrix_();
01084   rowMatrix_.appendRow(vec);
01085   colMatrixCurrent_ = false;
01086 }

void OsiVolSolverInterface::addRows const int  numrows,
const CoinPackedVectorBase *const *  rows,
const char *  rowsen,
const double *  rowrhs,
const double *  rowrng
[virtual]
 

Add a set of rows (constraints) to the problem.

The default implementation simply makes repeated calls to addRow().

Reimplemented from OsiSolverInterface.

Definition at line 1138 of file OsiVolSolverInterface.cpp.

References colMatrixCurrent_, OsiSolverInterface::convertSenseToBound(), getNumRows(), lhs_, rhs_, rowlower_, rowMatrix_, rowprice_, rowrange_, rowRimResize_(), rowsense_, rowupper_, and updateRowMatrix_().

01142 {
01143   if (numrows > 0) {
01144     const int rownum = getNumRows();
01145     rowRimResize_(rownum + numrows);
01146     CoinDisjointCopyN(rowsen, numrows, rowsense_ + rownum);
01147     CoinDisjointCopyN(rowrhs, numrows, rhs_ + rownum);
01148     CoinDisjointCopyN(rowrng, numrows, rowrange_ + rownum);
01149     for (int i = rownum + numrows - 1; i >= rownum; --i) {
01150       convertSenseToBound(rowsense_[i], rhs_[i], rowrange_[i],
01151                           rowlower_[i], rowupper_[i]);
01152     }
01153     CoinFillN(rowprice_ + rownum, numrows, 0.0);
01154     CoinFillN(lhs_      + rownum, numrows, 0.0);
01155 
01156     updateRowMatrix_();
01157     rowMatrix_.appendRows(numrows, rows);
01158     colMatrixCurrent_ = false;
01159   }
01160 }

void OsiVolSolverInterface::addRows const int  numrows,
const CoinPackedVectorBase *const *  rows,
const double *  rowlb,
const double *  rowub
[virtual]
 

Add a set of rows (constraints) to the problem.

The default implementation simply makes repeated calls to addRow().

Reimplemented from OsiSolverInterface.

Definition at line 1113 of file OsiVolSolverInterface.cpp.

References colMatrixCurrent_, OsiSolverInterface::convertBoundToSense(), getNumRows(), lhs_, rhs_, rowlower_, rowMatrix_, rowprice_, rowrange_, rowRimResize_(), rowsense_, rowupper_, and updateRowMatrix_().

01116 {
01117   if (numrows > 0) {
01118     const int rownum = getNumRows();
01119     rowRimResize_(rownum + numrows);
01120     CoinDisjointCopyN(rowlb, numrows, rowlower_ + rownum);
01121     CoinDisjointCopyN(rowub, numrows, rowupper_ + rownum);
01122     for (int i = rownum + numrows - 1; i >= rownum; --i) {
01123       convertBoundToSense(rowlower_[i], rowupper_[i],
01124                           rowsense_[i], rhs_[i], rowrange_[i]);
01125     }
01126     CoinFillN(rowprice_ + rownum, numrows, 0.0);
01127     CoinFillN(lhs_      + rownum, numrows, 0.0);
01128 
01129     updateRowMatrix_();
01130     rowMatrix_.appendRows(numrows, rows);
01131     colMatrixCurrent_ = false;
01132   }
01133 }

void OsiVolSolverInterface::applyColCut const OsiColCut cc  )  [protected, virtual]
 

Apply a column cut (adjust one or more bounds).

Implements OsiSolverInterface.

Definition at line 1358 of file OsiVolSolverInterface.cpp.

References collower_, colupper_, CoinPackedVector::getElements(), CoinPackedVector::getIndices(), CoinPackedVector::getNumElements(), OsiColCut::lbs(), and OsiColCut::ubs().

01359 {
01360    int i;
01361 
01362    const double* lb_elem = cc.lbs().getElements();
01363    const int* lb_ind = cc.lbs().getIndices();
01364    for (i = cc.lbs().getNumElements() - 1; i >= 0; --i) {
01365       collower_[lb_ind[i]] = CoinMax(collower_[lb_ind[i]], lb_elem[i]);
01366    }
01367    
01368    const double* ub_elem = cc.ubs().getElements();
01369    const int* ub_ind = cc.ubs().getIndices();
01370    for (i = cc.ubs().getNumElements() - 1; i >= 0; --i) {
01371       colupper_[ub_ind[i]] = CoinMin(colupper_[ub_ind[i]], ub_elem[i]);
01372    }
01373 }

void OsiVolSolverInterface::applyRowCut const OsiRowCut rc  )  [protected, virtual]
 

Apply a row cut (append to constraint matrix).

Implements OsiSolverInterface.

Definition at line 1338 of file OsiVolSolverInterface.cpp.

References colMatrixCurrent_, OsiSolverInterface::convertBoundToSense(), getNumRows(), OsiRowCut::lb(), rhs_, OsiRowCut::row(), rowlower_, rowMatrix_, rowprice_, rowrange_, rowRimResize_(), rowsense_, rowupper_, OsiRowCut::ub(), and updateRowMatrix_().

01339 {
01340    const int rownum = getNumRows();
01341    const double lb = rc.lb();
01342    const double ub = rc.ub();
01343    rowRimResize_(rownum + 1);
01344    rowprice_[rownum] = 0.0;
01345    rowlower_[rownum] = lb;
01346    rowupper_[rownum] = ub;
01347    convertBoundToSense(lb, ub,
01348                        rowsense_[rownum], rhs_[rownum], rowrange_[rownum]);
01349 
01350    updateRowMatrix_();
01351    rowMatrix_.appendRow(rc.row());
01352    colMatrixCurrent_ = false;
01353 }

void OsiVolSolverInterface::assignProblem CoinPackedMatrix *&  matrix,
double *&  collb,
double *&  colub,
double *&  obj,
char *&  rowsen,
double *&  rowrhs,
double *&  rowrng
[virtual]
 

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.
WARNING: The arguments passed to this method will be freed using the C++ delete and delete[] functions.

Implements OsiSolverInterface.

Definition at line 260 of file OsiVolSolverInterfaceIO.cpp.

References collower_, colMatrix_, colMatrixCurrent_, colsol_, colupper_, convertSensesToBounds_(), gutsOfDestructor_(), lhs_, maxNumcols_, maxNumrows_, objcoeffs_, rc_, rhs_, rowlower_, rowMatrix_, rowMatrixCurrent_, rowprice_, rowrange_, rowsense_, and rowupper_.

00265 {
00266    gutsOfDestructor_();
00267    const int rownum = matrix->getNumRows();
00268    const int colnum = matrix->getNumCols();
00269    maxNumcols_ = colnum;
00270    maxNumrows_ = rownum;
00271 
00272    if (matrix->isColOrdered()) {
00273       colMatrix_.swap(*matrix);
00274       colMatrixCurrent_ = true;
00275       rowMatrixCurrent_ = false;
00276    } else {
00277       rowMatrix_.swap(*matrix);
00278       rowMatrixCurrent_ = true;
00279       colMatrixCurrent_ = false;
00280    }
00281    delete matrix; matrix = 0;
00282       
00283    rowsense_  = rowsen;   rowsen = 0;
00284    rhs_       = rowrhs;   rowrhs = 0;
00285    rowrange_  = rowrng;   rowrng = 0;
00286    colupper_  = colub;    colub  = 0;
00287    collower_  = collb;    collb  = 0;
00288    objcoeffs_ = obj;      obj    = 0;
00289 
00290    if (maxNumrows_ > 0) {
00291       if (!rowsense_) {
00292          rowsense_ = new char[maxNumrows_];
00293          CoinFillN(rowsense_, rownum, 'G');
00294       }
00295       if (!rhs_) {
00296          rhs_ = new double[maxNumrows_];
00297          CoinFillN(rhs_, rownum, 0.0);
00298       }
00299       if (!rowrange_) {
00300          rowrange_ = new double[maxNumrows_];
00301          CoinFillN(rowrange_, rownum, 0.0);
00302       }
00303       rowlower_ = new double[maxNumrows_];
00304       rowupper_ = new double[maxNumrows_];
00305       rowprice_ = new double[maxNumrows_];
00306       lhs_      = new double[maxNumrows_];
00307       // Set the initial dual solution
00308       CoinFillN(rowprice_, rownum, 0.0);
00309       convertSensesToBounds_();
00310    }
00311    if (maxNumcols_ > 0) {
00312       if (!colupper_) {
00313          colupper_ = new double[maxNumcols_];
00314          CoinFillN(colupper_, colnum, OsiVolInfinity);
00315       }
00316       if (!collower_) {
00317          collower_ = new double[maxNumcols_];
00318          CoinFillN(collower_, colnum, -OsiVolInfinity);
00319       }
00320       if (!objcoeffs_) {
00321          objcoeffs_ = new double[maxNumcols_];
00322          CoinFillN(objcoeffs_, colnum, -OsiVolInfinity);
00323       }
00324 
00325     colsol_    = new double[maxNumcols_];
00326     int c;
00327     for ( c=0; c<colnum; c++ ) {
00328       if ( fabs(collower_[c]) < fabs(colupper_[c]) ) {
00329         colsol_[c] = collower_[c];
00330       }
00331       else {
00332         colsol_[c] = colupper_[c];
00333       }
00334     }
00335 
00336       rc_        = new double[maxNumcols_];
00337    }
00338 }

void OsiVolSolverInterface::assignProblem CoinPackedMatrix *&  matrix,
double *&  collb,
double *&  colub,
double *&  obj,
double *&  rowlb,
double *&  rowub
[virtual]
 

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.
WARNING: The arguments passed to this method will be freed using the C++ delete and delete[] functions.

Implements OsiSolverInterface.

Definition at line 149 of file OsiVolSolverInterfaceIO.cpp.

References collower_, colMatrix_, colMatrixCurrent_, colsol_, colupper_, convertBoundsToSenses_(), gutsOfDestructor_(), lhs_, maxNumcols_, maxNumrows_, objcoeffs_, rc_, rhs_, rowlower_, rowMatrix_, rowMatrixCurrent_, rowprice_, rowrange_, rowsense_, and rowupper_.

00153 {
00154    gutsOfDestructor_();
00155    const int rownum = matrix->getNumRows();
00156    const int colnum = matrix->getNumCols();
00157    maxNumcols_ = colnum;
00158    maxNumrows_ = rownum;
00159 
00160    if (matrix->isColOrdered()) {
00161       colMatrix_.swap(*matrix);
00162       colMatrixCurrent_ = true;
00163       rowMatrixCurrent_ = false;
00164    } else {
00165       rowMatrix_.swap(*matrix);
00166       rowMatrixCurrent_ = true;
00167       colMatrixCurrent_ = false;
00168    }
00169    delete matrix; matrix = 0;
00170       
00171    rowupper_  = rowub;     rowub  = 0;
00172    rowlower_  = rowlb;     rowlb  = 0;
00173    colupper_  = colub;     colub  = 0;
00174    collower_  = collb;     collb  = 0;
00175    objcoeffs_ = obj;       obj    = 0;
00176 
00177    if (maxNumrows_ > 0) {
00178       if (!rowupper_) {
00179          rowupper_ = new double[maxNumrows_];
00180          CoinFillN(rowupper_, rownum, OsiVolInfinity);
00181       }
00182       if (!rowlower_) {
00183          rowlower_ = new double[maxNumrows_];
00184          CoinFillN(rowlower_, rownum, -OsiVolInfinity);
00185       }
00186       rowsense_ = new char[maxNumrows_];
00187       rhs_      = new double[maxNumrows_];
00188       rowrange_ = new double[maxNumrows_];
00189       rowprice_ = new double[maxNumrows_];
00190       lhs_      = new double[maxNumrows_];
00191       // Set the initial dual solution
00192       CoinFillN(rowprice_, rownum, 0.0);
00193       convertBoundsToSenses_();
00194    }
00195    if (maxNumcols_ > 0) {
00196       if (!colupper_) {
00197          colupper_ = new double[maxNumcols_];
00198          CoinFillN(colupper_, colnum, OsiVolInfinity);
00199       }
00200       if (!collower_) {
00201          collower_ = new double[maxNumcols_];
00202          CoinFillN(collower_, colnum, -OsiVolInfinity);
00203       }
00204       if (!objcoeffs_) {
00205          objcoeffs_ = new double[maxNumcols_];
00206          CoinFillN(objcoeffs_, colnum, -OsiVolInfinity);
00207       }
00208 
00209     colsol_    = new double[maxNumcols_];
00210     int c;
00211     for ( c=0; c<colnum; c++ ) {
00212       if ( fabs(collower_[c]) < fabs(colupper_[c]) ) {
00213         colsol_[c] = collower_[c];
00214       }
00215       else {
00216         colsol_[c] = colupper_[c];
00217       }
00218     }
00219 
00220       rc_        = new double[maxNumcols_];
00221    }
00222 }

void OsiVolSolverInterface::checkData_  )  const throw (CoinError) [private]
 

Test whether the Volume Algorithm can be applied to the given problem.

Definition at line 45 of file OsiVolSolverInterface.cpp.

Referenced by resolve().

00046 {
00047    int i;
00048    for (i = getNumRows() - 1; i >= 0; --i) {
00049       if (rowlower_[i] > -1.0e20 &&
00050           rowupper_[i] < 1.0e20 &&
00051           rowlower_[i] != rowupper_[i])
00052          throw CoinError("Volume algorithm is unable to handle ranged rows",
00053                         "checkData_", "OsiVolSolverInterface");
00054    }
00055 
00056    for (i = getNumCols() - 1; i >= 0; --i)  {
00057       if (collower_[i] < -1.0e20 || colupper_[i] > 1.0e20)
00058          throw CoinError("Volume algorithm is unable to handle infinite bounds",
00059                         "checkData_", "OsiVolSolverInterface");
00060    }
00061 }

void OsiVolSolverInterface::colRimAllocator_  )  [private]
 

A method allocating sufficient space for the rim vectors corresponding to the columns.

Definition at line 276 of file OsiVolSolverInterface.cpp.

References collower_, colsol_, colupper_, continuous_, maxNumcols_, objcoeffs_, and rc_.

Referenced by colRimResize_(), and operator=().

00277 {
00278    colupper_  = new double[maxNumcols_];
00279    collower_  = new double[maxNumcols_];
00280    continuous_ = new bool[maxNumcols_];
00281    objcoeffs_ = new double[maxNumcols_];
00282    colsol_    = new double[maxNumcols_];
00283    rc_        = new double[maxNumcols_];
00284 }

void OsiVolSolverInterface::colRimResize_ const int  newSize  )  [private]
 

Reallocate the rim arrays corresponding to the columns.

Definition at line 322 of file OsiVolSolverInterface.cpp.

References collower_, colRimAllocator_(), colsol_, colupper_, continuous_, getNumCols(), maxNumcols_, objcoeffs_, and rc_.

Referenced by addCol(), and addCols().

00323 {
00324    if (newSize > maxNumcols_) {
00325       double* cub = colupper_;
00326       double* clb = collower_;
00327       bool* cont  = continuous_;
00328       double* obj = objcoeffs_;
00329       double* sol = colsol_;
00330       double* rc  = rc_;
00331       maxNumcols_ = CoinMax(1000, (maxNumcols_ * 5) / 4);
00332       colRimAllocator_();
00333       const int colnum = getNumCols();
00334       CoinDisjointCopyN(cub , colnum, colupper_);
00335       CoinDisjointCopyN(clb , colnum, collower_);
00336       CoinDisjointCopyN(cont, colnum, continuous_);
00337       CoinDisjointCopyN(obj , colnum, objcoeffs_);
00338       CoinDisjointCopyN(sol , colnum, colsol_);
00339       CoinDisjointCopyN(rc  , colnum, rc_);
00340       delete[] cub;
00341       delete[] clb;
00342       delete[] cont;
00343       delete[] obj;
00344       delete[] sol;
00345       delete[] rc;
00346    }
00347 }

void OsiVolSolverInterface::compute_rc_ const double *  u,
double *  rc
const [private]
 

Compute the reduced costs (rc) with respect to the dual values given in u.

Definition at line 66 of file OsiVolSolverInterface.cpp.

References getNumCols(), isZeroOneMinusOne_, objcoeffs_, rowMatrix_, and rowMatrixOneMinusOne_.

Referenced by compute_rc(), and resolve().

00067 {
00068   if (isZeroOneMinusOne_) {
00069     rowMatrixOneMinusOne_->timesMajor(u, rc);
00070   } else {
00071     rowMatrix_.transposeTimes(u, rc);
00072   }
00073 
00074   const int psize = getNumCols();
00075   std::transform(rc, rc+psize, objcoeffs_, rc, std::minus<double>());
00076   std::transform(rc, rc+psize, rc, std::negate<double>());
00077 }

void OsiVolSolverInterface::convertBoundsToSenses_  )  [private]
 

For each row convert LB/UB style row constraints to sense/rhs style.

Definition at line 352 of file OsiVolSolverInterface.cpp.

References OsiSolverInterface::convertBoundToSense(), getNumRows(), rhs_, rowlower_, rowrange_, rowsense_, and rowupper_.

Referenced by assignProblem(), and setRowSetBounds().

00353 {
00354    for (int i = getNumRows() - 1; i >= 0; --i ) {
00355       convertBoundToSense(rowlower_[i], rowupper_[i],
00356                           rowsense_[i], rhs_[i], rowrange_[i]);
00357    }
00358 }

void OsiVolSolverInterface::convertSensesToBounds_  )  [private]
 

For each row convert sense/rhs style row constraints to LB/UB style.

Definition at line 363 of file OsiVolSolverInterface.cpp.

References OsiSolverInterface::convertSenseToBound(), getNumRows(), rhs_, rowlower_, rowrange_, rowsense_, and rowupper_.

Referenced by assignProblem(), and setRowSetTypes().

00364 {
00365    for (int i = getNumRows() - 1; i >= 0; --i) {
00366       convertSenseToBound(rowsense_[i], rhs_[i], rowrange_[i],
00367                           rowlower_[i], rowupper_[i]);
00368    }
00369 }

void OsiVolSolverInterface::deleteCols const int  num,
const int *  colIndices
[virtual]
 

Remove a set of columns (primal variables) from the problem.

Implements OsiSolverInterface.

Definition at line 1039 of file OsiVolSolverInterface.cpp.

References collower_, colMatrix_, colsol_, colupper_, continuous_, getNumCols(), objcoeffs_, rc_, rowMatrixCurrent_, and updateColMatrix_().

01040 {
01041   if (num > 0) {
01042     int * delPos = new int[num];
01043     CoinDisjointCopyN(columnIndices, num, delPos);
01044     std::sort(delPos, delPos + num);
01045     const int delNum = std::unique(delPos, delPos + num) - delPos;
01046 
01047     const int colnum = getNumCols();
01048     CoinDeleteEntriesFromArray(collower_, collower_ + colnum,
01049                                delPos, delPos + delNum);
01050     CoinDeleteEntriesFromArray(colupper_, colupper_ + colnum,
01051                                delPos, delPos + delNum);
01052     CoinDeleteEntriesFromArray(objcoeffs_, objcoeffs_ + colnum,
01053                                delPos, delPos + delNum);
01054     CoinDeleteEntriesFromArray(continuous_, continuous_ + colnum,
01055                                delPos, delPos + delNum);
01056     CoinDeleteEntriesFromArray(colsol_, colsol_ + colnum,
01057                                delPos, delPos + delNum);
01058     CoinDeleteEntriesFromArray(rc_, rc_ + colnum,
01059                                delPos, delPos + delNum);
01060 
01061     updateColMatrix_();
01062     colMatrix_.deleteCols(delNum, delPos);
01063     rowMatrixCurrent_ = false;
01064   }
01065 }

void OsiVolSolverInterface::deleteRows const int  num,
const int *  rowIndices
[virtual]
 

Delete a set of rows (constraints) from the problem.

Implements OsiSolverInterface.

Definition at line 1165 of file OsiVolSolverInterface.cpp.

References colMatrixCurrent_, getNumRows(), lhs_, rhs_, rowlower_, rowMatrix_, rowprice_, rowrange_, rowsense_, rowupper_, and updateRowMatrix_().

01166 {
01167   if (num > 0) {
01168     int * delPos = new int[num];
01169     CoinDisjointCopyN(rowIndices, num, delPos);
01170     std::sort(delPos, delPos + num);
01171     const int delNum = std::unique(delPos, delPos + num) - delPos;
01172 
01173     const int rownum = getNumRows();
01174     CoinDeleteEntriesFromArray(rowlower_, rowlower_ + rownum,
01175                                delPos, delPos + delNum);
01176     CoinDeleteEntriesFromArray(rowupper_, rowupper_ + rownum,
01177                                delPos, delPos + delNum);
01178     CoinDeleteEntriesFromArray(rowsense_, rowsense_ + rownum,
01179                                delPos, delPos + delNum);
01180     CoinDeleteEntriesFromArray(rowrange_, rowrange_ + rownum,
01181                                delPos, delPos + delNum);
01182     CoinDeleteEntriesFromArray(rhs_, rhs_ + rownum,
01183                                delPos, delPos + delNum);
01184     CoinDeleteEntriesFromArray(rowprice_, rowprice_ + rownum,
01185                                delPos, delPos + delNum);
01186     CoinDeleteEntriesFromArray(lhs_, lhs_ + rownum,
01187                                delPos, delPos + delNum);
01188 
01189     updateRowMatrix_();
01190     rowMatrix_.deleteRows(delNum, delPos);
01191     colMatrixCurrent_ = false;
01192 
01193     delete[] delPos;
01194   }
01195 }

std::vector< double * > OsiVolSolverInterface::getDualRays int  maxNumRays  )  const [virtual]
 

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:
The double pointers in the vector should point to arrays of length getNumRows() and they should be allocated via new[].

NOTE for users of solver interfaces:
It is the user's responsibility to free the double pointers in the vector using delete[].

Implements OsiSolverInterface.

Definition at line 815 of file OsiVolSolverInterface.cpp.

00816 {
00817   // *FIXME* : must write the method -LL
00818   throw CoinError("method is not yet written", "getDualRays",
00819                  "OsiVolSolverInterface");
00820   return std::vector<double*>();
00821 }

CoinWarmStart * OsiVolSolverInterface::getEmptyWarmStart  )  const [virtual]
 

Get an empty warm start object.

This routine returns an empty warm start object. Its purpose is to provide a way to give a client a warm start object of the appropriate type, which can resized and modified as desired.

Implements OsiSolverInterface.

Definition at line 724 of file OsiVolSolverInterface.cpp.

00725 { return (dynamic_cast<CoinWarmStart *>(new CoinWarmStartDual())) ; }

virtual int OsiVolSolverInterface::getIterationCount  )  const [inline, virtual]
 

Get how many iterations it took to solve the problem (whatever "iteration" mean to the solver.

Implements OsiSolverInterface.

Definition at line 284 of file OsiVolSolverInterface.hpp.

References volprob_.

00284 { return volprob_.iter(); }

std::vector< double * > OsiVolSolverInterface::getPrimalRays int  maxNumRays  )  const [virtual]
 

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:
The double pointers in the vector should point to arrays of length getNumCols() and they should be allocated via new[].

NOTE for users of solver interfaces:
It is the user's responsibility to free the double pointers in the vector using delete[].

Implements OsiSolverInterface.

Definition at line 823 of file OsiVolSolverInterface.cpp.

00824 {
00825   // *FIXME* : must write the method -LL
00826   throw CoinError("method is not yet written", "getPrimalRays",
00827                  "OsiVolSolverInterface");
00828   return std::vector<double*>();
00829 }

virtual const double* OsiVolSolverInterface::getRightHandSide  )  const [inline, virtual]
 

Get pointer to array[getNumRows()] of rows right-hand sides

  • if rowsense()[i] == 'L' then rhs()[i] == rowupper()[i]
  • if rowsense()[i] == 'G' then rhs()[i] == rowlower()[i]
  • if rowsense()[i] == 'R' then rhs()[i] == rowupper()[i]
  • if rowsense()[i] == 'N' then rhs()[i] == 0.0

Implements OsiSolverInterface.

Definition at line 203 of file OsiVolSolverInterface.hpp.

References rhs_.

00203 { return rhs_; }

virtual const double* OsiVolSolverInterface::getRowActivity  )  const [inline, virtual]
 

Get pointer to array[getNumRows()] of row activity levels (constraint matrix times the solution vector

Implements OsiSolverInterface.

Definition at line 270 of file OsiVolSolverInterface.hpp.

References lhs_.

00270 { return lhs_; }

virtual const double* OsiVolSolverInterface::getRowRange  )  const [inline, virtual]
 

Get pointer to array[getNumRows()] of row ranges.

  • if rowsense()[i] == 'R' then rowrange()[i] == rowupper()[i] - rowlower()[i]
  • if rowsense()[i] != 'R' then rowrange()[i] is undefined

Implements OsiSolverInterface.

Definition at line 213 of file OsiVolSolverInterface.hpp.

References rowrange_.

00213 { return rowrange_; }

virtual const char* OsiVolSolverInterface::getRowSense  )  const [inline, virtual]
 

Get pointer to array[getNumRows()] of row constraint senses.

  • 'L' <= constraint
  • 'E' = constraint
  • 'G' >= constraint
  • 'R' ranged constraint
  • 'N' free constraint

Implements OsiSolverInterface.

Definition at line 193 of file OsiVolSolverInterface.hpp.

References rowsense_.

00193 { return rowsense_; }

void OsiVolSolverInterface::gutsOfDestructor_  )  [private]
 

A method deleting every member data

Definition at line 230 of file OsiVolSolverInterface.cpp.

References collower_, colMatrix_, colMatrixCurrent_, colsol_, colupper_, continuous_, lagrangeanCost_, lhs_, maxNumcols_, maxNumrows_, objcoeffs_, rc_, rhs_, rowlower_, rowMatrix_, rowMatrixCurrent_, rowprice_, rowpriceHotStart_, rowrange_, rowsense_, and rowupper_.

Referenced by assignProblem(), loadProblem(), operator=(), and ~OsiVolSolverInterface().

00231 {
00232   rowMatrix_.clear();
00233   colMatrix_.clear();
00234   rowMatrixCurrent_ = true;
00235   colMatrixCurrent_ = true;
00236 
00237   delete[] colupper_;   colupper_ = 0;  
00238   delete[] collower_;   collower_ = 0;  
00239   delete[] continuous_; continuous_ = 0;
00240   delete[] rowupper_;   rowupper_ = 0; 
00241   delete[] rowlower_;   rowlower_ = 0; 
00242   delete[] rowsense_;   rowsense_ = 0; 
00243   delete[] rhs_;        rhs_ = 0;      
00244   delete[] rowrange_;   rowrange_ = 0; 
00245   delete[] objcoeffs_;  objcoeffs_ = 0;
00246 
00247   delete[] colsol_;             colsol_ = 0;   
00248   delete[] rowprice_;           rowprice_ = 0;
00249   delete[] rowpriceHotStart_;   rowpriceHotStart_ = 0;
00250   delete[] rc_;                 rc_ = 0;
00251   delete[] lhs_;                lhs_ = 0;
00252 
00253   lagrangeanCost_ = 0.0;
00254 
00255   maxNumrows_ = 0;
00256   maxNumcols_ = 0;
00257 }

virtual int OsiVolSolverInterface::heuristics const VOL_problem &  p,
const VOL_dvector &  x,
double &  heur_val
[inline, private, virtual]
 

Starting from the primal vector x, run a heuristic to produce an integer solution. This is not done in LP solving.

Definition at line 710 of file OsiVolSolverInterface.hpp.

00711                                                                    {
00712       heur_val = DBL_MAX;
00713       return 0;
00714     };

void OsiVolSolverInterface::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]
 

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 367 of file OsiVolSolverInterfaceIO.cpp.

References colMatrix_, colMatrixCurrent_, gutsOfDestructor_(), maxNumcols_, maxNumrows_, and rowMatrixCurrent_.

00374 {
00375    gutsOfDestructor_();
00376 
00377    colMatrix_.copyOf(true, numrows, numcols, start[numcols],
00378                      value, index, start, 0);
00379    colMatrixCurrent_ = true;
00380    rowMatrixCurrent_ = false;
00381    maxNumcols_ = colMatrix_.getMaxMajorDim();
00382    maxNumrows_ = static_cast<int>((1+colMatrix_.getExtraGap()) *
00383                                   colMatrix_.getMinorDim());
00384 
00385    initFromRhsSenseRange(numrows, rowsen, rowrhs, rowrng);
00386    initFromClbCubObj(numcols, collb, colub, obj);
00387 }

void OsiVolSolverInterface::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]
 

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 343 of file OsiVolSolverInterfaceIO.cpp.

References colMatrix_, colMatrixCurrent_, gutsOfDestructor_(), maxNumcols_, maxNumrows_, and rowMatrixCurrent_.

00349 {
00350    gutsOfDestructor_();
00351 
00352    colMatrix_.copyOf(true, numrows, numcols, start[numcols],
00353                      value, index, start, 0);
00354    colMatrixCurrent_ = true;
00355    rowMatrixCurrent_ = false;
00356    maxNumcols_ = colMatrix_.getMaxMajorDim();
00357    maxNumrows_ = static_cast<int>((1+colMatrix_.getExtraGap()) *
00358                                   colMatrix_.getMinorDim());
00359 
00360    initFromRlbRub(numrows, rowlb, rowub);
00361    initFromClbCubObj(numcols, collb, colub, obj);
00362 }

void OsiVolSolverInterface::loadProblem const CoinPackedMatrix &  matrix,
const double *  collb,
const double *  colub,
const double *  obj,
const char *  rowsen,
const double *  rowrhs,
const double *  rowrng
[virtual]
 

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:

  • colub: all columns have upper bound infinity
  • collb: all columns have lower bound 0
  • obj: all variables have 0 objective coefficient
  • rowsen: all rows are >=
  • rowrhs: all right hand sides are 0
  • rowrng: 0 for the ranged rows

Implements OsiSolverInterface.

Definition at line 227 of file OsiVolSolverInterfaceIO.cpp.

References colMatrix_, colMatrixCurrent_, gutsOfDestructor_(), maxNumcols_, maxNumrows_, rowMatrix_, and rowMatrixCurrent_.

00232 {
00233    gutsOfDestructor_();
00234    const int rownum = matrix.getNumRows();
00235    const int colnum = matrix.getNumCols();
00236 
00237    if (matrix.isColOrdered()) {
00238       colMatrix_ = matrix;
00239       colMatrixCurrent_ = true;
00240       rowMatrixCurrent_ = false;
00241       maxNumcols_ = colMatrix_.getMaxMajorDim();
00242       maxNumrows_ = static_cast<int>((1+colMatrix_.getExtraGap()) *
00243                                      colMatrix_.getMinorDim());
00244    } else {
00245       rowMatrix_ = matrix;
00246       rowMatrixCurrent_ = true;
00247       colMatrixCurrent_ = false;
00248       maxNumcols_ = static_cast<int>((1+rowMatrix_.getExtraGap()) *
00249                                      rowMatrix_.getMinorDim());
00250       maxNumrows_ = rowMatrix_.getMaxMajorDim();
00251    }
00252 
00253    initFromRhsSenseRange(rownum, rowsen, rowrhs, rowrng);
00254    initFromClbCubObj(colnum, collb, colub, obj);
00255 }

void OsiVolSolverInterface::loadProblem const CoinPackedMatrix &  matrix,
const double *  collb,
const double *  colub,
const double *  obj,
const double *  rowlb,
const double *  rowub
[virtual]
 

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:

  • colub: all columns have upper bound infinity
  • collb: all columns have lower bound 0
  • rowub: all rows have upper bound infinity
  • rowlb: all rows have lower bound -infinity
  • obj: all variables have 0 objective coefficient

Implements OsiSolverInterface.

Definition at line 113 of file OsiVolSolverInterfaceIO.cpp.

References colMatrix_, colMatrixCurrent_, gutsOfDestructor_(), maxNumcols_, maxNumrows_, rowMatrix_, and rowMatrixCurrent_.

Referenced by readMps().

00117 {
00118    gutsOfDestructor_();
00119    const int rownum = matrix.getNumRows();
00120    const int colnum = matrix.getNumCols();
00121 
00122    if (matrix.isColOrdered()) {
00123       colMatrix_.setExtraGap(matrix.getExtraGap());
00124       colMatrix_.setExtraMajor(matrix.getExtraMajor());
00125       colMatrix_ = matrix;
00126       colMatrixCurrent_ = true;
00127       rowMatrixCurrent_ = false;
00128       maxNumcols_ = colMatrix_.getMaxMajorDim();
00129       maxNumrows_ = static_cast<int>((1+colMatrix_.getExtraGap()) *
00130                                      colMatrix_.getMinorDim());
00131    } else {
00132       rowMatrix_.setExtraGap(matrix.getExtraGap());
00133       rowMatrix_.setExtraMajor(matrix.getExtraMajor());
00134       rowMatrix_ = matrix;
00135       rowMatrixCurrent_ = true;
00136       colMatrixCurrent_ = false;
00137       maxNumcols_ = static_cast<int>((1+rowMatrix_.getExtraGap()) *
00138                                      rowMatrix_.getMinorDim());
00139       maxNumrows_ = rowMatrix_.getMaxMajorDim();
00140    }
00141 
00142    initFromRlbRub(rownum, rowlb, rowub);
00143    initFromClbCubObj(colnum, collb, colub, obj);
00144 }

int OsiVolSolverInterface::readMps const char *  filename,
const char *  extension = "mps"
[virtual]
 

Read an mps file from the given filename

Reimplemented from OsiSolverInterface.

Definition at line 393 of file OsiVolSolverInterfaceIO.cpp.

References continuous_, CoinMpsIO::getColLower(), CoinMpsIO::getColUpper(), getInfinity(), CoinMpsIO::getMatrixByCol(), getNumCols(), CoinMpsIO::getObjCoefficients(), CoinMpsIO::getRowLower(), CoinMpsIO::getRowUpper(), loadProblem(), maxNumcols_, CoinMpsIO::readMps(), and CoinMpsIO::setInfinity().

00394 {
00395    CoinMpsIO reader;
00396    reader.setInfinity(getInfinity());
00397    int retVal = reader.readMps(filename, extension);
00398    loadProblem(*reader.getMatrixByCol(),
00399                reader.getColLower(), reader.getColUpper(),
00400                reader.getObjCoefficients(),
00401                reader.getRowLower(), reader.getRowUpper());
00402    int nc = getNumCols();
00403    continuous_= new bool[maxNumcols_];
00404    CoinFillN(continuous_, nc, true);
00405    return retVal;
00406 }

void OsiVolSolverInterface::rowRimAllocator_  )  [private]
 

A method allocating sufficient space for the rim vectors corresponding to the rows.

Definition at line 262 of file OsiVolSolverInterface.cpp.

References lhs_, maxNumrows_, rhs_, rowlower_, rowprice_, rowrange_, rowsense_, and rowupper_.

Referenced by operator=(), and rowRimResize_().

00263 {
00264    rowupper_ = new double[maxNumrows_];
00265    rowlower_ = new double[maxNumrows_];
00266    rowsense_ = new char[maxNumrows_];
00267    rhs_      = new double[maxNumrows_];
00268    rowrange_ = new double[maxNumrows_];
00269    rowprice_ = new double[maxNumrows_];
00270    lhs_      = new double[maxNumrows_];
00271 }

void OsiVolSolverInterface::rowRimResize_ const int  newSize  )  [private]
 

Reallocate the rim arrays corresponding to the rows.

Definition at line 289 of file OsiVolSolverInterface.cpp.

References getNumRows(), lhs_, maxNumrows_, rhs_, rowlower_, rowprice_, rowrange_, rowRimAllocator_(), rowsense_, and rowupper_.

Referenced by addRow(), addRows(), and applyRowCut().

00290 {
00291    if (newSize > maxNumrows_) {
00292       double* rub   = rowupper_;
00293       double* rlb   = rowlower_;
00294       char*   sense = rowsense_;
00295       double* right = rhs_;
00296       double* range = rowrange_;
00297       double* dual  = rowprice_;
00298       double* left  = lhs_;
00299       maxNumrows_ = CoinMax(1000, (newSize * 5) / 4);
00300       rowRimAllocator_();
00301       const int rownum = getNumRows();
00302       CoinDisjointCopyN(rub  , rownum, rowupper_);
00303       CoinDisjointCopyN(rlb  , rownum, rowlower_);
00304       CoinDisjointCopyN(sense, rownum, rowsense_);
00305       CoinDisjointCopyN(right, rownum, rhs_);
00306       CoinDisjointCopyN(range, rownum, rowrange_);
00307       CoinDisjointCopyN(dual , rownum, rowprice_);
00308       CoinDisjointCopyN(left , rownum, lhs_);
00309       delete[] rub;
00310       delete[] rlb;
00311       delete[] sense;
00312       delete[] right;
00313       delete[] range;
00314       delete[] dual;
00315       delete[] left;
00316    }
00317 }

virtual void OsiVolSolverInterface::setColBounds int  elementIndex,
double  lower,
double  upper
[inline, virtual]
 

Set a single column lower and upper bound

Reimplemented from OsiSolverInterface.

Definition at line 345 of file OsiVolSolverInterface.hpp.

References collower_, and colupper_.

00346                                                               {
00347         collower_[elementIndex] = lower;
00348         colupper_[elementIndex] = upper;
00349       }

virtual void OsiVolSolverInterface::setColLower int  elementIndex,
double  elementValue
[inline, virtual]
 

Set a single column lower bound
Use -DBL_MAX for -infinity.

Implements OsiSolverInterface.

Definition at line 334 of file OsiVolSolverInterface.hpp.

References collower_.

00334                                                                         {
00335         collower_[elementIndex] = elementValue;
00336       }

void OsiVolSolverInterface::setColSetBounds const int *  indexFirst,
const int *  indexLast,
const double *  boundList
[virtual]
 

Set the bounds on a number of columns simultaneously
The default implementation just invokes setColLower() and setColUpper() over and over again.

Parameters:
indexFirst,indexLast pointers to the beginning and after the end of the array of the indices of the variables whose either bound changes
boundList the new lower/upper bound pairs for the variables

Reimplemented from OsiSolverInterface.

Definition at line 836 of file OsiVolSolverInterface.cpp.

References collower_, and colupper_.

00839 {
00840   while (indexFirst < indexLast) {
00841     const int ind = *indexFirst;
00842     collower_[ind] = boundList[0];
00843     colupper_[ind] = boundList[1];
00844     ++indexFirst;
00845     boundList += 2;
00846   }
00847 }

void OsiVolSolverInterface::setColSolution const double *  colsol  )  [virtual]
 

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 967 of file OsiVolSolverInterface.cpp.

References colsol_, and getNumCols().

00968 {
00969    CoinDisjointCopyN(colsol, getNumCols(), colsol_);
00970 }

virtual void OsiVolSolverInterface::setColUpper int  elementIndex,
double  elementValue
[inline, virtual]
 

Set a single column upper bound
Use DBL_MAX for infinity.

Implements OsiSolverInterface.

Definition at line 340 of file OsiVolSolverInterface.hpp.

References colupper_.

00340                                                                         {
00341         colupper_[elementIndex] = elementValue;
00342       }

void OsiVolSolverInterface::setContinuous const int *  indices,
int  len
[virtual]
 

Set the variables listed in indices (which is of length len) to be continuous variables

Reimplemented from OsiSolverInterface.

Definition at line 925 of file OsiVolSolverInterface.cpp.

References continuous_, and getNumCols().

00926 {
00927   assert(continuous_ != NULL);
00928   const int colnum = getNumCols();
00929   int i;
00930 
00931   for (i = len - 1; i >= 0; --i) {
00932     if (indices[i] < 0 || indices[i] > colnum) {
00933       throw CoinError("Index out of bound.", "setContinuous",
00934                      "OsiVolSolverInterface");
00935     }
00936   }
00937   
00938   for (i = len - 1; i >= 0; --i) {
00939     continuous_[indices[i]] = true;
00940   }
00941 }

void OsiVolSolverInterface::setContinuous int  index  )  [virtual]
 

Set the index-th variable to be a continuous variable

Implements OsiSolverInterface.

Definition at line 899 of file OsiVolSolverInterface.cpp.

References continuous_, and getNumCols().

00900 {
00901   assert(continuous_ != NULL);
00902   if (index < 0 || index > getNumCols()) {
00903     throw CoinError("Index out of bound.", "setContinuous",
00904                    "OsiVolSolverInterface");
00905   }
00906   continuous_[index] = true;
00907 }

void OsiVolSolverInterface::setInteger const int *  indices,
int  len
[virtual]
 

Set the variables listed in indices (which is of length len) to be integer variables

Reimplemented from OsiSolverInterface.

Definition at line 946 of file OsiVolSolverInterface.cpp.

References continuous_, and getNumCols().

00947 {
00948   assert(continuous_ != NULL);
00949   const int colnum = getNumCols();
00950   int i;
00951 
00952   for (i = len - 1; i >= 0; --i) {
00953     if (indices[i] < 0 || indices[i] > colnum) {
00954       throw CoinError("Index out of bound.", "setContinuous",
00955                      "OsiVolSolverInterface");
00956     }
00957   }
00958   
00959   for (i = len - 1; i >= 0; --i) {
00960     continuous_[indices[i]] = false;
00961   }
00962 }

void OsiVolSolverInterface::setInteger int  index  )  [virtual]
 

Set the index-th variable to be an integer variable

Implements OsiSolverInterface.

Definition at line 912 of file OsiVolSolverInterface.cpp.

References continuous_, and getNumCols().

00913 {
00914   assert(continuous_ != NULL);
00915   if (index < 0 || index > getNumCols()) {
00916     throw CoinError("Index out of bound.", "setContinuous",
00917                    "OsiVolSolverInterface");
00918   }
00919   continuous_[index] = false;
00920 }

virtual void OsiVolSolverInterface::setObjCoeff int  elementIndex,
double  elementValue
[inline, virtual]
 

Set an objective function coefficient

Implements OsiSolverInterface.

Definition at line 328 of file OsiVolSolverInterface.hpp.

References objcoeffs_.

00328                                                                         {
00329         objcoeffs_[elementIndex] = elementValue;
00330       }

virtual void OsiVolSolverInterface::setRowBounds int  elementIndex,
double  lower,
double  upper
[inline, virtual]
 

Set a single row lower and upper bound

Reimplemented from OsiSolverInterface.

Definition at line 382 of file OsiVolSolverInterface.hpp.

References OsiSolverInterface::convertBoundToSense(), rhs_, rowlower_, rowrange_, rowsense_, and rowupper_.

Referenced by setRowSetBounds().

00383                                                               {
00384         rowlower_[elementIndex] = lower;
00385         rowupper_[elementIndex] = upper;
00386         convertBoundToSense(lower, upper,
00387                             rowsense_[elementIndex], rhs_[elementIndex],
00388                             rowrange_[elementIndex]);
00389       }

virtual void OsiVolSolverInterface::setRowLower int  elementIndex,
double  elementValue
[inline, virtual]
 

Set a single row lower bound
Use -DBL_MAX for -infinity.

Implements OsiSolverInterface.

Definition at line 365 of file OsiVolSolverInterface.hpp.

References OsiSolverInterface::convertBoundToSense(), rhs_, rowlower_, rowrange_, rowsense_, and rowupper_.

00365                                                                         {
00366         rowlower_[elementIndex] = elementValue;
00367         convertBoundToSense(elementValue, rowupper_[elementIndex],
00368                             rowsense_[elementIndex], rhs_[elementIndex],
00369                             rowrange_[elementIndex]);
00370       }

void OsiVolSolverInterface::setRowPrice const double *  rowprice  )  [virtual]
 

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 975 of file OsiVolSolverInterface.cpp.

References getNumRows(), and rowprice_.

00976 {
00977    CoinDisjointCopyN(rowprice, getNumRows(), rowprice_);
00978 }

void OsiVolSolverInterface::setRowSetBounds const int *  indexFirst,
const int *  indexLast,
const double *  boundList
[virtual]
 

Set the bounds on a number of rows simultaneously
The default implementation just invokes setRowLower() and setRowUpper() over and over again.

Parameters:
indexFirst,indexLast pointers to the beginning and after the end of the array of the indices of the constraints whose either bound changes
boundList the new lower/upper bound pairs for the constraints

Reimplemented from OsiSolverInterface.

Definition at line 850 of file OsiVolSolverInterface.cpp.

References convertBoundsToSenses_(), getNumRows(), rowlower_, rowupper_, and setRowBounds().

00853 {
00854   if (indexLast - indexFirst < getNumRows() / 3) {
00855     while (indexFirst < indexLast) {
00856       setRowBounds(*indexFirst, boundList[0], boundList[1]);
00857       ++indexFirst;
00858       boundList += 2;
00859     }
00860   } else {
00861     // it's better to convert everything at once
00862     while (indexFirst < indexLast) {
00863       const int ind = *indexFirst;
00864       rowlower_[ind] = boundList[0];
00865       rowupper_[ind] = boundList[1];
00866       ++indexFirst;
00867       boundList += 2;
00868     }
00869     convertBoundsToSenses_();
00870   }
00871 }

void OsiVolSolverInterface::setRowSetTypes const int *  indexFirst,
const int *  indexLast,
const char *  senseList,
const double *  rhsList,
const double *  rangeList
[virtual]
 

Set the type of a number of rows simultaneously
The default implementation just invokes setRowType() over and over again.

Parameters:
indexFirst,indexLast pointers to the beginning and after the end of the array of the indices of the constraints whose any characteristics changes
senseList the new senses
rhsList the new right hand sides
rangeList the new ranges

Reimplemented from OsiSolverInterface.

Definition at line 874 of file OsiVolSolverInterface.cpp.

References convertSensesToBounds_(), getNumRows(), rhs_, rowrange_, rowsense_, and setRowType().

00879 {
00880   if (indexLast - indexFirst < getNumRows() / 3) {
00881     while (indexFirst < indexLast) {
00882       setRowType(*indexFirst++, *senseList++, *rhsList++, *rangeList++);
00883     }
00884   } else {
00885     // it's better to convert everything at once
00886     while (indexFirst < indexLast) {
00887       const int ind = *indexFirst++;
00888       rowsense_[ind] = *senseList++;
00889       rhs_[ind] = *rhsList++;
00890       rowrange_[ind] = *rangeList++;
00891     }
00892     convertSensesToBounds_();
00893   }
00894 }

virtual void OsiVolSolverInterface::setRowType int  index,
char  sense,
double  rightHandSide,
double  range
[inline, virtual]
 

Set the type of a single row

Implements OsiSolverInterface.

Definition at line 392 of file OsiVolSolverInterface.hpp.

References OsiSolverInterface::convertSenseToBound(), rhs_, rowlower_, rowrange_, rowsense_, and rowupper_.

Referenced by setRowSetTypes().

00393                                             {
00394         rowsense_[index] = sense;
00395         rhs_[index] = rightHandSide;
00396         rowrange_[index] = range;
00397         convertSenseToBound(sense, rightHandSide, range,
00398                             rowlower_[index], rowupper_[index]);
00399       }

virtual void OsiVolSolverInterface::setRowUpper int  elementIndex,
double  elementValue
[inline, virtual]
 

Set a single row upper bound
Use DBL_MAX for infinity.

Implements OsiSolverInterface.

Definition at line 374 of file OsiVolSolverInterface.hpp.

References OsiSolverInterface::convertBoundToSense(), rhs_, rowlower_, rowrange_, rowsense_, and rowupper_.

00374                                                                         {
00375         rowupper_[elementIndex] = elementValue;
00376         convertBoundToSense(rowlower_[elementIndex], elementValue,
00377                             rowsense_[elementIndex], rhs_[elementIndex],
00378                             rowrange_[elementIndex]);
00379       }

bool OsiVolSolverInterface::setWarmStart const CoinWarmStart warmstart  )  [virtual]
 

Set warmstarting information. Return true/false depending on whether the warmstart information was accepted or not.

Implements OsiSolverInterface.

Definition at line 736 of file OsiVolSolverInterface.cpp.

References CoinWarmStartDual::dual(), getNumRows(), rowprice_, and CoinWarmStartDual::size().

00737 {
00738   const CoinWarmStartDual* ws =
00739     dynamic_cast<const CoinWarmStartDual*>(warmstart);
00740 
00741   if (! ws)
00742     return false;
00743 
00744   const int ws_size = ws->size();
00745   if (ws_size != getNumRows() && ws_size != 0) {
00746     throw CoinError("wrong dual warmstart size", "setWarmStart",
00747                    "OsiVolSolverInterface");
00748   }
00749 
00750   CoinDisjointCopyN(ws->dual(), ws_size, rowprice_);
00751   return true;
00752 }

bool OsiVolSolverInterface::test_zero_one_minusone_ const CoinPackedMatrix &  m  )  const [private]
 

test whether the given matrix is 0/1/-1 entries only.

Definition at line 82 of file OsiVolSolverInterface.cpp.

Referenced by resolve().

00083 {
00084   const int vecnum = m.getMajorDim();
00085   const double* elem = m.getElements();
00086   const int* start = m.getVectorStarts();
00087   const int* length = m.getVectorLengths();
00088   int i, j;
00089   for (i = 0; i < vecnum; ++i) {
00090     for (j = start[i] + length[i] - 1; j >= start[i]; --j) {
00091       const double val = elem[j];
00092       if (val != 1.0 && val != 0.0 && val != -1.0) {
00093         return false;
00094       }
00095     }
00096   }
00097   return true;
00098 }

void OsiVolSolverInterface::updateColMatrix_  )  const [private]
 

Update the column ordered matrix from the row ordered one

Definition at line 34 of file OsiVolSolverInterface.cpp.

References colMatrix_, colMatrixCurrent_, and rowMatrix_.

Referenced by addCol(), addCols(), deleteCols(), getMatrixByCol(), and resolve().

00035 {
00036    if (! colMatrixCurrent_) {
00037       colMatrix_.reverseOrderedCopyOf(rowMatrix_);
00038       colMatrixCurrent_ = true;
00039    }
00040 }

void OsiVolSolverInterface::updateRowMatrix_  )  const [private]
 

Update the row ordered matrix from the column ordered one

Definition at line 25 of file OsiVolSolverInterface.cpp.

References colMatrix_, rowMatrix_, and rowMatrixCurrent_.

Referenced by addRow(), addRows(), applyRowCut(), deleteRows(), getMatrixByRow(), and resolve().

00026 {
00027    if (! rowMatrixCurrent_) {
00028       rowMatrix_.reverseOrderedCopyOf(colMatrix_);
00029       rowMatrixCurrent_ = true;
00030    }
00031 }

void OsiVolSolverInterface::writeMps const char *  filename,
const char *  extension = "mps",
double  objSense = 0.0
const [virtual]
 

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 412 of file OsiVolSolverInterfaceIO.cpp.

References getColLower(), getColUpper(), getInfinity(), getMatrixByCol(), getObjCoefficients(), getRowLower(), getRowUpper(), CoinMpsIO::setMpsData(), and CoinMpsIO::writeMps().

00415 {
00416    CoinMpsIO writer;
00417    writer.setMpsData(*getMatrixByCol(), getInfinity(),
00418                      getColLower(), getColUpper(),
00419                      getObjCoefficients(), (const char*) 0 /*integrality*/,
00420                      getRowLower(), getRowUpper(),
00421                      (const char**) 0 /*colnam*/, (const char**) 0 /*rownam*/);
00422    std::string fname = filename;
00423    fname += extension;
00424    writer.writeMps(fname.c_str());
00425 }


Friends And Related Function Documentation

void OsiVolSolverInterfaceUnitTest const std::string &  mpsDir,
const std::string &  netlibDir
[friend]
 

A function that tests the methods in the OsiVolSolverInterface 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. Also, if this method is compiled with optimization, the compilation takes 10-15 minutes and the machine pages (has 256M core memory!)...

Definition at line 17 of file OsiVolSolverInterfaceTest.cpp.

00018 {
00019 
00020   // Do common solverInterface testing
00021   {
00022     OsiVolSolverInterface m;
00023     OsiSolverInterfaceCommonUnitTest(&m, mpsDir,netlibDir);
00024   }
00025 
00026 }


Member Data Documentation

double* OsiVolSolverInterface::rowpriceHotStart_ [private]
 

An array to store the hotstart information between solveHotStart() calls

Definition at line 832 of file OsiVolSolverInterface.hpp.

Referenced by gutsOfDestructor_(), markHotStart(), solveFromHotStart(), and unmarkHotStart().

double* OsiVolSolverInterface::rowrange_ [private]
 

Pointer to dense vector of slack upper bounds for range constraints (undefined for non-range rows).

Definition at line 805 of file OsiVolSolverInterface.hpp.

Referenced by addRow(), addRows(), applyRowCut(), assignProblem(), convertBoundsToSenses_(), convertSensesToBounds_(), deleteRows(), getRowRange(), gutsOfDestructor_(), operator=(), rowRimAllocator_(), rowRimResize_(), setRowBounds(), setRowLower(), setRowSetTypes(), setRowType(), and setRowUpper().


The documentation for this class was generated from the following files:
Generated on Wed Dec 3 14:35:47 2003 for Osi by doxygen 1.3.5