[Osi-tickets] [COIN-OR Open Solver Interface] #10:
OsiClpSolverInterface::addCols
COIN-OR Open Solver Interface
coin-trac at coin-or.org
Mon Sep 4 02:57:46 EDT 2006
#10: OsiClpSolverInterface::addCols
--------------------+-------------------------------------------------------
Reporter: San | Owner: mjs
Type: defect | Status: new
Priority: major | Milestone:
Component: OsiClp | Version:
Keywords: |
--------------------+-------------------------------------------------------
Hi. I'm just wondering if I'm using the following Osi correctly to
add the columns.
{{{
void OsiClpSolverInterface::addCols(const int numcols,
const CoinPackedVectorBase * const * cols,
const double* collb, const double* colub,
const double* obj)
}}}
I don't want to add rows when I'm calling the addCols method, but when
I pass NULL for the CoinPackedVectorBase parameter, it'll crash in
{{{
void CoinPackedMatrix::appendMajorVectors(const int numvecs,
const CoinPackedVectorBase * const *
vecs)
{
...
for (i = 0; i < numvecs; ++i)
nz += CoinLengthWithExtra(vecs[i]->getNumElements(), extraGap_);
...
}
}}}
as it is accessing vecs[i] without checking to see if vecs is not NULL.
When I changed the addCols method to only append cols when the
CoinPackedVectorBase is not NULL, it seemed to be working ok for small
problems that I was testing.
{{{
void OsiClpSolverInterface::addCols(const int numcols,
const CoinPackedVectorBase * const * cols,
const double* collb, const double* colub,
const double* obj)
{
...
if (cols != NULL) // added this check so that it's only appending
cols when it is specified
{
modelPtr_->matrix()->appendCols(numcols,cols);
}
...
}
}}}
If I don't change the Osi code and just pass in an array with:
{{{
CoinPackedVectorBase ** columns= new CoinPackedVectorBase*
[numCol];
for (unsigned int i = 0; i < numCol; i++)
{
columns[i] = new CoinPackedVector(0,static_cast<const
int *>(NULL),static_cast<const double *>(NULL));
}
}}}
it seems to be working ok, but I don't see why I have to do that when
I could get the rest of the code working without appending any
CoinPackedVectorBase.
I'm just wondering if this was a bug or whether I've used the
interface incorrectly.
Thanks.
San
--
Ticket URL: <https://projects.coin-or.org/Osi/ticket/10>
COIN-OR Open Solver Interface <https://projects.coin-or.org/Osi/>
The COIN-OR Open Solver Interface
More information about the Osi-tickets
mailing list