25 #if defined(_WIN32) || defined(_WIN64) 32 #define HEUR_NAME "alns" 33 #define HEUR_DESC "Large neighborhood search heuristic that orchestrates the popular neighborhoods Local Branching, RINS, RENS, DINS etc." 34 #define HEUR_DISPCHAR 'L' 35 #define HEUR_PRIORITY -1100500 37 #define HEUR_FREQOFS 0 38 #define HEUR_MAXDEPTH -1 39 #define HEUR_TIMING SCIP_HEURTIMING_AFTERNODE 40 #define HEUR_USESSUBSCIP TRUE 42 #define NNEIGHBORHOODS 8 47 #define DEFAULT_NODESQUOT 0.1 48 #define DEFAULT_NODESOFFSET 500LL 49 #define DEFAULT_NSOLSLIM 3 50 #define DEFAULT_MINNODES 50LL 51 #define DEFAULT_MAXNODES 5000LL 52 #define DEFAULT_WAITINGNODES 25LL 53 #define DEFAULT_TARGETNODEFACTOR 1.5 54 #define DEFAULT_STALLNODEFACTOR 0.25 60 #define DEFAULT_MINIMPROVELOW 0.0001 61 #define DEFAULT_MINIMPROVEHIGH 0.1 62 #define MINIMPROVEFAC 1.5 63 #define DEFAULT_STARTMINIMPROVE 0.05 64 #define DEFAULT_ADJUSTMINIMPROVE TRUE 69 #define DEFAULT_BESTSOLWEIGHT 1 70 #define DEFAULT_BANDITALGO 'u' 71 #define DEFAULT_GAMMA 0.2 72 #define DEFAULT_BETA 0.0 73 #define DEFAULT_REWARDCONTROL 0.8 74 #define DEFAULT_SCALEBYEFFORT TRUE 75 #define DEFAULT_EPS 0.5 76 #define DEFAULT_RESETWEIGHTS TRUE 77 #define DEFAULT_SUBSCIPRANDSEEDS FALSE 78 #define DEFAULT_ALPHA 0.2 79 #define DEFAULT_REWARDBASELINE 0.5 80 #define DEFAULT_FIXTOL 0.1 81 #define DEFAULT_USELOCALREDCOST FALSE 86 #define DEFAULT_USEREDCOST TRUE 87 #define DEFAULT_USEPSCOST TRUE 88 #define DEFAULT_USEDISTANCES TRUE 89 #define DEFAULT_DOMOREFIXINGS TRUE 91 #define DEFAULT_ADJUSTFIXINGRATE TRUE 92 #define FIXINGRATE_DECAY 0.75 93 #define FIXINGRATE_STARTINC 0.2 94 #define DEFAULT_USESUBSCIPHEURS FALSE 95 #define DEFAULT_COPYCUTS FALSE 96 #define DEFAULT_REWARDFILENAME "-" 99 #define DEFAULT_SEED 113 100 #define MUTATIONSEED 121 101 #define CROSSOVERSEED 321 104 #define DEFAULT_MINFIXINGRATE_RENS 0.3 105 #define DEFAULT_MAXFIXINGRATE_RENS 0.7 106 #define DEFAULT_ACTIVE_RENS TRUE 107 #define DEFAULT_PRIORITY_RENS 1.0 109 #define DEFAULT_MINFIXINGRATE_RINS 0.2 110 #define DEFAULT_MAXFIXINGRATE_RINS 0.6 111 #define DEFAULT_ACTIVE_RINS TRUE 112 #define DEFAULT_PRIORITY_RINS 1.0 114 #define DEFAULT_MINFIXINGRATE_MUTATION 0.4 115 #define DEFAULT_MAXFIXINGRATE_MUTATION 0.9 116 #define DEFAULT_ACTIVE_MUTATION TRUE 117 #define DEFAULT_PRIORITY_MUTATION 1.0 119 #define DEFAULT_MINFIXINGRATE_LOCALBRANCHING 0.0 120 #define DEFAULT_MAXFIXINGRATE_LOCALBRANCHING 0.9 121 #define DEFAULT_ACTIVE_LOCALBRANCHING TRUE 122 #define DEFAULT_PRIORITY_LOCALBRANCHING 1.0 124 #define DEFAULT_MINFIXINGRATE_PROXIMITY 0.0 125 #define DEFAULT_MAXFIXINGRATE_PROXIMITY 0.9 126 #define DEFAULT_ACTIVE_PROXIMITY TRUE 127 #define DEFAULT_PRIORITY_PROXIMITY 1.0 129 #define DEFAULT_MINFIXINGRATE_CROSSOVER 0.4 130 #define DEFAULT_MAXFIXINGRATE_CROSSOVER 0.9 131 #define DEFAULT_ACTIVE_CROSSOVER TRUE 132 #define DEFAULT_PRIORITY_CROSSOVER 1.0 134 #define DEFAULT_MINFIXINGRATE_ZEROOBJECTIVE 0.0 135 #define DEFAULT_MAXFIXINGRATE_ZEROOBJECTIVE 0.9 136 #define DEFAULT_ACTIVE_ZEROOBJECTIVE TRUE 137 #define DEFAULT_PRIORITY_ZEROOBJECTIVE 1.0 139 #define DEFAULT_MINFIXINGRATE_DINS 0.1 140 #define DEFAULT_MAXFIXINGRATE_DINS 0.5 141 #define DEFAULT_ACTIVE_DINS TRUE 142 #define DEFAULT_PRIORITY_DINS 1.0 144 #define DEFAULT_NSOLS_CROSSOVER 2 145 #define DEFAULT_NPOOLSOLS_DINS 5 148 #define EVENTHDLR_NAME "Alns" 149 #define EVENTHDLR_DESC "LP event handler for " HEUR_NAME " heuristic" 150 #define SCIP_EVENTTYPE_ALNS (SCIP_EVENTTYPE_LPSOLVED | SCIP_EVENTTYPE_SOLFOUND | SCIP_EVENTTYPE_BESTSOLFOUND) 153 #define TABLE_NAME_NEIGHBORHOOD "neighborhood" 154 #define TABLE_DESC_NEIGHBORHOOD "ALNS neighborhood statistics" 155 #define TABLE_POSITION_NEIGHBORHOOD 12500 156 #define TABLE_EARLIEST_STAGE_NEIGHBORHOOD SCIP_STAGE_TRANSFORMED 177 typedef struct Nh NH;
186 #define DECL_VARFIXINGS(x) SCIP_RETCODE x ( \ 192 SCIP_RESULT* result \ 203 #define DECL_CHANGESUBSCIP(x) SCIP_RETCODE x ( \ 206 SCIP_VAR** subvars, \ 214 #define DECL_NHINIT(x) SCIP_RETCODE x ( \ 220 #define DECL_NHEXIT(x) SCIP_RETCODE x ( \ 226 #define DECL_NHFREE(x) SCIP_RETCODE x ( \ 239 #define DECL_NHREFSOL(x) SCIP_RETCODE x ( \ 243 SCIP_RESULT* result \ 247 #define DECL_NHDEACTIVATE(x) SCIP_RETCODE x (\ 249 SCIP_Bool* deactivate \ 264 #define NHISTENTRIES 7 340 char* rewardfilename;
365 int nactiveneighborhoods;
366 int ninitneighborhoods;
369 int currneighborhood;
388 struct SCIP_EventData
418 unsigned int useredcost:1;
419 unsigned int usedistances:1;
420 unsigned int usepscost:1;
434 assert(scip != NULL);
435 assert(fixingrate != NULL);
450 assert(heurdata != NULL);
451 heurdata->currneighborhood = -1;
452 heurdata->ndelayedcalls = 0;
507 switch (subscipstatus) {
542 heurdata->targetnodes = (
SCIP_Longint)(heurdata->targetnodes * heurdata->targetnodefactor);
543 heurdata->targetnodes = MIN(heurdata->targetnodes, heurdata->maxnodes);
552 heurdata->targetnodes = (
SCIP_Longint)(heurdata->targetnodes / heurdata->targetnodefactor);
553 heurdata->targetnodes =
MAX(heurdata->targetnodes, heurdata->minnodes);
562 heurdata->targetnodes = heurdata->minnodes;
573 switch (subscipstatus) {
608 assert(heurdata != NULL);
609 heurdata->minimprove = heurdata->startminimprove;
618 assert(heurdata != NULL);
621 heurdata->minimprove = MIN(heurdata->minimprove, heurdata->minimprovehigh);
630 assert(heurdata != NULL);
634 heurdata->minimprove =
MAX(heurdata->minimprove, heurdata->minimprovelow);
645 assert(heurdata != NULL);
652 switch (subscipstatus) {
691 assert(scip != NULL);
692 assert(stats != NULL);
731 assert(scip != NULL);
732 assert(heurdata != NULL);
733 assert(neighborhood != NULL);
734 assert(name != NULL);
737 assert(*neighborhood != NULL);
744 (*neighborhood)->changesubscip = changesubscip;
745 (*neighborhood)->varfixings = varfixings;
746 (*neighborhood)->nhinit = nhinit;
747 (*neighborhood)->nhexit = nhexit;
748 (*neighborhood)->nhfree = nhfree;
749 (*neighborhood)->nhrefsol = nhrefsol;
750 (*neighborhood)->nhdeactivate = nhdeactivate;
755 &(*neighborhood)->fixingrate.minfixingrate,
TRUE, minfixingrate, 0.0, 1.0, NULL, NULL) );
758 &(*neighborhood)->fixingrate.maxfixingrate,
TRUE, maxfixingrate, 0.0, 1.0, NULL, NULL) );
761 &(*neighborhood)->active,
TRUE,
active, NULL, NULL) );
764 &(*neighborhood)->priority,
TRUE, priority, 1e-2, 1.0, NULL, NULL) );
767 heurdata->neighborhoods[heurdata->nneighborhoods++] = (*neighborhood);
780 assert(scip != NULL);
781 assert(neighborhood != NULL);
783 nhptr = *neighborhood;
784 assert(nhptr != NULL);
789 if( nhptr->nhfree != NULL )
798 *neighborhood = NULL;
810 assert(scip != NULL);
811 assert(neighborhood != NULL);
814 if( neighborhood->nhinit != NULL )
816 SCIP_CALL( neighborhood->nhinit(scip, neighborhood) );
829 assert(scip != NULL);
830 assert(neighborhood != NULL);
832 if( neighborhood->nhexit != NULL )
834 SCIP_CALL( neighborhood->nhexit(scip, neighborhood) );
859 assert(subscip != NULL);
862 assert(subsol != NULL);
864 sourcescip = eventdata->sourcescip;
865 subvars = eventdata->subvars;
866 heur = eventdata->heur;
867 runstats = eventdata->runstats;
868 assert(sourcescip != NULL);
869 assert(sourcescip != subscip);
870 assert(heur != NULL);
871 assert(subvars != NULL);
872 assert(runstats != NULL);
895 if( eventdata->allrewardsmode )
936 assert(eventhdlr != NULL);
937 assert(eventdata != NULL);
939 assert(event != NULL);
941 assert(eventdata != NULL);
953 if(
SCIPgetNLPs(scip) > eventdata->lplimfac * eventdata->nodelimit )
1001 switch (subscipstatus)
1032 SCIPinfoMessage(scip, file,
"Neighborhoods : %10s %10s %10s %10s %10s %10s %10s %10s %10s %10s %4s %4s %4s %4s %4s %4s %4s %4s\n",
1033 "Calls",
"SetupTime",
"SolveTime",
"SolveNodes",
"Sols",
"Best",
"Exp3",
"EpsGreedy",
"UCB",
"TgtFixRate",
1034 "Opt",
"Inf",
"Node",
"Stal",
"Sol",
"Usr",
"Othr",
"Actv");
1038 for( i = 0; i < heurdata->nneighborhoods; ++i )
1044 neighborhood = heurdata->neighborhoods[i];
1055 epsgreedyweight = -1.0;
1057 if( heurdata->bandit != NULL && i < heurdata->nactiveneighborhoods )
1059 switch (heurdata->banditalgo) {
1083 SCIPinfoMessage(scip, file,
" %4d", i < heurdata->nactiveneighborhoods ? 1 : 0);
1098 stats = &neighborhood->
stats;
1137 assert(varprio != NULL);
1140 scip = varprio->
scip;
1141 assert(scip != NULL);
1165 else if( dist1 > dist2 )
1217 assert(scip != NULL);
1218 assert(var != NULL);
1224 if( ! uselocalredcost )
1250 score = redcost * (refsolval - bestbound);
1253 if( ! uselocalredcost )
1254 score =
MAX(score, 0.0);
1268 assert(scip != NULL);
1269 assert(var != NULL);
1278 if(
SCIPisEQ(scip, rootsolval, refsolval) )
1325 assert(solptr != NULL);
1326 assert(scip != NULL);
1327 assert(neighborhood != NULL);
1330 if( neighborhood->nhrefsol != NULL )
1333 SCIP_CALL( neighborhood->nhrefsol(scip, neighborhood, solptr, &result) );
1338 assert(*solptr != NULL);
1383 assert(scip != NULL);
1384 assert(varbuf != NULL);
1386 assert(success != NULL);
1387 assert(heurdata != NULL);
1388 assert(refsol != NULL);
1393 if( ! heurdata->domorefixings )
1398 nbinintvars = nbinvars + nintvars;
1400 if( ntargetfixings >= nbinintvars )
1404 nvarstoadd = ntargetfixings - *
nfixings;
1405 if( nvarstoadd == 0 )
1410 varprio.
usepscost = heurdata->usepscost;
1411 varprio.
scip = scip;
1413 assert(rng != NULL);
1442 assert(varbuf[b] != NULL);
1444 assert(probindex >= 0);
1446 if( probindex < nbinintvars )
1447 isfixed[probindex] =
TRUE;
1455 for( b = 0; b < nbinintvars; ++b )
1470 unfixedvars[nunfixedvars] = var;
1471 perm[nunfixedvars] = nunfixedvars;
1476 solvals[nunfixedvars] = solvals[b];
1477 distances[nunfixedvars] = distances[b];
1479 SCIPdebugMsg(scip,
"Var <%s> scores: dist %3d, red cost %15.9g, pscost %15.9g rand %6.4f\n",
1480 SCIPvarGetName(var), distances[nunfixedvars], redcostscores[nunfixedvars],
1481 pscostscores[nunfixedvars], randscores[nunfixedvars]);
1492 nvarstoadd = MIN(nunfixedvars, nvarstoadd);
1495 if( nvarstoadd < nunfixedvars )
1496 SCIPselectInd(perm, sortIndCompAlns, &varprio, nvarstoadd, nunfixedvars);
1499 for( b = 0; b < nvarstoadd; ++b )
1501 int permindex = perm[b];
1502 assert(permindex >= 0);
1503 assert(permindex < nunfixedvars);
1529 unsigned int initseed
1533 switch (heurdata->banditalgo) {
1536 heurdata->ucb_alpha, heurdata->nactiveneighborhoods, initseed) );
1541 heurdata->exp3_gamma, heurdata->exp3_beta, heurdata->nactiveneighborhoods, initseed) );
1546 heurdata->epsgreedy_eps, heurdata->nactiveneighborhoods, initseed) );
1565 assert(scip != NULL);
1566 assert(heur != NULL);
1602 int* fixeddistances;
1612 if( nbinintvars == 0 )
1639 assert(probindex >= 0);
1641 isfixedvar[probindex] =
TRUE;
1647 for( i = 0; i < nbinintvars; ++i )
1649 if( ! isfixedvar[i] )
1650 unfixedvars[nunfixed++] = vars[i];
1653 varprio.
usedistances = heurdata->usedistances && nunfixed > 0;
1663 if( probindex >= 0 )
1664 fixeddistances[i] = distances[probindex];
1685 SCIPdebugMsg(scip,
"Var <%s> scores: dist %3d, red cost %15.9g, pscost %15.9g rand %6.4f\n",
1686 SCIPvarGetName(fixedvar), fixeddistances[i], redcostscores[i], pscostscores[i], randscores[i]);
1694 varprio.
usepscost = heurdata->usepscost;
1695 varprio.
scip = scip;
1701 for( i = 0; i < ntargetfixings; ++i )
1703 valbuf[i] = valbufcpy[perm[i]];
1704 varbuf[i] = varbufcpy[perm[i]];
1740 assert(scip != NULL);
1741 assert(neighborhood != NULL);
1742 assert(varbuf != NULL);
1743 assert(valbuf != NULL);
1745 assert(result != NULL);
1751 if( neighborhood->varfixings != NULL )
1753 SCIP_CALL( neighborhood->varfixings(scip, neighborhood, varbuf, valbuf,
nfixings, result) );
1759 assert(neighborhood->varfixings == NULL || *result !=
SCIP_DIDNOTRUN);
1774 if( refsol != NULL )
1798 SCIPdebugMsg(scip,
"Unfixed variables, fixed variables remaining: %d\n", ntargetfixings);
1802 SCIPdebugMsg(scip,
"No additional fixings performed\n");
1821 assert(sourcescip != NULL);
1822 assert(targetscip != NULL);
1823 assert(neighborhood != NULL);
1824 assert(targetvars != NULL);
1825 assert(ndomchgs != NULL);
1826 assert(nchgobjs != NULL);
1827 assert(naddedconss != NULL);
1828 assert(success != NULL);
1836 if( neighborhood->changesubscip != NULL )
1838 SCIP_CALL( neighborhood->changesubscip(sourcescip, targetscip, targetvars, ndomchgs, nchgobjs, naddedconss, success) );
1855 assert(subscip != NULL);
1856 assert(solvelimits != NULL);
1881 assert(scip != NULL);
1882 assert(heur != NULL);
1883 assert(solvelimits != NULL);
1884 assert(runagain != NULL);
1905 nodesquot = heurdata->nodesquot;
1910 solvelimits->
nodelimit += heurdata->nodesoffset;
1911 solvelimits->
nodelimit -= heurdata->usednodes;
1916 assert(heurdata->ninitneighborhoods >= 0);
1917 initfactor = (heurdata->nactiveneighborhoods - heurdata->ninitneighborhoods + 1.0) / (heurdata->nactiveneighborhoods + 1.0);
1922 if( solvelimits->
nodelimit < heurdata->targetnodes )
1934 assert(heurdata != NULL);
1935 return heurdata->bandit;
1943 int* neighborhoodidx
1947 assert(scip != NULL);
1948 assert(heurdata != NULL);
1949 assert(neighborhoodidx != NULL);
1951 *neighborhoodidx = -1;
1956 assert(*neighborhoodidx >= 0);
1981 assert(rewardptr != NULL);
1988 SCIP_Real rewardcontrol = heurdata->rewardcontrol;
1994 bestsolreward = 1.0;
2001 closedgapreward = 1.0;
2003 closedgapreward = 1.0;
2010 reward = rewardcontrol * bestsolreward + (1.0 - rewardcontrol) * closedgapreward;
2013 if( heurdata->scalebyeffort )
2016 reward /= (effort + 1.0);
2020 reward = heurdata->rewardbaseline + (1.0 - heurdata->rewardbaseline) * reward;
2025 SCIP_Real maxeffort = heurdata->targetnodes * heurdata->stallnodefactor;
2030 reward = heurdata->rewardbaseline - (
usednodes) * heurdata->rewardbaseline / maxeffort;
2033 reward =
MAX(0.0, reward);
2036 *rewardptr = reward;
2050 assert(scip != NULL);
2051 assert(heurdata != NULL);
2052 assert(neighborhoodidx >= 0);
2053 assert(neighborhoodidx < heurdata->nactiveneighborhoods);
2057 SCIPdebugMsg(scip,
"Rewarding bandit algorithm action %d with reward %.2f\n", neighborhoodidx, reward);
2089 #ifdef ALNS_SUBSCIPOUTPUT 2099 if( ! heurdata->usesubscipheurs )
2162 cutoff = MIN(upperbound, cutoff);
2175 SCIPdebugMsg(scip,
"Cutoff added as Objective Limit\n");
2189 for( i = 0; i < nvars; ++i)
2207 if( heurdata->subsciprandseeds )
2212 SCIPdebugMsg(scip,
"Solve Limits: %lld (%lld) nodes (stall nodes), %.1f sec., %d sols\n",
2229 SCIP* subscip = NULL;
2233 int neighborhoodidx;
2246 assert(heurdata != NULL);
2250 if( heurdata->nactiveneighborhoods == 0 )
2264 SCIPdebugMsg(scip,
"Budget check: %" SCIP_LONGINT_FORMAT
" (%" SCIP_LONGINT_FORMAT
") %s\n", solvelimits.
nodelimit, heurdata->targetnodes, run ?
"passed" :
"must wait");
2279 allrewardsmode = heurdata->rewardfile != NULL;
2282 if( allrewardsmode )
2287 SCIPdebugMsg(scip,
"Not enough solutions for all rewards mode\n");
2296 SCIPdebugMsg(scip,
"Delay ALNS heuristic until a feasible node with optimally solved LP relaxation\n");
2303 if( heurdata->currneighborhood >= 0 )
2305 assert(! allrewardsmode);
2306 banditidx = heurdata->currneighborhood;
2307 SCIPdebugMsg(scip,
"Select delayed neighborhood %d (was delayed %d times)\n", banditidx, heurdata->ndelayedcalls);
2312 SCIPdebugMsg(scip,
"Selected neighborhood %d with bandit algorithm\n", banditidx);
2316 if( ! allrewardsmode )
2317 neighborhoodidx = banditidx;
2319 neighborhoodidx = 0;
2321 assert(neighborhoodidx >= 0);
2322 assert(heurdata->nactiveneighborhoods > neighborhoodidx);
2343 neighborhood = heurdata->neighborhoods[neighborhoodidx];
2344 SCIPdebugMsg(scip,
"Running '%s' neighborhood %d\n", neighborhood->
name, neighborhoodidx);
2347 rewards[neighborhoodidx] = 0.0;
2355 SCIPdebugMsg(scip,
"Fix %d/%d variables\n", nfixings, nvars);
2368 if( allrewardsmode )
2370 if( ntries == heurdata->nactiveneighborhoods )
2373 neighborhoodidx = (neighborhoodidx + 1) % heurdata->nactiveneighborhoods;
2394 else if( heurdata->currneighborhood == -1 )
2396 heurdata->currneighborhood = neighborhoodidx;
2397 heurdata->ndelayedcalls = 1;
2401 heurdata->ndelayedcalls++;
2407 if( ntries < heurdata->nactiveneighborhoods )
2414 SCIPdebugMsg(scip,
"Neighborhood cannot run -> try next neighborhood %d\n", neighborhoodidx);
2422 *result = fixresult;
2435 SCIP_CALL(
SCIPcopyLargeNeighborhoodSearch(scip, subscip, varmapf, neighborhood->
name, varbuf, valbuf, nfixings,
FALSE, heurdata->copycuts, &success, NULL) );
2438 for( v = 0; v < nvars; ++v )
2441 assert(subvars[v] != NULL);
2453 if( ! allrewardsmode || ntries == heurdata->nactiveneighborhoods )
2456 neighborhoodidx = (neighborhoodidx + 1) % heurdata->nactiveneighborhoods;
2469 eventdata.nodelimit = solvelimits.
nodelimit;
2470 eventdata.lplimfac = heurdata->lplimfac;
2471 eventdata.heur = heur;
2472 eventdata.sourcescip = scip;
2473 eventdata.subvars = subvars;
2474 eventdata.runstats = &runstats[neighborhoodidx];
2475 eventdata.allrewardsmode = allrewardsmode;
2493 #ifdef ALNS_SUBSCIPOUTPUT 2503 SCIP_CALL(
getReward(scip, heurdata, &runstats[neighborhoodidx], &rewards[neighborhoodidx]) );
2506 if( allrewardsmode && ntries < heurdata->nactiveneighborhoods )
2508 neighborhoodidx = (neighborhoodidx + 1) % heurdata->nactiveneighborhoods;
2517 if( subscip != NULL )
2527 if( ! allrewardsmode )
2528 banditidx = neighborhoodidx;
2534 --heurdata->ninitneighborhoods;
2536 heurdata->usednodes += runstats[banditidx].
usednodes;
2539 updateNeighborhoodStats(scip, &runstats[banditidx], heurdata->neighborhoods[banditidx], subscipstatus[banditidx]);
2541 SCIPdebugMsg(scip,
"Status of sub-SCIP run: %d\n", subscipstatus[banditidx]);
2546 if( heurdata->adjustfixingrate && ! allrewardsmode )
2548 SCIPdebugMsg(scip,
"Update fixing rate: %.2f\n", heurdata->neighborhoods[banditidx]->fixingrate.targetfixingrate);
2549 updateFixingRate(scip, heurdata->neighborhoods[banditidx], subscipstatus[banditidx], &runstats[banditidx]);
2550 SCIPdebugMsg(scip,
"New fixing rate: %.2f\n", heurdata->neighborhoods[banditidx]->fixingrate.targetfixingrate);
2555 if( heurdata->adjustminimprove && ! allrewardsmode )
2557 SCIPdebugMsg(scip,
"Update Minimum Improvement: %.4f\n", heurdata->minimprove);
2559 SCIPdebugMsg(scip,
"--> %.4f\n", heurdata->minimprove);
2572 if( allrewardsmode )
2574 for( i = 0; i < heurdata->nactiveneighborhoods; ++i )
2576 fprintf(heurdata->rewardfile,
"%.4f,", rewards[i]);
2578 fprintf(heurdata->rewardfile,
"%d\n", banditidx);
2592 assert(scip != NULL);
2593 assert(varbuf != NULL);
2595 assert(valbuf != NULL);
2610 if( nbinvars + nintvars == 0 )
2614 for( i = 0; i < nbinvars + nintvars; ++i )
2646 for( i = nbinvars; i < nbinvars + nintvars; ++i )
2691 assert(scip != NULL);
2692 assert(sols != NULL);
2694 assert(varbuf != NULL);
2695 assert(valbuf != NULL);
2699 if( nvars == -1 || vars == NULL )
2704 nbinintvars = nbinvars + nintvars;
2705 nvars = nbinintvars;
2711 for( v = 0; v < nvars; ++v )
2722 for( s = 1; s < nsols; ++s )
2725 if( !
SCIPisEQ(scip, solval, solval2) )
2749 assert(scip != NULL);
2750 assert(varbuf != NULL);
2752 assert(valbuf != NULL);
2764 if( incumbent == NULL )
2774 if( nbinvars + nintvars == 0 )
2778 sols[1] = incumbent;
2794 assert(data != NULL);
2796 if( data->
rng != NULL )
2813 assert(neighborhood != NULL);
2814 assert(data->
rng != NULL);
2841 assert(scip != NULL);
2842 assert(varbuf != NULL);
2844 assert(valbuf != NULL);
2848 assert(data != NULL);
2849 nsols = data->
nsols;
2873 if( lastdraw == nsols )
2878 for( s = 0; s < nsols; ++s )
2879 sols[s] = scipsols[s];
2887 assert(nsols < lastdraw);
2891 assert(nextdraw >= 0);
2893 sols[nsols - 1] = scipsols[nextdraw];
2895 lastdraw = nextdraw;
2903 assert(data->
selsol != NULL);
2920 if( data->
selsol != NULL )
2938 assert(scip != NULL);
2939 assert(neighborhood != NULL);
2944 assert(data != NULL);
2956 assert(scip != NULL);
2957 assert(neighborhood != NULL);
2959 assert(data != NULL);
2985 assert(scip != NULL);
2986 assert(neighborhood != NULL);
2996 nbinintvars = nbinvars + nintvars;
2997 if( nbinintvars == 0 )
3001 if( incumbentsol == NULL )
3005 ntargetfixings = (int)(targetfixingrate * nbinintvars) + 1;
3008 if( nbinintvars <= ntargetfixings )
3017 for( i = 0; *
nfixings < ntargetfixings && i < nbinintvars; ++i )
3020 assert(randint < nbinintvars);
3030 assert(i == nbinintvars || *
nfixings == ntargetfixings);
3065 assert(sourcescip != NULL);
3066 assert(*success ==
FALSE);
3076 if( referencesol == NULL )
3080 rhs =
MAX(rhs, 2.0);
3086 for( i = 0; i < nbinvars; ++i )
3137 if( referencesol == NULL )
3141 for( i = 0; i < nbinvars; ++i )
3144 if(
SCIPgetSolVal(sourcescip, referencesol, vars[i]) < 0.5 )
3152 for( ; i < nvars; ++i )
3171 assert(*success ==
FALSE);
3180 for( i = 0; i < nvars; ++i )
3221 if(
REALABS(lpsol - mipsol) >= 0.5 )
3229 range = 2 * lpsol - mipsol;
3231 if( mipsol >= lpsol )
3234 *lbptr =
MAX(*lbptr, range);
3245 *ubptr = MIN(*ubptr, range);
3255 *lbptr =
MAX(*lbptr, lbglobal);
3256 *ubptr = MIN(*ubptr, ubglobal);
3261 *lbptr =
MAX(mipsol, lbglobal);
3262 *ubptr = MIN(mipsol, ubglobal);
3281 assert(data != NULL);
3283 nmipsols = MIN(nmipsols, data->
npoolsols);
3297 if( nbinvars + nintvars == 0 )
3303 for( v = 0; v < nbinvars + nintvars; ++v )
3309 nsols = nmipsols + 2;
3313 sols[1] = rootlpsol;
3325 for( v = nbinvars; v < nintvars; ++v )
3359 for( v = nbinvars; v < nintvars; ++v )
3383 assert(neighborhood->
data.
dins != NULL);
3394 assert(scip != NULL);
3414 assert(scip != NULL);
3415 assert(deactivate != NULL);
3427 assert(scip != NULL);
3428 assert(deactivate != NULL);
3440 assert(scip != NULL);
3441 assert(deactivate != NULL);
3466 heurdata->nneighborhoods = 0;
3471 varFixingsRens, changeSubscipRens, NULL, NULL, NULL, NULL, nhDeactivateDiscreteVars) );
3476 varFixingsRins, NULL, NULL, NULL, NULL, nhRefsolIncumbent, nhDeactivateDiscreteVars) );
3481 varFixingsMutation, NULL, nhInitMutation, nhExitMutation, NULL, nhRefsolIncumbent, nhDeactivateDiscreteVars) );
3486 NULL, changeSubscipLocalbranching, NULL, NULL, NULL, nhRefsolIncumbent, nhDeactivateBinVars) );
3491 varFixingsCrossover, NULL,
3492 nhInitCrossover, nhExitCrossover, nhFreeCrossover, nhRefsolCrossover, nhDeactivateDiscreteVars) );
3499 SCIP_CALL(
SCIPaddIntParam(scip,
"heuristics/alns/crossover/nsols",
"the number of solutions that crossover should combine",
3505 NULL, changeSubscipProximity, NULL, NULL, NULL, nhRefsolIncumbent, nhDeactivateBinVars) );
3510 NULL, changeSubscipZeroobjective, NULL, NULL, NULL, nhRefsolIncumbent, nhDeactivateObjVars) );
3515 varFixingsDins, changeSubscipDins, NULL, NULL, nhFreeDins, nhRefsolIncumbent, nhDeactivateBinVars) );
3522 "number of pool solutions where binary solution values must agree",
3535 assert(scip != NULL);
3536 assert(heur != NULL);
3539 assert(heurdata != NULL);
3542 heurdata->nactiveneighborhoods = heurdata->nneighborhoods;
3545 for( i = 0; i < heurdata->nneighborhoods; ++i )
3547 NH* neighborhood = heurdata->neighborhoods[i];
3559 heurdata->rewardfile = fopen(heurdata->rewardfilename,
"w");
3561 if( heurdata->rewardfile == NULL )
3563 SCIPerrorMessage(
"Error: Could not open reward file <%s>\n", heurdata->rewardfilename);
3567 SCIPdebugMsg(scip,
"Writing reward information to <%s>\n", heurdata->rewardfilename);
3570 heurdata->rewardfile = NULL;
3583 unsigned int initseed;
3585 assert(scip != NULL);
3586 assert(heur != NULL);
3589 assert(heurdata != NULL);
3590 heurdata->nactiveneighborhoods = heurdata->nneighborhoods;
3595 for( i = heurdata->nneighborhoods - 1; i >= 0; --i )
3597 NH* neighborhood = heurdata->neighborhoods[i];
3600 SCIP_CALL( neighborhood->nhdeactivate(scip, &deactivate) );
3603 if( deactivate || ! neighborhood->
active )
3605 if( heurdata->nactiveneighborhoods - 1 > i )
3607 assert(heurdata->neighborhoods[heurdata->nactiveneighborhoods - 1]->active);
3608 SCIPswapPointers((
void **)&heurdata->neighborhoods[i], (
void **)&heurdata->neighborhoods[heurdata->nactiveneighborhoods - 1]);
3610 heurdata->nactiveneighborhoods--;
3615 for( i = 0; i < heurdata->nactiveneighborhoods; ++i )
3616 priorities[i] = heurdata->neighborhoods[i]->priority;
3618 initseed = (
unsigned int)heurdata->seed +
SCIPgetNVars(scip);
3621 if( heurdata->bandit != NULL &&
SCIPbanditGetNActions(heurdata->bandit) != heurdata->nactiveneighborhoods )
3625 heurdata->bandit = NULL;
3628 if( heurdata->nactiveneighborhoods > 0 )
3630 if( heurdata->bandit == NULL )
3637 else if( heurdata->resetweights )
3646 heurdata->usednodes = 0;
3647 heurdata->ninitneighborhoods = heurdata->nactiveneighborhoods;
3664 assert(scip != NULL);
3665 assert(heur != NULL);
3668 assert(heurdata != NULL);
3671 for( i = 0; i < heurdata->nneighborhoods; ++i )
3673 NH* neighborhood = heurdata->neighborhoods[i];
3678 if( heurdata->rewardfile != NULL )
3680 fclose(heurdata->rewardfile);
3681 heurdata->rewardfile = NULL;
3694 assert(scip != NULL);
3695 assert(heur != NULL);
3698 assert(heurdata != NULL);
3701 if( heurdata->bandit != NULL )
3707 for( i = 0; i < heurdata->nneighborhoods; ++i )
3727 assert(heurdata != NULL);
3763 assert(heur != NULL);
3777 "maximum number of nodes to regard in the subproblem",
3781 "offset added to the nodes budget",
3785 "minimum number of nodes required to start a sub-SCIP",
3789 "number of nodes since last incumbent solution that the heuristic should wait",
3793 "fraction of nodes compared to the main SCIP for budget computation",
3797 "initial factor by which ALNS should at least improve the incumbent",
3801 "lower threshold for the minimal improvement over the incumbent",
3805 "upper bound for the minimal improvement over the incumbent",
3809 "limit on the number of improving solutions in a sub-SCIP call",
3813 "the bandit algorithm: (u)pper confidence bounds, (e)xp.3, epsilon (g)reedy",
3817 "weight between uniform (gamma ~ 1) and weight driven (gamma ~ 0) probability distribution for exp3",
3821 "reward offset between 0 and 1 at every observation for Exp.3",
3825 "parameter to increase the confidence width in UCB",
3829 "distances from fixed variables be used for variable prioritization",
3833 "should reduced cost scores be used for variable prioritization?",
3837 "should the ALNS heuristic do more fixings by itself based on variable prioritization" 3838 "until the target fixing rate is reached?",
3842 "should the heuristic adjust the target fixing rate based on the success?",
3846 "should the heuristic activate other sub-SCIP heuristics during its search?",
3850 "reward control to increase the weight of the simple solution indicator and decrease the weight of the closed gap reward",
3854 "factor by which target node number is increased/decreased at every adjustment",
3858 "stall node limit as a fraction of total node limit",
3862 "initial random seed for bandit algorithms and random decisions by neighborhoods",
3866 "should the factor by which the minimum improvement is bound be dynamically updated?",
3870 "increase exploration in epsilon-greedy bandit algorithm",
3874 "the reward baseline to separate successful and failed calls",
3878 "should the bandit algorithms be reset when a new problem is read?",
3885 "should random seeds of sub-SCIPs be altered to increase diversification?",
3889 "should the reward be scaled by the effort?",
3893 "should cutting planes be copied to the sub-SCIP?",
3897 "tolerance by which the fixing rate may be missed/exceeded without generic (unfixing)",
3901 "should local reduced costs be used for generic (un)fixing?",
3905 "should pseudo cost scores be used for variable priorization?",
3910 NULL, NULL, NULL, NULL, NULL, NULL, tableOutputNeighborhood,
enum SCIP_Result SCIP_RESULT
#define DEFAULT_BANDITALGO
SCIP_Real targetfixingrate
void SCIPfreeRandom(SCIP *scip, SCIP_RANDNUMGEN **randnumgen)
#define SCIPfreeBlockMemoryArray(scip, ptr, num)
int SCIPgetNIntVars(SCIP *scip)
SCIP_Bool SCIPisFeasZero(SCIP *scip, SCIP_Real val)
#define DEFAULT_USESUBSCIPHEURS
#define DEFAULT_RESETWEIGHTS
static SCIP_DECL_TABLEOUTPUT(tableOutputNeighborhood)
static SCIP_RETCODE addLocalBranchingConstraint(SCIP *sourcescip, SCIP *targetscip, SCIP_VAR **subvars, int distance, SCIP_Bool *success, int *naddedconss)
SCIP_RETCODE SCIPchgVarLbGlobal(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
SCIP_Real SCIPgetSolvingTime(SCIP *scip)
static void decreaseTargetNodeLimit(SCIP_HEURDATA *heurdata)
#define SCIP_EVENTTYPE_LPSOLVED
SCIP_RETCODE SCIPsetSeparating(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
#define DEFAULT_STARTMINIMPROVE
#define SCIPallocBlockMemoryArray(scip, ptr, num)
static SCIP_RETCODE createBandit(SCIP *scip, SCIP_HEURDATA *heurdata, SCIP_Real *priorities, unsigned int initseed)
SCIP_RETCODE SCIPincludeTable(SCIP *scip, const char *name, const char *desc, SCIP_Bool active, SCIP_DECL_TABLECOPY((*tablecopy)), SCIP_DECL_TABLEFREE((*tablefree)), SCIP_DECL_TABLEINIT((*tableinit)), SCIP_DECL_TABLEEXIT((*tableexit)), SCIP_DECL_TABLEINITSOL((*tableinitsol)), SCIP_DECL_TABLEEXITSOL((*tableexitsol)), SCIP_DECL_TABLEOUTPUT((*tableoutput)), SCIP_TABLEDATA *tabledata, int position, SCIP_STAGE earlieststage)
SCIP_Bool SCIPisFeasEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_RETCODE SCIPcreateBanditExp3(SCIP *scip, SCIP_BANDIT **exp3, SCIP_Real *priorities, SCIP_Real gammaparam, SCIP_Real beta, int nactions, unsigned int initseed)
#define DEFAULT_REWARDBASELINE
SCIP_RETCODE SCIPcreateBanditUcb(SCIP *scip, SCIP_BANDIT **ucb, SCIP_Real *priorities, SCIP_Real alpha, int nactions, unsigned int initseed)
SCIP_RETCODE SCIPcreateConsBasicLinear(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *vals, SCIP_Real lhs, SCIP_Real rhs)
SCIP_RETCODE SCIPincludeHeurAlns(SCIP *scip)
#define DEFAULT_MAXFIXINGRATE_LOCALBRANCHING
static void updateMinimumImprovement(SCIP_HEURDATA *heurdata, SCIP_STATUS subscipstatus, NH_STATS *runstats)
static SCIP_RETCODE alnsUnfixVariables(SCIP *scip, SCIP_HEURDATA *heurdata, SCIP_VAR **varbuf, SCIP_Real *valbuf, int *nfixings, int ntargetfixings, SCIP_Bool *success)
static void decreaseMinimumImprovement(SCIP_HEURDATA *heurdata)
SCIP_CONSHDLR * SCIPfindConshdlr(SCIP *scip, const char *name)
SCIP_Real SCIPgetCutoffbound(SCIP *scip)
static void resetMinimumImprovement(SCIP_HEURDATA *heurdata)
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
SCIP_RETCODE SCIPgetRealParam(SCIP *scip, const char *name, SCIP_Real *value)
SCIP_Real SCIPgetVarPseudocostVal(SCIP *scip, SCIP_VAR *var, SCIP_Real solvaldelta)
static SCIP_DECL_HEURINIT(heurInitAlns)
SCIP_Longint SCIPheurGetNBestSolsFound(SCIP_HEUR *heur)
#define DEFAULT_ACTIVE_CROSSOVER
#define DEFAULT_PRIORITY_PROXIMITY
SCIP_RETCODE SCIPcreateRandom(SCIP *scip, SCIP_RANDNUMGEN **randnumgen, unsigned int initialseed)
SCIP_RETCODE SCIPbanditSelect(SCIP_BANDIT *bandit, int *action)
SCIP_RETCODE SCIPsetHeurExit(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEUREXIT((*heurexit)))
SCIP_Real SCIPgetVarRedcost(SCIP *scip, SCIP_VAR *var)
static SCIP_RETCODE alnsIncludeNeighborhood(SCIP *scip, SCIP_HEURDATA *heurdata, NH **neighborhood, const char *name, SCIP_Real minfixingrate, SCIP_Real maxfixingrate, SCIP_Bool active, SCIP_Real priority, DECL_VARFIXINGS((*varfixings)), DECL_CHANGESUBSCIP((*changesubscip)), DECL_NHINIT((*nhinit)), DECL_NHEXIT((*nhexit)), DECL_NHFREE((*nhfree)), DECL_NHREFSOL((*nhrefsol)), DECL_NHDEACTIVATE((*nhdeactivate)))
#define DEFAULT_PRIORITY_DINS
int SCIPgetNOrigVars(SCIP *scip)
#define DEFAULT_USEREDCOST
SCIP_RETCODE SCIPincludeEventhdlrBasic(SCIP *scip, SCIP_EVENTHDLR **eventhdlrptr, const char *name, const char *desc, SCIP_DECL_EVENTEXEC((*eventexec)), SCIP_EVENTHDLRDATA *eventhdlrdata)
SCIP_Bool SCIPvarIsBinary(SCIP_VAR *var)
#define DECL_VARFIXINGS(x)
SCIP_TABLE * SCIPfindTable(SCIP *scip, const char *name)
SCIP_RETCODE SCIPstopClock(SCIP *scip, SCIP_CLOCK *clck)
SCIP_Bool SCIPisFeasNegative(SCIP *scip, SCIP_Real val)
#define DEFAULT_ACTIVE_RINS
DATA_CROSSOVER * crossover
SCIP_Real SCIPvarGetRootSol(SCIP_VAR *var)
#define TABLE_DESC_NEIGHBORHOOD
void SCIPswapPointers(void **pointer1, void **pointer2)
SCIP_RETCODE SCIPgetVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars)
SCIP_SOL ** SCIPgetSols(SCIP *scip)
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
#define DEFAULT_ACTIVE_LOCALBRANCHING
const char * SCIPeventhdlrGetName(SCIP_EVENTHDLR *eventhdlr)
SCIP_RETCODE SCIPaddLongintParam(SCIP *scip, const char *name, const char *desc, SCIP_Longint *valueptr, SCIP_Bool isadvanced, SCIP_Longint defaultvalue, SCIP_Longint minvalue, SCIP_Longint maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
#define DEFAULT_NODESOFFSET
SCIP_Real SCIPinfinity(SCIP *scip)
int SCIPsnprintf(char *t, int len, const char *s,...)
#define DEFAULT_PRIORITY_RINS
enum SCIP_Retcode SCIP_RETCODE
#define DEFAULT_ACTIVE_PROXIMITY
#define DEFAULT_MINFIXINGRATE_PROXIMITY
SCIP_RETCODE SCIPsetPresolving(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
#define DEFAULT_WAITINGNODES
SCIP_BRANCHRULE * SCIPfindBranchrule(SCIP *scip, const char *name)
int SCIPvarGetProbindex(SCIP_VAR *var)
#define DEFAULT_NODESQUOT
SCIP_Bool SCIPisDualfeasZero(SCIP *scip, SCIP_Real val)
#define DEFAULT_MINIMPROVELOW
struct SCIP_HeurData SCIP_HEURDATA
static GRAPHNODE ** active
void SCIPselectInd(int *indarray, SCIP_DECL_SORTINDCOMP((*indcomp)), void *dataptr, int k, int len)
static SCIP_RETCODE neighborhoodFixVariables(SCIP *scip, SCIP_HEURDATA *heurdata, NH *neighborhood, SCIP_VAR **varbuf, SCIP_Real *valbuf, int *nfixings, SCIP_RESULT *result)
static SCIP_DECL_HEUREXIT(heurExitAlns)
#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)
SCIP_RETCODE SCIPaddStringParam(SCIP *scip, const char *name, const char *desc, char **valueptr, SCIP_Bool isadvanced, const char *defaultvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
#define DEFAULT_REWARDFILENAME
#define DEFAULT_MAXFIXINGRATE_DINS
int SCIPrandomGetInt(SCIP_RANDNUMGEN *randnumgen, int minrandval, int maxrandval)
#define DEFAULT_MINFIXINGRATE_RENS
static SCIP_RETCODE alnsFixMoreVariables(SCIP *scip, SCIP_HEURDATA *heurdata, SCIP_SOL *refsol, SCIP_VAR **varbuf, SCIP_Real *valbuf, int *nfixings, int ntargetfixings, SCIP_Bool *success)
#define SCIPduplicateBufferArray(scip, ptr, source, num)
SCIP_RETCODE SCIPfreeClock(SCIP *scip, SCIP_CLOCK **clck)
void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin)
SCIP_Bool SCIPisEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
#define SCIPfreeBufferArray(scip, ptr)
SCIP_RETCODE SCIPcreate(SCIP **scip)
#define SCIPallocBlockMemory(scip, ptr)
SCIP_Bool SCIPisTransformed(SCIP *scip)
SCIP_RETCODE SCIPsetRealParam(SCIP *scip, const char *name, SCIP_Real value)
#define SCIP_EVENTTYPE_ALNS
SCIP_RETCODE SCIPchgVarUbGlobal(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
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)
SCIP_RETCODE SCIPprintStatistics(SCIP *scip, FILE *file)
SCIP_RETCODE SCIPaddCoefLinear(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real val)
void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...)
#define DEFAULT_PRIORITY_ZEROOBJECTIVE
#define DEFAULT_ADJUSTFIXINGRATE
SCIP_Real SCIPfeasCeil(SCIP *scip, SCIP_Real val)
static SCIP_RETCODE alnsFreeNeighborhood(SCIP *scip, NH **neighborhood)
SCIP_Real SCIPfeasFloor(SCIP *scip, SCIP_Real val)
static void updateTargetNodeLimit(SCIP_HEURDATA *heurdata, NH_STATS *runstats, SCIP_STATUS subscipstatus)
static void updateNeighborhoodStats(SCIP *scip, NH_STATS *runstats, NH *neighborhood, SCIP_STATUS subscipstatus)
#define DEFAULT_ACTIVE_RENS
static void increaseTargetNodeLimit(SCIP_HEURDATA *heurdata)
#define DEFAULT_USEDISTANCES
#define DEFAULT_MINIMPROVEHIGH
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
#define DEFAULT_PRIORITY_LOCALBRANCHING
#define TABLE_POSITION_NEIGHBORHOOD
#define DEFAULT_MINFIXINGRATE_RINS
static void resetCurrentNeighborhood(SCIP_HEURDATA *heurdata)
#define SCIP_EVENTTYPE_SOLFOUND
static SCIP_RETCODE neighborhoodStatsReset(SCIP *scip, NH_STATS *stats)
static void increaseFixingRate(NH_FIXINGRATE *fx)
SCIP_RETCODE SCIPsetHeurInitsol(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURINITSOL((*heurinitsol)))
SCIP_RETCODE SCIPsolve(SCIP *scip)
const char * SCIPheurGetName(SCIP_HEUR *heur)
SCIP_RETCODE SCIPcreateClock(SCIP *scip, SCIP_CLOCK **clck)
SCIP_HEUR * SCIPfindHeur(SCIP *scip, const char *name)
#define BMSfreeMemoryArray(ptr)
SCIP_Bool SCIPisParamFixed(SCIP *scip, const char *name)
SCIP_RETCODE SCIPaddCons(SCIP *scip, SCIP_CONS *cons)
static SCIP_DECL_HEURCOPY(heurCopyAlns)
#define DECL_NHDEACTIVATE(x)
SCIP_RETCODE SCIPsetHeurFree(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURFREE((*heurfree)))
SCIP_Bool SCIPisLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
#define DEFAULT_MINFIXINGRATE_DINS
SCIP_Real * redcostscores
SCIP_RETCODE SCIPgetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
static SCIP_DECL_HEURFREE(heurFreeAlns)
SCIP_RETCODE SCIPsetBoolParam(SCIP *scip, const char *name, SCIP_Bool value)
SCIP_STATUS SCIPgetStatus(SCIP *scip)
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
void SCIPselectDownInd(int *indarray, SCIP_DECL_SORTINDCOMP((*indcomp)), void *dataptr, int k, int len)
#define DEFAULT_ACTIVE_ZEROOBJECTIVE
struct SCIP_EventData SCIP_EVENTDATA
static SCIP_DECL_SORTINDCOMP(sortIndCompAlns)
const char * SCIPvarGetName(SCIP_VAR *var)
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
static void updateFixingRate(SCIP *scip, NH *neighborhood, SCIP_STATUS subscipstatus, NH_STATS *runstats)
static SCIP_DECL_HEURINITSOL(heurInitsolAlns)
SCIP_Real SCIPgetSolTransObj(SCIP *scip, SCIP_SOL *sol)
#define DEFAULT_MAXFIXINGRATE_RENS
int SCIPheurGetFreq(SCIP_HEUR *heur)
SCIP_Real SCIPvarGetLPSol(SCIP_VAR *var)
Adaptive large neighborhood search heuristic that orchestrates popular LNS heuristics.
static SCIP_RETCODE neighborhoodInit(SCIP *scip, NH *neighborhood)
SCIP_Real SCIPgetLowerbound(SCIP *scip)
#define DEFAULT_SUBSCIPRANDSEEDS
SCIP_Longint nbestsolsfound
#define DEFAULT_PRIORITY_MUTATION
static SCIP_Real getVariableRedcostScore(SCIP *scip, SCIP_VAR *var, SCIP_Real refsolval, SCIP_Bool uselocalredcost)
SCIP_Longint SCIPheurGetNCalls(SCIP_HEUR *heur)
static void updateFixingRateIncrement(NH_FIXINGRATE *fx)
SCIP_Bool SCIPisDualfeasNegative(SCIP *scip, SCIP_Real val)
#define BMSduplicateMemoryArray(ptr, source, num)
SCIP_Bool SCIPhasCurrentNodeLP(SCIP *scip)
SCIP_RETCODE SCIPchgVarObj(SCIP *scip, SCIP_VAR *var, SCIP_Real newobj)
#define SCIPallocBufferArray(scip, ptr, num)
#define DEFAULT_USEPSCOST
SCIP_RETCODE SCIPsetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real val)
#define DEFAULT_BESTSOLWEIGHT
SCIP_RETCODE SCIPcheckSol(SCIP *scip, SCIP_SOL *sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *feasible)
SCIP_Real SCIPgetProbabilityExp3(SCIP_BANDIT *exp3, int action)
SCIP_RETCODE SCIPcatchEvent(SCIP *scip, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int *filterpos)
SCIP_LPSOLSTAT SCIPgetLPSolstat(SCIP *scip)
SCIP_EVENTTYPE SCIPeventGetType(SCIP_EVENT *event)
static SCIP_RETCODE fixMatchingSolutionValues(SCIP *scip, SCIP_SOL **sols, int nsols, SCIP_VAR **vars, int nvars, SCIP_VAR **varbuf, SCIP_Real *valbuf, int *nfixings)
SCIP_Longint SCIPsolGetNodenum(SCIP_SOL *sol)
SCIP_RETCODE SCIPvariablegraphBreadthFirst(SCIP *scip, SCIP_VGRAPH *vargraph, SCIP_VAR **startvars, int nstartvars, int *distances, int maxdistance, int maxvars, int maxbinintvars)
enum SCIP_Status SCIP_STATUS
#define DEFAULT_MAXFIXINGRATE_ZEROOBJECTIVE
SCIP_RETCODE SCIPsetObjlimit(SCIP *scip, SCIP_Real objlimit)
SCIP_Real SCIPgetClockTime(SCIP *scip, SCIP_CLOCK *clck)
int SCIPgetDepth(SCIP *scip)
static SCIP_Real getVariablePscostScore(SCIP *scip, SCIP_VAR *var, SCIP_Real refsolval)
static SCIP_RETCODE transferSolution(SCIP *subscip, SCIP_EVENTDATA *eventdata)
SCIP_RETCODE SCIPtrySolFree(SCIP *scip, SCIP_SOL **sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
SCIP_RETCODE SCIPcreateBanditEpsgreedy(SCIP *scip, SCIP_BANDIT **epsgreedy, SCIP_Real *priorities, SCIP_Real eps, int nactions, unsigned int initseed)
static void initRunStats(SCIP *scip, NH_STATS *stats)
#define DECL_CHANGESUBSCIP(x)
SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value)
#define DEFAULT_MAXFIXINGRATE_PROXIMITY
static void tryAdd2variableBuffer(SCIP *scip, SCIP_VAR *var, SCIP_Real val, SCIP_VAR **varbuf, SCIP_Real *valbuf, int *nfixings, SCIP_Bool integer)
SCIP_RETCODE SCIPfreeSol(SCIP *scip, SCIP_SOL **sol)
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
SCIP_Real SCIPvarGetBestRootRedcost(SCIP_VAR *var)
#define DEFAULT_MINFIXINGRATE_CROSSOVER
int SCIPgetNSols(SCIP *scip)
#define DEFAULT_ADJUSTMINIMPROVE
#define BMScopyMemoryArray(ptr, source, num)
static void decreaseFixingRate(NH_FIXINGRATE *fx)
static SCIP_RETCODE neighborhoodExit(SCIP *scip, NH *neighborhood)
#define DEFAULT_SCALEBYEFFORT
static SCIP_DECL_HEUREXEC(heurExecAlns)
#define DEFAULT_MINFIXINGRATE_ZEROOBJECTIVE
#define DEFAULT_MINFIXINGRATE_LOCALBRANCHING
int SCIPgetNObjVars(SCIP *scip)
static SCIP_RETCODE neighborhoodGetRefsol(SCIP *scip, NH *neighborhood, SCIP_SOL **solptr)
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
#define BMSclearMemory(ptr)
static SCIP_RETCODE determineLimits(SCIP *scip, SCIP_HEUR *heur, SOLVELIMITS *solvelimits, SCIP_Bool *runagain)
static SCIP_RETCODE updateBanditAlgorithms(SCIP *scip, SCIP_HEURDATA *heurdata, SCIP_Real reward, int neighborhoodidx)
int SCIPgetNBinVars(SCIP *scip)
#define DEFAULT_DOMOREFIXINGS
unsigned int usedistances
SCIP_Real SCIPrandomGetReal(SCIP_RANDNUMGEN *randnumgen, SCIP_Real minrandval, SCIP_Real maxrandval)
static SCIP_BANDIT * getBandit(SCIP_HEURDATA *heurdata)
int SCIPgetNVars(SCIP *scip)
SCIP_RETCODE SCIPbanditUpdate(SCIP_BANDIT *bandit, int action, SCIP_Real score)
SCIP_RETCODE SCIPfreeBandit(SCIP *scip, SCIP_BANDIT **bandit)
static SCIP_RETCODE resetFixingRate(SCIP *scip, NH_FIXINGRATE *fixingrate)
static SCIP_DECL_EVENTEXEC(eventExecAlns)
SCIP_RETCODE SCIPcreateConsLinear(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *vals, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
SCIP_Bool SCIPisDualfeasPositive(SCIP *scip, SCIP_Real val)
SCIP_RETCODE SCIPresetBandit(SCIP *scip, SCIP_BANDIT *bandit, SCIP_Real *priorities, unsigned int seed)
SCIP_Bool SCIPisObjIntegral(SCIP *scip)
#define DEFAULT_PRIORITY_RENS
#define DEFAULT_MINFIXINGRATE_MUTATION
#define SCIP_EVENTTYPE_BESTSOLFOUND
#define DEFAULT_MAXFIXINGRATE_MUTATION
SCIP_SOL * SCIPgetBestSol(SCIP *scip)
SCIP_Bool SCIPisGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_RETCODE SCIPaddCharParam(SCIP *scip, const char *name, const char *desc, char *valueptr, SCIP_Bool isadvanced, char defaultvalue, const char *allowedvalues, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
static void printNeighborhoodStatistics(SCIP *scip, SCIP_HEURDATA *heurdata, FILE *file)
static SCIP_RETCODE selectNeighborhood(SCIP *scip, SCIP_HEURDATA *heurdata, int *neighborhoodidx)
SCIP_Longint SCIPgetMemUsed(SCIP *scip)
#define DEFAULT_NPOOLSOLS_DINS
SCIP_RETCODE SCIPresetClock(SCIP *scip, SCIP_CLOCK *clck)
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
SCIP_Real SCIPvarGetBestRootSol(SCIP_VAR *var)
static SCIP_RETCODE getReward(SCIP *scip, SCIP_HEURDATA *heurdata, NH_STATS *runstats, SCIP_Real *rewardptr)
static SCIP_RETCODE setLimits(SCIP *subscip, SOLVELIMITS *solvelimits)
SCIP_SOLORIGIN SCIPsolGetOrigin(SCIP_SOL *sol)
#define DEFAULT_NSOLS_CROSSOVER
SCIP_RETCODE SCIPsetHeurInit(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURINIT((*heurinit)))
SCIP_Real SCIPretransformObj(SCIP *scip, SCIP_Real obj)
SCIP_Bool SCIPisFeasPositive(SCIP *scip, SCIP_Real val)
SCIP_Longint SCIPgetMemExternEstim(SCIP *scip)
SCIP_NODESEL * SCIPfindNodesel(SCIP *scip, const char *name)
SCIP_RETCODE SCIPcopyLargeNeighborhoodSearch(SCIP *sourcescip, SCIP *subscip, SCIP_HASHMAP *varmap, const char *suffix, SCIP_VAR **fixedvars, SCIP_Real *fixedvals, int nfixedvars, SCIP_Bool uselprows, SCIP_Bool copycuts, SCIP_Bool *success, SCIP_Bool *valid)
SCIP_VAR ** SCIPgetVars(SCIP *scip)
SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
int statushist[NHISTENTRIES]
SCIP_Real * SCIPgetWeightsEpsgreedy(SCIP_BANDIT *epsgreedy)
SCIP_Bool SCIPisStopped(SCIP *scip)
static int getHistIndex(SCIP_STATUS subscipstatus)
int SCIPbanditGetNActions(SCIP_BANDIT *bandit)
static void updateRunStats(SCIP *scip, NH_STATS *stats, SCIP *subscip)
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
SCIP_RANDNUMGEN * SCIPbanditGetRandnumgen(SCIP_BANDIT *bandit)
SCIP_RETCODE SCIPsetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
SCIP_RETCODE SCIPtransformProb(SCIP *scip)
#define DEFAULT_PRIORITY_CROSSOVER
#define DEFAULT_MAXFIXINGRATE_RINS
#define DEFAULT_ACTIVE_DINS
SCIP_RETCODE SCIPsetHeurCopy(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURCOPY((*heurcopy)))
SCIP_Bool SCIPisFeasIntegral(SCIP *scip, SCIP_Real val)
#define DEFAULT_MAXFIXINGRATE_CROSSOVER
SCIP_Real SCIPsumepsilon(SCIP *scip)
SCIP_RETCODE SCIPinterruptSolve(SCIP *scip)
SCIP_Real SCIPgetUpperbound(SCIP *scip)
#define BMSclearMemoryArray(ptr, num)
#define DEFAULT_USELOCALREDCOST
#define DEFAULT_TARGETNODEFACTOR
#define SCIP_CALL_ABORT(x)
SCIP_HEURDATA * SCIPheurGetData(SCIP_HEUR *heur)
static void computeIntegerVariableBoundsDins(SCIP *scip, SCIP_VAR *var, SCIP_Real *lbptr, SCIP_Real *ubptr)
#define TABLE_NAME_NEIGHBORHOOD
SCIP_Longint SCIPgetNNodes(SCIP *scip)
SCIP_Longint SCIPgetNLPs(SCIP *scip)
SCIP_Real SCIPgetConfidenceBoundUcb(SCIP_BANDIT *ucb, int action)
SCIP_Bool SCIPvarIsIntegral(SCIP_VAR *var)
static SCIP_RETCODE neighborhoodChangeSubscip(SCIP *sourcescip, SCIP *targetscip, NH *neighborhood, SCIP_VAR **targetvars, int *ndomchgs, int *nchgobjs, int *naddedconss, SCIP_Bool *success)
#define TABLE_EARLIEST_STAGE_NEIGHBORHOOD
SCIP_RETCODE SCIPstartClock(SCIP *scip, SCIP_CLOCK *clck)
static SCIP_RETCODE setupSubScip(SCIP *scip, SCIP *subscip, SCIP_VAR **subvars, SOLVELIMITS *solvelimits, SCIP_HEUR *heur, SCIP_Bool objchgd)
#define DEFAULT_REWARDCONTROL
SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
#define DEFAULT_STALLNODEFACTOR
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)
SCIP_RETCODE SCIPsetSubscipsOff(SCIP *scip, SCIP_Bool quiet)
SCIP_Real SCIPfloor(SCIP *scip, SCIP_Real val)
static void increaseMinimumImprovement(SCIP_HEURDATA *heurdata)
#define FIXINGRATE_STARTINC
SCIP_RETCODE SCIPsetLongintParam(SCIP *scip, const char *name, SCIP_Longint value)
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 void resetTargetNodeLimit(SCIP_HEURDATA *heurdata)
SCIP_RETCODE SCIPfree(SCIP **scip)
#define DEFAULT_ACTIVE_MUTATION
SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
static SCIP_RETCODE includeNeighborhoods(SCIP *scip, SCIP_HEURDATA *heurdata)