[Coin-discuss] OsiGlpk bug and solution

Brady Hunsaker hunsaker at engr.pitt.edu
Fri Feb 4 12:27:26 EST 2005


Thanks for the bug report and fix, Michael.  I've updated OsiGlpk in the 
repository.  As you can imagine, this indexing issue is present 
throughout the OsiGlpk interface, but that routine was obviously 
overlooked until now.

Brady

Michael Hennebry wrote:
> 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.
> 


-- 
Brady Hunsaker
Assistant Professor
Industrial Engineering
University of Pittsburgh
http://www.engr.pitt.edu/hunsaker/



More information about the Coin-discuss mailing list