Changeset 2033 for trunk/Cbc/test
 Timestamp:
 May 8, 2014 1:41:51 PM (5 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Cbc/test/CInterfaceTest.c
r2032 r2033 111 111 } 112 112 113 void testSOS() { 114 115 Cbc_Model *model = Cbc_newModel(); 116 117 /* 118 Minimize 5x[1] + 3x[2] + 2x[3] + 7x[4] + 4x[5] 119 s.t. x[1] + x[2] + x[3] + x[4] + x[5] == 1 120 All x binary 121 */ 122 123 CoinBigIndex start[] = {0, 0, 0, 0, 0, 0, 0}; 124 /*int rowindex[] = {};*/ 125 /*double value[] = {};*/ 126 double collb[] = {0,0,0,0,0}; 127 double colub[] = {1,1,1,1,1}; 128 double obj[] = {5, 3, 2, 7, 4}; 129 /*double rowlb[] = {};*/ 130 /*double rowub[] = {};*/ 131 int sosrowstart[] = {0,5}; 132 int soscolindex[] = {0,1,2,3,4}; 133 const double *sol; 134 int i; 135 136 Cbc_loadProblem(model, 5, 0, start, NULL, NULL, collb, colub, obj, NULL, NULL); 137 138 assert(Cbc_getNumCols(model) == 5); 139 assert(Cbc_getNumRows(model) == 0); 140 141 for (i = 0; i < 5; i++) { 142 Cbc_setInteger(model, i); 143 assert(Cbc_isInteger(model,i)); 144 } 145 146 assert(Cbc_getObjSense(model) == 1); 147 148 Cbc_addSOS(model,1,sosrowstart,soscolindex,obj,1); 149 150 Cbc_solve(model); 151 152 assert(Cbc_isProvenOptimal(model)); 153 assert(!Cbc_isAbandoned(model)); 154 assert(!Cbc_isProvenInfeasible(model)); 155 assert(!Cbc_isContinuousUnbounded(model)); 156 assert(!Cbc_isNodeLimitReached(model)); 157 assert(!Cbc_isSecondsLimitReached(model)); 158 assert(!Cbc_isSolutionLimitReached(model)); 159 assert(fabs( Cbc_getObjValue(model) (2.0) < 1e6)); 160 assert(fabs( Cbc_getBestPossibleObjValue(model) (2.0) < 1e6)); 161 162 sol = Cbc_getColSolution(model); 163 164 assert(fabs(sol[0]  0.0) < 1e6); 165 assert(fabs(sol[1]  0.0) < 1e6); 166 assert(fabs(sol[2]  1.0) < 1e6); 167 assert(fabs(sol[3]  0.0) < 1e6); 168 assert(fabs(sol[4]  0.0) < 1e6); 169 170 Cbc_deleteModel(model); 171 172 } 173 113 174 void testIntegerInfeasible() { 114 175 … … 187 248 int main() { 188 249 250 printf("Knapsack test\n"); 189 251 testKnapsack(); 252 printf("SOS test\n"); 253 testSOS(); 254 printf("Infeasible test\n"); 190 255 testIntegerInfeasible(); 256 printf("Unbounded test\n"); 191 257 testIntegerUnbounded(); 192 258
Note: See TracChangeset
for help on using the changeset viewer.