Changeset 2019 for trunk/Cbc/test


Ignore:
Timestamp:
Mar 11, 2014 5:10:15 PM (5 years ago)
Author:
mlubin
Message:

Major cleaning of C interface, more to come

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cbc/test/CInterfaceTest.c

    r2016 r2019  
    1616
    1717    /* Simple knapsack problem
    18        Minimize -5x[1] - 3x[2] - 2x[3] - 7x[4] - 4x[5]
     18       Maximize  5x[1] + 3x[2] + 2x[3] + 7x[4] + 4x[5]
    1919       s.t.      2x[1] + 8x[2] + 4x[3] + 2x[4] + 5x[5] <= 10
    2020       All x binary
     
    2626    double collb[] = {0,0,0,0,0};
    2727    double colub[] = {1,1,1,1,1};
    28     double obj[] = {-5, -3, -2, -7, -4};
     28    double obj[] = {5, 3, 2, 7, 4};
    2929    double rowlb[] = {-INFINITY};
    3030    double rowub[] = {10};
    31     char integer[] = {1,1,1,1,1};
    32     char *information;
    3331    const double *sol;
    3432    int i;
     
    3634    Cbc_loadProblem(model, 5, 1, start, rowindex, value, collb, colub, obj, rowlb, rowub);
    3735
    38     Cbc_copyInIntegerInformation(model, integer);
    39 
    4036    assert(Cbc_getNumCols(model) == 5);
    4137    assert(Cbc_getNumRows(model) == 1);
    4238
    43     information = Cbc_integerInformation(model);
    4439    for (i = 0; i < 5; i++) {
    45         assert(information[i] == 1);
     40        Cbc_setInteger(model, i);
     41        assert(Cbc_isInteger(model,i));
    4642    }
    4743
    48     assert(Cbc_optimizationDirection(model) == 1);
     44    Cbc_setObjSense(model, -1);
     45    assert(Cbc_getObjSense(model) == -1);
    4946
    5047    Cbc_solve(model);
    5148
    5249    assert(Cbc_isProvenOptimal(model));
    53     assert(fabs( Cbc_objectiveValue(model)- (-16.0) < 1e-6));
     50    assert(!Cbc_isAbandoned(model));
     51    assert(!Cbc_isProvenInfeasible(model));
     52    assert(!Cbc_isContinuousUnbounded(model));
     53    assert(!Cbc_isNodeLimitReached(model));
     54    assert(!Cbc_isSecondsLimitReached(model));
     55    assert(!Cbc_isSolutionLimitReached(model));
     56    assert(fabs( Cbc_getObjValue(model)- (16.0) < 1e-6));
    5457   
    5558    sol = Cbc_getColSolution(model);
     
    8083    double colub[] = {1.0};
    8184    double obj[] = {1.0};
    82     char integer[] = {1};
    8385
    8486    Cbc_loadProblem(model, 1, 1, start, rowindex, value, collb, colub, obj, rowlb, rowub);
    8587
    86     Cbc_copyInIntegerInformation(model, integer);
     88    Cbc_setInteger(model, 0);
    8789
    8890    assert(Cbc_getNumCols(model) == 1);
     
    9294   
    9395    assert(!Cbc_isProvenOptimal(model));
    94     assert(Cbc_isProvenPrimalInfeasible(model));
     96    assert(Cbc_isProvenInfeasible(model));
    9597
    9698}
     
    115117    double colub[] = {INFINITY, INFINITY};
    116118    double obj[] = {1.0};
    117     char integer[] = {1,0};
    118119
    119120    Cbc_loadProblem(model, 2, 2, start, rowindex, value, collb, colub, obj, rowlb, rowub);
    120121
    121     Cbc_copyInIntegerInformation(model, integer);
     122    Cbc_setInteger(model, 0);
    122123
    123124    Cbc_solve(model);
    124125   
    125126    assert(!Cbc_isProvenOptimal(model));
    126     assert(!Cbc_isProvenPrimalInfeasible(model));
    127     assert(Cbc_isProvenDualInfeasible(model));
     127    assert(!Cbc_isProvenInfeasible(model));
     128    assert(Cbc_isContinuousUnbounded(model));
    128129
    129130
Note: See TracChangeset for help on using the changeset viewer.