42 #include "scip/scipdefplugins.h"
43 #include "scip/cons_linear.h"
45 #define HEUR_NAME "gcgdins"
46 #define HEUR_DESC "distance induced neighborhood search by Ghosh"
47 #define HEUR_DISPCHAR 'D'
48 #define HEUR_PRIORITY -1105000
50 #define HEUR_FREQOFS 0
51 #define HEUR_MAXDEPTH -1
52 #define HEUR_TIMING SCIP_HEURTIMING_AFTERNODE
53 #define HEUR_USESSUBSCIP TRUE
55 #define DEFAULT_NODESOFS 5000LL
56 #define DEFAULT_MAXNODES 5000LL
57 #define DEFAULT_MINNODES 500LL
58 #define DEFAULT_MINIMPROVE 0.01
59 #define DEFAULT_NODESQUOT 0.05
60 #define DEFAULT_NWAITINGNODES 0LL
61 #define DEFAULT_NEIGHBORHOODSIZE 18
62 #define DEFAULT_SOLNUM 5
63 #define DEFAULT_USELPROWS FALSE
65 #define DEFAULT_COPYCUTS TRUE
97 SCIP_Real avgzerorate;
98 SCIP_Longint totalsols;
101 SCIP_Real subsciptime;
102 SCIP_Real bestprimalbd;
129 assert(scip != NULL);
130 assert(subscip != NULL);
131 assert(vars != NULL);
132 assert(subvars != NULL);
135 bestsol = SCIPgetBestSol(scip);
136 assert(bestsol != NULL);
139 for( i = nbinvars; i < nbinvars + nintvars; i++ )
148 lbglobal = SCIPvarGetLbGlobal(vars[i]);
149 ubglobal = SCIPvarGetUbGlobal(vars[i]);
151 assert(SCIPvarGetType(vars[i]) == SCIP_VARTYPE_INTEGER);
153 lpsol = SCIPgetRelaxSolVal(scip, vars[i]);
155 mipsol = SCIPgetSolVal(scip, bestsol, vars[i]);
158 if( REALABS(lpsol-mipsol) >= 0.5 )
168 range = 2*lpsol-mipsol;
170 if( mipsol >= lpsol )
172 range = SCIPfeasCeil(scip, range);
176 if( SCIPisFeasEQ(scip, mipsol, lb) )
183 range = SCIPfeasFloor(scip, range);
187 if( SCIPisFeasEQ(scip, mipsol, ub) )
194 lb = MAX(lb, lbglobal);
195 ub = MIN(ub, ubglobal);
198 SCIP_CALL( SCIPchgVarLbGlobal(subscip, subvars[i], lb) );
199 SCIP_CALL( SCIPchgVarUbGlobal(subscip, subvars[i], ub) );
200 if( SCIPisEQ(scip, lb, ub) )
203 if( SCIPisZero(scip, ub) )
210 mipsol = MAX(mipsol, lbglobal);
211 mipsol = MIN(mipsol, ubglobal);
214 SCIP_CALL( SCIPchgVarLbGlobal(subscip, subvars[i], mipsol) );
215 SCIP_CALL( SCIPchgVarUbGlobal(subscip, subvars[i], mipsol) );
217 if( SCIPisZero(scip, mipsol) )
228 SCIP_CALL( SCIPgetLPRowsData(scip, &rows, &nrows) );
231 for( i = 0; i < nrows; i++ )
245 if( SCIProwIsLocal(rows[i]) )
249 constant = SCIProwGetConstant(rows[i]);
250 lhs = SCIProwGetLhs(rows[i]) - constant;
251 rhs = SCIProwGetRhs(rows[i]) - constant;
252 vals = SCIProwGetVals(rows[i]);
253 nnonz = SCIProwGetNNonz(rows[i]);
254 cols = SCIProwGetCols(rows[i]);
259 SCIP_CALL( SCIPallocBufferArray(subscip, &consvars, nnonz) );
260 for( j = 0; j < nnonz; j++ )
261 consvars[j] = subvars [ SCIPvarGetProbindex(SCIPcolGetVar(cols[j])) ];
264 SCIP_CALL( SCIPcreateConsLinear(subscip, &cons, SCIProwGetName(rows[i]), nnonz, consvars, vals, lhs, rhs,
265 TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE) );
266 SCIP_CALL( SCIPaddCons(subscip, cons) );
267 SCIP_CALL( SCIPreleaseCons(subscip, &cons) );
270 SCIPfreeBufferArray(subscip, &consvars);
283 SCIP_HEURDATA* heurdata,
297 char consname[SCIP_MAXSTRLEN];
302 (void) SCIPsnprintf(consname, SCIP_MAXSTRLEN,
"%s_dinsLBcons", SCIPgetProbName(scip));
305 SCIP_CALL( SCIPgetVarsData(scip, &vars, NULL, &nbinvars, NULL, NULL, NULL) );
306 bestsol = SCIPgetBestSol(scip);
307 assert(bestsol != NULL);
310 SCIP_CALL( SCIPallocBufferArray(scip, &consvars, nbinvars) );
311 SCIP_CALL( SCIPallocBufferArray(scip, &consvals, nbinvars) );
315 rhs = (SCIP_Real) heurdata->neighborhoodsize;
318 for( i = 0; i < nbinvars; i++ )
320 consvars[i] = subvars[i];
321 assert(SCIPvarGetType(consvars[i]) == SCIP_VARTYPE_BINARY);
328 solval = SCIPgetSolVal(scip, bestsol, vars[i]);
329 assert(SCIPisFeasIntegral(scip, solval));
332 if( SCIPisFeasEQ(scip, solval, 1.0) )
343 SCIP_CALL( SCIPcreateConsLinear(subscip, &cons, consname, nbinvars, consvars, consvals,
344 lhs, rhs, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE) );
345 SCIP_CALL( SCIPaddCons(subscip, cons) );
346 SCIP_CALL( SCIPreleaseCons(subscip, &cons) );
349 SCIPfreeBufferArray(scip, &consvals);
350 SCIPfreeBufferArray(scip, &consvars);
363 SCIP_SOL* masterrootsol;
364 SCIP_VAR** mastervars;
370 assert(masterprob != NULL);
373 SCIP_CALL( SCIPcreateSol(masterprob, &masterrootsol, NULL) );
376 SCIP_CALL( SCIPgetVarsData(masterprob, &mastervars, &nmastervars, NULL, NULL, NULL, NULL) );
377 assert(mastervars != NULL);
378 assert(nmastervars >= 0);
381 for( i = 0; i < nmastervars; i++ )
382 SCIP_CALL( SCIPsetSolVal(masterprob, masterrootsol, mastervars[i], SCIPvarGetRootSol(mastervars[i])) );
388 SCIP_CALL( SCIPfreeSol(masterprob, &masterrootsol) );
404 #ifdef SCIP_STATISTIC
405 SCIP_HEURDATA* heurdata;
409 SCIP_Real* subsolvals;
412 assert(scip != NULL);
413 assert(heur != NULL);
414 assert(subscip != NULL);
415 assert(subvars != NULL);
416 assert(subsol != NULL);
418 #ifdef SCIP_STATISTIC
420 heurdata = SCIPheurGetData(heur);
421 assert( heurdata != NULL );
425 SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, NULL, NULL, NULL, NULL) );
429 assert(nvars <= SCIPgetNOrigVars(subscip));
431 SCIP_CALL( SCIPallocBufferArray(scip, &subsolvals, nvars) );
434 SCIP_CALL( SCIPgetSolVals(subscip, subsol, nvars, subvars, subsolvals) );
437 SCIP_CALL( SCIPcreateSol(scip, &newsol, heur) );
438 SCIP_CALL( SCIPsetSolVals(scip, newsol, nvars, vars, subsolvals) );
441 SCIP_CALL( SCIPtrySol(scip, newsol, FALSE, FALSE, TRUE, TRUE, TRUE, success) );
443 #ifdef SCIP_STATISTIC
446 if( SCIPgetSolTransObj(scip, newsol) < heurdata->bestprimalbd )
447 heurdata->bestprimalbd = SCIPgetSolTransObj(scip, newsol);
451 SCIP_CALL( SCIPfreeSol(scip, &newsol) );
453 SCIPfreeBufferArray(scip, &subsolvals);
466 SCIP_HEURDATA* heurdata;
468 assert(heur != NULL);
469 assert(scip != NULL);
472 heurdata = SCIPheurGetData(heur);
473 assert(heurdata != NULL);
476 SCIPfreeMemory(scip, &heurdata);
477 SCIPheurSetData(heur, NULL);
487 SCIP_HEURDATA* heurdata;
489 assert(heur != NULL);
490 assert(scip != NULL);
493 heurdata = SCIPheurGetData(heur);
494 assert(heurdata != NULL);
497 heurdata->usednodes = 0;
498 heurdata->lastnsolsfound = 0;
499 heurdata->rootsol = NULL;
500 heurdata->firstrun = TRUE;
503 heurdata->deltalength = SCIPgetNBinVars(scip);
506 if( heurdata->deltalength > 0 )
510 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(heurdata->delta), heurdata->deltalength) );
511 for( i = 0; i < heurdata->deltalength; i++ )
512 heurdata->delta[i] = TRUE;
515 #ifdef SCIP_STATISTIC
517 heurdata->avgfixrate = 0.0;
518 heurdata->avgzerorate = 0.0;
519 heurdata->totalsols = 0;
520 heurdata->subsciptime = 0.0;
521 heurdata->bestprimalbd = SCIPinfinity(scip);
531 SCIP_HEURDATA* heurdata;
532 #ifdef SCIP_STATISTIC
536 assert(heur != NULL);
537 assert(scip != NULL);
540 heurdata = SCIPheurGetData(heur);
541 assert(heurdata != NULL);
544 if( heurdata->deltalength > 0 )
546 SCIPfreeBlockMemoryArray(scip, &(heurdata->delta), heurdata->deltalength);
550 if( heurdata->rootsol != NULL )
551 SCIP_CALL( SCIPfreeSol(scip, &heurdata->rootsol) );
553 #ifdef SCIP_STATISTIC
554 ncalls = SCIPheurGetNCalls(heur);
555 heurdata->avgfixrate /= MAX((SCIP_Real)ncalls, 1.0);
556 heurdata->avgzerorate /= MAX((SCIP_Real)ncalls, 1.0);
559 SCIPstatisticPrintf(
"LNS Statistics -- %s:\n", SCIPheurGetName(heur));
560 SCIPstatisticPrintf(
"Calls : %13"SCIP_LONGINT_FORMAT
"\n", ncalls);
561 SCIPstatisticPrintf(
"Sols : %13"SCIP_LONGINT_FORMAT
"\n", SCIPheurGetNSolsFound(heur));
562 SCIPstatisticPrintf(
"Improving Sols : %13"SCIP_LONGINT_FORMAT
"\n", SCIPheurGetNBestSolsFound(heur));
563 SCIPstatisticPrintf(
"Total Sols : %13"SCIP_LONGINT_FORMAT
"\n", heurdata->totalsols);
564 SCIPstatisticPrintf(
"subSCIP time : %13.2f\n", heurdata->subsciptime);
565 SCIPstatisticPrintf(
"subSCIP nodes : %13"SCIP_LONGINT_FORMAT
"\n", heurdata->usednodes);
566 SCIPstatisticPrintf(
"Avg. fixing rate : %13.2f\n", 100.0 * heurdata->avgfixrate);
567 SCIPstatisticPrintf(
"Avg. zero rate : %13.2f\n", 100.0 * heurdata->avgzerorate);
568 SCIPstatisticPrintf(
"Best primal bd. :");
569 if( SCIPisInfinity(scip, heurdata->bestprimalbd) )
570 SCIPstatisticPrintf(
" infinity\n");
572 SCIPstatisticPrintf(
" %13.6e\n", heurdata->bestprimalbd);
573 SCIPstatisticPrintf(
"\n");
584 SCIP_HEURDATA* heurdata;
588 SCIP_HASHMAP* varmapfw;
596 SCIP_Longint maxnnodes;
597 SCIP_Longint nsubnodes;
598 SCIP_Longint nsolsfound;
602 SCIP_Real upperbound;
603 SCIP_Real memorylimit;
605 SCIP_Real rootlpsolval;
608 #ifdef SCIP_STATISTIC
609 SCIP_Real allfixingrate;
610 SCIP_Real intfixingrate;
611 SCIP_Real zerofixingrate;
627 SCIP_Bool infeasible;
629 SCIP_RETCODE retcode;
631 assert(heur != NULL);
632 assert(scip != NULL);
633 assert(result != NULL);
637 assert(masterprob != NULL);
639 *result = SCIP_DELAYED;
644 if( !SCIPisRelaxSolValid(scip) )
648 if( SCIPgetNSols(scip) <= 0 )
652 if( SCIPgetStage(masterprob) > SCIP_STAGE_SOLVING || SCIPgetLPSolstat(masterprob) != SCIP_LPSOLSTAT_OPTIMAL )
656 heurdata = SCIPheurGetData(heur);
657 assert(heurdata != NULL);
658 delta = heurdata->delta;
661 if( SCIPgetNNodes(scip) - SCIPgetSolNodenum(scip, SCIPgetBestSol(scip)) < heurdata->nwaitingnodes )
664 *result = SCIP_DIDNOTRUN;
667 maxnnodes = (SCIP_Longint) (heurdata->nodesquot * SCIPgetNNodes(scip));
670 maxnnodes = (SCIP_Longint) (maxnnodes * (1.0 + 2.0 * (SCIPheurGetNBestSolsFound(heur)+1.0) / (SCIPheurGetNCalls(heur) + 1.0)));
673 maxnnodes -= 100 * SCIPheurGetNCalls(heur);
674 maxnnodes += heurdata->nodesofs;
677 nsubnodes = maxnnodes - heurdata->usednodes;
678 nsubnodes = MIN(nsubnodes , heurdata->maxnodes);
681 if( nsubnodes < heurdata->minnodes )
684 if( SCIPisStopped(scip) )
688 SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, &nbinvars, &nintvars, NULL, NULL) );
689 assert(nbinvars <= nvars);
692 if( nbinvars == 0 && nintvars == 0 )
695 assert(vars != NULL);
698 if( heurdata->firstrun )
700 assert(heurdata->rootsol == NULL);
702 assert(heurdata->rootsol != NULL);
703 heurdata->firstrun = FALSE;
707 SCIP_CALL( SCIPcreate(&subscip) );
710 SCIP_CALL( SCIPallocBufferArray(scip, &subvars, nvars) );
711 SCIP_CALL( SCIPhashmapCreate(&varmapfw, SCIPblkmem(subscip), nvars) );
714 if( heurdata->uselprows )
716 char probname[SCIP_MAXSTRLEN];
719 SCIP_CALL( SCIPincludeDefaultPlugins(subscip) );
722 (void) SCIPsnprintf(probname, SCIP_MAXSTRLEN,
"%s_gcgdinssub", SCIPgetProbName(scip));
725 SCIP_CALL( SCIPcreateProb(subscip, probname, NULL, NULL, NULL, NULL, NULL, NULL, NULL) );
728 SCIP_CALL( SCIPcopyVars(scip, subscip, varmapfw, NULL, NULL, NULL, 0, TRUE) );
732 SCIP_CALL( SCIPcopy(scip, subscip, varmapfw, NULL,
"gcgdins", TRUE, FALSE, FALSE, TRUE, &success) );
734 if( heurdata->copycuts )
737 SCIP_CALL( SCIPcopyCuts(scip, subscip, varmapfw, NULL, TRUE, NULL) );
740 SCIPdebugMessage(
"Copying the SCIP instance was %ssuccessful.\n", success ?
"" :
"not ");
743 for( i = 0; i < nvars; i++ )
744 subvars[i] = (SCIP_VAR*) SCIPhashmapGetImage(varmapfw, vars[i]);
747 SCIPhashmapFree(&varmapfw);
752 SCIPstatisticPrintf(
"gcgdins statistic: called at node %"SCIP_LONGINT_FORMAT
"\n", SCIPgetNNodes(scip));
755 SCIP_CALL(
createSubproblem(scip, subscip, vars, subvars, nbinvars, nintvars, heurdata->uselprows, &fixingcounter, &zerocounter) );
756 SCIPdebugMessage(
"DINS subproblem: %d vars (%d binvars & %d intvars), %d cons\n",
757 SCIPgetNVars(subscip), SCIPgetNBinVars(subscip) , SCIPgetNIntVars(subscip) , SCIPgetNConss(subscip));
759 *result = SCIP_DIDNOTFIND;
762 SCIP_CALL( SCIPsetBoolParam(subscip,
"misc/catchctrlc", FALSE) );
765 SCIP_CALL( SCIPsetIntParam(subscip,
"display/verblevel", 0) );
768 SCIP_CALL( SCIPgetRealParam(scip,
"limits/time", &timelimit) );
769 if( !SCIPisInfinity(scip, timelimit) )
770 timelimit -= SCIPgetSolvingTime(scip);
771 SCIP_CALL( SCIPgetRealParam(scip,
"limits/memory", &memorylimit) );
774 if( !SCIPisInfinity(scip, memorylimit) )
776 memorylimit -= SCIPgetMemUsed(scip)/1048576.0;
777 memorylimit -= SCIPgetMemExternEstim(scip)/1048576.0;
781 if( timelimit <= 0.0 || memorylimit <= 2.0*SCIPgetMemExternEstim(scip)/1048576.0 )
785 SCIP_CALL( SCIPsetLongintParam(subscip,
"limits/nodes", nsubnodes) );
786 SCIP_CALL( SCIPsetIntParam(subscip,
"limits/bestsol", 3) );
787 SCIP_CALL( SCIPsetRealParam(subscip,
"limits/time", timelimit) );
788 SCIP_CALL( SCIPsetRealParam(subscip,
"limits/memory", memorylimit) );
791 SCIP_CALL( SCIPsetSubscipsOff(subscip, TRUE) );
794 SCIP_CALL( SCIPsetSeparating(subscip, SCIP_PARAMSETTING_OFF, TRUE) );
797 SCIP_CALL( SCIPsetPresolving(subscip, SCIP_PARAMSETTING_FAST, TRUE) );
800 if( SCIPfindNodesel(subscip,
"estimate") != NULL && !SCIPisParamFixed(subscip,
"nodeselection/estimate/stdpriority") )
802 SCIP_CALL( SCIPsetIntParam(subscip,
"nodeselection/estimate/stdpriority", INT_MAX/4) );
806 if( SCIPfindBranchrule(subscip,
"inference") != NULL && !SCIPisParamFixed(subscip,
"branching/inference/priority") )
808 SCIP_CALL( SCIPsetIntParam(subscip,
"branching/inference/priority", INT_MAX/4) );
812 if( !SCIPisParamFixed(subscip,
"conflict/enable") )
814 SCIP_CALL( SCIPsetBoolParam(subscip,
"conflict/enable", FALSE) );
818 bestsol = SCIPgetBestSol(scip);
819 assert(bestsol != NULL);
822 sols = SCIPgetSols(scip);
823 nsols = SCIPgetNSols(scip);
824 nsolsfound = SCIPgetNSolsFound(scip);
825 checklength = MIN(nsols, heurdata->solnum);
826 assert(sols != NULL);
830 SCIP_CALL( SCIPallocBufferArray(scip, &fixed, nbinvars) );
833 if( heurdata->deltalength < nbinvars )
837 newsize = SCIPcalcMemGrowSize(scip, nbinvars);
838 assert(newsize >= nbinvars);
840 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &heurdata->delta, heurdata->deltalength, newsize) );
841 delta = heurdata->delta;
844 for( i = heurdata->deltalength; i < newsize; i++ )
847 heurdata->deltalength = newsize;
853 for( i = 0; i < nbinvars; i++ )
859 lpsolval = SCIPgetRelaxSolVal(scip, vars[i]);
861 mipsolval = SCIPgetSolVal(scip, bestsol, vars[i]);
863 rootlpsolval = SCIPgetSolVal(scip, heurdata->rootsol, vars[i]);
865 if( SCIPisFeasEQ(scip, lpsolval, mipsolval) && SCIPisFeasEQ(scip, mipsolval, rootlpsolval) )
868 if( nsols > 1 && heurdata->lastnsolsfound != nsolsfound && delta[i] )
871 for( j = 0; delta[i] && j < checklength && SCIPgetSolHeur(scip, sols[j]) != heur ; j++ )
873 solval = SCIPgetSolVal(scip, sols[j], vars[i]);
874 delta[i] = delta[i] && SCIPisFeasEQ(scip, mipsolval, solval);
879 if( delta[i] && SCIPisFeasEQ(scip, mipsolval, lpsolval) && SCIPisFeasEQ(scip, mipsolval, rootlpsolval )
880 && SCIPisFeasEQ(scip, rootlpsolval, lpsolval) )
882 SCIP_CALL( SCIPfixVar(subscip, subvars[i], mipsolval, &infeasible, &success) );
883 fixed[i] = !infeasible;
886 SCIPdebugMessage(
"variable %d was already fixed\n", i);
891 if( SCIPisZero(scip, mipsolval) )
896 SCIPdebugMessage(
"fixing of variable %d to value %f was infeasible\n", i, mipsolval);
904 #ifdef SCIP_STATISTIC
905 intfixingrate = (SCIP_Real)fixingcounter / (SCIP_Real)(MAX(nbinvars + nintvars, 1));
906 zerofixingrate = (SCIP_Real)zerocounter / MAX((SCIP_Real)fixingcounter, 1.0);
910 heurdata->lastnsolsfound = nsolsfound;
913 if( ufcount > heurdata->neighborhoodsize )
919 SCIPfreeBufferArray(scip, &fixed);
922 assert(!SCIPisInfinity(scip, SCIPgetUpperbound(scip)));
924 if( !SCIPisInfinity(scip, -1.0*SCIPgetLowerbound(scip)) )
926 cutoff = (1 - heurdata->minimprove) * SCIPgetUpperbound(scip) + heurdata->minimprove * SCIPgetLowerbound(scip);
927 upperbound = SCIPgetUpperbound(scip) - SCIPsumepsilon(scip);
928 cutoff = MIN(upperbound, cutoff);
932 if( SCIPgetUpperbound(scip) >= 0 )
933 cutoff = (1 - heurdata->minimprove) * SCIPgetUpperbound(scip);
935 cutoff = (1 + heurdata->minimprove) * SCIPgetUpperbound(scip);
936 upperbound = SCIPgetUpperbound(scip) - SCIPsumepsilon(scip);
937 cutoff = MIN(upperbound, cutoff);
939 SCIP_CALL( SCIPsetObjlimit(subscip, cutoff) );
941 #ifdef SCIP_STATISTIC
942 heurdata->avgfixrate += intfixingrate;
943 heurdata->avgzerorate += zerofixingrate;
947 retcode = SCIPpresolve(subscip);
952 if( retcode != SCIP_OKAY )
955 SCIP_CALL( retcode );
957 SCIPwarningMessage(scip,
"Error while presolving subproblem in GCG RINS heuristic; sub-SCIP terminated with code <%d>\n",retcode);
961 SCIPdebugMessage(
"GCG DINS presolved subproblem: %d vars, %d cons, success=%u\n", SCIPgetNVars(subscip), SCIPgetNConss(subscip), success);
963 #ifdef SCIP_STATISTIC
964 allfixingrate = (SCIPgetNOrigVars(subscip) - SCIPgetNVars(subscip)) / (SCIP_Real)SCIPgetNOrigVars(subscip);
967 allfixingrate = MAX(allfixingrate, 0.0);
971 SCIPdebugMessage(
"solving DINS sub-MIP with neighborhoodsize %d and maxnodes %"SCIP_LONGINT_FORMAT
"\n", heurdata->neighborhoodsize, nsubnodes);
972 retcode = SCIPsolve(subscip);
977 if( retcode != SCIP_OKAY )
980 SCIP_CALL( retcode );
982 SCIPwarningMessage(scip,
"Error while solving subproblem in DINS heuristic; sub-SCIP terminated with code <%d>\n", retcode);
985 heurdata->usednodes += SCIPgetNNodes(subscip);
986 nsubsols = SCIPgetNSols(subscip);
987 #ifdef SCIP_STATISTIC
988 heurdata->subsciptime += SCIPgetTotalTime(subscip);
989 heurdata->totalsols += nsubsols;
991 SCIPdebugMessage(
"DINS used %"SCIP_LONGINT_FORMAT
"/%"SCIP_LONGINT_FORMAT
" nodes and found %d solutions\n", SCIPgetNNodes(subscip), nsubnodes, nsubsols);
999 subsols = SCIPgetSols(subscip);
1001 for( i = 0; i < nsubsols && !success; ++i )
1003 SCIP_CALL(
createNewSol(scip, subscip, subvars, heur, subsols[i], &success) );
1005 *result = SCIP_FOUNDSOL;
1008 #ifdef SCIP_STATISTIC
1009 SCIPstatisticPrintf(
"gcgdins statistic: fixed %6.3f integer variables ( %6.3f zero), %6.3f all variables, needed %6.1f sec (SCIP time: %6.1f sec), %"SCIP_LONGINT_FORMAT
" nodes, found %d solutions, solution %10.4f found at node %"SCIP_LONGINT_FORMAT
"\n",
1010 intfixingrate, zerofixingrate, allfixingrate, SCIPgetSolvingTime(subscip), SCIPgetSolvingTime(scip), SCIPgetNNodes(subscip), nsubsols,
1011 success ? SCIPgetPrimalbound(scip) : SCIPinfinity(scip), nsubsols > 0 ? SCIPsolGetNodenum(SCIPgetBestSol(subscip)) : -1 );
1018 SCIPfreeBufferArray(scip, &subvars);
1019 SCIP_CALL( SCIPfree(&subscip) );
1034 SCIP_HEURDATA* heurdata;
1038 SCIP_CALL( SCIPallocMemory(scip, &heurdata) );
1041 SCIP_CALL( SCIPincludeHeurBasic(scip, &heur,
1045 assert(heur != NULL);
1048 SCIP_CALL( SCIPsetHeurFree(scip, heur, heurFreeGcgdins) );
1049 SCIP_CALL( SCIPsetHeurInitsol(scip, heur, heurInitsolGcgdins) );
1050 SCIP_CALL( SCIPsetHeurExitsol(scip, heur, heurExitsolGcgdins) );
1053 SCIP_CALL( SCIPaddLongintParam(scip,
"heuristics/"HEUR_NAME"/nodesofs",
1054 "number of nodes added to the contingent of the total nodes",
1055 &heurdata->nodesofs, FALSE,
DEFAULT_NODESOFS, 0LL, SCIP_LONGINT_MAX, NULL, NULL) );
1056 SCIP_CALL( SCIPaddRealParam(scip,
"heuristics/"HEUR_NAME"/nodesquot",
1057 "contingent of sub problem nodes in relation to the number of nodes of the original problem",
1059 SCIP_CALL( SCIPaddLongintParam(scip,
"heuristics/"HEUR_NAME"/minnodes",
1060 "minimum number of nodes required to start the subproblem",
1061 &heurdata->minnodes, FALSE,
DEFAULT_MINNODES, 0LL, SCIP_LONGINT_MAX, NULL, NULL) );
1062 SCIP_CALL( SCIPaddIntParam(scip,
"heuristics/"HEUR_NAME"/solnum",
1063 "number of pool-solutions to be checked for flag array update (for hard fixing of binary variables)",
1064 &heurdata->solnum, FALSE,
DEFAULT_SOLNUM, 1, INT_MAX, NULL, NULL) );
1065 SCIP_CALL( SCIPaddIntParam(scip,
"heuristics/"HEUR_NAME"/neighborhoodsize",
1066 "radius (using Manhattan metric) of the incumbent's neighborhood to be searched",
1068 SCIP_CALL( SCIPaddLongintParam(scip,
"heuristics/"HEUR_NAME"/maxnodes",
1069 "maximum number of nodes to regard in the subproblem",
1070 &heurdata->maxnodes,TRUE,
DEFAULT_MAXNODES, 0LL, SCIP_LONGINT_MAX, NULL, NULL) );
1071 SCIP_CALL( SCIPaddRealParam(scip,
"heuristics/"HEUR_NAME"/minimprove",
1072 "factor by which "HEUR_NAME" should at least improve the incumbent",
1074 SCIP_CALL( SCIPaddLongintParam(scip,
"heuristics/"HEUR_NAME"/nwaitingnodes",
1075 "number of nodes without incumbent change that heuristic should wait",
1077 SCIP_CALL( SCIPaddBoolParam(scip,
"heuristics/"HEUR_NAME"/uselprows",
1078 "should subproblem be created out of the rows in the LP rows?",
1080 SCIP_CALL( SCIPaddBoolParam(scip,
"heuristics/"HEUR_NAME"/copycuts",
1081 "if uselprows == FALSE, should all active cuts from cutpool be copied to constraints in subproblem?",