[Coin-discuss] OsiGlpk bug and solution

Michael Hennebry hennebry at web.cs.ndsu.nodak.edu
Wed Feb 2 16:39:26 EST 2005


from OsiGlpkSolverInterface.cpp (comments are mine):
void
OsiGlpkSolverInterface::deleteRows(const int num, const int * rowIndices)
{

        int rowIndicesPlus1[num];  // all used, rowIndicesPlus1[0..num-1]
        LPX *model = getMutableModelPtr();
        freeCachedData( OsiGlpkSolverInterface::KEEPCACHED_COLUMN );

        for( int i = 0; i < num; i++ )
        {
                rowIndicesPlus1[i]=rowIndices[i]+1;
        }
        // rowIndicesPlus1[0] has data, there is no rowIndicesPlus1[num]
        lpx_del_rows(model,num,rowIndicesPlus1);
}


from glplpx1.c:
-- The routine lpx_del_rows deletes specified rows from the problem
-- object. Ordinal numbers of rows to be deleted should be placed in
-- locations num[1], ..., num[nrs], where nrs > 0.
--
-- Note that deleting rows involves changing ordinal numbers of other
-- rows remaining in the problem object. New ordinal numbers of the
-- remaining rows are assigned under the assumption that the original
-- order of rows is not changed. */

the fix for OsiGlpkSolverInterface.cpp (comments are mine):
void
OsiGlpkSolverInterface::deleteRows(const int num, const int * rowIndices)
{
    int rowIndicesPlus1[num+1];  // rowIndicesPlus1[1..num] used
    LPX *model = getMutableModelPtr();
    freeCachedData( OsiGlpkSolverInterface::KEEPCACHED_COLUMN );

    for(int i=0; i< num; i++ )
    {
        rowIndicesPlus1[i+1]=rowIndices[i]+1;
    }
    // rowIndicesPlus1[0] unused, rowIndicesPlus1[num] has data
    lpx_del_rows(model, num, rowIndicesPlus1);
} // deleteRows


Thank you Ted Ralphs for pointing me to valgrind.

-- 
Mike   hennebry at web.cs.ndsu.NoDak.edu
"Our gods are dead.  Ancient Klingon warriors slew them
... they were more trouble than they were worth."          --  Worf





More information about the Coin-discuss mailing list