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);
436 assert(nslaverows == 0 || slavecolvals !=
NULL);
437 assert(nmasterrows == 0 || mastercolvals !=
NULL);
439 SCIPdebugMsg(scip,
" Master: %s with direction %d and %d rows, Slave: %s with direction %d and %d rows \n",
SCIPvarGetName(master),
440 (
int)masterdirection, nmasterrows,
SCIPvarGetName(slave), (
int)slavedirection, nslaverows);
474 slaveincrement =
FALSE;
480 slaveindex = INT_MAX;
482 if( j < nmasterrows )
485 masterindex = INT_MAX;
487 assert(0 <= slaveindex && 0 <= masterindex);
489 assert(slaveindex < INT_MAX || masterindex < INT_MAX);
492 if( slaveindex <= masterindex )
496 slaveincrement =
TRUE;
497 masterincrement = (slaveindex == masterindex);
501 assert(j < nmasterrows);
505 masterincrement =
TRUE;
514 if( slaveindex <= masterindex )
515 effect += (slavecolvals[i] * (int)slavedirection);
516 if( masterindex <= slaveindex )
517 effect += (mastercolvals[j] * (int)masterdirection);
527 assert(rowpos < nrows);
529 activity = activities[rowpos];
539 SCIPdebugMsg(scip,
" %g <= %g <= %g, bound = %g, effect = %g (%g * %d + %g * %d) (i=%d,j=%d)\n", lhs, activity, rhs,
bound, effect,
540 slaveindex <= masterindex ? slavecolvals[i] : 0.0, (
int)slavedirection, masterindex <= slaveindex ? mastercolvals[j] : 0.0,
541 (
int)masterdirection, i, j);
551 bound =
MIN(bound - 1.0, newval);
562 bound =
MIN(bound - 1.0, newval);
570 SCIPdebugMsg(scip,
" Zero effect on row %s, effect %g, master coeff: %g slave coeff: %g (i=%d, j=%d)\n",
571 SCIProwGetName(row), effect, mastercolvals[j], slavecolvals[i], i, j);
583 if( masterincrement )
606 assert(blockend !=
NULL);
607 assert(varindex <= *blockend);
609 vars[varindex] = vars[*blockend];
632 assert(scip !=
NULL);
633 assert(vars !=
NULL);
635 assert(nblocks !=
NULL);
636 assert(nblockvars !=
NULL);
637 assert(blockstart !=
NULL);
638 assert(blockend !=
NULL);
639 assert(heur !=
NULL);
640 assert(heurdata !=
NULL);
646 SCIPsortPtr((
void**)(*varspointer), SCIPvarcolComp, nvars);
659 for( v = 1; v < nvars; ++v )
665 if( v - startindex >= 2 )
667 assert(*nblocks < nvars/2);
668 (*nblockvars) += v - startindex;
669 (*maxblocksize) =
MAX((*maxblocksize), v - startindex);
670 (*blockstart)[*nblocks] = startindex;
671 (*blockend)[*nblocks] = v - 1;
676 else if( v == nvars - 1 && v - startindex >= 1 )
678 assert(*nblocks < nvars/2);
679 (*nblockvars) += v - startindex + 1;
680 (*maxblocksize) =
MAX((*maxblocksize), v - startindex + 1);
681 (*blockstart)[*nblocks] = startindex;
682 (*blockend)[*nblocks] = v;
724 int nbinblockvars = 0;
726 int maxbinblocksize = 0;
729 assert(scip !=
NULL);
730 assert(heurdata !=
NULL);
733 if( heurdata->presolved )
743 SCIP_CALL(
innerPresolve(scip, vars, &(heurdata->binvars), nbinvars, &(heurdata->nbinblocks), &maxbinblocksize,
744 &nbinblockvars, &(heurdata->binblockstart), &(heurdata->binblockend), heur, heurdata) );
747 heurdata->nbinvars = nbinvars;
748 heurdata->execute = nbinvars > 1 && heurdata->nbinblocks > 0;
750 #ifdef SCIP_STATISTIC 752 heurdata->binnblocks += (heurdata->nbinblocks);
753 heurdata->binnblockvars += nbinblockvars;
754 heurdata->ntotalbinvars += nbinvars;
755 heurdata->maxbinblocksize =
MAX(maxbinblocksize, heurdata->maxbinblocksize);
757 SCIPstatisticMessage(
" Twoopt BINARY presolving finished with <%d> blocks, <%d> block variables \n",
758 heurdata->nbinblocks, nbinblockvars);
761 if( heurdata->intopt && nintvars > 1 )
763 SCIP_CALL(
innerPresolve(scip, &(vars[nbinvars]), &(heurdata->intvars), nintvars, &(heurdata->nintblocks), &maxintblocksize,
764 &nintblockvars, &(heurdata->intblockstart), &(heurdata->intblockend),
767 heurdata->execute = heurdata->execute || heurdata->nintblocks > 0;
769 #ifdef SCIP_STATISTIC 771 heurdata->intnblocks += heurdata->nintblocks;
772 heurdata->intnblockvars += nintblockvars;
773 heurdata->ntotalintvars += nintvars;
774 heurdata->maxintblocksize =
MAX(maxintblocksize, heurdata->maxintblocksize);
775 SCIPstatisticMessage(
" Twoopt Integer presolving finished with <%d> blocks, <%d> block variables \n",
776 heurdata->nintblocks, nintblockvars);
780 heurdata->nintvars = nintvars;
783 heurdata->presolved =
TRUE;
797 assert(scip !=
NULL);
798 assert(heur !=
NULL);
813 assert(heur !=
NULL);
815 assert(scip !=
NULL);
819 assert(heurdata !=
NULL);
832 assert(heur !=
NULL);
834 assert(scip !=
NULL);
837 assert(heurdata !=
NULL);
840 heurdata->nbinvars = 0;
841 heurdata->nintvars = 0;
842 heurdata->lastsolindex = -1;
843 heurdata->presolved =
FALSE;
844 heurdata->nbinblocks = 0;
845 heurdata->nintblocks = 0;
851 #ifdef SCIP_STATISTIC 853 heurdata->binnexchanges = 0;
854 heurdata->intnexchanges = 0;
855 heurdata->binnblockvars = 0;
856 heurdata->intnblockvars = 0;
857 heurdata->binnblocks = 0;
858 heurdata->intnblocks = 0;
860 heurdata->maxbinblocksize = 0;
861 heurdata->maxintblocksize = 0;
863 heurdata->ntotalbinvars = 0;
864 heurdata->ntotalintvars = 0;
873 heurdata->binvars =
NULL;
874 heurdata->intvars =
NULL;
875 heurdata->binblockstart =
NULL;
876 heurdata->binblockend =
NULL;
877 heurdata->intblockstart =
NULL;
878 heurdata->intblockend =
NULL;
912 assert(scip !=
NULL);
914 assert(blockstart !=
NULL && blockend !=
NULL);
915 assert(varboundserr !=
NULL);
916 assert(activities !=
NULL);
917 assert(worksol !=
NULL);
918 assert(improvement !=
NULL);
920 *varboundserr =
FALSE;
929 for( b = 0; b < nblocks; ++b )
934 blocklen = blockend[b] - blockstart[b] + 1;
937 for( m = 0; m < blocklen; ++m )
953 master = vars[blockstart[b] + m];
961 *varboundserr =
TRUE;
962 SCIPdebugMsg(scip,
"Solution has violated variable bounds for var %s: %g <= %g <= %g \n",
982 bestimprovement = 0.0;
990 if( heurdata->maxnslaves >= 0 && blocklen > heurdata->maxnslaves )
991 firstslave =
SCIPrandomGetInt(heurdata->randnumgen, blockstart[b] + m, blockend[b]);
993 firstslave = blockstart[b] + m + 1;
995 nslaves =
MIN((heurdata->maxnslaves == -1 ? INT_MAX : heurdata->maxnslaves), blocklen);
1000 for( s = 0; s < nslaves; ++s )
1011 slaveindex = (firstslave + s - blockstart[b]) % blocklen;
1012 slaveindex += blockstart[b];
1015 if( (blocklen <= heurdata->maxnslaves || heurdata->maxnslaves == -1) && slaveindex < blockstart[b] + m )
1018 if( slaveindex == blockstart[b] + m )
1022 slave = vars[slaveindex];
1034 *varboundserr =
TRUE;
1035 SCIPdebugMsg(scip,
"Solution has violated variable bounds for var %s: %g <= %g <= %g \n",
1058 equaldirbound = 0.0;
1065 changedobj = (masterobj - slaveobj) * diffdirbound;
1067 else if(
SCIPisFeasGT(scip, masterobj - slaveobj, 0.0) )
1071 changedobj = (slaveobj - masterobj) * diffdirbound;
1077 if(
SCIPisFeasLT(scip, (slaveobj + masterobj) * equaldirbound, changedobj) )
1079 changedobj = (slaveobj + masterobj) * equaldirbound;
1083 else if(
SCIPisFeasGT(scip, masterobj + slaveobj, 0.0) )
1086 if(
SCIPisFeasLT(scip, -(slaveobj + masterobj) * equaldirbound, changedobj) )
1088 changedobj = -(slaveobj + masterobj) * equaldirbound;
1101 bestimprovement = changedobj;
1102 bestslavepos = slaveindex;
1103 bestdirection = directions;
1109 if( directions / 2 == 1 )
1114 if( directions % 2 == 1 )
1119 if( bestmasterdir == bestslavedir )
1120 bestbound = equaldirbound;
1122 bestbound = diffdirbound;
1127 if( bestslavepos >= 0 )
1129 if( npairs == arraysize )
1135 arraysize = 2 * arraysize;
1137 assert( npairs < arraysize );
1139 bestmasters[npairs] = master;
1140 bestslaves[npairs] = vars[bestslavepos];
1141 objchanges[npairs] = ((int)bestslavedir *
SCIPvarGetObj(bestslaves[npairs]) + (int)bestmasterdir * masterobj) * bestbound;
1142 bestdirections[npairs] = bestdirection;
1144 assert(objchanges[npairs] < 0);
1146 SCIPdebugMsg(scip,
" Saved candidate pair {%s=%g, %s=%g} with objectives <%g>, <%g> to be set to {%g, %g} %d\n",
1148 masterobj,
SCIPvarGetObj(bestslaves[npairs]), mastersolval + (
int)bestmasterdir * bestbound,
SCIPgetSolVal(scip, worksol, bestslaves[npairs])
1149 + (
int)bestslavedir * bestbound, bestdirections[npairs]);
1161 for( b = 0; b < npairs; ++b )
1173 master = bestmasters[b];
1174 slave = bestslaves[b];
1180 assert(0 <= bestdirections[b] && bestdirections[b] < 4);
1182 if( bestdirections[b] / 2 == 1 )
1187 if( bestdirections[b] % 2 == 1 )
1192 bound =
determineBound(scip, worksol, master, masterdir, slave, slavedir, activities, nrows);
1201 SCIPdebugMsg(scip,
" Promising candidates {%s=%g, %s=%g} with objectives <%g>, <%g> to be set to {%g, %g}\n",
1203 masterobj, slaveobj, mastersolval + (
int)masterdir * bound, slavesolval + (
int)slavedir * bound);
1207 changedobj = ((int)slavedir * slaveobj + (
int)masterdir * masterobj) * bound;
1214 SCIP_CALL(
shiftValues(scip, master, slave, mastersolval, masterdir, slavesolval, slavedir, bound,
1215 activities, nrows, &feasible) );
1225 SCIPdebugMsg(scip,
" Feasible shift: <%s>[%g, %g] (obj: %f) <%f> --> <%f>\n",
1227 SCIPdebugMsg(scip,
" <%s>[%g, %g] (obj: %f) <%f> --> <%f>\n",
1230 #ifdef SCIP_STATISTIC 1233 ++(heurdata->binnexchanges);
1235 ++(heurdata->intnexchanges);
1238 *improvement =
TRUE;
1258 assert(heurdata !=
NULL);
1261 assert(heurdata->nbinvars <= 1 || heurdata->binvars !=
NULL);
1263 #ifdef SCIP_STATISTIC 1266 " Twoopt Binary Statistics : " 1267 "%6.2g %6.2g %4.2g %4.0g %6d (blocks/run, variables/run, varpercentage, avg. block size, max block size) \n",
1268 heurdata->nruns == 0 ? 0.0 : (
SCIP_Real)heurdata->binnblocks/(heurdata->nruns),
1269 heurdata->nruns == 0 ? 0.0 : (
SCIP_Real)heurdata->binnblockvars/(heurdata->nruns),
1270 heurdata->ntotalbinvars == 0 ? 0.0 : (
SCIP_Real)heurdata->binnblockvars/(heurdata->ntotalbinvars) * 100.0,
1271 heurdata->binnblocks == 0 ? 0.0 : heurdata->binnblockvars/(
SCIP_Real)(heurdata->binnblocks),
1272 heurdata->maxbinblocksize);
1275 " Twoopt Integer statistics : " 1276 "%6.2g %6.2g %4.2g %4.0g %6d (blocks/run, variables/run, varpercentage, avg block size, max block size) \n",
1277 heurdata->nruns == 0 ? 0.0 : (
SCIP_Real)heurdata->intnblocks/(heurdata->nruns),
1278 heurdata->nruns == 0 ? 0.0 : (
SCIP_Real)heurdata->intnblockvars/(heurdata->nruns),
1279 heurdata->ntotalintvars == 0 ? 0.0 : (
SCIP_Real)heurdata->intnblockvars/(heurdata->ntotalintvars) * 100.0,
1280 heurdata->intnblocks == 0 ? 0.0 : heurdata->intnblockvars/(
SCIP_Real)(heurdata->intnblocks),
1281 heurdata->maxintblocksize);
1284 " Twoopt results : " 1285 "%6d %6d %4d %4.2g (runs, binary exchanges, Integer shiftings, matching rate)\n",
1287 heurdata->binnexchanges,
1288 heurdata->intnexchanges,
1289 heurdata->matchingrate);
1292 heurdata->binnblockvars = 0;
1293 heurdata->binnblocks = 0;
1294 heurdata->intnblocks = 0;
1295 heurdata->intnblockvars = 0;
1296 heurdata->binnexchanges = 0;
1297 heurdata->intnexchanges = 0;
1301 if( heurdata->binvars !=
NULL )
1306 if( heurdata->nbinblocks > 0 )
1308 assert(heurdata->binblockstart !=
NULL);
1309 assert(heurdata->binblockend !=
NULL);
1314 heurdata->nbinvars = 0;
1315 heurdata->nbinblocks = 0;
1317 if( heurdata->nintblocks > 0 )
1319 assert(heurdata->intblockstart !=
NULL);
1320 assert(heurdata->intblockend !=
NULL);
1327 if( heurdata->intvars !=
NULL )
1332 heurdata->nbinblocks = 0;
1333 heurdata->nintblocks = 0;
1334 heurdata->nbinvars = 0;
1335 heurdata->nintvars = 0;
1337 assert(heurdata->binvars ==
NULL);
1338 assert(heurdata->intvars ==
NULL);
1353 assert(heur !=
NULL);
1355 assert(scip !=
NULL);
1360 assert(heurdata !=
NULL);
1361 assert(heurdata->binvars ==
NULL && heurdata->intvars ==
NULL);
1362 assert(heurdata->binblockstart ==
NULL && heurdata->binblockend ==
NULL);
1363 assert(heurdata->intblockstart ==
NULL && heurdata->intblockend ==
NULL);
1366 heurdata->nbinvars = 0;
1367 heurdata->nintvars = 0;
1368 heurdata->lastsolindex = -1;
1369 heurdata->presolved =
FALSE;
1371 #ifdef SCIP_STATISTIC 1372 ++(heurdata->nruns);
1389 assert(heur !=
NULL);
1390 assert(scip !=
NULL);
1392 assert(scip !=
NULL);
1397 assert(heurdata !=
NULL);
1399 nbinvars = heurdata->nbinvars;
1400 nintvars = heurdata->nintvars;
1403 if( heurdata->binvars !=
NULL )
1407 if( heurdata->binblockstart !=
NULL )
1409 assert(heurdata->binblockend !=
NULL);
1414 heurdata->nbinvars = 0;
1415 heurdata->nbinblocks = 0;
1417 if( heurdata->intblockstart !=
NULL )
1419 assert(heurdata->intblockend !=
NULL);
1424 heurdata->nintblocks = 0;
1427 if( heurdata->intvars !=
NULL )
1432 heurdata->nintvars = 0;
1434 assert(heurdata->binvars ==
NULL && heurdata->intvars ==
NULL);
1435 assert(heurdata->binblockstart ==
NULL && heurdata->binblockend ==
NULL);
1436 assert(heurdata->intblockstart ==
NULL && heurdata->intblockend ==
NULL);
1460 int ncolsforsorting;
1465 assert(heur !=
NULL);
1466 assert(scip !=
NULL);
1467 assert(result !=
NULL);
1471 assert(heurdata !=
NULL);
1499 presolthiscall =
FALSE;
1502 ncolsforsorting =
MIN(ncols, ndiscvars);
1505 if( !heurdata->presolved )
1509 for( i = 0; i < ncolsforsorting; ++i )
1513 presolthiscall =
TRUE;
1516 assert(heurdata->presolved);
1518 SCIPdebugMsg(scip,
" Twoopt heuristic is %sexecuting.\n", heurdata->execute ?
"" :
"not ");
1521 if( !heurdata->execute )
1524 nbinvars = heurdata->nbinvars;
1525 nintvars = heurdata->nintvars;
1526 ndiscvars = nbinvars + nintvars;
1546 for( i = 0; i < nlprows; i++ )
1551 assert(row !=
NULL);
1565 if( !presolthiscall )
1567 for( i = 0; i < ncolsforsorting; ++i )
1570 SCIPdebugMsg(scip,
" Twoopt heuristic has initialized activities and sorted rows! \n");
1573 improvement =
FALSE;
1574 varboundserr =
FALSE;
1576 if( heurdata->nbinblocks > 0 )
1578 SCIP_CALL(
optimize(scip, worksol, heurdata->binvars, heurdata->binblockstart, heurdata->binblockend, heurdata->nbinblocks,
1579 OPTTYPE_BINARY, activities, nlprows, &improvement, &varboundserr, heurdata) );
1581 SCIPdebugMsg(scip,
" Binary Optimization finished!\n");
1590 if( heurdata->nintblocks > 0 )
1592 assert(heurdata->intopt);
1593 SCIP_CALL(
optimize(scip, worksol, heurdata->intvars, heurdata->intblockstart, heurdata->intblockend, heurdata->nintblocks,
1594 OPTTYPE_INTEGER, activities, nlprows, &improvement, &varboundserr, heurdata) );
1596 SCIPdebugMsg(scip,
" Integer Optimization finished!\n");
1599 if( ! improvement || varboundserr )
1615 SCIPdebugMsg(scip,
"found feasible shifted solution:\n");
1620 #ifdef SCIP_STATISTIC 1635 SCIPdebugMsg(scip,
"shifted solution should be feasible -> solve LP to fix continuous variables to best values\n");
1642 SCIPdebugMsg(scip,
" Cont. variable <%s>, status %d with bounds [%g <= %g <= x <= %g <= %g]\n",
1662 for( i = 0; i < ndiscvars; ++i )
1676 for( i = 0; i < ndiscvars; ++i )
1689 SCIPwarningMessage(scip,
"Error while solving LP in Twoopt heuristic; LP solve terminated with code <%d>\n",retstat);
1715 SCIPdebugMsg(scip,
"found feasible shifted solution:\n");
1720 #ifdef SCIP_STATISTIC 1732 SCIPdebugMsg(scip,
"Termination of Twoopt heuristic\n");
1759 assert(heur !=
NULL);
1775 "nodes to wait after last best solution before calling heuristic",
1779 SCIP_CALL(
SCIPaddIntParam(scip,
"heuristics/twoopt/maxnslaves",
"maximum number of slaves for one master variable",
1784 "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)))
#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)
SCIP_RETCODE SCIPrandomCreate(SCIP_RANDNUMGEN **randnumgen, BMS_BLKMEM *blkmem, unsigned int initialseed)
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_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)
void SCIPrandomFree(SCIP_RANDNUMGEN **randnumgen)
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)
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
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)
unsigned int SCIPinitializeRandomSeed(SCIP *scip, int initialseedvalue)
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)