Changeset 2019 for trunk/Cbc/test
 Timestamp:
 Mar 11, 2014 5:10:15 PM (5 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Cbc/test/CInterfaceTest.c
r2016 r2019 16 16 17 17 /* Simple knapsack problem 18 M inimize 5x[1]  3x[2]  2x[3]  7x[4] 4x[5]18 Maximize 5x[1] + 3x[2] + 2x[3] + 7x[4] + 4x[5] 19 19 s.t. 2x[1] + 8x[2] + 4x[3] + 2x[4] + 5x[5] <= 10 20 20 All x binary … … 26 26 double collb[] = {0,0,0,0,0}; 27 27 double colub[] = {1,1,1,1,1}; 28 double obj[] = { 5, 3, 2, 7, 4};28 double obj[] = {5, 3, 2, 7, 4}; 29 29 double rowlb[] = {INFINITY}; 30 30 double rowub[] = {10}; 31 char integer[] = {1,1,1,1,1};32 char *information;33 31 const double *sol; 34 32 int i; … … 36 34 Cbc_loadProblem(model, 5, 1, start, rowindex, value, collb, colub, obj, rowlb, rowub); 37 35 38 Cbc_copyInIntegerInformation(model, integer);39 40 36 assert(Cbc_getNumCols(model) == 5); 41 37 assert(Cbc_getNumRows(model) == 1); 42 38 43 information = Cbc_integerInformation(model);44 39 for (i = 0; i < 5; i++) { 45 assert(information[i] == 1); 40 Cbc_setInteger(model, i); 41 assert(Cbc_isInteger(model,i)); 46 42 } 47 43 48 assert(Cbc_optimizationDirection(model) == 1); 44 Cbc_setObjSense(model, 1); 45 assert(Cbc_getObjSense(model) == 1); 49 46 50 47 Cbc_solve(model); 51 48 52 49 assert(Cbc_isProvenOptimal(model)); 53 assert(fabs( Cbc_objectiveValue(model) (16.0) < 1e6)); 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) < 1e6)); 54 57 55 58 sol = Cbc_getColSolution(model); … … 80 83 double colub[] = {1.0}; 81 84 double obj[] = {1.0}; 82 char integer[] = {1};83 85 84 86 Cbc_loadProblem(model, 1, 1, start, rowindex, value, collb, colub, obj, rowlb, rowub); 85 87 86 Cbc_ copyInIntegerInformation(model, integer);88 Cbc_setInteger(model, 0); 87 89 88 90 assert(Cbc_getNumCols(model) == 1); … … 92 94 93 95 assert(!Cbc_isProvenOptimal(model)); 94 assert(Cbc_isProven PrimalInfeasible(model));96 assert(Cbc_isProvenInfeasible(model)); 95 97 96 98 } … … 115 117 double colub[] = {INFINITY, INFINITY}; 116 118 double obj[] = {1.0}; 117 char integer[] = {1,0};118 119 119 120 Cbc_loadProblem(model, 2, 2, start, rowindex, value, collb, colub, obj, rowlb, rowub); 120 121 121 Cbc_ copyInIntegerInformation(model, integer);122 Cbc_setInteger(model, 0); 122 123 123 124 Cbc_solve(model); 124 125 125 126 assert(!Cbc_isProvenOptimal(model)); 126 assert(!Cbc_isProven PrimalInfeasible(model));127 assert(Cbc_is ProvenDualInfeasible(model));127 assert(!Cbc_isProvenInfeasible(model)); 128 assert(Cbc_isContinuousUnbounded(model)); 128 129 129 130
Note: See TracChangeset
for help on using the changeset viewer.