54 #include "scip/nodesel_estimate.h"
55 #include "scip/nodesel_hybridestim.h"
56 #include "scip/nodesel_restartdfs.h"
57 #include "scip/branch_allfullstrong.h"
58 #include "scip/branch_fullstrong.h"
59 #include "scip/branch_inference.h"
60 #include "scip/branch_mostinf.h"
61 #include "scip/branch_leastinf.h"
62 #include "scip/branch_pscost.h"
63 #include "scip/branch_random.h"
64 #include "scip/branch_relpscost.h"
65 #include "scip/nodesel_bfs.h"
66 #include "scip/nodesel_dfs.h"
69 #define BRANCHRULE_NAME "relpsprob"
70 #define BRANCHRULE_DESC "generalized reliability branching using probing"
71 #define BRANCHRULE_PRIORITY -100
72 #define BRANCHRULE_MAXDEPTH -1
73 #define BRANCHRULE_MAXBOUNDDIST 1.0
75 #define DEFAULT_CONFLICTWEIGHT 0.01
76 #define DEFAULT_CONFLENGTHWEIGHT 0.0001
77 #define DEFAULT_INFERENCEWEIGHT 0.1
78 #define DEFAULT_CUTOFFWEIGHT 0.0001
79 #define DEFAULT_PSCOSTWEIGHT 1.0
80 #define DEFAULT_MINRELIABLE 1.0
81 #define DEFAULT_MAXRELIABLE 8.0
82 #define DEFAULT_ITERQUOT 0.5
83 #define DEFAULT_ITEROFS 100000
84 #define DEFAULT_MAXLOOKAHEAD 8
85 #define DEFAULT_INITCAND 100
86 #define DEFAULT_MAXBDCHGS 20
87 #define DEFAULT_MINBDCHGS 1
88 #define DEFAULT_USELP TRUE
89 #define DEFAULT_RELIABILITY 0.8
91 #define HASHSIZE_VARS 131101
156 assert(scip != NULL);
157 assert(*bdchgdata == NULL);
160 SCIP_CALL( SCIPallocBuffer(scip, bdchgdata) );
163 SCIP_CALL( SCIPhashmapCreate(&(*bdchgdata)->varhashmap, SCIPblkmem(scip),
HASHSIZE_VARS) );
166 SCIP_CALL( SCIPallocBufferArray(scip, &(*bdchgdata)->lbchgs,
nvars) );
167 SCIP_CALL( SCIPallocBufferArray(scip, &(*bdchgdata)->ubchgs,
nvars) );
168 SCIP_CALL( SCIPallocBufferArray(scip, &(*bdchgdata)->infroundings,
nvars) );
169 (*bdchgdata)->nvars =
nvars;
172 for( i = 0; i <
nvars; ++i )
174 SCIP_CALL( SCIPhashmapInsert((*bdchgdata)->varhashmap, vars[i], (
void*) (
size_t)i) );
176 (*bdchgdata)->lbchgs[i] = SCIPfeasCeil(scip, SCIPvarGetLbLocal(vars[i]));
177 (*bdchgdata)->ubchgs[i] = SCIPfeasFloor(scip, SCIPvarGetUbLocal(vars[i]));
178 (*bdchgdata)->infroundings[i] = FALSE;
192 assert(scip != NULL);
193 assert(bdchgdata != NULL);
197 SCIPfreeBufferArray(scip, &bdchgdata->
ubchgs);
198 SCIPfreeBufferArray(scip, &bdchgdata->
lbchgs);
203 SCIPfreeBuffer(scip, &bdchgdata);
216 SCIP_BOUNDTYPE boundtype,
217 SCIP_Bool infrounding,
219 SCIP_Bool* infeasible
225 assert(scip != NULL);
226 assert(bdchgdata != NULL);
228 assert(bdchgdata->
lbchgs != NULL);
229 assert(bdchgdata->
ubchgs != NULL);
234 if( infeasible != NULL )
238 if( !SCIPhashmapExists(bdchgdata->
varhashmap, var) )
240 SCIP_CALL( SCIPhashmapInsert(bdchgdata->
varhashmap, var, (
void*) (
size_t)
nvars) );
241 SCIP_CALL( SCIPreallocBufferArray(scip, &bdchgdata->
lbchgs,
nvars + 1) );
242 SCIP_CALL( SCIPreallocBufferArray(scip, &bdchgdata->
ubchgs,
nvars + 1) );
244 bdchgdata->
lbchgs[
nvars] = SCIPfeasCeil(scip, SCIPvarGetLbLocal(var));
245 bdchgdata->
ubchgs[
nvars] = SCIPfeasFloor(scip, SCIPvarGetUbLocal(var));
246 (bdchgdata->
nvars)++;
248 assert(SCIPhashmapExists(bdchgdata->
varhashmap, var)
249 && (
int)(
size_t) SCIPhashmapGetImage(bdchgdata->
varhashmap, var) ==
nvars);
254 pos = (int)(
size_t) SCIPhashmapGetImage(bdchgdata->
varhashmap, var);
262 if( boundtype == SCIP_BOUNDTYPE_LOWER )
264 if( bdchgdata->
lbchgs[pos] < newbound )
266 bdchgdata->
lbchgs[pos] = newbound;
270 if( (infeasible != NULL) && (newbound > bdchgdata->
ubchgs[pos]) )
278 if( newbound < bdchgdata->
ubchgs[pos] )
280 bdchgdata->
ubchgs[pos] = newbound;
283 if( (infeasible != NULL) && (newbound < bdchgdata->
lbchgs[pos]) )
310 assert(scip != NULL);
311 assert(bdchgdata != NULL);
313 SCIPdebugMessage(
"apply bound changes\n");
318 SCIP_CALL( SCIPgetVarsData(scip, &vars, NULL, &nbinvars, &nintvars, NULL, NULL) );
319 nvars = nbinvars + nintvars;
320 assert(vars != NULL);
323 for( i = 0; i <
nvars; ++i )
325 if( SCIPhashmapExists(bdchgdata->
varhashmap, vars[i]) )
328 pos = (int)(
size_t)SCIPhashmapGetImage(bdchgdata->
varhashmap, vars[i]);
331 if( SCIPisFeasGT(scip, (bdchgdata->
lbchgs)[pos], SCIPvarGetLbLocal(vars[i])) )
333 SCIPdebugMessage(
"branch_relpsprob: update lower bound of <%s> from %g to %g\n",
334 SCIPvarGetName(vars[i]), SCIPvarGetLbLocal(vars[i]), (bdchgdata->
lbchgs)[pos]);
335 SCIP_CALL( SCIPchgVarLbNode(scip, node, vars[i], (bdchgdata->
lbchgs)[pos]) );
339 if( SCIPisFeasLT(scip, (bdchgdata->
ubchgs)[pos], SCIPvarGetUbLocal(vars[i])) )
341 SCIPdebugMessage(
"branch_relpsprob: update upper bound of <%s> from %g to %g\n",
342 SCIPvarGetName(vars[i]), SCIPvarGetUbLocal(vars[i]), (bdchgdata->
ubchgs)[pos]);
344 SCIP_CALL( SCIPchgVarUbNode(scip, node, vars[i], (bdchgdata->
ubchgs)[pos]) );
350 SCIPdebugMessage(
"applied %d bound changes\n", nbdchgs);
359 SCIP_BRANCHRULEDATA* branchruledata,
360 SCIP_Real conflictscore,
361 SCIP_Real avgconflictscore,
362 SCIP_Real conflengthscore,
363 SCIP_Real avgconflengthscore,
364 SCIP_Real inferencescore,
365 SCIP_Real avginferencescore,
366 SCIP_Real cutoffscore,
367 SCIP_Real avgcutoffscore,
368 SCIP_Real pscostscore,
369 SCIP_Real avgpscostscore,
375 assert(branchruledata != NULL);
378 score = branchruledata->conflictweight * (1.0 - 1.0/(1.0+conflictscore/avgconflictscore))
379 + branchruledata->conflengthweight * (1.0 - 1.0/(1.0+conflengthscore/avgconflengthscore))
380 + branchruledata->inferenceweight * (1.0 - 1.0/(1.0+inferencescore/avginferencescore))
381 + branchruledata->cutoffweight * (1.0 - 1.0/(1.0+cutoffscore/avgcutoffscore))
382 + branchruledata->pscostweight * (1.0 - 1.0/(1.0+pscostscore/avgpscostscore));
385 if( frac < 0.00000001 || frac > 0.999999 )
387 if( MIN(frac, 1.0 - frac) < 10.0*SCIPfeastol(scip) )
414 assert(scip != NULL);
415 assert(branchvar != NULL);
417 varsol = SCIPgetVarSol(scip, branchvar);
419 lblocal = SCIPfeasCeil(scip, SCIPvarGetLbLocal(branchvar));
420 ublocal = SCIPfeasFloor(scip, SCIPvarGetUbLocal(branchvar));
426 ubdown = SCIPfeasFloor(scip, varsol) ;
427 if( SCIPisEQ(scip, ubdown, ublocal) )
430 assert(lbdown <= ubdown);
436 lbup = SCIPfeasCeil(scip, varsol);
437 if( SCIPisEQ(scip, lbup, lblocal) )
440 assert(SCIPisLE(scip, lbup, ubup));
443 if( SCIPisEQ(scip, lbup, ubdown) )
445 SCIP_Real middle = SCIPfloor(scip, lblocal/2 + ublocal/2);
447 if( SCIPisLE(scip, lbup, middle) )
454 assert(SCIPisLT(scip, ubdown, lbup));
455 assert(SCIPisLE(scip, lbdown, ubdown));
456 assert(SCIPisLE(scip, lbup, ubup));
478 SCIP_VAR* probingvar,
479 SCIP_Bool probingdir,
481 SCIP_Longint* nlpiterations,
484 SCIP_Real* lpobjvalue,
494 SCIP_Real leftlbprobing;
495 SCIP_Real leftubprobing;
496 SCIP_Real rightlbprobing;
497 SCIP_Real rightubprobing;
499 leftubprobing = -1.0;
500 leftlbprobing = -1.0;
501 rightlbprobing = -1.0;
502 rightubprobing = -1.0;
504 assert(proplbs != NULL);
505 assert(propubs != NULL);
506 assert(cutoff != NULL);
507 assert(SCIPvarGetLbLocal(probingvar) - 0.5 < SCIPvarGetUbLocal(probingvar));
508 assert(SCIPisFeasIntegral(scip, SCIPvarGetLbLocal(probingvar)));
509 assert(SCIPisFeasIntegral(scip, SCIPvarGetUbLocal(probingvar)));
511 assert(!solvelp || (lpsolved!=NULL && lpobjvalue!=NULL && lperror!=NULL));
515 assert(masterscip != NULL);
519 if( probingdir == FALSE )
523 &leftlbprobing, &leftubprobing, NULL, NULL) );
528 NULL, NULL, &rightlbprobing, &rightubprobing) );
531 SCIPdebugMessage(
"applying probing on variable <%s> == %u [%g,%g] (nlocks=%d/%d, impls=%d/%d, clqs=%d/%d)\n",
532 SCIPvarGetName(probingvar), probingdir,
533 probingdir ? rightlbprobing : leftlbprobing, probingdir ? rightubprobing : leftubprobing,
534 SCIPvarGetNLocksDown(probingvar), SCIPvarGetNLocksUp(probingvar),
535 SCIPvarGetNImpls(probingvar, FALSE), SCIPvarGetNImpls(probingvar, TRUE),
536 SCIPvarGetNCliques(probingvar, FALSE), SCIPvarGetNCliques(probingvar, TRUE));
546 if( probingdir == FALSE )
548 SCIP_CALL( SCIPchgVarUbProbing(scip, probingvar, leftubprobing) );
552 SCIP_CALL( SCIPchgVarLbProbing(scip, probingvar, rightlbprobing) );
558 SCIP_CALL( SCIPpropagateProbing(scip, -1, cutoff, NULL) );
566 for( i = 0; i <
nvars; ++i )
568 proplbs[i] = SCIPvarGetLbLocal(vars[i]);
569 propubs[i] = SCIPvarGetUbLocal(vars[i]);
574 if( !(*cutoff) && solvelp )
576 *nlpiterations -= SCIPgetNLPIterations(masterscip);
581 lpobjvalue, lpsolved, lperror, cutoff) );
587 SCIPdebugMessage(
"probing results in cutoff/lpsolved/lpobj: %s / %s / %g\n",
588 *cutoff?
"cutoff":
"no cutoff", *lpsolved?
"lpsolved":
"lp not solved", *lpobjvalue);
598 SCIP_VAR* probingvar,
601 SCIP_Longint* nlpiterations,
604 SCIP_Bool* downvalid,
622 SCIP_Real* leftproplbs;
623 SCIP_Real* leftpropubs;
624 SCIP_Real* rightproplbs;
625 SCIP_Real* rightpropubs;
627 SCIP_Real leftlpbound;
628 SCIP_Real rightlpbound;
629 SCIP_Bool leftlpsolved;
630 SCIP_Bool rightlpsolved;
631 SCIP_Bool leftlperror;
632 SCIP_Bool rightlperror;
633 SCIP_Bool leftcutoff;
634 SCIP_Bool rightcutoff;
639 assert(lperror != NULL);
641 if( downvalid != NULL )
643 if( upvalid != NULL )
645 if( downinf != NULL )
650 if( SCIPisStopped(scip) )
652 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL,
653 " (%.1fs) probing aborted: solving stopped\n", SCIPgetSolvingTime(scip));
659 SCIP_CALL( SCIPgetVarsData(scip, &probvars, NULL, &nbinvars, &nintvars, NULL, NULL) );
660 nvars = nbinvars + nintvars;
662 SCIP_CALL( SCIPduplicateBufferArray(scip, &vars, probvars,
nvars) );
665 for( i = 0; i <
nvars; ++i )
667 SCIP_CALL( SCIPcaptureVar(scip, vars[i]) );
671 SCIP_CALL( SCIPallocBufferArray(scip, &leftproplbs,
nvars) );
672 SCIP_CALL( SCIPallocBufferArray(scip, &leftpropubs,
nvars) );
673 SCIP_CALL( SCIPallocBufferArray(scip, &rightproplbs,
nvars) );
674 SCIP_CALL( SCIPallocBufferArray(scip, &rightpropubs,
nvars) );
683 rightlperror = FALSE;
686 leftlpsolved = FALSE;
687 rightlpsolved = FALSE;
691 SCIP_CALL(
applyProbing(scip, vars,
nvars, probingvar, FALSE, solvelp, nlpiterations,
692 leftproplbs, leftpropubs,
693 &leftlpbound, &leftlpsolved, &leftlperror, &leftcutoff) );
699 SCIP_CALL(
calculateBounds(scip, probingvar, NULL, NULL, &newbound, NULL) );
702 SCIPdebugMessage(
"change lower bound of probing variable <%s> from %g to %g, nlocks=(%d/%d)\n",
703 SCIPvarGetName(probingvar), SCIPvarGetLbLocal(probingvar), newbound,
704 SCIPvarGetNLocksDown(probingvar), SCIPvarGetNLocksUp(probingvar));
706 SCIP_CALL(
addBdchg(scip, bdchgdata, probingvar, newbound, SCIP_BOUNDTYPE_LOWER, TRUE, nbdchgs, &cutoff) );
712 SCIP_CALL(
applyProbing(scip, vars,
nvars, probingvar, TRUE, solvelp, nlpiterations,
713 rightproplbs, rightpropubs,
714 &rightlpbound, &rightlpsolved, &rightlperror, &rightcutoff) );
720 SCIP_CALL(
calculateBounds(scip, probingvar, NULL, &newbound, NULL, NULL) );
723 SCIPdebugMessage(
"change probing variable <%s> upper bound from %g to %g, nlocks=(%d/%d)\n",
724 SCIPvarGetName(probingvar), SCIPvarGetUbLocal(probingvar), newbound,
725 SCIPvarGetNLocksDown(probingvar), SCIPvarGetNLocksUp(probingvar));
727 SCIP_CALL(
addBdchg(scip, bdchgdata, probingvar, newbound, SCIP_BOUNDTYPE_UPPER, TRUE, nbdchgs, &cutoff) );
732 cutoff = cutoff || (leftcutoff && rightcutoff);
733 *lperror = leftlperror || rightlperror;
745 for( j = 0; j <
nvars && !cutoff; ++j )
750 if( vars[j] == probingvar )
754 newlb = MIN(leftproplbs[j], rightproplbs[j]);
755 newub = MAX(leftpropubs[j], rightpropubs[j]);
758 if( SCIPisFeasEQ(scip, newlb, newub) )
761 SCIP_CALL(
addBdchg(scip, bdchgdata, vars[j], newlb, SCIP_BOUNDTYPE_LOWER, FALSE, nbdchgs, &cutoff) );
762 SCIP_CALL(
addBdchg(scip, bdchgdata, vars[j], newub, SCIP_BOUNDTYPE_UPPER, FALSE, nbdchgs, &cutoff) );
770 assert(SCIPvarGetType(vars[j]) == SCIP_VARTYPE_BINARY || SCIPvarGetType(vars[j]) == SCIP_VARTYPE_INTEGER);
773 oldlb = SCIPvarGetLbLocal(vars[j]);
774 oldub = SCIPvarGetUbLocal(vars[j]);
775 if( SCIPisLbBetter(scip, newlb, oldlb, oldub) )
778 SCIP_CALL(
addBdchg(scip, bdchgdata, vars[j], newlb, SCIP_BOUNDTYPE_LOWER, FALSE, nbdchgs, &cutoff) );
780 if( SCIPisUbBetter(scip, newub, oldlb, oldub) && !cutoff )
783 SCIP_CALL(
addBdchg(scip, bdchgdata, vars[j], newub, SCIP_BOUNDTYPE_UPPER, FALSE, nbdchgs, &cutoff) );
791 if( down != NULL && leftlpsolved )
793 if( up != NULL && rightlpsolved )
795 if( downvalid != NULL && leftlpsolved )
797 if( downvalid != NULL && !leftlpsolved )
799 if( upvalid != NULL && rightlpsolved )
801 if( upvalid != NULL && !rightlpsolved )
803 if( downinf != NULL )
804 *downinf = leftcutoff;
806 *upinf = rightcutoff;
810 if( downinf != NULL )
817 SCIPfreeBufferArray(scip, &rightpropubs);
818 SCIPfreeBufferArray(scip, &rightproplbs);
819 SCIPfreeBufferArray(scip, &leftpropubs);
820 SCIPfreeBufferArray(scip, &leftproplbs);
823 for( i = 0; i <
nvars; ++i )
825 SCIP_CALL( SCIPreleaseVar(scip, &vars[i]) );
827 SCIPfreeBufferArray(scip, &vars);
840 SCIP_BRANCHRULE* branchrule,
841 SCIP_VAR** branchcands,
846 SCIP_BRANCHRULEDATA* branchruledata;
851 branchruledata = SCIPbranchruleGetData(branchrule);
852 assert(branchruledata != NULL);
854 if( branchruledata->nvars == 0 )
858 assert(branchruledata->varhashmap == NULL);
859 SCIP_CALL( SCIPhashmapCreate(&(branchruledata->varhashmap), SCIPblkmem(scip),
HASHSIZE_VARS) );
861 branchruledata->maxvars = SCIPcalcMemGrowSize(scip, nbranchcands);
862 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &branchruledata->nvarprobings, branchruledata->maxvars) );
863 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &branchruledata->nvarbranchings, branchruledata->maxvars) );
864 branchruledata->nvars = nbranchcands;
867 for( j = 0; j < nbranchcands; ++j )
869 SCIP_CALL( SCIPhashmapInsert(branchruledata->varhashmap, branchcands[j], (
void*) (
size_t)j) );
870 branchruledata->nvarprobings[j] = 0;
871 branchruledata->nvarbranchings[j] = 0;
878 for( j = 0; j < nbranchcands; ++j )
883 var = branchcands[j];
885 nvars = branchruledata->nvars;
888 if( !SCIPhashmapExists(branchruledata->varhashmap, var) )
890 int newsize = SCIPcalcMemGrowSize(scip,
nvars + 1);
891 SCIP_CALL( SCIPhashmapInsert(branchruledata->varhashmap, var, (
void*) (
size_t)
nvars) );
892 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &branchruledata->nvarprobings, branchruledata->maxvars,
894 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &branchruledata->nvarbranchings, branchruledata->maxvars,
896 branchruledata->maxvars = newsize;
898 branchruledata->nvarprobings[
nvars] = 0;
899 branchruledata->nvarbranchings[
nvars] = 0;
901 assert(SCIPhashmapExists(branchruledata->varhashmap, var)
902 && (
int)(
size_t) SCIPhashmapGetImage(branchruledata->varhashmap, var) ==
nvars);
904 ++(branchruledata->nvars);
917 SCIP_BRANCHRULE* branchrule,
921 SCIP_BRANCHRULEDATA* branchruledata;
924 assert(scip != NULL);
925 assert(branchrule != NULL);
929 branchruledata = SCIPbranchruleGetData(branchrule);
930 assert(branchruledata != NULL);
932 assert(SCIPhashmapExists(branchruledata->varhashmap, var) );
934 pos = (int)(
size_t) SCIPhashmapGetImage(branchruledata->varhashmap, var);
935 (branchruledata->nvarbranchings[pos])++;
937 (branchruledata->nbranchings)++;
946 SCIP_BRANCHRULE* branchrule,
950 SCIP_BRANCHRULEDATA* branchruledata;
953 assert(scip != NULL);
954 assert(branchrule != NULL);
958 branchruledata = SCIPbranchruleGetData(branchrule);
959 assert(branchruledata != NULL);
961 assert(SCIPhashmapExists(branchruledata->varhashmap, var) );
963 pos = (int)(
size_t) SCIPhashmapGetImage(branchruledata->varhashmap, var);
964 (branchruledata->nvarprobings[pos])++;
966 (branchruledata->nprobings)++;
976 SCIP_BRANCHRULE* branchrule,
977 SCIP_VAR** branchcands,
978 SCIP_Real* branchcandssol,
986 SCIP_BRANCHRULEDATA* branchruledata;
990 SCIP_Real cutoffbound;
992 SCIP_Real provedbound;
994 SCIP_Bool bestisstrongbranch = FALSE;
998 *result = SCIP_DIDNOTRUN;
1000 SCIPdebugMessage(
"execrelpsprob method called\n relpsprob\n relpsprob\n relpsprob\n relpsprob\n relpsprob\n relpsprob\n relpsprob\n relpsprob\n");
1004 assert(masterscip != NULL);
1007 branchruledata = SCIPbranchruleGetData(branchrule);
1008 assert(branchruledata != NULL);
1016 assert(bdchgdata != NULL);
1019 lpobjval = SCIPgetLocalLowerbound(scip);
1021 cutoffbound = SCIPgetCutoffbound(scip);
1023 provedbound = lpobjval;
1025 if( nbranchcands == 1 )
1032 SCIP_Real* initcandscores;
1036 SCIP_Real avgconflictscore;
1037 SCIP_Real avgconflengthscore;
1038 SCIP_Real avginferencescore;
1039 SCIP_Real avgcutoffscore;
1040 SCIP_Real avgpscostscore;
1041 SCIP_Real bestpsscore;
1042 SCIP_Real bestsbscore;
1043 SCIP_Real bestuninitsbscore;
1044 SCIP_Real bestsbfracscore;
1045 SCIP_Real bestsbdomainscore;
1056 avgconflictscore = SCIPgetAvgConflictScore(scip);
1057 avgconflictscore = MAX(avgconflictscore, 0.1);
1058 avgconflengthscore = SCIPgetAvgConflictlengthScore(scip);
1059 avgconflengthscore = MAX(avgconflengthscore, 0.1);
1060 avginferencescore = SCIPgetAvgInferenceScore(scip);
1061 avginferencescore = MAX(avginferencescore, 0.1);
1062 avgcutoffscore = SCIPgetAvgCutoffScore(scip);
1063 avgcutoffscore = MAX(avgcutoffscore, 0.1);
1064 avgpscostscore = SCIPgetAvgPseudocostScore(scip);
1065 avgpscostscore = MAX(avgpscostscore, 0.1);
1070 maxninitcands = MIN(nbranchcands, branchruledata->initcand);
1072 if( !SCIPisLPSolBasic(masterscip) )
1075 SCIPdebugMessage(
"solution is not basic\n");
1078 SCIPdebugMessage(
"maxninitcands = %d\n", maxninitcands);
1081 SCIP_CALL( SCIPallocBufferArray(scip, &initcands, maxninitcands+1) );
1082 SCIP_CALL( SCIPallocBufferArray(scip, &initcandscores, maxninitcands+1) );
1086 maxbdchgs = branchruledata->maxbdchgs;
1093 bestpsscore = -SCIPinfinity(scip);
1094 for( c = 0; c < nbranchcands; ++c )
1096 SCIP_Real conflictscore;
1097 SCIP_Real conflengthscore;
1098 SCIP_Real inferencescore;
1099 SCIP_Real cutoffscore;
1100 SCIP_Real pscostscore;
1103 assert(branchcands[c] != NULL);
1106 conflictscore = SCIPgetVarConflictScore(scip, branchcands[c]);
1107 conflengthscore = SCIPgetVarConflictlengthScore(scip, branchcands[c]);
1108 inferencescore = SCIPgetVarAvgInferenceScore(scip, branchcands[c]);
1109 cutoffscore = SCIPgetVarAvgCutoffScore(scip, branchcands[c]);
1110 pscostscore = SCIPgetVarPseudocostScore(scip, branchcands[c], branchcandssol[c]);
1114 score =
calcScore(scip, branchruledata, conflictscore, avgconflictscore, conflengthscore, avgconflengthscore,
1115 inferencescore, avginferencescore, cutoffscore, avgcutoffscore, pscostscore, avgpscostscore,
1116 branchcandssol[c] - SCIPfloor(scip, branchcandssol[c]));
1119 for( j = ninitcands; j > 0 && score > initcandscores[j-1]; --j )
1121 initcands[j] = initcands[j-1];
1122 initcandscores[j] = initcandscores[j-1];
1126 initcandscores[j] = score;
1128 ninitcands = MIN(ninitcands, maxninitcands);
1134 SCIPdebugMessage(
"ninitcands = %d\n", ninitcands);
1137 bestsbscore = -SCIPinfinity(scip);
1138 bestsbfracscore = -SCIPinfinity(scip);
1139 bestsbdomainscore = -SCIPinfinity(scip);
1140 for( i = 0; i < ninitcands; ++i )
1146 SCIP_Bool downvalid;
1159 SCIPdebugMessage(
"init pseudo cost (%g/%g) of <%s> with bounds [%g,%g] at %g (score:%g)\n",
1160 SCIPgetVarPseudocostCountCurrentRun(scip, branchcands[c], SCIP_BRANCHDIR_DOWNWARDS),
1161 SCIPgetVarPseudocostCountCurrentRun(scip, branchcands[c], SCIP_BRANCHDIR_UPWARDS),
1162 SCIPvarGetName(branchcands[c]), SCIPvarGetLbLocal(branchcands[c]), SCIPvarGetUbLocal(branchcands[c]),
1163 branchcandssol[c], initcandscores[i]);
1166 SCIP_CALL(
getVarProbingbranch(scip, branchcands[c], bdchgdata, branchruledata->uselp, &branchruledata->nlpiterations,
1167 &down, &up, &downvalid, &upvalid, &downinf, &upinf, &lperror, &nbdchgs) );
1169 branchruledata->nprobingnodes++;
1170 branchruledata->nprobingnodes++;
1176 if( !SCIPisStopped(scip) )
1178 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL,
1179 "(node %"SCIP_LONGINT_FORMAT
") error in strong branching call for variable <%s> with solution %g\n",
1180 SCIPgetNNodes(scip), SCIPvarGetName(branchcands[c]), branchcandssol[c]);
1186 if( SCIPisStopped(scip) )
1192 if( downinf && upinf )
1195 SCIPdebugMessage(
" -> variable <%s> is infeasible in both directions\n",
1196 SCIPvarGetName(branchcands[c]));
1198 *result = SCIP_CUTOFF;
1204 down = MAX(down, lpobjval);
1205 up = MAX(up, lpobjval);
1206 downgain = down - lpobjval;
1207 upgain = up - lpobjval;
1208 assert(!downvalid || downinf == SCIPisGE(scip, down, cutoffbound));
1209 assert(!upvalid || upinf == SCIPisGE(scip, up, cutoffbound));
1212 if( downvalid && upvalid )
1216 minbound = MIN(down, up);
1217 provedbound = MAX(provedbound, minbound);
1222 if( maxbdchgs >= 0 && nbdchgs >= maxbdchgs )
1226 if( downinf || upinf )
1228 branchruledata->ninfprobings++;
1233 if( !downinf && !upinf )
1236 SCIP_Real conflictscore;
1237 SCIP_Real conflengthscore;
1238 SCIP_Real inferencescore;
1239 SCIP_Real cutoffscore;
1240 SCIP_Real pscostscore;
1243 frac = branchcandssol[c] - SCIPfloor(scip, branchcandssol[c]);
1246 conflictscore = SCIPgetVarConflictScore(scip, branchcands[c]);
1247 conflengthscore = SCIPgetVarConflictlengthScore(scip, branchcands[c]);
1248 inferencescore = SCIPgetVarAvgInferenceScore(scip, branchcands[c]);
1249 cutoffscore = SCIPgetVarAvgCutoffScore(scip, branchcands[c]);
1250 pscostscore = SCIPgetBranchScore(scip, branchcands[c], downgain, upgain);
1251 score =
calcScore(scip, branchruledata, conflictscore, avgconflictscore, conflengthscore, avgconflengthscore,
1252 inferencescore, avginferencescore, cutoffscore, avgcutoffscore, pscostscore, avgpscostscore, frac);
1254 if( SCIPisSumGE(scip, score, bestsbscore) )
1256 SCIP_Real fracscore;
1257 SCIP_Real domainscore;
1259 fracscore = MIN(frac, 1.0 - frac);
1260 domainscore = -(SCIPvarGetUbLocal(branchcands[c]) - SCIPvarGetLbLocal(branchcands[c]));
1261 if( SCIPisSumGT(scip, score, bestsbscore )
1262 || SCIPisSumGT(scip, fracscore, bestsbfracscore)
1263 || (SCIPisSumGE(scip, fracscore, bestsbfracscore) && domainscore > bestsbdomainscore) )
1266 bestsbscore = score;
1267 bestsbfracscore = fracscore;
1268 bestsbdomainscore = domainscore;
1273 assert(!SCIPisFeasNegative(scip, frac));
1274 SCIP_CALL( SCIPupdateVarPseudocost(scip, branchcands[c], 0.0-frac, downgain, 1.0) );
1275 SCIP_CALL( SCIPupdateVarPseudocost(scip, branchcands[c], 1.0-frac, upgain, 1.0) );
1277 SCIPdebugMessage(
" -> variable <%s> (solval=%g, down=%g (%+g), up=%g (%+g), score=%g/ %g/%g %g/%g -> %g)\n",
1278 SCIPvarGetName(branchcands[c]), branchcandssol[c], down, downgain, up, upgain,
1279 pscostscore, conflictscore, conflengthscore, inferencescore, cutoffscore, score);
1284 if( bestsbcand >= 0 )
1286 SCIPdebugMessage(
" -> best: <%s> (%g / %g / %g)\n",
1287 SCIPvarGetName(branchcands[bestsbcand]), bestsbscore, bestsbfracscore, bestsbdomainscore);
1290 if( bestsbcand >= 0 )
1292 SCIPdebugMessage(
" -> best: <%s> (%g / %g / %g)\n",
1293 SCIPvarGetName(branchcands[bestsbcand]), bestsbscore, bestsbfracscore, bestsbdomainscore);
1297 if( i < ninitcands )
1298 bestuninitsbscore = initcandscores[i];
1300 bestuninitsbscore = -SCIPinfinity(scip);
1305 if( bestpsscore > bestuninitsbscore && SCIPisSumGT(scip, bestpsscore, bestsbscore) )
1307 bestcand = bestpscand;
1309 bestisstrongbranch = FALSE;
1312 else if( bestsbcand >= 0 )
1314 bestcand = bestsbcand;
1316 bestisstrongbranch = TRUE;
1324 assert(ninitcands >= 1);
1325 bestcand = initcands[0];
1327 bestisstrongbranch = FALSE;
1332 if( (nbdchgs >= branchruledata->minbdchgs || ninfprobings >= 5 )
1333 && *result != SCIP_CUTOFF && !SCIPisStopped(scip) )
1335 SCIP_CALL(
applyBdchgs(scip, bdchgdata, SCIPgetCurrentNode(scip)) );
1336 branchruledata->nresolvesminbdchgs++;
1337 *result = SCIP_REDUCEDDOM;
1341 SCIPfreeBufferArray(scip, &initcandscores);
1342 SCIPfreeBufferArray(scip, &initcands);
1346 if( *result != SCIP_CUTOFF && *result != SCIP_REDUCEDDOM
1347 && *result != SCIP_CONSADDED && !SCIPisStopped(scip) )
1349 assert(*result == SCIP_DIDNOTRUN);
1350 assert(0 <= bestcand && bestcand < nbranchcands);
1351 assert(SCIPisLT(scip, provedbound, cutoffbound));
1354 SCIPdebugMessage(
" -> best: <%s> (strongbranch = %ud)\n", SCIPvarGetName(branchcands[bestcand]), bestisstrongbranch);
1356 *branchvar = branchcands[bestcand];
1375 SCIP_BRANCHRULEDATA* branchruledata;
1378 branchruledata = SCIPbranchruleGetData(branchrule);
1380 SCIPdebugMessage(
"**needed in total %d probing nodes\n", branchruledata->nprobingnodes);
1382 SCIPfreeMemory(scip, &branchruledata);
1383 SCIPbranchruleSetData(branchrule, NULL);
1393 SCIP_BRANCHRULEDATA* branchruledata;
1396 branchruledata = SCIPbranchruleGetData(branchrule);
1398 branchruledata->nprobingnodes = 0;
1399 branchruledata->nlpiterations = 0;
1401 branchruledata->nprobings = 0;
1402 branchruledata->nbranchings = 0;
1403 branchruledata->ninfprobings = 0;
1404 branchruledata->nresolvesminbdchgs = 0;
1405 branchruledata->nresolvesinfcands = 0;
1407 branchruledata->varhashmap = NULL;
1408 branchruledata->nvarbranchings = NULL;
1409 branchruledata->nvarprobings = NULL;
1410 branchruledata->nvars = 0;
1411 branchruledata->maxvars = 0;
1420 SCIP_BRANCHRULEDATA* branchruledata;
1423 branchruledata = SCIPbranchruleGetData(branchrule);
1425 SCIPdebugMessage(
"**in total: nprobings = %d; part of it are ninfprobings = %d\n",
1426 branchruledata->nprobings, branchruledata->ninfprobings );
1428 SCIPdebugMessage(
"**nbranchings = %d, nresolvesinfcands = %d, nresolvesminbdchgs = %d\n",
1429 branchruledata->nbranchings, branchruledata->nresolvesinfcands, branchruledata->nresolvesminbdchgs );
1433 SCIPfreeBlockMemoryArrayNull(scip, &branchruledata->nvarprobings, branchruledata->maxvars);
1434 SCIPfreeBlockMemoryArrayNull(scip, &branchruledata->nvarbranchings, branchruledata->maxvars);
1435 branchruledata->nvars = 0;
1437 if( branchruledata->varhashmap != NULL )
1439 SCIPhashmapFree(&(branchruledata->varhashmap));
1456 SCIP_BRANCHRULE* branchrule;
1457 SCIP_BRANCHRULEDATA* branchruledata;
1461 assert(origscip != NULL);
1464 SCIP_CALL( SCIPallocMemory(scip, &branchruledata) );
1469 assert(branchrule != NULL);
1472 SCIP_CALL( SCIPsetBranchruleFree(scip, branchrule, branchFreeRelpsprob) );
1473 SCIP_CALL( SCIPsetBranchruleInitsol(scip, branchrule, branchInitsolRelpsprob) );
1474 SCIP_CALL( SCIPsetBranchruleExitsol(scip, branchrule, branchExitsolRelpsprob) );
1477 SCIP_CALL( SCIPaddRealParam(origscip,
1478 "branching/relpsprob/conflictweight",
1479 "weight in score calculations for conflict score",
1480 &branchruledata->conflictweight, TRUE,
DEFAULT_CONFLICTWEIGHT, SCIP_REAL_MIN, SCIP_REAL_MAX, NULL, NULL) );
1481 SCIP_CALL( SCIPaddRealParam(origscip,
1482 "branching/relpsprob/conflictlengthweight",
1483 "weight in score calculations for conflict length score",
1485 SCIP_CALL( SCIPaddRealParam(origscip,
1486 "branching/relpsprob/inferenceweight",
1487 "weight in score calculations for inference score",
1489 SCIP_CALL( SCIPaddRealParam(origscip,
1490 "branching/relpsprob/cutoffweight",
1491 "weight in score calculations for cutoff score",
1492 &branchruledata->cutoffweight, TRUE,
DEFAULT_CUTOFFWEIGHT, SCIP_REAL_MIN, SCIP_REAL_MAX, NULL, NULL) );
1493 SCIP_CALL( SCIPaddRealParam(origscip,
1494 "branching/relpsprob/pscostweight",
1495 "weight in score calculations for pseudo cost score",
1496 &branchruledata->pscostweight, TRUE,
DEFAULT_PSCOSTWEIGHT, SCIP_REAL_MIN, SCIP_REAL_MAX, NULL, NULL) );
1497 SCIP_CALL( SCIPaddRealParam(origscip,
1498 "branching/relpsprob/minreliable",
1499 "minimal value for minimum pseudo cost size to regard pseudo cost value as reliable",
1500 &branchruledata->minreliable, TRUE,
DEFAULT_MINRELIABLE, 0.0, SCIP_REAL_MAX, NULL, NULL) );
1501 SCIP_CALL( SCIPaddRealParam(origscip,
1502 "branching/relpsprob/maxreliable",
1503 "maximal value for minimum pseudo cost size to regard pseudo cost value as reliable",
1504 &branchruledata->maxreliable, TRUE,
DEFAULT_MAXRELIABLE, 0.0, SCIP_REAL_MAX, NULL, NULL) );
1505 SCIP_CALL( SCIPaddRealParam(origscip,
1506 "branching/relpsprob/iterquot",
1507 "maximal fraction of branching LP iterations compared to node relaxation LP iterations",
1508 &branchruledata->iterquot, FALSE,
DEFAULT_ITERQUOT, 0.0, SCIP_REAL_MAX, NULL, NULL) );
1509 SCIP_CALL( SCIPaddIntParam(origscip,
1510 "branching/relpsprob/iterofs",
1511 "additional number of allowed LP iterations",
1512 &branchruledata->iterofs, FALSE,
DEFAULT_ITEROFS, 0, INT_MAX, NULL, NULL) );
1513 SCIP_CALL( SCIPaddIntParam(origscip,
1514 "branching/relpsprob/maxlookahead",
1515 "maximal number of further variables evaluated without better score",
1517 SCIP_CALL( SCIPaddIntParam(origscip,
1518 "branching/relpsprob/initcand",
1519 "maximal number of candidates initialized with strong branching per node",
1520 &branchruledata->initcand, FALSE,
DEFAULT_INITCAND, 0, INT_MAX, NULL, NULL) );
1521 SCIP_CALL( SCIPaddIntParam(origscip,
1522 "branching/relpsprob/maxbdchgs",
1523 "maximal number of bound tightenings before the node is immediately reevaluated (-1: unlimited)",
1524 &branchruledata->maxbdchgs, TRUE,
DEFAULT_MAXBDCHGS, -1, INT_MAX, NULL, NULL) );
1525 SCIP_CALL( SCIPaddIntParam(origscip,
1526 "branching/relpsprob/minbdchgs",
1527 "minimal number of bound tightenings before bound changes are applied",
1529 SCIP_CALL( SCIPaddBoolParam(origscip,
1530 "branching/relpsprob/uselp",
1531 "shall the LP be solved during probing? (TRUE)",
1532 &branchruledata->uselp, FALSE,
DEFAULT_USELP, NULL, NULL) );
1533 SCIP_CALL( SCIPaddRealParam(origscip,
1534 "branching/relpsprob/reliability",
1535 "reliability value for probing",
1547 SCIP_VAR** branchcands,
1548 SCIP_Real* branchcandssol,
1551 SCIP_RESULT* result,
1552 SCIP_VAR** branchvar
1555 SCIP_BRANCHRULE* branchrule;
1558 assert(scip != NULL);
1559 assert(result != NULL);
1563 assert(branchrule != NULL);
1565 assert(origscip != NULL);
1568 SCIP_CALL(
execRelpsprob(origscip, branchrule, branchcands, branchcandssol, nbranchcands,
nvars, result, branchvar) );