[Coin-discuss] OsiClpSolverInterface::getBInvACol()

John J Forrest jjforre at us.ibm.com
Fri Dec 31 06:46:52 EST 2004


Miroslav,

It should be okay now.  It was not designed to do slacks initially and in 
fact would complain if NDEBUG had not been defined.

John Forrest



Miroslav Karamanov <miroslav at andrew.cmu.edu> 
Sent by: coin-discuss-bounces at list.coin-or.org
12/29/2004 03:35 PM
Please respond to
Discussions about open source software for Operations Research 


To
coin-discuss at list.coin-or.org
cc

Subject
[Coin-discuss] OsiClpSolverInterface::getBInvACol()






Hello,

It seems the tableau obtained by OsiClpSolverInterface::getBInvACol() 
differs from the one from OsiClpSolverInterface::getBInvARow() and the 
difference is in the sign of the slack/artificial columns.
Matthew Galati kindly helped me localize the problem and pointed out 
that this is not the case when the tableau is obtained through Clp, not 
through Osi. The function below shows this. I attached a small test 
instance too but the problem appeared with all instances I tested.
The incorrect routine seems to be OsiClpSolverInterface::getBInvACol().

Best,
Miroslav

==========================
Miroslav Karamanov
PhD Student
Carnegie Mellon University
==========================


========================================================
void TableauCheck(OsiClpSolverInterface * siCLP){

    /*
      ---
      --- CLP tableau from getBInvARow = from getBInvACol
      ---
    */
    int ii, jj, i, j;
    int n_cols = siCLP->getNumCols();
    int n_rows = siCLP->getNumRows();
    double * binvACol  = (double*) malloc(n_rows * sizeof(double));
    double * binvASRow = (double*) malloc(n_cols * sizeof(double));
    double * binvAARow = (double*) malloc(n_rows * sizeof(double));
    double * binvARow  = (double*) malloc((n_cols+n_rows) * 
sizeof(double));
    int    * indCol     = (int*)   malloc((n_cols+n_rows) * sizeof(int));
    int    * indRow     = (int*)   malloc(n_rows * sizeof(int));

    CoinPackedMatrix Mcol;
    CoinPackedMatrix Mrow;
    CoinPackedMatrix OSIMcol;
    CoinPackedMatrix OSIMrow;

    CoinIotaN(indCol, n_cols+n_rows, 0);
    CoinIotaN(indRow, n_rows,        0);

    Mcol.setDimensions   (n_rows, 0);
    Mrow.setDimensions   (0,      n_cols+n_rows);
    OSIMcol.setDimensions(n_rows, 0);            // tableau accessed
through OSI
    OSIMrow.setDimensions(0,      n_cols+n_rows);

    for(j = 0; j < (n_cols + n_rows); j++){
      /* access artificial columns thru CLP directly, not thru OSI */
      siCLP->getModelPtr()->getBInvACol(j, binvACol);
      Mcol.appendCol(n_rows, indRow, binvACol);

      // access through OSI
      siCLP->getBInvACol(j, binvACol);
      OSIMcol.appendCol(n_rows, indRow, binvACol);
    }

    for(i = 0; i < n_rows; i++){
      siCLP->getModelPtr()->getBInvARow(i, binvASRow, binvAARow);
      for(jj = 0; jj < n_cols; jj++)
        binvARow[jj] = binvASRow[jj];
      for(ii = 0; ii < n_rows; ii++)
        binvARow[n_cols+ii] = binvAARow[ii];
      Mrow.appendRow(n_cols+n_rows, indCol, binvARow);

      // access through OSI
      siCLP->getBInvARow(i, binvASRow, binvAARow);
      for(jj = 0; jj < n_cols; jj++)
        binvARow[jj] = binvASRow[jj];
      for(ii = 0; ii < n_rows; ii++)
        binvARow[n_cols+ii] = binvAARow[ii];
      OSIMrow.appendRow(n_cols+n_rows, indCol, binvARow);
    }

    printf("\nCOL MATRIX:");
    Mcol.dumpMatrix();

    printf("\nROW MATRIX:");
    Mrow.dumpMatrix();

    assert(Mcol.isEquivalent2(Mrow));

    printf("\nCOL MATRIX (OSI):");
    OSIMcol.dumpMatrix();

    printf("\nROW MATRIX (OSI):");
    OSIMrow.dumpMatrix();

    assert(OSIMcol.isEquivalent2(OSIMrow));

    free(binvACol);
    free(binvASRow);
    free(binvAARow);
    free(binvARow);
    free(indCol);
    free(indRow);

}
==========================================================
NAME small
ROWS
 N  obj
 L  c1
 L  c2
COLUMNS
 x0    obj    -1     c1   1
 x0    c2      2
 x1    obj    -1     c1   2
 x1    c2      1
RHS
 rhs   c1      1     c2   1
ENDATA
 
_______________________________________________
Coin-discuss mailing list
Coin-discuss at list.coin-or.org
http://list.coin-or.org/mailman/listinfo/coin-discuss

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/coin-discuss/attachments/20041231/f924e394/attachment.html>


More information about the Coin-discuss mailing list