29 #define HEUR_NAME "twoopt" 30 #define HEUR_DESC "primal heuristic to improve incumbent solution by flipping pairs of variables" 31 #define HEUR_DISPCHAR 'B' 32 #define HEUR_PRIORITY -20100 34 #define HEUR_FREQOFS 0 35 #define HEUR_MAXDEPTH -1 37 #define HEUR_TIMING SCIP_HEURTIMING_AFTERNODE 38 #define HEUR_USESSUBSCIP FALSE 41 #define DEFAULT_INTOPT FALSE 42 #define DEFAULT_WAITINGNODES 0 43 #define DEFAULT_MATCHINGRATE 0.5 45 #define DEFAULT_MAXNSLAVES 199 46 #define DEFAULT_ARRAYSIZE 10 47 #define DEFAULT_RANDSEED 37 151 assert(scip != NULL);
152 assert(master != NULL);
153 assert(slave != NULL);
154 assert(activities != NULL);
168 assert(ncolmasterrows == 0 || masterrows != NULL);
174 assert(ncolslaverows == 0 || slaverows != NULL);
177 for( i = 0; i < ncolmasterrows && SCIProwGetLPPos(masterrows[i]) >= 0; ++i )
182 assert(rowpos < nrows);
186 activities[rowpos] += mastercolvals[i] * (int)masterdir * shiftval;
190 for( j = 0; j < ncolslaverows && SCIProwGetLPPos(slaverows[j]) >= 0; ++j )
195 assert(rowpos < nrows);
200 activities[rowpos] += slavecolvals[j] * (int)slavedir * shiftval;
209 for( i = 0; i < ncolmasterrows && SCIProwGetLPPos(masterrows[i]) >= 0; ++i )
245 assert(var1 != NULL);
246 assert(var2 != NULL);
256 assert(nnonzeros1 == 0 || rows1 != NULL);
257 assert(nnonzeros2 == 0 || rows2 != NULL);
261 for( i = 0; i < nnonzeros1 && i < nnonzeros2; ++i )
270 return nnonzeros2 - nnonzeros1 ;
305 assert(var1 != NULL);
306 assert(var2 != NULL);
316 assert(nnonzeros1 == 0 || rows1 != NULL);
317 assert(nnonzeros2 == 0 || rows2 != NULL);
319 if( nnonzeros1 == 0 && nnonzeros2 == 0 )
323 nrowmaximum =
MAX(nnonzeros1, nnonzeros2);
325 nrowabs = ABS(nnonzeros1 - nnonzeros2);
326 nrows1not2 = nrowmaximum - nnonzeros2;
327 nrows2not1 = nrowmaximum - nnonzeros1;
332 assert(nrowmaximum > 0);
334 if( (nrowmaximum - nrowabs) / (
SCIP_Real) nrowmaximum < matchingrate )
341 while( i < nnonzeros1 && j < nnonzeros2 )
401 assert(scip != NULL);
403 assert(master != NULL);
404 assert(slave != NULL);
420 bound = MIN(slavebound, masterbound);
437 assert(nslaverows == 0 || slavecolvals != NULL);
438 assert(nmasterrows == 0 || mastercolvals != NULL);
440 SCIPdebugMsg(scip,
" Master: %s with direction %d and %d rows, Slave: %s with direction %d and %d rows \n",
SCIPvarGetName(master),
441 (
int)masterdirection, nmasterrows,
SCIPvarGetName(slave), (
int)slavedirection, nslaverows);
475 slaveincrement =
FALSE;
481 slaveindex = INT_MAX;
483 if( j < nmasterrows )
486 masterindex = INT_MAX;
488 assert(0 <= slaveindex && 0 <= masterindex);
490 assert(slaveindex < INT_MAX || masterindex < INT_MAX);
493 if( slaveindex <= masterindex )
497 slaveincrement =
TRUE;
498 masterincrement = (slaveindex == masterindex);
502 assert(j < nmasterrows);
506 masterincrement =
TRUE;
515 if( slaveindex <= masterindex )
516 effect += (slavecolvals[i] * (int)slavedirection);
517 if( masterindex <= slaveindex )
518 effect += (mastercolvals[j] * (int)masterdirection);
528 assert(rowpos < nrows);
530 activity = activities[rowpos];
540 SCIPdebugMsg(scip,
" %g <= %g <= %g, bound = %g, effect = %g (%g * %d + %g * %d) (i=%d,j=%d)\n", lhs, activity, rhs,
bound, effect,
541 slaveindex <= masterindex ? slavecolvals[i] : 0.0, (
int)slavedirection, masterindex <= slaveindex ? mastercolvals[j] : 0.0,
542 (
int)masterdirection, i, j);
552 bound = MIN(bound - 1.0, newval);
563 bound = MIN(bound - 1.0, newval);
571 SCIPdebugMsg(scip,
" Zero effect on row %s, effect %g, master coeff: %g slave coeff: %g (i=%d, j=%d)\n",
572 SCIProwGetName(row), effect, mastercolvals[j], slavecolvals[i], i, j);
584 if( masterincrement )
607 assert(blockend != NULL);
608 assert(varindex <= *blockend);
610 vars[varindex] = vars[*blockend];
633 assert(scip != NULL);
634 assert(vars != NULL);
636 assert(nblocks != NULL);
637 assert(nblockvars != NULL);
638 assert(blockstart != NULL);
639 assert(blockend != NULL);
640 assert(heur != NULL);
641 assert(heurdata != NULL);
647 SCIPsortPtr((
void**)(*varspointer), SCIPvarcolComp, nvars);
660 for( v = 1; v < nvars; ++v )
666 if( v - startindex >= 2 )
668 assert(*nblocks < nvars/2);
669 (*nblockvars) += v - startindex;
670 (*maxblocksize) =
MAX((*maxblocksize), v - startindex);
671 (*blockstart)[*nblocks] = startindex;
672 (*blockend)[*nblocks] = v - 1;
677 else if( v == nvars - 1 && v - startindex >= 1 )
679 assert(*nblocks < nvars/2);
680 (*nblockvars) += v - startindex + 1;
681 (*maxblocksize) =
MAX((*maxblocksize), v - startindex + 1);
682 (*blockstart)[*nblocks] = startindex;
683 (*blockend)[*nblocks] = v;
725 int nbinblockvars = 0;
727 int maxbinblocksize = 0;
730 assert(scip != NULL);
731 assert(heurdata != NULL);
734 if( heurdata->presolved )
744 SCIP_CALL(
innerPresolve(scip, vars, &(heurdata->binvars), nbinvars, &(heurdata->nbinblocks), &maxbinblocksize,
745 &nbinblockvars, &(heurdata->binblockstart), &(heurdata->binblockend), heur, heurdata) );
748 heurdata->nbinvars = nbinvars;
749 heurdata->execute = nbinvars > 1 && heurdata->nbinblocks > 0;
751 #ifdef SCIP_STATISTIC 753 heurdata->binnblocks += (heurdata->nbinblocks);
754 heurdata->binnblockvars += nbinblockvars;
755 heurdata->ntotalbinvars += nbinvars;
756 heurdata->maxbinblocksize =
MAX(maxbinblocksize, heurdata->maxbinblocksize);
758 SCIPstatisticMessage(
" Twoopt BINARY presolving finished with <%d> blocks, <%d> block variables \n",
759 heurdata->nbinblocks, nbinblockvars);
762 if( heurdata->intopt && nintvars > 1 )
764 SCIP_CALL(
innerPresolve(scip, &(vars[nbinvars]), &(heurdata->intvars), nintvars, &(heurdata->nintblocks), &maxintblocksize,
765 &nintblockvars, &(heurdata->intblockstart), &(heurdata->intblockend),
768 heurdata->execute = heurdata->execute || heurdata->nintblocks > 0;
770 #ifdef SCIP_STATISTIC 772 heurdata->intnblocks += heurdata->nintblocks;
773 heurdata->intnblockvars += nintblockvars;
774 heurdata->ntotalintvars += nintvars;
775 heurdata->maxintblocksize =
MAX(maxintblocksize, heurdata->maxintblocksize);
776 SCIPstatisticMessage(
" Twoopt Integer presolving finished with <%d> blocks, <%d> block variables \n",
777 heurdata->nintblocks, nintblockvars);
781 heurdata->nintvars = nintvars;
784 heurdata->presolved =
TRUE;
798 assert(scip != NULL);
799 assert(heur != NULL);
814 assert(heur != NULL);
816 assert(scip != NULL);
820 assert(heurdata != NULL);
833 assert(heur != NULL);
835 assert(scip != NULL);
838 assert(heurdata != NULL);
841 heurdata->nbinvars = 0;
842 heurdata->nintvars = 0;
843 heurdata->lastsolindex = -1;
844 heurdata->presolved =
FALSE;
845 heurdata->nbinblocks = 0;
846 heurdata->nintblocks = 0;
852 #ifdef SCIP_STATISTIC 854 heurdata->binnexchanges = 0;
855 heurdata->intnexchanges = 0;
856 heurdata->binnblockvars = 0;
857 heurdata->intnblockvars = 0;
858 heurdata->binnblocks = 0;
859 heurdata->intnblocks = 0;
861 heurdata->maxbinblocksize = 0;
862 heurdata->maxintblocksize = 0;
864 heurdata->ntotalbinvars = 0;
865 heurdata->ntotalintvars = 0;
874 heurdata->binvars = NULL;
875 heurdata->intvars = NULL;
876 heurdata->binblockstart = NULL;
877 heurdata->binblockend = NULL;
878 heurdata->intblockstart = NULL;
879 heurdata->intblockend = NULL;
913 assert(scip != NULL);
915 assert(blockstart != NULL && blockend != NULL);
916 assert(varboundserr != NULL);
917 assert(activities != NULL);
918 assert(worksol != NULL);
919 assert(improvement != NULL);
921 *varboundserr =
FALSE;
930 for( b = 0; b < nblocks; ++b )
935 blocklen = blockend[b] - blockstart[b] + 1;
938 for( m = 0; m < blocklen; ++m )
954 master = vars[blockstart[b] + m];
962 *varboundserr =
TRUE;
963 SCIPdebugMsg(scip,
"Solution has violated variable bounds for var %s: %g <= %g <= %g \n",
983 bestimprovement = 0.0;
991 if( heurdata->maxnslaves >= 0 && blocklen > heurdata->maxnslaves )
992 firstslave =
SCIPrandomGetInt(heurdata->randnumgen, blockstart[b] + m, blockend[b]);
994 firstslave = blockstart[b] + m + 1;
996 nslaves = MIN((heurdata->maxnslaves == -1 ? INT_MAX : heurdata->maxnslaves), blocklen);
1001 for( s = 0; s < nslaves; ++s )
1012 slaveindex = (firstslave + s - blockstart[b]) % blocklen;
1013 slaveindex += blockstart[b];
1016 if( (blocklen <= heurdata->maxnslaves || heurdata->maxnslaves == -1) && slaveindex < blockstart[b] + m )
1019 if( slaveindex == blockstart[b] + m )
1023 slave = vars[slaveindex];
1035 *varboundserr =
TRUE;
1036 SCIPdebugMsg(scip,
"Solution has violated variable bounds for var %s: %g <= %g <= %g \n",
1059 equaldirbound = 0.0;
1066 changedobj = (masterobj - slaveobj) * diffdirbound;
1068 else if(
SCIPisFeasGT(scip, masterobj - slaveobj, 0.0) )
1072 changedobj = (slaveobj - masterobj) * diffdirbound;
1078 if(
SCIPisFeasLT(scip, (slaveobj + masterobj) * equaldirbound, changedobj) )
1080 changedobj = (slaveobj + masterobj) * equaldirbound;
1084 else if(
SCIPisFeasGT(scip, masterobj + slaveobj, 0.0) )
1087 if(
SCIPisFeasLT(scip, -(slaveobj + masterobj) * equaldirbound, changedobj) )
1089 changedobj = -(slaveobj + masterobj) * equaldirbound;
1102 bestimprovement = changedobj;
1103 bestslavepos = slaveindex;
1104 bestdirection = directions;
1110 if( directions / 2 == 1 )
1115 if( directions % 2 == 1 )
1120 if( bestmasterdir == bestslavedir )
1121 bestbound = equaldirbound;
1123 bestbound = diffdirbound;
1128 if( bestslavepos >= 0 )
1130 if( npairs == arraysize )
1136 arraysize = 2 * arraysize;
1138 assert( npairs < arraysize );
1140 bestmasters[npairs] = master;
1141 bestslaves[npairs] = vars[bestslavepos];
1142 objchanges[npairs] = ((int)bestslavedir *
SCIPvarGetObj(bestslaves[npairs]) + (int)bestmasterdir * masterobj) * bestbound;
1143 bestdirections[npairs] = bestdirection;
1145 assert(objchanges[npairs] < 0);
1147 SCIPdebugMsg(scip,
" Saved candidate pair {%s=%g, %s=%g} with objectives <%g>, <%g> to be set to {%g, %g} %d\n",
1149 masterobj,
SCIPvarGetObj(bestslaves[npairs]), mastersolval + (
int)bestmasterdir * bestbound,
SCIPgetSolVal(scip, worksol, bestslaves[npairs])
1150 + (
int)bestslavedir * bestbound, bestdirections[npairs]);
1162 for( b = 0; b < npairs; ++b )
1174 master = bestmasters[b];
1175 slave = bestslaves[b];
1181 assert(0 <= bestdirections[b] && bestdirections[b] < 4);
1183 if( bestdirections[b] / 2 == 1 )
1188 if( bestdirections[b] % 2 == 1 )
1193 bound =
determineBound(scip, worksol, master, masterdir, slave, slavedir, activities, nrows);
1202 SCIPdebugMsg(scip,
" Promising candidates {%s=%g, %s=%g} with objectives <%g>, <%g> to be set to {%g, %g}\n",
1204 masterobj, slaveobj, mastersolval + (
int)masterdir * bound, slavesolval + (
int)slavedir * bound);
1208 changedobj = ((int)slavedir * slaveobj + (
int)masterdir * masterobj) * bound;
1215 SCIP_CALL(
shiftValues(scip, master, slave, mastersolval, masterdir, slavesolval, slavedir, bound,
1216 activities, nrows, &feasible) );
1226 SCIPdebugMsg(scip,
" Feasible shift: <%s>[%g, %g] (obj: %f) <%f> --> <%f>\n",
1228 SCIPdebugMsg(scip,
" <%s>[%g, %g] (obj: %f) <%f> --> <%f>\n",
1231 #ifdef SCIP_STATISTIC 1234 ++(heurdata->binnexchanges);
1236 ++(heurdata->intnexchanges);
1239 *improvement =
TRUE;
1259 assert(heurdata != NULL);
1262 assert(heurdata->nbinvars <= 1 || heurdata->binvars != NULL);
1264 #ifdef SCIP_STATISTIC 1267 " Twoopt Binary Statistics : " 1268 "%6.2g %6.2g %4.2g %4.0g %6d (blocks/run, variables/run, varpercentage, avg. block size, max block size) \n",
1269 heurdata->nruns == 0 ? 0.0 : (
SCIP_Real)heurdata->binnblocks/(heurdata->nruns),
1270 heurdata->nruns == 0 ? 0.0 : (
SCIP_Real)heurdata->binnblockvars/(heurdata->nruns),
1271 heurdata->ntotalbinvars == 0 ? 0.0 : (
SCIP_Real)heurdata->binnblockvars/(heurdata->ntotalbinvars) * 100.0,
1272 heurdata->binnblocks == 0 ? 0.0 : heurdata->binnblockvars/(
SCIP_Real)(heurdata->binnblocks),
1273 heurdata->maxbinblocksize);
1276 " Twoopt Integer statistics : " 1277 "%6.2g %6.2g %4.2g %4.0g %6d (blocks/run, variables/run, varpercentage, avg block size, max block size) \n",
1278 heurdata->nruns == 0 ? 0.0 : (
SCIP_Real)heurdata->intnblocks/(heurdata->nruns),
1279 heurdata->nruns == 0 ? 0.0 : (
SCIP_Real)heurdata->intnblockvars/(heurdata->nruns),
1280 heurdata->ntotalintvars == 0 ? 0.0 : (
SCIP_Real)heurdata->intnblockvars/(heurdata->ntotalintvars) * 100.0,
1281 heurdata->intnblocks == 0 ? 0.0 : heurdata->intnblockvars/(
SCIP_Real)(heurdata->intnblocks),
1282 heurdata->maxintblocksize);
1285 " Twoopt results : " 1286 "%6d %6d %4d %4.2g (runs, binary exchanges, Integer shiftings, matching rate)\n",
1288 heurdata->binnexchanges,
1289 heurdata->intnexchanges,
1290 heurdata->matchingrate);
1293 heurdata->binnblockvars = 0;
1294 heurdata->binnblocks = 0;
1295 heurdata->intnblocks = 0;
1296 heurdata->intnblockvars = 0;
1297 heurdata->binnexchanges = 0;
1298 heurdata->intnexchanges = 0;
1302 if( heurdata->binvars != NULL )
1307 if( heurdata->nbinblocks > 0 )
1309 assert(heurdata->binblockstart != NULL);
1310 assert(heurdata->binblockend != NULL);
1315 heurdata->nbinvars = 0;
1316 heurdata->nbinblocks = 0;
1318 if( heurdata->nintblocks > 0 )
1320 assert(heurdata->intblockstart != NULL);
1321 assert(heurdata->intblockend != NULL);
1328 if( heurdata->intvars != NULL )
1333 heurdata->nbinblocks = 0;
1334 heurdata->nintblocks = 0;
1335 heurdata->nbinvars = 0;
1336 heurdata->nintvars = 0;
1338 assert(heurdata->binvars == NULL);
1339 assert(heurdata->intvars == NULL);
1354 assert(heur != NULL);
1356 assert(scip != NULL);
1361 assert(heurdata != NULL);
1362 assert(heurdata->binvars == NULL && heurdata->intvars == NULL);
1363 assert(heurdata->binblockstart == NULL && heurdata->binblockend == NULL);
1364 assert(heurdata->intblockstart == NULL && heurdata->intblockend == NULL);
1367 heurdata->nbinvars = 0;
1368 heurdata->nintvars = 0;
1369 heurdata->lastsolindex = -1;
1370 heurdata->presolved =
FALSE;
1372 #ifdef SCIP_STATISTIC 1373 ++(heurdata->nruns);
1390 assert(heur != NULL);
1391 assert(scip != NULL);
1393 assert(scip != NULL);
1398 assert(heurdata != NULL);
1400 nbinvars = heurdata->nbinvars;
1401 nintvars = heurdata->nintvars;
1404 if( heurdata->binvars != NULL )
1408 if( heurdata->binblockstart != NULL )
1410 assert(heurdata->binblockend != NULL);
1415 heurdata->nbinvars = 0;
1416 heurdata->nbinblocks = 0;
1418 if( heurdata->intblockstart != NULL )
1420 assert(heurdata->intblockend != NULL);
1425 heurdata->nintblocks = 0;
1428 if( heurdata->intvars != NULL )
1433 heurdata->nintvars = 0;
1435 assert(heurdata->binvars == NULL && heurdata->intvars == NULL);
1436 assert(heurdata->binblockstart == NULL && heurdata->binblockend == NULL);
1437 assert(heurdata->intblockstart == NULL && heurdata->intblockend == NULL);
1461 int ncolsforsorting;
1466 assert(heur != NULL);
1467 assert(scip != NULL);
1468 assert(result != NULL);
1472 assert(heurdata != NULL);
1483 if( bestsol == NULL || heurdata->lastsolindex ==
SCIPsolGetIndex(bestsol) )
1500 presolthiscall =
FALSE;
1503 ncolsforsorting = MIN(ncols, ndiscvars);
1506 if( !heurdata->presolved )
1510 for( i = 0; i < ncolsforsorting; ++i )
1514 presolthiscall =
TRUE;
1517 assert(heurdata->presolved);
1519 SCIPdebugMsg(scip,
" Twoopt heuristic is %sexecuting.\n", heurdata->execute ?
"" :
"not ");
1522 if( !heurdata->execute )
1525 nbinvars = heurdata->nbinvars;
1526 nintvars = heurdata->nintvars;
1527 ndiscvars = nbinvars + nintvars;
1547 for( i = 0; i < nlprows; i++ )
1552 assert(row != NULL);
1566 if( !presolthiscall )
1568 for( i = 0; i < ncolsforsorting; ++i )
1571 SCIPdebugMsg(scip,
" Twoopt heuristic has initialized activities and sorted rows! \n");
1574 improvement =
FALSE;
1575 varboundserr =
FALSE;
1577 if( heurdata->nbinblocks > 0 )
1579 SCIP_CALL(
optimize(scip, worksol, heurdata->binvars, heurdata->binblockstart, heurdata->binblockend, heurdata->nbinblocks,
1580 OPTTYPE_BINARY, activities, nlprows, &improvement, &varboundserr, heurdata) );
1582 SCIPdebugMsg(scip,
" Binary Optimization finished!\n");
1591 if( heurdata->nintblocks > 0 )
1593 assert(heurdata->intopt);
1594 SCIP_CALL(
optimize(scip, worksol, heurdata->intvars, heurdata->intblockstart, heurdata->intblockend, heurdata->nintblocks,
1595 OPTTYPE_INTEGER, activities, nlprows, &improvement, &varboundserr, heurdata) );
1597 SCIPdebugMsg(scip,
" Integer Optimization finished!\n");
1600 if( ! improvement || varboundserr )
1616 SCIPdebugMsg(scip,
"found feasible shifted solution:\n");
1621 #ifdef SCIP_STATISTIC 1636 SCIPdebugMsg(scip,
"shifted solution should be feasible -> solve LP to fix continuous variables to best values\n");
1643 SCIPdebugMsg(scip,
" Cont. variable <%s>, status %d with bounds [%g <= %g <= x <= %g <= %g]\n",
1663 for( i = 0; i < ndiscvars; ++i )
1677 for( i = 0; i < ndiscvars; ++i )
1690 SCIPwarningMessage(scip,
"Error while solving LP in Twoopt heuristic; LP solve terminated with code <%d>\n",retstat);
1716 SCIPdebugMsg(scip,
"found feasible shifted solution:\n");
1721 #ifdef SCIP_STATISTIC 1733 SCIPdebugMsg(scip,
"Termination of Twoopt heuristic\n");
1760 assert(heur != NULL);
1776 "nodes to wait after last best solution before calling heuristic",
1780 SCIP_CALL(
SCIPaddIntParam(scip,
"heuristics/twoopt/maxnslaves",
"maximum number of slaves for one master variable",
1785 "parameter to determine the percentage of rows two variables have to share before they are considered equal",
SCIP_Bool SCIPsolIsOriginal(SCIP_SOL *sol)
SCIP_RETCODE SCIPsetHeurExitsol(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEUREXITSOL((*heurexitsol)))
void SCIPfreeRandom(SCIP *scip, SCIP_RANDNUMGEN **randnumgen)
#define SCIPfreeBlockMemoryArray(scip, ptr, num)
int SCIPgetNIntVars(SCIP *scip)
SCIP_Bool SCIPisFeasZero(SCIP *scip, SCIP_Real val)
static SCIP_RETCODE shiftValues(SCIP *scip, SCIP_VAR *master, SCIP_VAR *slave, SCIP_Real mastersolval, DIRECTION masterdir, SCIP_Real slavesolval, DIRECTION slavedir, SCIP_Real shiftval, SCIP_Real *activities, int nrows, SCIP_Bool *feasible)
#define SCIPreallocBlockMemoryArray(scip, ptr, oldnum, newnum)
Primal heuristic to improve incumbent solution by flipping pairs of variables.
SCIP_RETCODE SCIPlinkLPSol(SCIP *scip, SCIP_SOL *sol)
#define SCIPallocBlockMemoryArray(scip, ptr, num)
SCIP_Bool SCIPisFeasEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Longint SCIPgetNLPIterations(SCIP *scip)
SCIP_Bool SCIPisFeasLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
static SCIP_DECL_HEURFREE(heurFreeTwoopt)
void SCIPsortRealPtrPtrInt(SCIP_Real *realarray, void **ptrarray1, void **ptrarray2, int *intarray, int len)
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
SCIP_RETCODE SCIPcreateRandom(SCIP *scip, SCIP_RANDNUMGEN **randnumgen, unsigned int initialseed)
SCIP_Real * SCIPcolGetVals(SCIP_COL *col)
SCIP_RETCODE SCIPsetHeurExit(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEUREXIT((*heurexit)))
SCIP_Bool SCIPisPositive(SCIP *scip, SCIP_Real val)
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
const char * SCIProwGetName(SCIP_ROW *row)
#define DEFAULT_WAITINGNODES
SCIP_Bool SCIPisFeasGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
#define DEFAULT_MAXNSLAVES
SCIP_RETCODE SCIPgetVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars)
SCIP_Real SCIProwGetLhs(SCIP_ROW *row)
static SCIP_RETCODE optimize(SCIP *scip, SCIP_SOL *worksol, SCIP_VAR **vars, int *blockstart, int *blockend, int nblocks, OPTTYPE opttype, SCIP_Real *activities, int nrows, SCIP_Bool *improvement, SCIP_Bool *varboundserr, SCIP_HEURDATA *heurdata)
SCIP_Bool SCIPisNegative(SCIP *scip, SCIP_Real val)
enum SCIP_Retcode SCIP_RETCODE
#define SCIPstatisticMessage
SCIP_RETCODE SCIPchgVarLbDive(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
struct SCIP_HeurData SCIP_HEURDATA
#define SCIPfreeBlockMemory(scip, ptr)
SCIP_RETCODE SCIPincludeHeurBasic(SCIP *scip, SCIP_HEUR **heur, const char *name, const char *desc, char dispchar, int priority, int freq, int freqofs, int maxdepth, SCIP_HEURTIMING timingmask, SCIP_Bool usessubscip, SCIP_DECL_HEUREXEC((*heurexec)), SCIP_HEURDATA *heurdata)
int SCIPrandomGetInt(SCIP_RANDNUMGEN *randnumgen, int minrandval, int maxrandval)
static SCIP_DECL_SORTPTRCOMP(SCIPvarcolComp)
#define SCIPfreeBufferArray(scip, ptr)
void SCIPheurSetData(SCIP_HEUR *heur, SCIP_HEURDATA *heurdata)
#define SCIPallocBlockMemory(scip, ptr)
SCIP_RETCODE SCIPgetLPColsData(SCIP *scip, SCIP_COL ***cols, int *ncols)
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
SCIP_RETCODE SCIPaddIntParam(SCIP *scip, const char *name, const char *desc, int *valueptr, SCIP_Bool isadvanced, int defaultvalue, int minvalue, int maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
static SCIP_DECL_HEURINITSOL(heurInitsolTwoopt)
SCIP_Real SCIPfeasFloor(SCIP *scip, SCIP_Real val)
static SCIP_DECL_HEURINIT(heurInitTwoopt)
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
#define SCIPduplicateBlockMemoryArray(scip, ptr, source, num)
static SCIP_DECL_HEUREXIT(heurExitTwoopt)
SCIP_RETCODE SCIPcreateSolCopy(SCIP *scip, SCIP_SOL **sol, SCIP_SOL *sourcesol)
SCIP_Real SCIPgetVarUbDive(SCIP *scip, SCIP_VAR *var)
static SCIP_RETCODE presolveTwoOpt(SCIP *scip, SCIP_HEUR *heur, SCIP_HEURDATA *heurdata)
SCIP_RETCODE SCIPsetHeurInitsol(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURINITSOL((*heurinitsol)))
const char * SCIPheurGetName(SCIP_HEUR *heur)
SCIP_RETCODE SCIPsolveDiveLP(SCIP *scip, int itlim, SCIP_Bool *lperror, SCIP_Bool *cutoff)
SCIP_RETCODE SCIPsetHeurFree(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURFREE((*heurfree)))
SCIP_ROW ** SCIPcolGetRows(SCIP_COL *col)
SCIP_Bool SCIProwIsLocal(SCIP_ROW *row)
static SCIP_DECL_HEUREXEC(heurExecTwoopt)
const char * SCIPvarGetName(SCIP_VAR *var)
SCIP_HEUR * SCIPsolGetHeur(SCIP_SOL *sol)
int SCIPgetNLPRows(SCIP *scip)
static int varColCompare(SCIP_VAR *var1, SCIP_VAR *var2)
void SCIPsortPtr(void **ptrarray, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), int len)
SCIP_Bool SCIPisFeasGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisFeasLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Real SCIProwGetRhs(SCIP_ROW *row)
SCIP_Bool SCIPhasCurrentNodeLP(SCIP *scip)
#define SCIPallocBufferArray(scip, ptr, num)
SCIP_RETCODE SCIPsetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real val)
public data structures and miscellaneous methods
SCIP_LPSOLSTAT SCIPgetLPSolstat(SCIP *scip)
#define DEFAULT_ARRAYSIZE
SCIP_Longint SCIPsolGetNodenum(SCIP_SOL *sol)
SCIP_RETCODE SCIPchgVarUbDive(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
void SCIPsolSetHeur(SCIP_SOL *sol, SCIP_HEUR *heur)
static SCIP_RETCODE innerPresolve(SCIP *scip, SCIP_VAR **vars, SCIP_VAR ***varspointer, int nvars, int *nblocks, int *maxblocksize, int *nblockvars, int **blockstart, int **blockend, SCIP_HEUR *heur, SCIP_HEURDATA *heurdata)
SCIP_RETCODE SCIPfreeSol(SCIP *scip, SCIP_SOL **sol)
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
SCIP_COL * SCIPvarGetCol(SCIP_VAR *var)
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
SCIP_Real SCIPgetRowSolActivity(SCIP *scip, SCIP_ROW *row, SCIP_SOL *sol)
SCIP_RETCODE SCIPtrySol(SCIP *scip, SCIP_SOL *sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
int SCIPgetNBinVars(SCIP *scip)
#define DEFAULT_MATCHINGRATE
int SCIPgetNVars(SCIP *scip)
static SCIP_DECL_HEURCOPY(heurCopyTwoopt)
SCIP_RETCODE SCIPincludeHeurTwoopt(SCIP *scip)
int SCIPcolGetNNonz(SCIP_COL *col)
SCIP_SOL * SCIPgetBestSol(SCIP *scip)
static void disposeVariable(SCIP_VAR **vars, int *blockend, int varindex)
SCIP_RETCODE SCIPsetHeurInit(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURINIT((*heurinit)))
SCIP_VAR ** SCIPgetVars(SCIP *scip)
SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
int SCIProwGetLPPos(SCIP_ROW *row)
SCIP_RETCODE SCIPprintRow(SCIP *scip, SCIP_ROW *row, FILE *file)
SCIP_Real SCIPgetVarLbDive(SCIP *scip, SCIP_VAR *var)
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
SCIP_RETCODE SCIPstartDive(SCIP *scip)
int SCIProwGetIndex(SCIP_ROW *row)
SCIP_Bool SCIPisZero(SCIP *scip, SCIP_Real val)
SCIP_RETCODE SCIPsetHeurCopy(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURCOPY((*heurcopy)))
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
SCIP_Bool SCIPisFeasIntegral(SCIP *scip, SCIP_Real val)
void SCIPcolSort(SCIP_COL *col)
SCIP_RETCODE SCIPgetLPRowsData(SCIP *scip, SCIP_ROW ***rows, int *nrows)
SCIP_RETCODE SCIPendDive(SCIP *scip)
SCIP_HEURDATA * SCIPheurGetData(SCIP_HEUR *heur)
SCIP_Longint SCIPgetNNodes(SCIP *scip)
static SCIP_DECL_HEUREXITSOL(heurExitsolTwoopt)
SCIP_Bool SCIPvarIsIntegral(SCIP_VAR *var)
SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
int SCIPsolGetIndex(SCIP_SOL *sol)
SCIP_RETCODE SCIPaddRealParam(SCIP *scip, const char *name, const char *desc, SCIP_Real *valueptr, SCIP_Bool isadvanced, SCIP_Real defaultvalue, SCIP_Real minvalue, SCIP_Real maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
static SCIP_Bool checkConstraintMatching(SCIP *scip, SCIP_VAR *var1, SCIP_VAR *var2, SCIP_Real matchingrate)
SCIP_RETCODE SCIPaddBoolParam(SCIP *scip, const char *name, const char *desc, SCIP_Bool *valueptr, SCIP_Bool isadvanced, SCIP_Bool defaultvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
static SCIP_Real determineBound(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *master, DIRECTION masterdirection, SCIP_VAR *slave, DIRECTION slavedirection, SCIP_Real *activities, int nrows)
#define SCIPreallocBufferArray(scip, ptr, num)
SCIP_RETCODE SCIPprintSol(SCIP *scip, SCIP_SOL *sol, FILE *file, SCIP_Bool printzeros)