[Coin-discuss] Bug report for COIN/Osi

Mikhail Nediak msnediak at rutcor.rutgers.edu
Wed Feb 27 00:00:15 EST 2002


Dear COIN community,

We would also like to report a few bugs in COIN/OSI which we
have recently discovered.

First, the setDimensions() method of OsiPackedMatrix actually
keeps dimensions the same in the current implementation.
To solve the problem, the last if() of the method should read

  if (numplus > 0) {
    int* lengths = new int[numplus];
    CoinFillN(lengths, numplus, 0); //1 in the original version
    resizeForAddingMajorVectors(numplus, lengths);
    delete[] lengths;
    majorDim_ += numplus; //forgot to change majorDim_
  }

Second, there is memory drain in the
void
OsiPackedVector::assignVector(int size, int*& inds, double*& elems,
			      bool testForDuplicateIndex)

since it first uses reserve(size) to allocate memory, and then
simply copies over the pointers inds and elems. The correct way is to
avoid using resize() as follows:

void
OsiPackedVector::assignVector(int size, int*& inds, double*& elems,
			      bool testForDuplicateIndex)
{
   clear();
   // Allocate storage
   if ( size != 0 ) {
	 //reserve(size); //This is a BUG!!!
      nElements_ = size;
	  if (indices_ != NULL) delete[] indices_;
      indices_ = inds;    inds = NULL;
	  if (elements_ != NULL) delete[] elements_;
      elements_ = elems;  elems = NULL;
	  if (origIndices_ != NULL) delete[] origIndices_;
	  origIndices_ = new int[size];
      CoinIotaN(origIndices_, size, 0);
	  capacity_ = size;
   }
   try {

OsiPackedVectorBase::setTestForDuplicateIndex(testForDuplicateIndex);
   }
   catch (CoinError e) {
      throw CoinError("duplicate index", "assignVector",
"OsiPackedVector");
   }
}


Third, there is not exactly a bug but rather a design problem in
OsiSolverInterface. It is best illustrated on OsiCpxSolverInterface.
Note that CPXaddcols() can not coefficients to rows that do not
already exist. CPXaddrows() can also add new columns but its "not
recommended" according to the manual. There are methods CPXnewrows() and
CPXnewcols() to address this issue, however there is no this
kind of functionality in OsiSolverInterface.

The solution is to add setDimensions() method to OsiSolverInterface.
For CPLEX, it can be implemented via functions mentioned above. For
OSL, this method is available. Unfortunately, I do not know about
XPRESS-MP, but I suppose it should also have some similar functions.
Other way is to make sure that the existing methods can handle
the coefficients in new rows/columns but is seems messier.

Best regards,
Mikhail Nediak




More information about the Coin-discuss mailing list