[Coin-discuss] OsiClpSolverInterface::getBInvACol()

Miroslav Karamanov miroslav at andrew.cmu.edu
Wed Dec 29 15:35:09 EST 2004


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);

}
==========================================================
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: small.mps
URL: <http://list.coin-or.org/pipermail/coin-discuss/attachments/20041229/8dcd437a/attachment.ksh>


More information about the Coin-discuss mailing list