|
Go to the documentation of this file. 52 static unsigned char warnedbeta = 0; 54 #define CHECK_ZERO(messagehdlr, x) { int _restat_; \ 55 if( (_restat_ = (x)) != 0 ) \ 57 SCIPmessagePrintWarning((messagehdlr), "Gurobi error %d: %s\n", _restat_, GRBgeterrormsg(grbenv)); \ 58 return SCIP_LPERROR; \ 62 #if GRB_VERSION_MAJOR == 6 && GRB_VERSION_MINOR == 0 && GRB_VERSION_TECHNICAL < 2 72 #define SVECTOR GRBsvec 75 #if( GRB_VERSION_MAJOR < 4 ) 76 #define GRB_METHOD_DUAL GRB_LPMETHOD_DUAL 77 #define GRB_METHOD_PRIMAL GRB_LPMETHOD_PRIMAL 78 #define GRB_INT_PAR_METHOD GRB_INT_PAR_LPMETHOD 82 #define SCIP_SINGLEPACKETSIZE (sizeof(SCIP_SINGLEPACKET)*8) 84 #define SCIP_DUALPACKETSIZE (sizeof(SCIP_DUALPACKET)*4) 87 #define COLS_PER_PACKET SCIP_DUALPACKETSIZE 89 #define ROWS_PER_PACKET SCIP_DUALPACKETSIZE 95 #define GRB_REFACTORMAXITERS 50 103 GRB_INT_PAR_SCALEFLAG, 104 GRB_INT_PAR_PRESOLVE, 105 GRB_INT_PAR_SIMPLEXPRICING, 106 GRB_INT_PAR_OUTPUTFLAG 109 #define NUMDBLPARAM 6 113 GRB_DBL_PAR_FEASIBILITYTOL, 114 GRB_DBL_PAR_OPTIMALITYTOL, 116 GRB_DBL_PAR_TIMELIMIT, 117 GRB_DBL_PAR_ITERATIONLIMIT, 118 GRB_DBL_PAR_MARKOWITZTOL 176 static GRBenv* grbenv = NULL; 177 static int numlp = 0; 194 if( num > lpi->sidechgsize ) 198 newsize = MAX(2*lpi->sidechgsize, num); 199 SCIP_ALLOC( BMSreallocMemoryArray(&lpi->senarray, newsize) ); 200 SCIP_ALLOC( BMSreallocMemoryArray(&lpi->rhsarray, newsize) ); 201 lpi->sidechgsize = newsize; 203 assert(num <= lpi->sidechgsize); 217 if( num > lpi->valsize ) 221 newsize = MAX(2*lpi->valsize, num); 222 SCIP_ALLOC( BMSreallocMemoryArray(&lpi->valarray, newsize) ); 223 SCIP_ALLOC( BMSreallocMemoryArray(&lpi->indarray, newsize) ); 224 lpi->valsize = newsize; 226 assert(num <= lpi->valsize); 240 if( num > lpi->cstatsize ) 244 newsize = MAX(2*lpi->cstatsize, num); 245 SCIP_ALLOC( BMSreallocMemoryArray(&lpi->cstat, newsize) ); 246 lpi->cstatsize = newsize; 248 assert(num <= lpi->cstatsize); 262 if( num > lpi->rstatsize ) 266 newsize = MAX(2*lpi->rstatsize, num); 267 SCIP_ALLOC( BMSreallocMemoryArray(&lpi->rstat, newsize) ); 268 lpi->rstatsize = newsize; 270 assert(num <= lpi->rstatsize); 286 assert( lpi != NULL ); 287 assert( lpi->grbmodel != NULL ); 288 assert( lpi->grbenv != NULL ); 291 if ( success != NULL ) 294 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMVARS, &ncols) ); 295 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMCONSTRS, &nrows) ); 302 res = GRBgetintattrarray(lpi->grbmodel, GRB_INT_ATTR_VBASIS, 0, ncols, lpi->cstat); 303 if ( res == GRB_ERROR_DATA_NOT_AVAILABLE ) 306 if ( success != NULL ) 312 SCIPerrorMessage( "Gurobi error %d: %s\n", res, GRBgeterrormsg(lpi->grbenv)); 316 res = GRBgetintattrarray(lpi->grbmodel, GRB_INT_ATTR_CBASIS, 0, nrows, lpi->rstat); 317 if ( res == GRB_ERROR_DATA_NOT_AVAILABLE ) 320 if ( success != NULL ) 326 SCIPerrorMessage( "Gurobi error %d: %s\n", res, GRBgeterrormsg(lpi->grbenv)); 342 assert( lpi != NULL ); 343 assert( lpi->grbmodel != NULL ); 347 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMVARS, &ncols) ); 348 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMCONSTRS, &nrows) ); 351 CHECK_ZERO( lpi->messagehdlr, GRBsetintattrarray(lpi->grbmodel, GRB_INT_ATTR_VBASIS, 0, ncols, lpi->cstat) ); 352 CHECK_ZERO( lpi->messagehdlr, GRBsetintattrarray(lpi->grbmodel, GRB_INT_ATTR_CBASIS, 0, nrows, lpi->rstat) ); 354 CHECK_ZERO( lpi->messagehdlr, GRBupdatemodel(lpi->grbmodel) ); 389 void SCIPencodeDualBitNeg( 396 {0x00000000, 0x00000001, 0x00000002, 0x00000003}, 397 {0x00000000, 0x00000004, 0x00000008, 0x0000000C}, 398 {0x00000000, 0x00000010, 0x00000020, 0x00000030}, 399 {0x00000000, 0x00000040, 0x00000080, 0x000000C0}, 400 {0x00000000, 0x00000100, 0x00000200, 0x00000300}, 401 {0x00000000, 0x00000400, 0x00000800, 0x00000C00}, 402 {0x00000000, 0x00001000, 0x00002000, 0x00003000}, 403 {0x00000000, 0x00004000, 0x00008000, 0x0000C000}, 404 {0x00000000, 0x00010000, 0x00020000, 0x00030000}, 405 {0x00000000, 0x00040000, 0x00080000, 0x000C0000}, 406 {0x00000000, 0x00100000, 0x00200000, 0x00300000}, 407 {0x00000000, 0x00400000, 0x00800000, 0x00C00000}, 408 {0x00000000, 0x01000000, 0x02000000, 0x03000000}, 409 {0x00000000, 0x04000000, 0x08000000, 0x0C000000}, 410 {0x00000000, 0x10000000, 0x20000000, 0x30000000}, 411 {0x00000000, 0x40000000, 0x80000000, 0xC0000000} 417 assert(inp != NULL || count == 0); 418 assert(out != NULL || count == 0); 423 nfull = count - rest; 434 assert(0 <= -inp[j] && -inp[j] <= 3); 438 mask[0][-inp[0]] | mask[1][-inp[1]] | mask[2][-inp[2]] | mask[3][inp[3]] 439 | mask[4][-inp[4]] | mask[5][-inp[5]] | mask[6][-inp[6]] 440 | mask[7][-inp[7]] | mask[8][-inp[8]] | mask[9][-inp[9]] 441 | mask[10][-inp[10]] | mask[11][-inp[11]] | mask[12][-inp[12]] 442 | mask[13][-inp[13]] | mask[14][-inp[14]] | mask[15][-inp[15]]; 452 for( i = 0; i < rest; i++ ) 453 m |= mask[i][-inp[i]]; 460 void SCIPdecodeDualBitNeg( 471 assert(inp != NULL || count == 0); 472 assert(out != NULL || count == 0); 477 nfull = count - rest; 486 *out++ = -(int)(m & 3); 488 *out++ = -(int)(m & 3); 490 *out++ = -(int)(m & 3); 492 *out++ = -(int)(m & 3); 494 *out++ = -(int)(m & 3); 496 *out++ = -(int)(m & 3); 498 *out++ = -(int)(m & 3); 500 *out++ = -(int)(m & 3); 502 *out++ = -(int)(m & 3); 504 *out++ = -(int)(m & 3); 506 *out++ = -(int)(m & 3); 508 *out++ = -(int)(m & 3); 510 *out++ = -(int)(m & 3); 512 *out++ = -(int)(m & 3); 514 *out++ = -(int)(m & 3); 516 *out++ = -(int)(m & 3); 526 for( i = 0; i < rest; i++ ) 528 *out++ = -(int)(m & 3); 542 assert(lpistate != NULL); 543 assert(lpistate->packcstat != NULL); 544 assert(lpistate->packrstat != NULL); 546 SCIPencodeDualBitNeg(cstat, lpistate->packcstat, lpistate->ncols); 547 SCIPencodeDualBitNeg(rstat, lpistate->packrstat, lpistate->nrows); 558 assert(lpistate != NULL); 559 assert(lpistate->packcstat != NULL); 560 assert(lpistate->packrstat != NULL); 562 SCIPdecodeDualBitNeg(lpistate->packcstat, cstat, lpistate->ncols); 563 SCIPdecodeDualBitNeg(lpistate->packrstat, rstat, lpistate->nrows); 575 assert(lpistate != NULL); 576 assert(blkmem != NULL); 580 SCIP_ALLOC( BMSallocBlockMemory(blkmem, lpistate) ); 581 SCIP_ALLOC( BMSallocBlockMemoryArray(blkmem, &(*lpistate)->packcstat, colpacketNum(ncols)) ); 582 SCIP_ALLOC( BMSallocBlockMemoryArray(blkmem, &(*lpistate)->packrstat, rowpacketNum(nrows)) ); 594 assert(blkmem != NULL); 595 assert(lpistate != NULL); 596 assert(*lpistate != NULL); 598 BMSfreeBlockMemoryArrayNull(blkmem, &(*lpistate)->packcstat, colpacketNum((*lpistate)->ncols)); 599 BMSfreeBlockMemoryArrayNull(blkmem, &(*lpistate)->packrstat, rowpacketNum((*lpistate)->nrows)); 600 BMSfreeBlockMemory(blkmem, lpistate); 618 assert( lpi != NULL ); 619 assert( lpi->grbenv != NULL ); 620 assert( grbparam != NULL ); 626 CHECK_ZERO( lpi->messagehdlr, GRBgetintparam(lpi->grbenv, intparam[i], &(grbparam->intparval[i])) ); 630 CHECK_ZERO( lpi->messagehdlr, GRBgetdblparam(lpi->grbenv, dblparam[i], &(grbparam->dblparval[i])) ); 646 SCIP_CALL( getParameterValues(lpi, &par) ); 648 assert( lpi->curparam.intparval[i] == par.intparval[i] ); 650 assert( MAX(lpi->curparam.dblparval[i], dblparammin[i]) == par.dblparval[i]); 665 assert( lpi != NULL ); 666 assert( lpi->grbenv != NULL ); 667 assert( grbparam != NULL ); 673 if( lpi->curparam.intparval[i] != grbparam->intparval[i] ) 676 intparam[i], lpi->curparam.intparval[i], grbparam->intparval[i]); 677 lpi->curparam.intparval[i] = grbparam->intparval[i]; 678 CHECK_ZERO( lpi->messagehdlr, GRBsetintparam(lpi->grbenv, intparam[i], lpi->curparam.intparval[i]) ); 683 if( lpi->curparam.dblparval[i] != grbparam->dblparval[i] ) 686 dblparam[i], lpi->curparam.dblparval[i], MAX(grbparam->dblparval[i], dblparammin[i])); 687 lpi->curparam.dblparval[i] = MAX(grbparam->dblparval[i], dblparammin[i]); 688 CHECK_ZERO( lpi->messagehdlr, GRBsetdblparam(lpi->grbenv, dblparam[i], lpi->curparam.dblparval[i]) ); 699 void copyParameterValues( 707 dest->intparval[i] = source->intparval[i]; 708 for( i = 0; i < NUMDBLPARAM; ++i ) 709 dest->dblparval[i] = source->dblparval[i]; 722 assert( lpi != NULL ); 726 if( strcmp(intparam[i], param) == 0 ) 728 *p = lpi->grbparam.intparval[i]; 747 assert( lpi != NULL ); 751 if( strcmp(intparam[i], param) == 0 ) 753 lpi->grbparam.intparval[i] = parval; 772 if( strcmp(dblparam[i], param) == 0 ) 774 *p = lpi->grbparam.dblparval[i]; 793 assert( lpi != NULL ); 797 if( strcmp(dblparam[i], param) == 0 ) 799 lpi->grbparam.dblparval[i] = parval; 810 void invalidateSolution( 837 for( i = 0; i < nrows; ++i ) 839 assert(lhs[i] <= rhs[i]); 841 if( lhs[i] == rhs[i] ) 843 assert(-GRB_INFINITY < rhs[i] && rhs[i] < GRB_INFINITY); 844 lpi->senarray[i] = GRB_EQUAL; 845 lpi->rhsarray[i] = rhs[i]; 847 else if( lhs[i] <= -GRB_INFINITY ) 849 assert(-GRB_INFINITY < rhs[i] && rhs[i] < GRB_INFINITY); 850 lpi->senarray[i] = GRB_LESS_EQUAL; 851 lpi->rhsarray[i] = rhs[i]; 853 else if( rhs[i] >= GRB_INFINITY ) 855 assert(-GRB_INFINITY < lhs[i] && lhs[i] < GRB_INFINITY); 856 lpi->senarray[i] = GRB_GREATER_EQUAL; 857 lpi->rhsarray[i] = lhs[i]; 887 for (i = 0; i < nrows; ++i) 889 switch( lpi->senarray[i] ) 892 lhs[i] = lpi->rhsarray[i]; 893 rhs[i] = lpi->rhsarray[i]; 897 lhs[i] = -GRB_INFINITY; 898 rhs[i] = lpi->rhsarray[i]; 901 case GRB_GREATER_EQUAL: 902 lhs[i] = lpi->rhsarray[i]; 903 rhs[i] = GRB_INFINITY; 911 assert(lhs[i] <= rhs[i]); 930 for (i = 0; i < nrows; ++i) 932 switch( lpi->senarray[i] ) 935 lhs[i] = lpi->rhsarray[i]; 939 lhs[i] = -GRB_INFINITY; 942 case GRB_GREATER_EQUAL: 943 lhs[i] = lpi->rhsarray[i]; 969 for (i = 0; i < nrows; ++i) 971 switch( lpi->senarray[i] ) 974 rhs[i] = lpi->rhsarray[i]; 978 rhs[i] = lpi->rhsarray[i]; 981 case GRB_GREATER_EQUAL: 982 rhs[i] = GRB_INFINITY; 1005 SCIP_CALL( reconvertBothSides(lpi, nrows, lhs, rhs) ); 1007 else if( lhs != NULL ) 1009 SCIP_CALL( reconvertLhs(lpi, nrows, lhs) ); 1011 else if( rhs != NULL ) 1013 SCIP_CALL( reconvertRhs(lpi, nrows, rhs) ); 1024 assert( lpi != NULL ); 1028 CHECK_ZERO( lpi->messagehdlr, GRBoptimize(lpi->grbmodel) ); 1040 CHECK_ZERO( lpi->messagehdlr, GRBgetdblattr(lpi->grbmodel, GRB_DBL_ATTR_ITERCOUNT, &cnt) ); 1042 SCIPmessagePrintWarning(lpi->messagehdlr, "Gurobi needed %d iterations to restore optimal basis.\n", ( int) cnt); 1060 static char grbname[100]; 1074 GRBversion(&major, &minor, &technical); 1075 sprintf(grbname, "Gurobi %d.%d.%d", major, minor, technical); 1084 return "Linear Programming Solver developed by Gurobi Optimization (www.gurobi.com)"; 1095 return ( void*) lpi->grbmodel; 1117 assert( sizeof( SCIP_Real) == sizeof( double)); 1118 assert( sizeof( SCIP_Bool) == sizeof( int)); 1119 assert(lpi != NULL); 1128 if ( grbenv == NULL ) 1134 CHECK_ZERO( messagehdlr, GRBsetintparam(grbenv, GRB_INT_PAR_OUTPUTFLAG, 0) ); 1137 CHECK_ZERO( messagehdlr, GRBsetintparam(grbenv, GRB_INT_PAR_INFUNBDINFO, 1) ); 1139 assert( grbenv != NULL ); 1146 (*lpi)->grbenv = GRBgetenv((*lpi)->grbmodel); 1147 (*lpi)->senarray = NULL; 1148 (*lpi)->rhsarray = NULL; 1149 (*lpi)->valarray = NULL; 1150 (*lpi)->cstat = NULL; 1151 (*lpi)->rstat = NULL; 1152 (*lpi)->indarray = NULL; 1153 (*lpi)->sidechgsize = 0; 1154 (*lpi)->valsize = 0; 1155 (*lpi)->cstatsize = 0; 1156 (*lpi)->rstatsize = 0; 1157 (*lpi)->iterations = 0; 1158 (*lpi)->solisbasic = FALSE; 1159 (*lpi)->fromscratch = FALSE; 1161 (*lpi)->messagehdlr = messagehdlr; 1162 invalidateSolution(*lpi); 1165 SCIP_CALL( getParameterValues((*lpi), &((*lpi)->defparam)) ); 1166 copyParameterValues(&((*lpi)->curparam), &((*lpi)->defparam)); 1167 copyParameterValues(&((*lpi)->grbparam), &((*lpi)->defparam)); 1189 assert(grbenv != NULL); 1190 assert(lpi != NULL); 1191 assert(*lpi != NULL); 1196 CHECK_ZERO( (*lpi)->messagehdlr, GRBfreemodel((*lpi)->grbmodel) ); 1199 BMSfreeMemoryArrayNull(&(*lpi)->senarray); 1200 BMSfreeMemoryArrayNull(&(*lpi)->rhsarray); 1201 BMSfreeMemoryArrayNull(&(*lpi)->cstat); 1202 BMSfreeMemoryArrayNull(&(*lpi)->rstat); 1251 assert(lpi != NULL); 1252 assert(lpi->grbmodel != NULL); 1253 assert(lpi->grbenv != NULL); 1256 SCIPdebugMessage( "loading LP in column format into Gurobi: %d cols, %d rows\n", ncols, nrows); 1258 invalidateSolution(lpi); 1260 SCIP_CALL( ensureSidechgMem(lpi, nrows) ); 1263 SCIP_CALL( convertSides(lpi, nrows, lhs, rhs, &rngcount) ); 1264 assert( rngcount == 0 ); 1267 SCIP_ALLOC( BMSallocMemoryArray(&cnt, ncols) ); 1268 for( c = 0; c < ncols-1; ++c ) 1270 cnt[c] = beg[c+1] - beg[c]; 1271 assert(cnt[c] >= 0); 1273 cnt[ncols-1] = nnonz - beg[ncols-1]; 1274 assert(cnt[ncols-1] >= 0); 1277 assert( lpi->grbmodel != NULL ); 1278 CHECK_ZERO( lpi->messagehdlr, GRBfreemodel(lpi->grbmodel) ); 1281 CHECK_ZERO( lpi->messagehdlr, GRBloadmodel(lpi->grbenv, &(lpi->grbmodel), NULL, ncols, nrows, objsen, 0.0, ( SCIP_Real*)obj, 1282 lpi->senarray, lpi->rhsarray, ( int*)beg, cnt, ( int*)ind, ( SCIP_Real*)val, ( SCIP_Real*)lb, ( SCIP_Real*)ub, NULL, colnames, rownames) ); 1283 CHECK_ZERO( lpi->messagehdlr, GRBupdatemodel(lpi->grbmodel) ); 1286 BMSfreeMemoryArray(&cnt); 1292 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMVARS, &temp) ); 1293 assert( temp == ncols); 1295 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMCONSTRS, &temp) ); 1296 assert( temp == nrows); 1298 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMNZS, &temp) ); 1299 assert( temp == nnonz); 1320 assert(lpi != NULL); 1321 assert(lpi->grbmodel != NULL); 1323 SCIPdebugMessage( "adding %d columns with %d nonzeros to Gurobi\n", ncols, nnonz); 1325 invalidateSolution(lpi); 1328 CHECK_ZERO( lpi->messagehdlr, GRBaddvars(lpi->grbmodel, ncols, nnonz, ( int*)beg, ( int*)ind, ( SCIP_Real*)val, ( SCIP_Real*)obj, ( SCIP_Real*)lb, ( SCIP_Real*)ub, NULL, colnames) ) 1329 CHECK_ZERO( lpi->messagehdlr, GRBupdatemodel(lpi->grbmodel) ); 1344 assert(lpi != NULL); 1345 assert(lpi->grbmodel != NULL); 1350 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMVARS, &temp) ); 1351 assert(0 <= firstcol && firstcol <= lastcol && lastcol < temp); 1355 SCIPdebugMessage( "deleting %d columns from Gurobi\n", lastcol - firstcol + 1); 1357 invalidateSolution(lpi); 1360 SCIP_ALLOC( BMSallocMemoryArray(&which, lastcol-firstcol+1) );; 1361 for( j = firstcol; j <= lastcol; ++j ) 1362 which[j - firstcol] = j; 1364 CHECK_ZERO( lpi->messagehdlr, GRBdelvars(lpi->grbmodel, lastcol-firstcol+1, which) ); 1365 CHECK_ZERO( lpi->messagehdlr, GRBupdatemodel(lpi->grbmodel) ); 1367 BMSfreeMemoryArray( &which ); 1383 assert(lpi != NULL); 1384 assert(lpi->grbmodel != NULL); 1388 invalidateSolution(lpi); 1391 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMVARS, &nvars) ); 1393 SCIP_ALLOC( BMSallocMemoryArray(&which, nvars) );; 1395 for( j = 0; j < nvars; ++j ) 1400 CHECK_ZERO( lpi->messagehdlr, GRBdelvars(lpi->grbmodel, num, which) ); 1401 CHECK_ZERO( lpi->messagehdlr, GRBupdatemodel(lpi->grbmodel) ); 1403 BMSfreeMemoryArray( &which ); 1423 assert(lpi != NULL); 1424 assert(lpi->grbmodel != NULL); 1426 SCIPdebugMessage( "adding %d rows with %d nonzeros to Gurobi\n", nrows, nnonz); 1428 invalidateSolution(lpi); 1430 SCIP_CALL( ensureSidechgMem(lpi, nrows) ); 1433 SCIP_CALL( convertSides(lpi, nrows, lhs, rhs, &rngcount) ); 1434 assert( rngcount == 0 ); 1437 CHECK_ZERO( lpi->messagehdlr, GRBaddconstrs(lpi->grbmodel, nrows, nnonz, ( int*)beg, ( int*)ind, ( SCIP_Real*)val, lpi->senarray, lpi->rhsarray, rownames) ); 1438 CHECK_ZERO( lpi->messagehdlr, GRBupdatemodel(lpi->grbmodel) ); 1453 assert(lpi != NULL); 1454 assert(lpi->grbmodel != NULL); 1458 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMCONSTRS, &nrows) ); 1459 assert(0 <= firstrow && firstrow <= lastrow && lastrow < nrows); 1463 SCIPdebugMessage( "deleting %d rows from Gurobi\n", lastrow - firstrow + 1); 1465 invalidateSolution(lpi); 1468 SCIP_ALLOC( BMSallocMemoryArray(&which, lastrow-firstrow+1) );; 1469 for( i = firstrow; i <= lastrow; ++i ) 1470 which[i - firstrow] = i; 1472 CHECK_ZERO( lpi->messagehdlr, GRBdelconstrs(lpi->grbmodel, lastrow-firstrow+1, which) ); 1473 CHECK_ZERO( lpi->messagehdlr, GRBupdatemodel(lpi->grbmodel) ); 1475 BMSfreeMemoryArray( &which ); 1492 assert(lpi != NULL); 1493 assert(lpi->grbmodel != NULL); 1497 invalidateSolution(lpi); 1500 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMCONSTRS, &nrows) ); 1501 SCIP_ALLOC( BMSallocMemoryArray(&which, nrows) );; 1503 for( i = 0; i < nrows; ++i ) 1508 CHECK_ZERO( lpi->messagehdlr, GRBdelconstrs(lpi->grbmodel, num, which) ); 1509 CHECK_ZERO( lpi->messagehdlr, GRBupdatemodel(lpi->grbmodel) ); 1513 for( i = 0; i < nrows; ++i ) 1524 BMSfreeMemoryArray( &which ); 1534 assert( lpi != NULL ); 1535 assert( lpi->grbmodel != NULL ); 1536 assert( lpi->grbenv != NULL ); 1540 invalidateSolution(lpi); 1542 CHECK_ZERO( lpi->messagehdlr, GRBfreemodel(lpi->grbmodel) ); 1544 CHECK_ZERO( lpi->messagehdlr, GRBupdatemodel(lpi->grbmodel) ); 1558 assert(lpi != NULL); 1559 assert(lpi->grbmodel != NULL); 1565 for( i = 0; i < ncols; ++i ) 1570 invalidateSolution(lpi); 1572 CHECK_ZERO( lpi->messagehdlr, GRBsetdblattrlist(lpi->grbmodel, GRB_DBL_ATTR_LB, ncols, ( int*)ind, ( SCIP_Real*)lb) ); 1573 CHECK_ZERO( lpi->messagehdlr, GRBsetdblattrlist(lpi->grbmodel, GRB_DBL_ATTR_UB, ncols, ( int*)ind, ( SCIP_Real*)ub) ); 1575 CHECK_ZERO( lpi->messagehdlr, GRBupdatemodel(lpi->grbmodel) ); 1591 assert(lpi != NULL); 1592 assert(lpi->grbmodel != NULL); 1596 invalidateSolution(lpi); 1599 SCIP_CALL( ensureSidechgMem(lpi, nrows) ); 1600 SCIP_CALL( convertSides(lpi, nrows, lhs, rhs, &rngcount) ); 1601 assert( rngcount == 0 ); 1604 CHECK_ZERO( lpi->messagehdlr, GRBsetdblattrlist(lpi->grbmodel, GRB_DBL_ATTR_RHS, nrows, ( int*)ind, lpi->rhsarray) ); 1605 CHECK_ZERO( lpi->messagehdlr, GRBsetcharattrlist(lpi->grbmodel, GRB_CHAR_ATTR_SENSE, nrows, ( int*)ind, lpi->senarray) ); 1607 CHECK_ZERO( lpi->messagehdlr, GRBupdatemodel(lpi->grbmodel) ); 1620 assert(lpi != NULL); 1621 assert(lpi->grbmodel != NULL); 1623 SCIPdebugMessage( "changing coefficient row %d, column %d in Gurobi to %g\n", row, col, newval); 1625 invalidateSolution(lpi); 1627 CHECK_ZERO( lpi->messagehdlr, GRBchgcoeffs(lpi->grbmodel, 1, &row, &col, &newval) ); 1628 CHECK_ZERO( lpi->messagehdlr, GRBupdatemodel(lpi->grbmodel) ); 1639 assert(lpi != NULL); 1640 assert(lpi->grbmodel != NULL); 1645 invalidateSolution(lpi); 1648 CHECK_ZERO( lpi->messagehdlr, GRBsetintattr(lpi->grbmodel, GRB_INT_ATTR_MODELSENSE, objsen) ); 1650 CHECK_ZERO( lpi->messagehdlr, GRBupdatemodel(lpi->grbmodel) ); 1663 assert(lpi != NULL); 1664 assert(lpi->grbmodel != NULL); 1668 CHECK_ZERO( lpi->messagehdlr, GRBsetdblattrlist(lpi->grbmodel, GRB_DBL_ATTR_OBJ, ncols, ind, obj) ); 1670 CHECK_ZERO( lpi->messagehdlr, GRBupdatemodel(lpi->grbmodel) ); 1689 assert(lpi != NULL); 1690 assert(lpi->grbmodel != NULL); 1691 assert(scaleval != 0.0); 1693 SCIPdebugMessage( "scaling row %d with factor %g in Gurobi\n", row, scaleval); 1695 invalidateSolution(lpi); 1697 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMVARS, &ncols) ); 1704 for ( i = 0; i < nnonz; ++i ) 1710 if( lhs > -GRB_INFINITY ) 1712 else if( scaleval < 0.0 ) 1714 if( rhs < GRB_INFINITY ) 1716 else if( scaleval < 0.0 ) 1717 rhs = -GRB_INFINITY; 1718 if( scaleval > 0.0 ) 1747 assert(lpi != NULL); 1748 assert(lpi->grbmodel != NULL); 1749 assert(scaleval != 0.0); 1751 SCIPdebugMessage( "scaling column %d with factor %g in Gurobi\n", col, scaleval); 1753 invalidateSolution(lpi); 1755 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMVARS, &ncols) ); 1765 for( i = 0; i < nnonz; ++i ) 1775 if( lb > -GRB_INFINITY ) 1777 else if( scaleval < 0.0 ) 1779 if( ub < GRB_INFINITY ) 1781 else if( scaleval < 0.0 ) 1783 if( scaleval > 0.0 ) 1813 assert(lpi != NULL); 1814 assert(nrows != NULL); 1818 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMCONSTRS, nrows) ); 1829 assert(lpi != NULL); 1830 assert(ncols != NULL); 1834 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMVARS, ncols) ); 1845 assert(lpi != NULL); 1846 assert(nnonz != NULL); 1850 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMNZS, nnonz) ); 1871 assert(lpi != NULL); 1872 assert(lpi->grbmodel != NULL); 1876 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMVARS, &ncols) ); 1877 assert(0 <= firstcol && firstcol <= lastcol && lastcol < ncols); 1887 CHECK_ZERO( lpi->messagehdlr, GRBgetdblattrarray(lpi->grbmodel, GRB_DBL_ATTR_LB, firstcol, lastcol-firstcol+1, lb) ); 1888 CHECK_ZERO( lpi->messagehdlr, GRBgetdblattrarray(lpi->grbmodel, GRB_DBL_ATTR_UB, firstcol, lastcol-firstcol+1, ub) ); 1895 assert(beg != NULL); 1896 assert(ind != NULL); 1897 assert(val != NULL); 1900 CHECK_ZERO( lpi->messagehdlr, GRBgetvars(lpi->grbmodel, nnonz, beg, ind, val, firstcol, lastcol-firstcol+1) ); 1904 assert(beg == NULL); 1905 assert(ind == NULL); 1906 assert(val == NULL); 1928 assert(lpi != NULL); 1929 assert(lpi->grbmodel != NULL); 1933 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMCONSTRS, &nrows) ); 1934 assert(0 <= firstrow && firstrow <= lastrow && lastrow < nrows); 1943 SCIP_CALL( ensureSidechgMem(lpi, lastrow - firstrow + 1) ); 1944 CHECK_ZERO( lpi->messagehdlr, GRBgetdblattrarray(lpi->grbmodel, GRB_DBL_ATTR_RHS, firstrow, lastrow-firstrow+1, lpi->rhsarray) ); 1945 CHECK_ZERO( lpi->messagehdlr, GRBgetcharattrarray(lpi->grbmodel, GRB_CHAR_ATTR_SENSE, firstrow, lastrow-firstrow+1, lpi->senarray) ); 1948 SCIP_CALL( reconvertSides(lpi, lastrow - firstrow + 1, lhs, rhs) ); 1953 assert(beg != NULL); 1954 assert(ind != NULL); 1955 assert(val != NULL); 1958 CHECK_ZERO( lpi->messagehdlr, GRBgetconstrs(lpi->grbmodel, nnonz, beg, ind, val, firstrow, lastrow-firstrow+1) ); 1962 assert(beg == NULL); 1963 assert(ind == NULL); 1964 assert(val == NULL); 1977 int namestoragesize, 1992 int namestoragesize, 2008 assert( lpi != NULL ); 2009 assert( lpi->grbmodel != NULL ); 2010 assert( objsen != NULL ); 2014 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_MODELSENSE, &grbobjsen) ); 2015 assert(grbobjsen == GRB_MINIMIZE || grbobjsen == GRB_MAXIMIZE); 2030 assert(lpi != NULL); 2031 assert(lpi->grbmodel != NULL); 2032 assert(firstcol <= lastcol); 2033 assert(vals != NULL); 2035 SCIPdebugMessage( "getting objective values %d to %d\n", firstcol, lastcol); 2037 CHECK_ZERO( lpi->messagehdlr, GRBgetdblattrarray(lpi->grbmodel, GRB_DBL_ATTR_OBJ, firstcol, lastcol-firstcol+1, vals) ); 2051 assert(lpi != NULL); 2052 assert(lpi->grbmodel != NULL); 2056 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMVARS, &ncols) ); 2057 assert(0 <= firstcol && firstcol <= lastcol && lastcol < ncols); 2065 CHECK_ZERO( lpi->messagehdlr, GRBgetdblattrarray(lpi->grbmodel, GRB_DBL_ATTR_LB, firstcol, lastcol-firstcol+1, lbs) ); 2070 CHECK_ZERO( lpi->messagehdlr, GRBgetdblattrarray(lpi->grbmodel, GRB_DBL_ATTR_UB, firstcol, lastcol-firstcol+1, ubs) ); 2085 assert(lpi != NULL); 2086 assert(lpi->grbmodel != NULL); 2087 assert(firstrow <= lastrow); 2092 SCIP_CALL( ensureSidechgMem(lpi, lastrow - firstrow + 1) ); 2094 CHECK_ZERO( lpi->messagehdlr, GRBgetdblattrarray(lpi->grbmodel, GRB_DBL_ATTR_RHS, firstrow, lastrow-firstrow+1, lpi->rhsarray) ); 2095 CHECK_ZERO( lpi->messagehdlr, GRBgetcharattrarray(lpi->grbmodel, GRB_CHAR_ATTR_SENSE, firstrow, lastrow-firstrow+1, lpi->senarray) ); 2098 SCIP_CALL( reconvertSides(lpi, lastrow - firstrow + 1, lhss, rhss) ); 2111 assert(lpi != NULL); 2112 assert(lpi->grbmodel != NULL); 2116 CHECK_ZERO( lpi->messagehdlr, GRBgetcoeff(lpi->grbmodel, row, col, val) ); 2146 assert( lpi != NULL ); 2147 assert( lpi->grbmodel != NULL ); 2148 assert( lpi->grbenv != NULL ); 2153 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMVARS, &ncols) ); 2154 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMCONSTRS, &nrows) ); 2155 SCIPdebugMessage( "calling Gurobi primal simplex: %d cols, %d rows\n", ncols, nrows); 2159 invalidateSolution(lpi); 2161 if ( lpi->fromscratch ) 2163 CHECK_ZERO( lpi->messagehdlr, GRBresetmodel(lpi->grbmodel) ); 2169 SCIP_CALL( setParameterValues(lpi, &(lpi->grbparam)) ); 2172 retval = GRBoptimize(lpi->grbmodel); 2177 case GRB_ERROR_OUT_OF_MEMORY: 2183 CHECK_ZERO( lpi->messagehdlr, GRBgetdblattr(lpi->grbmodel, GRB_DBL_ATTR_ITERCOUNT, &cnt) ); 2184 lpi->iterations = (int) cnt; 2186 lpi->solisbasic = TRUE; 2187 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_STATUS, &lpi->solstat) ); 2189 SCIPdebugMessage( "Gurobi primal simplex needed %d iterations to gain LP status %d\n", ( int) cnt, lpi->solstat); 2196 primalfeasible = FALSE; 2197 dualfeasible = FALSE; 2199 if( lpi->solstat == GRB_INF_OR_UNBD 2200 || (lpi->solstat == GRB_INFEASIBLE && !dualfeasible) 2201 || (lpi->solstat == GRB_UNBOUNDED && !primalfeasible) ) 2205 CHECK_ZERO( lpi->messagehdlr, GRBgetintparam(lpi->grbenv, GRB_INT_PAR_PRESOLVE, &presolve) ); 2207 if( presolve != GRB_PRESOLVE_OFF ) 2210 SCIPdebugMessage( "presolver may have solved the problem -> calling Gurobi primal simplex again without presolve\n"); 2213 CHECK_ZERO( lpi->messagehdlr, GRBsetintparam(lpi->grbenv, GRB_INT_PAR_PRESOLVE, GRB_PRESOLVE_OFF) ); 2215 retval = GRBoptimize(lpi->grbmodel); 2220 case GRB_ERROR_OUT_OF_MEMORY: 2226 CHECK_ZERO( lpi->messagehdlr, GRBgetdblattr(lpi->grbmodel, GRB_DBL_ATTR_ITERCOUNT, &cnt) ); 2227 lpi->iterations += (int) cnt; 2228 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_STATUS, &lpi->solstat) ); 2229 SCIPdebugMessage( " -> Gurobi returned solstat=%d (%d iterations)\n", lpi->solstat, lpi->iterations); 2232 CHECK_ZERO( lpi->messagehdlr, GRBsetintparam(lpi->grbenv, GRB_INT_PAR_PRESOLVE, presolve) ); 2235 if( lpi->solstat == GRB_INF_OR_UNBD ) 2238 SCIPerrorMessage( "Gurobi primal simplex returned GRB_INF_OR_UNBD after presolving was turned off\n"); 2256 assert( lpi != NULL ); 2257 assert( lpi->grbmodel != NULL ); 2258 assert( lpi->grbenv != NULL ); 2263 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMVARS, &ncols) ); 2264 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMCONSTRS, &nrows) ); 2265 SCIPdebugMessage( "calling Gurobi dual simplex: %d cols, %d rows\n", ncols, nrows); 2269 invalidateSolution(lpi); 2271 if ( lpi->fromscratch ) 2273 CHECK_ZERO( lpi->messagehdlr, GRBresetmodel(lpi->grbmodel) ); 2278 SCIP_CALL( setParameterValues(lpi, &(lpi->grbparam)) ); 2283 retval = GRBoptimize(lpi->grbmodel); 2288 case GRB_ERROR_OUT_OF_MEMORY: 2294 CHECK_ZERO( lpi->messagehdlr, GRBgetdblattr(lpi->grbmodel, GRB_DBL_ATTR_ITERCOUNT, &cnt) ); 2295 lpi->iterations = (int) cnt; 2297 lpi->solisbasic = TRUE; 2298 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_STATUS, &lpi->solstat) ); 2300 SCIPdebugMessage( "Gurobi dual simplex needed %d iterations to gain LP status %d\n", ( int) cnt, lpi->solstat); 2307 if( lpi->solstat == GRB_INF_OR_UNBD ) 2310 CHECK_ZERO( lpi->messagehdlr, getIntParam(lpi, GRB_INT_PAR_PRESOLVE, &presolve) ); 2312 if( presolve != GRB_PRESOLVE_OFF ) 2315 SCIPdebugMessage( "presolver may have solved the problem -> calling Gurobi dual simplex again without presolve\n"); 2318 CHECK_ZERO( lpi->messagehdlr, setIntParam(lpi, GRB_INT_PAR_PRESOLVE, GRB_PRESOLVE_OFF) ); 2319 SCIP_CALL( setParameterValues(lpi, &(lpi->grbparam)) ); 2321 retval = GRBoptimize(lpi->grbmodel); 2326 case GRB_ERROR_OUT_OF_MEMORY: 2332 CHECK_ZERO( lpi->messagehdlr, GRBgetdblattr(lpi->grbmodel, GRB_DBL_ATTR_ITERCOUNT, &cnt) ); 2333 lpi->iterations += (int) cnt; 2334 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_STATUS, &lpi->solstat) ); 2335 SCIPdebugMessage( " -> Gurobi returned solstat=%d (%d iterations)\n", lpi->solstat, lpi->iterations); 2338 CHECK_ZERO( lpi->messagehdlr, setIntParam(lpi, GRB_INT_PAR_PRESOLVE, GRB_PRESOLVE_AUTO) ); 2341 if( lpi->solstat == GRB_INF_OR_UNBD ) 2344 SCIPerrorMessage( "Gurobi dual simplex returned GRB_INF_OR_UNBD after presolving was turned off\n"); 2360 assert( lpi != NULL ); 2361 assert( lpi->grbmodel != NULL ); 2362 assert( lpi->grbenv != NULL ); 2367 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMVARS, &ncols) ); 2368 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMCONSTRS, &nrows) ); 2369 SCIPdebugMessage( "calling Gurobi barrier: %d cols, %d rows\n", ncols, nrows); 2373 invalidateSolution(lpi); 2375 if ( lpi->fromscratch ) 2377 CHECK_ZERO( lpi->messagehdlr, GRBresetmodel(lpi->grbmodel) ); 2383 SCIP_CALL( setParameterValues(lpi, &(lpi->grbparam)) ); 2388 CHECK_ZERO( lpi->messagehdlr, GRBsetintparam(lpi->grbenv, GRB_INT_PAR_CROSSOVER, -1) ); 2393 CHECK_ZERO( lpi->messagehdlr, GRBsetintparam(lpi->grbenv, GRB_INT_PAR_CROSSOVER, 0) ); 2398 retval = GRBoptimize(lpi->grbmodel); 2403 case GRB_ERROR_OUT_OF_MEMORY: 2409 CHECK_ZERO( lpi->messagehdlr, GRBgetdblattr(lpi->grbmodel, GRB_DBL_ATTR_ITERCOUNT, &cnt) ); 2410 lpi->iterations = (int) cnt; 2412 lpi->solisbasic = crossover; 2413 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_STATUS, &lpi->solstat) ); 2415 SCIPdebugMessage( "Gurobi barrier needed %d iterations to gain LP status %d\n", ( int) cnt, lpi->solstat); 2422 if( lpi->solstat == GRB_INF_OR_UNBD ) 2425 CHECK_ZERO( lpi->messagehdlr, getIntParam(lpi, GRB_INT_PAR_PRESOLVE, &presolve) ); 2427 if( presolve != GRB_PRESOLVE_OFF ) 2430 SCIPdebugMessage( "presolver may have solved the problem -> calling Gurobi barrier again without presolve\n"); 2433 CHECK_ZERO( lpi->messagehdlr, setIntParam(lpi, GRB_INT_PAR_PRESOLVE, GRB_PRESOLVE_OFF) ); 2434 SCIP_CALL( setParameterValues(lpi, &(lpi->grbparam)) ); 2436 retval = GRBoptimize(lpi->grbmodel); 2441 case GRB_ERROR_OUT_OF_MEMORY: 2447 CHECK_ZERO( lpi->messagehdlr, GRBgetdblattr(lpi->grbmodel, GRB_DBL_ATTR_ITERCOUNT, &cnt) ); 2448 lpi->iterations += (int) cnt; 2449 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_STATUS, &lpi->solstat) ); 2450 SCIPdebugMessage( " -> Gurobi returned solstat=%d (%d iterations)\n", lpi->solstat, lpi->iterations); 2453 CHECK_ZERO( lpi->messagehdlr, setIntParam(lpi, GRB_INT_PAR_PRESOLVE, GRB_PRESOLVE_AUTO) ); 2456 if( lpi->solstat == GRB_INF_OR_UNBD ) 2459 SCIPerrorMessage( "Gurobi dual simplex returned GRB_INF_OR_UNBD after presolving was turned off\n"); 2509 assert( lpi != NULL ); 2510 assert( lpi->grbmodel != NULL ); 2511 assert( lpi->grbenv != NULL ); 2512 assert( down != NULL ); 2513 assert( up != NULL ); 2514 assert( downvalid != NULL ); 2515 assert( upvalid != NULL ); 2517 SCIPdebugMessage( "performing strong branching on variable %d (%d iterations)\n", col, itlim); 2519 SCIP_CALL( setParameterValues(lpi, &(lpi->grbparam)) ); 2527 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_MODELSENSE, &objsen) ); 2531 CHECK_ZERO( lpi->messagehdlr, GRBgetdblattrelement(lpi->grbmodel, GRB_DBL_ATTR_LB, col, &oldlb) ); 2532 CHECK_ZERO( lpi->messagehdlr, GRBgetdblattrelement(lpi->grbmodel, GRB_DBL_ATTR_UB, col, &oldub) ); 2534 if ( lpi->fromscratch ) 2536 CHECK_ZERO( lpi->messagehdlr, GRBresetmodel(lpi->grbmodel) ); 2540 if( itlim > INT_MAX ) 2543 SCIP_CALL( getDblParam(lpi, GRB_DBL_PAR_ITERATIONLIMIT, &olditlim) ); 2544 SCIP_CALL( setDblParam(lpi, GRB_DBL_PAR_ITERATIONLIMIT, ( double) itlim) ); 2547 newub = EPSCEIL(psol-1.0, 1e-06); 2548 if( newub >= oldlb - 0.5 ) 2550 SCIPdebugMessage( "strong branching down (%g) on x%d (%g) with %d iterations\n", newub, col, psol, itlim); 2552 CHECK_ZERO( lpi->messagehdlr, GRBsetdblattrelement(lpi->grbmodel, GRB_DBL_ATTR_UB, col, newub) ); 2563 CHECK_ZERO( lpi->messagehdlr, GRBgetdblparam(lpi->grbenv, GRB_DBL_PAR_CUTOFF, down) ); 2575 CHECK_ZERO( lpi->messagehdlr, GRBsetdblattrelement(lpi->grbmodel, GRB_DBL_ATTR_UB, col, oldub) ); 2576 CHECK_ZERO( lpi->messagehdlr, GRBupdatemodel(lpi->grbmodel) ); 2580 CHECK_ZERO( lpi->messagehdlr, GRBgetdblattrelement(lpi->grbmodel, GRB_DBL_ATTR_UB, col, &b) ); 2581 assert( b == oldub ); 2592 CHECK_ZERO( lpi->messagehdlr, GRBgetdblparam(lpi->grbenv, GRB_DBL_PAR_CUTOFF, down) ); 2600 if( newlb <= oldub + 0.5 ) 2602 SCIPdebugMessage( "strong branching up (%g) on x%d (%g) with %d iterations\n", newlb, col, psol, itlim); 2604 CHECK_ZERO( lpi->messagehdlr, GRBsetdblattrelement(lpi->grbmodel, GRB_DBL_ATTR_LB, col, newlb) ); 2615 CHECK_ZERO( lpi->messagehdlr, GRBgetdblparam(lpi->grbenv, GRB_DBL_PAR_CUTOFF, up) ); 2627 CHECK_ZERO( lpi->messagehdlr, GRBsetdblattrelement(lpi->grbmodel, GRB_DBL_ATTR_LB, col, oldlb) ); 2628 CHECK_ZERO( lpi->messagehdlr, GRBupdatemodel(lpi->grbmodel) ); 2632 CHECK_ZERO( lpi->messagehdlr, GRBgetdblattrelement(lpi->grbmodel, GRB_DBL_ATTR_LB, col, &b) ); 2633 assert( b == oldlb ); 2644 CHECK_ZERO( lpi->messagehdlr, GRBgetdblparam(lpi->grbenv, GRB_DBL_PAR_CUTOFF, up) ); 2650 SCIP_CALL( setDblParam(lpi, GRB_DBL_PAR_ITERATIONLIMIT, olditlim) ); 2678 SCIP_CALL( lpiStrongbranch(lpi, col, psol, itlim, down, up, downvalid, upvalid, iter) ); 2701 assert( iter != NULL ); 2702 assert( cols != NULL ); 2703 assert( psols != NULL ); 2704 assert( down != NULL ); 2705 assert( up != NULL ); 2706 assert( downvalid != NULL ); 2707 assert( upvalid != NULL ); 2708 assert( down != NULL ); 2713 for( j = 0; j < ncols; ++j ) 2716 SCIP_CALL( lpiStrongbranch(lpi, cols[j], psols[j], itlim, &(down[j]), &(up[j]), &(downvalid[j]), &(upvalid[j]), iter) ); 2737 SCIP_CALL( lpiStrongbranch(lpi, col, psol, itlim, down, up, downvalid, upvalid, iter) ); 2760 assert( iter != NULL ); 2761 assert( cols != NULL ); 2762 assert( psols != NULL ); 2763 assert( down != NULL ); 2764 assert( up != NULL ); 2765 assert( downvalid != NULL ); 2766 assert( upvalid != NULL ); 2767 assert( down != NULL ); 2772 for( j = 0; j < ncols; ++j ) 2775 SCIP_CALL( lpiStrongbranch(lpi, cols[j], psols[j], itlim, &(down[j]), &(up[j]), &(downvalid[j]), &(upvalid[j]), iter) ); 2796 assert(lpi != NULL); 2798 return (lpi->solstat != -1); 2810 assert( lpi != NULL ); 2811 assert( lpi->grbmodel != NULL ); 2812 assert( lpi->grbenv != NULL ); 2813 assert( lpi->solstat >= 1 ); 2819 if( primalfeasible != NULL ) 2821 *primalfeasible = (lpi->solstat == GRB_OPTIMAL || (lpi->solstat == GRB_UNBOUNDED && algo == GRB_METHOD_PRIMAL)); 2824 if( dualfeasible != NULL ) 2826 *dualfeasible = (lpi->solstat == GRB_OPTIMAL || (lpi->solstat == GRB_INFEASIBLE && algo == GRB_METHOD_DUAL)); 2830 #ifdef SCIP_DISABLED_CODE 2835 assert( lpi != NULL ); 2836 assert( lpi->grbmodel != NULL ); 2837 assert( lpi->solstat >= 1 ); 2841 if( primalfeasible != NULL ) 2843 if(lpi->solstat != GRB_INF_OR_UNBD && lpi->solstat != GRB_INFEASIBLE) 2846 CHECK_ZERO( lpi->messagehdlr, GRBgetdblattr(lpi->grbmodel, GRB_DBL_ATTR_CONSTR_SRESIDUAL, &viol) ); 2847 CHECK_ZERO( lpi->messagehdlr, GRBgetdblparam(lpi->grbenv, GRB_DBL_PAR_FEASIBILITYTOL, &tol) ); 2848 *primalfeasible = (viol <= tol) ? TRUE : FALSE; 2852 *primalfeasible = FALSE; 2855 if( dualfeasible != NULL ) 2857 if(lpi->solstat != GRB_UNBOUNDED && lpi->solstat != GRB_INFEASIBLE) 2860 CHECK_ZERO( lpi->messagehdlr, GRBgetdblattr(lpi->grbmodel, GRB_DBL_ATTR_DUAL_SRESIDUAL, &viol) ); 2861 CHECK_ZERO( lpi->messagehdlr, GRBgetdblparam(lpi->grbenv, GRB_DBL_PAR_OPTIMALITYTOL, &tol) ); 2862 *dualfeasible = (viol <= tol) ? TRUE : FALSE; 2866 *dualfeasible = FALSE; 2880 assert(lpi != NULL); 2881 assert(lpi->grbmodel != NULL); 2882 assert(lpi->solstat >= 0); 2884 return (lpi->solstat == GRB_UNBOUNDED); 2894 assert(lpi != NULL); 2895 assert(lpi->grbmodel != NULL); 2896 assert(lpi->solstat >= 0); 2898 return (lpi->solstat == GRB_UNBOUNDED); 2909 assert(lpi != NULL); 2910 assert(lpi->grbmodel != NULL); 2911 assert(lpi->solstat >= 0); 2915 primalfeasible = FALSE; 2921 return (primalfeasible && (lpi->solstat == GRB_UNBOUNDED || lpi->solstat == GRB_INF_OR_UNBD)); 2929 assert(lpi != NULL); 2930 assert(lpi->grbmodel != NULL); 2931 assert(lpi->solstat >= 0); 2935 assert( lpi->solstat != GRB_INF_OR_UNBD ); 2936 return (lpi->solstat == GRB_INFEASIBLE); 2946 assert( lpi != NULL ); 2947 assert( lpi->grbmodel != NULL ); 2948 assert( lpi->grbenv != NULL ); 2949 assert( lpi->solstat >= 0 ); 2955 return (lpi->solstat == GRB_OPTIMAL || (lpi->solstat == GRB_UNBOUNDED && algo == GRB_METHOD_PRIMAL)); 2965 assert(lpi != NULL); 2966 assert(lpi->grbmodel != NULL); 2967 assert(lpi->solstat >= 0); 2969 return (lpi->solstat == GRB_INFEASIBLE); 2981 assert( lpi != NULL ); 2982 assert( lpi->grbmodel != NULL ); 2983 assert( lpi->grbenv != NULL ); 2984 assert( lpi->solstat >= 0 ); 2998 assert( lpi != NULL ); 2999 assert( lpi->grbmodel != NULL ); 3000 assert( lpi->grbenv != NULL ); 3001 assert( lpi->solstat >= 0 ); 3015 assert( lpi != NULL ); 3016 assert( lpi->grbmodel != NULL ); 3017 assert( lpi->solstat >= 0 ); 3021 return (lpi->solstat == GRB_UNBOUNDED); 3031 assert( lpi != NULL ); 3032 assert( lpi->grbmodel != NULL ); 3033 assert( lpi->grbenv != NULL ); 3034 assert( lpi->solstat >= 0 ); 3040 return (lpi->solstat == GRB_OPTIMAL || (lpi->solstat == GRB_INFEASIBLE && algo == GRB_METHOD_DUAL)); 3048 assert(lpi != NULL); 3049 assert(lpi->grbmodel != NULL); 3050 assert(lpi->solstat >= 0); 3052 return (lpi->solstat == GRB_OPTIMAL); 3060 assert(lpi != NULL); 3061 assert(lpi->grbmodel != NULL); 3062 assert(lpi->solstat >= 0); 3064 SCIPdebugMessage( "checking for stability: Gurobi solstat = %d\n", lpi->solstat); 3066 return (lpi->solstat != GRB_NUMERIC); 3074 assert(lpi != NULL); 3075 assert(lpi->grbmodel != NULL); 3076 assert(lpi->solstat >= 0); 3078 return (lpi->solstat == GRB_CUTOFF); 3086 assert(lpi != NULL); 3087 assert(lpi->grbmodel != NULL); 3088 assert(lpi->solstat >= 0); 3090 return (lpi->solstat == GRB_ITERATION_LIMIT); 3098 assert(lpi != NULL); 3099 assert(lpi->grbmodel != NULL); 3100 assert(lpi->solstat >= 0); 3102 return (lpi->solstat == GRB_TIME_LIMIT); 3110 assert(lpi != NULL); 3111 assert(lpi->grbmodel != NULL); 3113 return lpi->solstat; 3122 assert(lpi != NULL); 3123 assert(lpi->grbmodel != NULL); 3124 assert(success != NULL); 3140 assert(lpi != NULL); 3141 assert(lpi->grbmodel != NULL); 3145 CHECK_ZERO( lpi->messagehdlr, GRBgetdblattr(lpi->grbmodel, GRB_DBL_ATTR_OBJVAL, objval) ); 3163 assert(lpi != NULL); 3164 assert(lpi->grbmodel != NULL); 3165 assert(lpi->solstat >= 0); 3169 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMVARS, &ncols) ); 3170 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMCONSTRS, &nrows) ); 3171 assert( ncols >= 0 && nrows >= 0 ); 3173 if( objval != NULL ) 3175 CHECK_ZERO( lpi->messagehdlr, GRBgetdblattr(lpi->grbmodel, GRB_DBL_ATTR_OBJVAL, objval) ); 3178 if( primsol != NULL ) 3180 CHECK_ZERO( lpi->messagehdlr, GRBgetdblattrarray(lpi->grbmodel, GRB_DBL_ATTR_X, 0, ncols, primsol) ); 3183 if( dualsol != NULL ) 3185 CHECK_ZERO( lpi->messagehdlr, GRBgetdblattrarray(lpi->grbmodel, GRB_DBL_ATTR_PI, 0, nrows, dualsol) ); 3188 if( activity != NULL ) 3193 CHECK_ZERO( lpi->messagehdlr, GRBgetdblattrarray(lpi->grbmodel, GRB_DBL_ATTR_SLACK, 0, nrows, activity) ); 3195 SCIP_CALL( ensureSidechgMem(lpi, nrows) ); 3197 CHECK_ZERO( lpi->messagehdlr, GRBgetdblattrarray(lpi->grbmodel, GRB_DBL_ATTR_RHS, 0, nrows, lpi->rhsarray) ); 3198 CHECK_ZERO( lpi->messagehdlr, GRBgetcharattrarray(lpi->grbmodel, GRB_CHAR_ATTR_SENSE, 0, nrows, lpi->senarray) ); 3200 for( i = 0; i < nrows; ++i ) 3202 switch(lpi->senarray[i]) 3204 case GRB_LESS_EQUAL: 3206 activity[i] = lpi->rhsarray[i] - activity[i]; 3208 case GRB_GREATER_EQUAL: 3209 activity[i] = lpi->rhsarray[i] - activity[i]; 3219 if( redcost != NULL ) 3221 CHECK_ZERO( lpi->messagehdlr, GRBgetdblattrarray(lpi->grbmodel, GRB_DBL_ATTR_RC, 0, ncols, redcost) ); 3235 assert(lpi != NULL); 3236 assert(lpi->grbmodel != NULL); 3237 assert(lpi->solstat >= 0); 3239 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMVARS, &ncols) ); 3240 assert( ncols >= 0 ); 3244 CHECK_ZERO( lpi->messagehdlr, GRBgetdblattrarray(lpi->grbmodel, GRB_DBL_ATTR_UNBDRAY, 0, ncols, ray) ); 3257 assert(lpi != NULL); 3258 assert(lpi->grbmodel != NULL); 3259 assert(lpi->solstat >= 0); 3260 assert(dualfarkas != NULL); 3262 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMCONSTRS, &nrows) ); 3263 assert( nrows >= 0 ); 3267 CHECK_ZERO( lpi->messagehdlr, GRBgetdblattrarray(lpi->grbmodel, GRB_DBL_ATTR_FARKASDUAL, 0, nrows, dualfarkas) ); 3278 assert(lpi != NULL); 3279 assert(lpi->grbmodel != NULL); 3280 assert(iterations != NULL); 3282 *iterations = lpi->iterations; 3298 assert(lpi != NULL); 3299 assert(quality != NULL); 3301 CHECK_ZERO( lpi->messagehdlr, GRBgetdblattr(lpi->grbmodel, GRB_DBL_ATTR_KAPPA, quality) ); 3325 assert(lpi != NULL); 3326 assert(lpi->grbmodel != NULL); 3328 SCIPdebugMessage( "saving Gurobi basis into %p/%p\n", ( void*) cstat, ( void*) rstat); 3335 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMCONSTRS, &nrows) ); 3337 for( i = 0; i < nrows; ++i ) 3340 CHECK_ZERO( lpi->messagehdlr, GRBgetintattrelement(lpi->grbmodel, GRB_INT_ATTR_CBASIS, i, &stat) ); 3348 case GRB_NONBASIC_LOWER: 3352 case GRB_NONBASIC_UPPER: 3356 case GRB_SUPERBASIC: 3373 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMVARS, &ncols) ); 3375 for( j = 0; j < ncols; ++j ) 3378 CHECK_ZERO( lpi->messagehdlr, GRBgetintattrelement(lpi->grbmodel, GRB_INT_ATTR_VBASIS, j, &stat) ); 3386 case GRB_NONBASIC_LOWER: 3390 case GRB_NONBASIC_UPPER: 3393 case GRB_SUPERBASIC: 3418 assert(lpi != NULL); 3419 assert(lpi->grbmodel != NULL); 3420 assert(cstat != NULL); 3421 assert(rstat != NULL); 3423 SCIPdebugMessage( "loading basis %p/%p into Gurobi\n", ( void*) cstat, ( void*) rstat); 3425 invalidateSolution(lpi); 3427 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMCONSTRS, &nrows) ); 3428 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMVARS, &ncols) ); 3430 for( i = 0; i < nrows; ++i ) 3435 CHECK_ZERO( lpi->messagehdlr, GRBsetintattrelement(lpi->grbmodel, GRB_INT_ATTR_CBASIS, i, GRB_BASIC) ); 3439 CHECK_ZERO( lpi->messagehdlr, GRBsetintattrelement(lpi->grbmodel, GRB_INT_ATTR_CBASIS, i, GRB_NONBASIC_LOWER) ); 3443 CHECK_ZERO( lpi->messagehdlr, GRBsetintattrelement(lpi->grbmodel, GRB_INT_ATTR_CBASIS, i, GRB_NONBASIC_UPPER) ); 3447 CHECK_ZERO( lpi->messagehdlr, GRBsetintattrelement(lpi->grbmodel, GRB_INT_ATTR_CBASIS, i, GRB_SUPERBASIC) ); 3457 for( j = 0; j < ncols; ++j ) 3462 CHECK_ZERO( lpi->messagehdlr, GRBsetintattrelement(lpi->grbmodel, GRB_INT_ATTR_VBASIS, j, GRB_BASIC) ); 3466 CHECK_ZERO( lpi->messagehdlr, GRBsetintattrelement(lpi->grbmodel, GRB_INT_ATTR_VBASIS, j, GRB_NONBASIC_LOWER) ); 3470 CHECK_ZERO( lpi->messagehdlr, GRBsetintattrelement(lpi->grbmodel, GRB_INT_ATTR_VBASIS, j, GRB_NONBASIC_UPPER) ); 3473 CHECK_ZERO( lpi->messagehdlr, GRBsetintattrelement(lpi->grbmodel, GRB_INT_ATTR_VBASIS, j, GRB_SUPERBASIC) ); 3499 assert(lpi != NULL); 3500 assert(lpi->grbmodel != NULL); 3505 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_STATUS, &status) ); 3506 if ( status == GRB_LOADED || status == GRB_INTERRUPTED || status == GRB_INPROGRESS ) 3511 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMCONSTRS, &nrows) ); 3512 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMVARS, &ncols) ); 3516 SCIP_ALLOC( BMSallocMemoryArray(&bhead, nrows+ncols) ); 3519 CHECK_ZERO( lpi->messagehdlr, GRBgetBasisHead(lpi->grbmodel, bhead) ); 3521 for (i = 0; i < nrows; ++i) 3524 if ( bhead[i] < ncols ) 3527 bind[i] = -1 - (bhead[i] - ncols); 3529 BMSfreeMemoryArray(&bhead); 3531 #ifdef SCIP_DISABLED_CODE 3534 for( i = 0; i < nrows; ++i ) 3537 CHECK_ZERO( lpi->messagehdlr, GRBgetintattrelement(lpi->grbmodel, GRB_INT_ATTR_CBASIS, i, &stat) ); 3539 if( stat == GRB_BASIC ) 3540 bind[cnt++] = -1 - i; 3543 for( j = 0; j < ncols; ++j ) 3546 CHECK_ZERO( lpi->messagehdlr, GRBgetintattrelement(lpi->grbmodel, GRB_INT_ATTR_VBASIS, j, &stat) ); 3548 if( stat == GRB_BASIC ) 3551 assert( cnt == nrows ); 3583 assert(lpi != NULL); 3584 assert(lpi->grbmodel != NULL); 3589 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_STATUS, &status) ); 3590 if ( status == GRB_LOADED || status == GRB_INTERRUPTED || status == GRB_INPROGRESS ) 3595 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMCONSTRS, &nrows) ); 3599 SCIP_ALLOC( BMSallocMemoryArray(&(x.ind), nrows) ); 3600 SCIP_ALLOC( BMSallocMemoryArray(&(x.val), nrows) ); 3610 CHECK_ZERO( lpi->messagehdlr, GRBBSolve(lpi->grbmodel, &b, &x) ); 3613 assert( x.len <= nrows ); 3616 if ( ninds != NULL && inds != NULL ) 3621 for (i = 0; i < x.len; ++i) 3625 coef[idx] = (x.val)[i]; 3633 for (i = 0; i < nrows; ++i) 3635 assert( k <= x.len ); 3636 if ( k < x.len && (x.ind)[k] == i ) 3637 coef[i] = (x.val)[k++]; 3644 BMSfreeMemoryArray(&(x.val)); 3645 BMSfreeMemoryArray(&(x.ind)); 3680 assert(lpi != NULL); 3681 assert(lpi->grbmodel != NULL); 3686 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_STATUS, &status) ); 3687 if ( status == GRB_LOADED || status == GRB_INTERRUPTED || status == GRB_INPROGRESS ) 3692 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMCONSTRS, &nrows) ); 3696 SCIP_ALLOC( BMSallocMemoryArray(&(x.ind), nrows) ); 3697 SCIP_ALLOC( BMSallocMemoryArray(&(x.val), nrows) ); 3707 CHECK_ZERO( lpi->messagehdlr, GRBFSolve(lpi->grbmodel, &b, &x) ); 3710 assert( x.len <= nrows ); 3713 if ( ninds != NULL && inds != NULL ) 3718 for (i = 0; i < x.len; ++i) 3722 coef[idx] = (x.val)[i]; 3730 for (i = 0; i < nrows; ++i) 3732 assert( k <= x.len ); 3733 if ( k < x.len && (x.ind)[k] == i ) 3734 coef[i] = (x.val)[k++]; 3741 BMSfreeMemoryArray(&(x.val)); 3742 BMSfreeMemoryArray(&(x.ind)); 3772 assert(lpi != NULL); 3773 assert(lpi->grbmodel != NULL); 3778 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_STATUS, &status) ); 3779 if ( status == GRB_LOADED || status == GRB_INTERRUPTED || status == GRB_INPROGRESS ) 3784 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMVARS, &ncols) ); 3785 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMCONSTRS, &nrows) ); 3788 SCIP_ALLOC( BMSallocMemoryArray(&(x.ind), ncols + nrows) ); 3789 SCIP_ALLOC( BMSallocMemoryArray(&(x.val), ncols + nrows) ); 3791 CHECK_ZERO( lpi->messagehdlr, GRBBinvRowi(lpi->grbmodel, r, &x) ); 3794 assert( x.len <= ncols + nrows ); 3797 if ( ninds != NULL && inds != NULL ) 3802 for (j = 0; j < x.len; ++j) 3806 coef[idx] = (x.val)[j]; 3813 for (j = 0; j < ncols; ++j) 3815 assert( k <= x.len ); 3816 if ( k < x.len && (x.ind)[k] == j ) 3817 coef[j] = (x.val)[k++]; 3824 BMSfreeMemoryArray(&(x.val)); 3825 BMSfreeMemoryArray(&(x.ind)); 3853 assert(lpi != NULL); 3854 assert(lpi->grbmodel != NULL); 3859 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_STATUS, &status) ); 3860 if ( status == GRB_LOADED || status == GRB_INTERRUPTED || status == GRB_INPROGRESS ) 3865 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMCONSTRS, &nrows) ); 3868 SCIP_ALLOC( BMSallocMemoryArray(&(x.ind), nrows) ); 3869 SCIP_ALLOC( BMSallocMemoryArray(&(x.val), nrows) ); 3871 CHECK_ZERO( lpi->messagehdlr, GRBBinvColj(lpi->grbmodel, c, &x) ); 3874 assert( x.len <= nrows ); 3877 if ( ninds != NULL && inds != NULL ) 3882 for (j = 0; j < x.len; ++j) 3886 coef[idx] = (x.val)[j]; 3893 for (j = 0; j < nrows; ++j) 3895 assert( k <= x.len ); 3896 if ( k < x.len && (x.ind)[k] == j ) 3897 coef[j] = (x.val)[k++]; 3904 BMSfreeMemoryArray(&(x.val)); 3905 BMSfreeMemoryArray(&(x.ind)); 3933 assert(blkmem != NULL); 3934 assert(lpi != NULL); 3935 assert(lpi->grbmodel != NULL); 3936 assert(lpistate != NULL); 3939 if( !lpi->solisbasic ) 3945 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMCONSTRS, &nrows) ); 3946 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMVARS, &ncols) ); 3956 SCIP_CALL( lpistateCreate(lpistate, blkmem, ncols, nrows) ); 3957 (*lpistate)->ncols = ncols; 3958 (*lpistate)->nrows = nrows; 3960 SCIPdebugMessage( "stored Gurobi LPI state in %p (%d cols, %d rows)\n", ( void*) *lpistate, ncols, nrows); 3963 lpistatePack(*lpistate, lpi->cstat, lpi->rstat); 3971 SCIP_ALLOC( BMSallocBlockMemory(blkmem, lpistate) ); 3972 (*lpistate)->ncols = ncols; 3973 (*lpistate)->nrows = nrows; 3974 (*lpistate)->packrstat = NULL; 3975 (*lpistate)->packcstat = NULL; 3994 assert(blkmem != NULL); 3995 assert(lpi != NULL); 3996 assert(lpi->grbmodel != NULL); 3999 if( lpistate == NULL || lpistate->packrstat == NULL || lpistate->packcstat ) 4002 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMCONSTRS, &nrows) ); 4003 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_NUMVARS, &ncols) ); 4004 assert(lpistate->ncols <= ncols); 4005 assert(lpistate->nrows <= nrows); 4007 SCIPdebugMessage( "loading LPI state %p (%d cols, %d rows) into Gurobi LP with %d cols and %d rows\n", 4008 ( void*) lpistate, lpistate->ncols, lpistate->nrows, ncols, nrows); 4010 if( lpistate->ncols == 0 || lpistate->nrows == 0 ) 4014 SCIP_CALL( ensureCstatMem(lpi, ncols) ); 4015 SCIP_CALL( ensureRstatMem(lpi, nrows) ); 4018 lpistateUnpack(lpistate, lpi->cstat, lpi->rstat); 4021 for( i = lpistate->ncols; i < ncols; ++i ) 4024 CHECK_ZERO( lpi->messagehdlr, GRBgetdblattrarray(lpi->grbmodel, GRB_DBL_ATTR_LB, i, i, &bnd) ); 4028 CHECK_ZERO( lpi->messagehdlr, GRBgetdblattrarray(lpi->grbmodel, GRB_DBL_ATTR_UB, i, i, &bnd) ); 4037 for( i = lpistate->nrows; i < nrows; ++i ) 4051 assert(lpi != NULL); 4053 CHECK_ZERO( lpi->messagehdlr, GRBresetmodel(lpi->grbmodel) ); 4065 assert(lpi != NULL); 4066 assert(lpistate != NULL); 4068 if( *lpistate != NULL ) 4069 lpistateFree(lpistate, blkmem); 4080 return (lpistate != NULL); 4090 assert(lpi != NULL); 4091 assert(lpi->grbmodel != NULL); 4097 if ( l > 4 && fname[l-4] == '.' && fname[l-3] == 'b' && fname[l-2] == 'a' && fname[l-1] == 's' ) 4099 CHECK_ZERO( lpi->messagehdlr, GRBread(lpi->grbmodel, fname) ); 4103 SCIPerrorMessage( "To read a basis with gurobi, the extension has to be '.bas'.\n"); 4117 assert(lpi != NULL); 4118 assert(lpi->grbmodel != NULL); 4124 if ( l > 4 && fname[l-4] == '.' && fname[l-3] == 'b' && fname[l-2] == 'a' && fname[l-1] == 's' ) 4126 CHECK_ZERO( lpi->messagehdlr, GRBwrite(lpi->grbmodel, fname) ); 4134 sprintf(name, "%s.bas", fname); 4135 CHECK_ZERO( lpi->messagehdlr, GRBwrite(lpi->grbmodel, fname) ); 4162 assert(lpinorms != NULL); 4178 assert(lpinorms == NULL); 4191 assert(lpinorms == NULL); 4219 assert(lpi != NULL); 4220 assert(lpi->grbmodel != NULL); 4221 assert(ival != NULL); 4228 *ival = (int) lpi->fromscratch; 4234 SCIP_CALL( getIntParam(lpi, GRB_INT_PAR_SCALEFLAG, &temp) ); 4235 assert( temp == 0 || temp == 1 ); 4239 SCIP_CALL( getIntParam(lpi, GRB_INT_PAR_PRESOLVE, &temp) ); 4240 assert( temp == GRB_PRESOLVE_AUTO || temp == GRB_PRESOLVE_OFF || temp == GRB_PRESOLVE_CONSERVATIVE || temp == GRB_PRESOLVE_AGGRESSIVE ); 4241 *ival = (temp == GRB_PRESOLVE_OFF) ? FALSE : TRUE; 4244 *ival = (int) lpi->pricing; 4247 SCIP_CALL( getIntParam(lpi, GRB_INT_PAR_OUTPUTFLAG, &temp) ); 4248 assert( temp == 0 || temp == 1 ); 4252 SCIP_CALL( getDblParam(lpi, GRB_DBL_PAR_ITERATIONLIMIT, &dtemp) ); 4253 assert( dtemp >= 0.0 ); 4254 if( dtemp >= GRB_INFINITY ) 4257 *ival = (int) dtemp; 4273 assert(lpi != NULL); 4274 assert(lpi->grbmodel != NULL); 4291 SCIP_CALL( setIntParam(lpi, GRB_INT_PAR_SCALEFLAG, 1) ); 4293 SCIP_CALL( setIntParam(lpi, GRB_INT_PAR_SCALEFLAG, 0) ); 4298 SCIP_CALL( setIntParam(lpi, GRB_INT_PAR_PRESOLVE, GRB_PRESOLVE_AUTO) ); 4300 SCIP_CALL( setIntParam(lpi, GRB_INT_PAR_PRESOLVE, GRB_PRESOLVE_OFF) ); 4308 SCIP_CALL( setIntParam(lpi, GRB_INT_PAR_SIMPLEXPRICING, GRB_SIMPLEXPRICING_AUTO) ); 4312 SCIP_CALL( setIntParam(lpi, GRB_INT_PAR_SIMPLEXPRICING, GRB_SIMPLEXPRICING_AUTO) ); 4315 SCIP_CALL( setIntParam(lpi, GRB_INT_PAR_SIMPLEXPRICING, GRB_SIMPLEXPRICING_PARTIAL) ); 4318 SCIP_CALL( setIntParam(lpi, GRB_INT_PAR_SIMPLEXPRICING, GRB_SIMPLEXPRICING_STEEPEST_EDGE) ); 4321 SCIP_CALL( setIntParam(lpi, GRB_INT_PAR_SIMPLEXPRICING, GRB_SIMPLEXPRICING_STEEPEST_QUICK) ); 4324 SCIP_CALL( setIntParam(lpi, GRB_INT_PAR_SIMPLEXPRICING, GRB_SIMPLEXPRICING_DEVEX) ); 4333 SCIP_CALL( setIntParam(lpi, GRB_INT_PAR_OUTPUTFLAG, 1) ); 4335 SCIP_CALL( setIntParam(lpi, GRB_INT_PAR_OUTPUTFLAG, 0) ); 4338 SCIP_CALL( setDblParam(lpi, GRB_DBL_PAR_ITERATIONLIMIT, ( double) ival) ); 4356 assert(lpi != NULL); 4357 assert(lpi->grbmodel != NULL); 4358 assert(dval != NULL); 4365 SCIP_CALL( getDblParam(lpi, GRB_DBL_PAR_FEASIBILITYTOL, dval) ); 4368 SCIP_CALL( getDblParam(lpi, GRB_DBL_PAR_OPTIMALITYTOL, dval) ); 4374 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_MODELSENSE, &objsen) ); 4376 SCIP_CALL( getDblParam(lpi, GRB_DBL_PAR_CUTOFF, dval) ); 4381 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_MODELSENSE, &objsen) ); 4383 SCIP_CALL( getDblParam(lpi, GRB_DBL_PAR_CUTOFF, dval) ); 4388 SCIP_CALL( getDblParam(lpi, GRB_DBL_PAR_TIMELIMIT, dval) ); 4391 SCIP_CALL( getDblParam(lpi, GRB_DBL_PAR_MARKOWITZTOL, dval) ); 4409 assert(lpi != NULL); 4410 assert(lpi->grbmodel != NULL); 4417 SCIP_CALL( setDblParam(lpi, GRB_DBL_PAR_FEASIBILITYTOL, dval) ); 4420 SCIP_CALL( setDblParam(lpi, GRB_DBL_PAR_OPTIMALITYTOL, dval) ); 4426 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_MODELSENSE, &objsen) ); 4428 SCIP_CALL( setDblParam(lpi, GRB_DBL_PAR_CUTOFF, dval) ); 4431 CHECK_ZERO( lpi->messagehdlr, GRBgetintattr(lpi->grbmodel, GRB_INT_ATTR_MODELSENSE, &objsen) ); 4433 SCIP_CALL( setDblParam(lpi, GRB_DBL_PAR_CUTOFF, dval) ); 4436 SCIP_CALL( setDblParam(lpi, GRB_DBL_PAR_TIMELIMIT, dval) ); 4439 SCIP_CALL( setDblParam(lpi, GRB_DBL_PAR_MARKOWITZTOL, dval) ); 4465 return GRB_INFINITY; 4474 return (val >= GRB_INFINITY); 4495 assert(lpi != NULL); 4496 assert(lpi->grbmodel != NULL); 4500 CHECK_ZERO( lpi->messagehdlr, GRBread(lpi->grbmodel, fname) ); 4511 assert(lpi != NULL); 4512 assert(lpi->grbmodel != NULL); 4516 CHECK_ZERO( lpi->messagehdlr, GRBwrite(lpi->grbmodel, fname) ); SCIP_RETCODE SCIPlpiStrongbranchesInt(SCIP_LPI *lpi, int *cols, int ncols, SCIP_Real *psols, int itlim, SCIP_Real *down, SCIP_Real *up, SCIP_Bool *downvalid, SCIP_Bool *upvalid, int *iter)
enum SCIP_LPSolQuality SCIP_LPSOLQUALITY
SCIP_RETCODE SCIPlpiGetRealSolQuality(SCIP_LPI *lpi, SCIP_LPSOLQUALITY qualityindicator, SCIP_Real *quality)
SCIP_RETCODE SCIPlpiSetState(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPISTATE *lpistate)
SCIP_DUALPACKET COLPACKET
SCIP_RETCODE SCIPlpiGetObjsen(SCIP_LPI *lpi, SCIP_OBJSEN *objsen)
SCIP_RETCODE SCIPlpiGetBInvACol(SCIP_LPI *lpi, int c, SCIP_Real *coef, int *inds, int *ninds)
SCIP_RETCODE SCIPlpiStartStrongbranch(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetNNonz(SCIP_LPI *lpi, int *nnonz)
SCIP_RETCODE SCIPlpiGetCols(SCIP_LPI *lpi, int firstcol, int lastcol, SCIP_Real *lb, SCIP_Real *ub, int *nnonz, int *beg, int *ind, SCIP_Real *val)
unsigned int SCIP_DUALPACKET
SCIP_RETCODE SCIPlpiScaleCol(SCIP_LPI *lpi, int col, SCIP_Real scaleval)
SCIP_RETCODE SCIPlpiChgBounds(SCIP_LPI *lpi, int ncols, const int *ind, const SCIP_Real *lb, const SCIP_Real *ub)
SCIP_RETCODE SCIPlpiAddCols(SCIP_LPI *lpi, int ncols, const SCIP_Real *obj, const SCIP_Real *lb, const SCIP_Real *ub, char **colnames, int nnonz, const int *beg, const int *ind, const SCIP_Real *val)
enum SCIP_ObjSen SCIP_OBJSEN
SCIP_Bool SCIPlpiIsObjlimExc(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiChgCoef(SCIP_LPI *lpi, int row, int col, SCIP_Real newval)
SCIP_RETCODE SCIPlpiFreeNorms(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPINORMS **lpinorms)
interface methods for specific LP solvers
SCIP_Bool SCIPlpiIsIterlimExc(SCIP_LPI *lpi)
struct SCIP_Messagehdlr SCIP_MESSAGEHDLR
SCIP_RETCODE SCIPlpiGetDualfarkas(SCIP_LPI *lpi, SCIP_Real *dualfarkas)
SCIP_RETCODE SCIPlpiSolveDual(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiDelRowset(SCIP_LPI *lpi, int *dstat)
SCIP_RETCODE SCIPlpiStrongbranchInt(SCIP_LPI *lpi, int col, SCIP_Real psol, int itlim, SCIP_Real *down, SCIP_Real *up, SCIP_Bool *downvalid, SCIP_Bool *upvalid, int *iter)
enum SCIP_Retcode SCIP_RETCODE
SCIP_RETCODE SCIPlpiGetNorms(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPINORMS **lpinorms)
SCIP_RETCODE SCIPlpiGetRowNames(SCIP_LPI *lpi, int firstrow, int lastrow, char **rownames, char *namestorage, int namestoragesize, int *storageleft)
enum SCIP_LPParam SCIP_LPPARAM
SCIP_RETCODE SCIPlpiGetSol(SCIP_LPI *lpi, SCIP_Real *objval, SCIP_Real *primsol, SCIP_Real *dualsol, SCIP_Real *activity, SCIP_Real *redcost)
SCIP_Bool SCIPlpiIsTimelimExc(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetIntpar(SCIP_LPI *lpi, SCIP_LPPARAM type, int *ival)
SCIP_RETCODE SCIPlpiGetCoef(SCIP_LPI *lpi, int row, int col, SCIP_Real *val)
SCIP_RETCODE SCIPlpiGetObj(SCIP_LPI *lpi, int firstcol, int lastcol, SCIP_Real *vals)
SCIP_RETCODE SCIPlpiGetBInvRow(SCIP_LPI *lpi, int r, SCIP_Real *coef, int *inds, int *ninds)
SCIP_RETCODE SCIPlpiSetIntpar(SCIP_LPI *lpi, SCIP_LPPARAM type, int ival)
enum SCIP_Pricing SCIP_PRICING
SCIP_Bool SCIPlpiIsDualInfeasible(SCIP_LPI *lpi)
#define GRB_REFACTORMAXITERS
SCIP_Bool SCIPlpiIsInfinity(SCIP_LPI *lpi, SCIP_Real val)
#define GRB_METHOD_PRIMAL
#define GRB_INT_PAR_METHOD
void SCIPmessagePrintWarning(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr,...)
SCIP_RETCODE SCIPlpiGetBasisInd(SCIP_LPI *lpi, int *bind)
SCIP_DUALPACKET COLPACKET
SCIP_RETCODE SCIPlpiChgObjsen(SCIP_LPI *lpi, SCIP_OBJSEN objsen)
#define SCIP_DUALPACKETSIZE
SCIP_RETCODE SCIPlpiFreeState(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPISTATE **lpistate)
SCIP_Bool SCIPlpiIsOptimal(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiReadLP(SCIP_LPI *lpi, const char *fname)
SCIP_RETCODE SCIPlpiGetNCols(SCIP_LPI *lpi, int *ncols)
SCIP_RETCODE SCIPlpiGetBInvARow(SCIP_LPI *lpi, int r, const SCIP_Real *binvrow, SCIP_Real *coef, int *inds, int *ninds)
void * SCIPlpiGetSolverPointer(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetNRows(SCIP_LPI *lpi, int *nrows)
SCIP_RETCODE SCIPlpiGetState(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPISTATE **lpistate)
SCIP_RETCODE SCIPlpiGetSolFeasibility(SCIP_LPI *lpi, SCIP_Bool *primalfeasible, SCIP_Bool *dualfeasible)
SCIP_RETCODE SCIPlpiCreate(SCIP_LPI **lpi, SCIP_MESSAGEHDLR *messagehdlr, const char *name, SCIP_OBJSEN objsen)
SCIP_DUALPACKET ROWPACKET
SCIP_Bool SCIPlpiIsDualFeasible(SCIP_LPI *lpi)
struct SCIP_LPiState SCIP_LPISTATE
SCIP_RETCODE SCIPlpiIgnoreInstability(SCIP_LPI *lpi, SCIP_Bool *success)
SCIP_RETCODE SCIPlpiChgObj(SCIP_LPI *lpi, int ncols, int *ind, SCIP_Real *obj)
SCIP_Bool SCIPlpiExistsPrimalRay(SCIP_LPI *lpi)
int SCIPlpiGetInternalStatus(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiSolveBarrier(SCIP_LPI *lpi, SCIP_Bool crossover)
SCIP_RETCODE SCIPlpiGetIterations(SCIP_LPI *lpi, int *iterations)
SCIP_RETCODE SCIPlpiGetColNames(SCIP_LPI *lpi, int firstcol, int lastcol, char **colnames, char *namestorage, int namestoragesize, int *storageleft)
SCIP_RETCODE SCIPlpiGetBounds(SCIP_LPI *lpi, int firstcol, int lastcol, SCIP_Real *lbs, SCIP_Real *ubs)
SCIP_RETCODE SCIPlpiGetObjval(SCIP_LPI *lpi, SCIP_Real *objval)
SCIP_RETCODE SCIPlpiGetSides(SCIP_LPI *lpi, int firstrow, int lastrow, SCIP_Real *lhss, SCIP_Real *rhss)
SCIP_RETCODE SCIPlpiGetBase(SCIP_LPI *lpi, int *cstat, int *rstat)
SCIP_RETCODE SCIPlpiSetBase(SCIP_LPI *lpi, int *cstat, int *rstat)
SCIP_Bool SCIPlpiIsDualUnbounded(SCIP_LPI *lpi)
const char * SCIPlpiGetSolverDesc(void)
SCIP_RETCODE SCIPlpiClearState(SCIP_LPI *lpi)
SCIP_Bool SCIPlpiIsPrimalInfeasible(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiSetNorms(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPINORMS *lpinorms)
SCIP_Bool SCIPlpiIsStable(SCIP_LPI *lpi)
SCIP_Bool SCIPlpiHasPrimalRay(SCIP_LPI *lpi)
#define SCIP_CALL_QUIET(x)
SCIP_RETCODE SCIPlpiSolvePrimal(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiClear(SCIP_LPI *lpi)
SCIP_Bool SCIPlpiIsPrimalUnbounded(SCIP_LPI *lpi)
unsigned int SCIP_SINGLEPACKET
SCIP_RETCODE SCIPlpiWriteLP(SCIP_LPI *lpi, const char *fname)
SCIP_RETCODE SCIPlpiGetBInvCol(SCIP_LPI *lpi, int c, SCIP_Real *coef, int *inds, int *ninds)
SCIP_RETCODE SCIPlpiReadState(SCIP_LPI *lpi, const char *fname)
SCIP_Real SCIPlpiInfinity(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiStrongbranchesFrac(SCIP_LPI *lpi, int *cols, int ncols, SCIP_Real *psols, int itlim, SCIP_Real *down, SCIP_Real *up, SCIP_Bool *downvalid, SCIP_Bool *upvalid, int *iter)
SCIP_RETCODE SCIPlpiFree(SCIP_LPI **lpi)
SCIP_DUALPACKET ROWPACKET
SCIP_Bool SCIPlpiHasStateBasis(SCIP_LPI *lpi, SCIP_LPISTATE *lpistate)
SCIP_RETCODE SCIPlpiLoadColLP(SCIP_LPI *lpi, SCIP_OBJSEN objsen, int ncols, const SCIP_Real *obj, const SCIP_Real *lb, const SCIP_Real *ub, char **colnames, int nrows, const SCIP_Real *lhs, const SCIP_Real *rhs, char **rownames, int nnonz, const int *beg, const int *ind, const SCIP_Real *val)
const char * SCIPlpiGetSolverName(void)
SCIP_RETCODE SCIPlpiDelRows(SCIP_LPI *lpi, int firstrow, int lastrow)
SCIP_RETCODE SCIPlpiWriteState(SCIP_LPI *lpi, const char *fname)
public methods for message output
SCIP_RETCODE SCIPlpiSetRealpar(SCIP_LPI *lpi, SCIP_LPPARAM type, SCIP_Real dval)
SCIP_RETCODE SCIPlpiGetRealpar(SCIP_LPI *lpi, SCIP_LPPARAM type, SCIP_Real *dval)
SCIP_Bool SCIPlpiIsPrimalFeasible(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiDelCols(SCIP_LPI *lpi, int firstcol, int lastcol)
SCIP_RETCODE SCIPlpiEndStrongbranch(SCIP_LPI *lpi)
SCIP_Bool SCIPlpiHasDualRay(SCIP_LPI *lpi)
SCIP_Bool SCIPlpiExistsDualRay(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiAddRows(SCIP_LPI *lpi, int nrows, const SCIP_Real *lhs, const SCIP_Real *rhs, char **rownames, int nnonz, const int *beg, const int *ind, const SCIP_Real *val)
SCIP_RETCODE SCIPlpiChgSides(SCIP_LPI *lpi, int nrows, const int *ind, const SCIP_Real *lhs, const SCIP_Real *rhs)
SCIP_Bool SCIPlpiWasSolved(SCIP_LPI *lpi)
#define CHECK_ZERO(messagehdlr, x)
SCIP_RETCODE SCIPlpiGetPrimalRay(SCIP_LPI *lpi, SCIP_Real *ray)
SCIP_RETCODE SCIPlpiScaleRow(SCIP_LPI *lpi, int row, SCIP_Real scaleval)
SCIP_RETCODE SCIPlpiStrongbranchFrac(SCIP_LPI *lpi, int col, SCIP_Real psol, int itlim, SCIP_Real *down, SCIP_Real *up, SCIP_Bool *downvalid, SCIP_Bool *upvalid, int *iter)
SCIP_RETCODE SCIPlpiGetRows(SCIP_LPI *lpi, int firstrow, int lastrow, SCIP_Real *lhs, SCIP_Real *rhs, int *nnonz, int *beg, int *ind, SCIP_Real *val)
SCIP_RETCODE SCIPlpiDelColset(SCIP_LPI *lpi, int *dstat)
|