Changeset 2203


Ignore:
Timestamp:
Feb 19, 2019 12:24:23 PM (21 months ago)
Author:
stefan
Message:

add test for adding columns with contradicting sides and adding rows with contradicting rows

  • the LP should be infeasible, if no exception is thrown
  • removed an assert in OsiCpx? which prevented adding rows with contradicting sides (could be changed into throwing an exception, too)
Location:
trunk/Osi/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Osi/src/OsiCommonTest/OsiSolverInterfaceTest.cpp

    r2202 r2203  
    31773177  Add rows to an empty system. Begin by creating empty columns, then add some
    31783178  rows.
    3179 */
     3179  */
    31803180  {
    31813181    OsiSolverInterface *si = emptySi->clone();
     
    32533253  Add columns to an empty system. Start by creating empty rows, then add
    32543254  some columns.
    3255 */
     3255  */
    32563256  {
    32573257    OsiSolverInterface *si = emptySi->clone();
     
    33283328      }
    33293329    }
     3330    delete si;
     3331  }
     3332  /*
     3333  Add contradicting columns to an empty system.
     3334  Either the OSI rejects these column via an exception or the LP is proven infeasible.
     3335  */
     3336  {
     3337    OsiSolverInterface *si = emptySi->clone();
     3338    int i;
     3339
     3340    //Matrix
     3341    int row[] = { 0, 1 };
     3342    double col1E[] = { 4.0, 7.0 };
     3343    double col2E[] = { 7.0, 4.0 };
     3344    double col3E[] = { 5.0, 5.0 };
     3345    CoinPackedVector col1(2, row, col1E);
     3346    CoinPackedVector col2(2, row, col2E);
     3347    CoinPackedVector col3(2, row, col3E);
     3348
     3349    double objective[] = { 5.0, 6.0, 5.5 };
     3350    {
     3351      // Add empty rows
     3352      for (i = 0; i < 2; i++) {
     3353        const CoinPackedVector reqdBySunCC;
     3354        si->addRow(reqdBySunCC, 100.0, 100.0);
     3355      }
     3356
     3357      // Add columns
     3358      try {
     3359        si->addCol(col1, 10.0, -10.0, objective[0]);
     3360        si->addCol(col2, si->getInfinity(), 0.0, objective[1]);
     3361        si->addCol(col3, si->getInfinity(), si->getInfinity(), objective[2]);
     3362
     3363        // solve
     3364        si->initialSolve();
     3365
     3366        OSIUNITTEST_ASSERT_ERROR(si->isProvenPrimalInfeasible(), {}, solverName, "testAddToEmptySystem: isProvenPrimalInfeasible() after adding contradicting columns");
     3367      }
     3368      catch( CoinError& e )
     3369      {
     3370        OSIUNITTEST_ADD_OUTCOME(solverName, "testAddToEmptySystem", "addCol adds contradicting columns threw CoinError", TestOutcome::PASSED, true);
     3371      }
     3372    }
     3373    delete si;
     3374  }
     3375  /*
     3376  Add rows with contradicting sides to an empty system. Begin by creating empty columns, then add some
     3377  rows.
     3378  */
     3379  {
     3380    OsiSolverInterface *si = emptySi->clone();
     3381    int i;
     3382
     3383    //Matrix
     3384    int column[] = { 0, 1, 2 };
     3385    double row1E[] = { 4.0, 7.0, 5.0 };
     3386    double row2E[] = { 7.0, 4.0, 5.0 };
     3387    CoinPackedVector row1(3, column, row1E);
     3388    CoinPackedVector row2(3, column, row2E);
     3389
     3390    double objective[] = { 5.0, 6.0, 5.5 };
     3391
     3392    {
     3393      // Add empty columns
     3394      for (i = 0; i < 3; i++) {
     3395        const CoinPackedVector reqdBySunCC;
     3396        si->addCol(reqdBySunCC, 0.0, 10.0, objective[i]);
     3397      }
     3398
     3399      try {
     3400        // Add rows
     3401        si->addRow(row1, -100.0, 100.0);
     3402        si->addRow(row2, si->getInfinity(), -si->getInfinity());
     3403
     3404        // Vol can not solve problem of this form
     3405        if (!volSolverInterface) {
     3406          // solve
     3407          si->initialSolve();
     3408          OSIUNITTEST_ASSERT_ERROR(si->isProvenPrimalInfeasible(), {}, solverName, "testAddToEmptySystem: isProvenPrimalInfeasible() after adding rows with contradicting sides");
     3409        }
     3410      }
     3411      catch( CoinError& e )
     3412      {
     3413        OSIUNITTEST_ADD_OUTCOME(solverName, "testAddToEmptySystem", "addRow for rows with contradicting sides threw CoinError", TestOutcome::PASSED, true);
     3414      }
     3415    }
     3416
    33303417    delete si;
    33313418  }
  • trunk/Osi/src/OsiCpx/OsiCpxSolverInterface.cpp

    r2196 r2203  
    22552255  switch (rowsen) {
    22562256  case 'R':
    2257     assert(rowrng >= 0.0);
     2257    //assert(rowrng >= 0.0);
    22582258    rhs = rowrhs - rowrng;
    22592259    range = rowrng;
Note: See TracChangeset for help on using the changeset viewer.