heur_dins.c
Go to the documentation of this file.
22 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ 45 #define DEFAULT_NODESQUOT 0.05 /* subproblem nodes in relation to nodes of the original problem */ 46 #define DEFAULT_LPLIMFAC 1.5 /* factor by which the limit on the number of LP depends on the node limit */ 47 #define DEFAULT_MINFIXINGRATE 0.3 /* minimum percentage of integer variables that have to be fixed */ 48 #define DEFAULT_NWAITINGNODES 200LL /* number of nodes without incumbent change that heuristic should wait */ 53 #define DEFAULT_COPYCUTS TRUE /* if DEFAULT_USELPROWS is FALSE, then should all active cuts from the cutpool 71 SCIP_Longint nwaitingnodes; /**< number of nodes without incumbent change that heuristic should wait */ 75 SCIP_Real nodelimit; /**< the nodelimit employed in the current sub-SCIP, for the event handler*/ 76 SCIP_Real lplimfac; /**< factor by which the limit on the number of LP depends on the node limit */ 137 /* if the solution values differ by 0.5 or more, the variable is rebounded, otherwise it is just copied */ 147 /* create a equally sized range around lpsol for general integers: bounds are lpsol +- (mipsol-lpsol) */ 155 /* when the bound new upper bound is equal to the current MIP solution, we set both bounds to the integral bound (without eps) */ 166 /* when the bound new upper bound is equal to the current MIP solution, we set both bounds to the integral bound (without eps) */ 173 /* the global domain of variables might have been reduced since incumbent was found: adjust lb and ub accordingly */ 186 /* the global domain of variables might have been reduced since incumbent was found: adjust it accordingly */ 239 SCIP_CALL( SCIPcreateConsLinear(subscip, &cons, SCIProwGetName(rows[i]), nnonz, consvars, vals, lhs, rhs, 330 /** creates a new solution for the original problem by copying the solution of the subproblem */ 354 /* sub-SCIP may have more variables than the number of active (transformed) variables in the main SCIP 355 * since constraint copying may have required the copy of variables that are fixed in the main SCIP 450 /** solving process initialization method of primal heuristic (called when branch and bound process is about to begin) */ 481 /** solving process deinitialization method of primal heuristic (called before branch and bound process data is freed) */ 577 if( SCIPgetNNodes(scip) - SCIPgetSolNodenum(scip, SCIPgetBestSol(scip)) < heurdata->nwaitingnodes ) 586 maxnnodes = (SCIP_Longint) (maxnnodes * (1.0 + 2.0 * (SCIPheurGetNBestSolsFound(heur)+1.0) / (SCIPheurGetNCalls(heur) + 1.0))); 618 SCIP_CALL( SCIPhashmapCreate(&varmapfw, SCIPblkmem(subscip), SCIPcalcHashtableSize(5 * nvars)) ); 650 SCIP_CALL( SCIPincludeEventhdlrBasic(subscip, &eventhdlr, EVENTHDLR_NAME, EVENTHDLR_DESC, eventExecDins, NULL) ); 668 SCIP_CALL( createSubproblem(scip, subscip, vars, subvars, nbinvars, nintvars, &fixingcounter, heurdata->uselprows) ); 670 SCIPgetNVars(subscip), SCIPgetNBinVars(subscip) , SCIPgetNIntVars(subscip) , SCIPgetNConss(subscip)); 692 /* substract the memory already used by the main SCIP and the estimated memory usage of external software */ 699 /* abort if no time is left or not enough memory to create a copy of SCIP, including external memory usage */ 703 /* disable statistic timing inside sub SCIP unless we are in debug mode and print the statistic timing */ 729 if( SCIPfindNodesel(subscip, "estimate") != NULL && !SCIPisParamFixed(subscip, "nodeselection/estimate/stdpriority") ) 735 if( SCIPfindBranchrule(subscip, "inference") != NULL && !SCIPisParamFixed(subscip, "branching/inference/priority") ) 762 /* employ a limit on the number of enforcement rounds in the quadratic constraint handler; this fixes the issue that 763 * sometimes the quadratic constraint handler needs hundreds or thousands of enforcement rounds to determine the 764 * feasibility status of a single node without fractional branching candidates by separation (namely for uflquad 765 * instances); however, the solution status of the sub-SCIP might get corrupted by this; hence no deductions shall be 768 if( SCIPfindConshdlr(subscip, "quadratic") != NULL && !SCIPisParamFixed(subscip, "constraints/quadratic/enfolplimit") ) 788 /* if new binary variables have been created, e.g., due to column generation, reallocate the delta array */ 796 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &heurdata->delta, heurdata->deltalength, newsize) ); 807 /* hard fixing for some with mipsol(s)=lpsolval=rootlpsolval and preparation for soft fixing for the remaining */ 811 /* soft fixing if the variable somewhen changed its value or the relaxations differ by adding a local branching constraint */ 824 if( nsols > 1 && heurdata->lastnsolsfound != nsolsfound && delta[i] ) /* no need to update delta[i] if already FALSE */ 826 /* no need to update delta[i] if already FALSE or sols[i] already checked on previous run or worse than DINS-solution of last run */ 835 if( delta[i] && SCIPisFeasEQ(scip, mipsolval, lpsolval) && SCIPisFeasEQ(scip, mipsolval, rootlpsolval) 862 /* perform prepared softfixing for all unfixed vars if the number of unfixed vars is larger than the neighborhoodsize (otherwise it will be useless) */ 887 cutoff = (1 - heurdata->minimprove) * SCIPgetUpperbound(scip) + heurdata->minimprove * SCIPgetLowerbound(scip); 908 SCIP_CALL( SCIPcatchEvent(subscip, SCIP_EVENTTYPE_LPSOLVED, eventhdlr, (SCIP_EVENTDATA*) heurdata, NULL) ); 912 SCIPdebugMessage("solving DINS sub-MIP with neighborhoodsize %d and maxnodes %" SCIP_LONGINT_FORMAT "\n", heurdata->neighborhoodsize, nsubnodes); 920 SCIP_CALL( SCIPdropEvent(subscip, SCIP_EVENTTYPE_LPSOLVED, eventhdlr, (SCIP_EVENTDATA*) heurdata, -1) ); 924 * Hence, the return code is caught and a warning is printed, only in debug mode, SCIP will stop. 931 SCIPwarningMessage(scip, "Error while solving subproblem in DINS heuristic; sub-SCIP terminated with code <%d>\n", retcode); 939 SCIPdebugMessage("DINS used %" SCIP_LONGINT_FORMAT "/%" SCIP_LONGINT_FORMAT " nodes and found %d solutions\n", SCIPgetNNodes(subscip), nsubnodes, nsubsols); 946 /* check, whether a solution was found; due to numerics, it might happen that not all solutions are feasible -> try all solutions until one was accepted */ 1005 "number of pool-solutions to be checked for flag array update (for hard fixing of binary variables)", 1033 "if uselprows == FALSE, should all active cuts from cutpool be copied to constraints in subproblem?", SCIP_RETCODE SCIPsetHeurInitsol(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURINITSOL((*heurinitsol))) Definition: scip.c:7361 SCIP_RETCODE SCIPfixVar(SCIP *scip, SCIP_VAR *var, SCIP_Real fixedval, SCIP_Bool *infeasible, SCIP_Bool *fixed) Definition: scip.c:22777 Definition: type_result.h:33 SCIP_CONSHDLR * SCIPfindConshdlr(SCIP *scip, const char *name) Definition: scip.c:5878 Definition: type_result.h:47 Definition: type_result.h:34 Definition: struct_scip.h:53 SCIP_RETCODE SCIPsetHeurCopy(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURCOPY((*heurcopy))) Definition: scip.c:7297 void SCIPwarningMessage(SCIP *scip, const char *formatstr,...) Definition: scip.c:1248 Definition: struct_var.h:196 SCIP_RETCODE SCIPincludeHeurBasic(SCIP *scip, SCIP_HEUR **heur, const char *name, const char *desc, char dispchar, int priority, int freq, int freqofs, int maxdepth, unsigned int timingmask, SCIP_Bool usessubscip, SCIP_DECL_HEUREXEC((*heurexec)), SCIP_HEURDATA *heurdata) Definition: scip.c:7252 SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize) Definition: misc.c:2057 SCIP_RETCODE SCIPsetLongintParam(SCIP *scip, const char *name, SCIP_Longint value) Definition: scip.c:4046 SCIP_RETCODE SCIPincludeEventhdlrBasic(SCIP *scip, SCIP_EVENTHDLR **eventhdlrptr, const char *name, const char *desc, SCIP_DECL_EVENTEXEC((*eventexec)), SCIP_EVENTHDLRDATA *eventhdlrdata) Definition: scip.c:7778 Definition: type_var.h:53 SCIP_RETCODE SCIPtrySolFree(SCIP *scip, SCIP_SOL **sol, SCIP_Bool printreason, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored) Definition: scip.c:36299 SCIP_RETCODE SCIPsetRealParam(SCIP *scip, const char *name, SCIP_Real value) Definition: scip.c:4109 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) Definition: scip.c:3601 SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var) Definition: scip.c:34983 void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin) Definition: misc.c:2116 SCIP_RETCODE SCIPcopyCuts(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, int *ncutsadded) Definition: scip.c:2883 Definition: struct_lp.h:123 Definition: struct_sol.h:50 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) Definition: scip.c:3547 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) Definition: scip.c:3573 Definition: struct_misc.h:101 SCIP_RETCODE SCIPcopy(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, const char *suffix, SCIP_Bool global, SCIP_Bool enablepricing, SCIP_Bool passmessagehdlr, SCIP_Bool *valid) Definition: scip.c:3254 static SCIP_RETCODE createSubproblem(SCIP *scip, SCIP *subscip, SCIP_VAR **vars, SCIP_VAR **subvars, int nbinvars, int nintvars, int *fixingcounter, SCIP_Bool uselprows) Definition: heur_dins.c:95 Definition: type_result.h:35 SCIP_RETCODE SCIPchgVarUbGlobal(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound) Definition: scip.c:20049 Definition: struct_cons.h:36 Definition: type_paramset.h:54 SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur) Definition: scip.c:34002 SCIP_Bool SCIPisFeasEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2) Definition: scip.c:41907 SCIP_RETCODE SCIPsetSeparating(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet) Definition: scip.c:4457 #define SCIPreallocBlockMemoryArray(scip, ptr, oldnum, newnum) Definition: scip.h:20562 SCIP_RETCODE SCIPcreateProb(SCIP *scip, const char *name, SCIP_DECL_PROBDELORIG((*probdelorig)), SCIP_DECL_PROBTRANS((*probtrans)), SCIP_DECL_PROBDELTRANS((*probdeltrans)), SCIP_DECL_PROBINITSOL((*probinitsol)), SCIP_DECL_PROBEXITSOL((*probexitsol)), SCIP_DECL_PROBCOPY((*probcopy)), SCIP_PROBDATA *probdata) Definition: scip.c:9019 Definition: type_retcode.h:33 SCIP_RETCODE SCIPgetLPRowsData(SCIP *scip, SCIP_ROW ***rows, int *nrows) Definition: scip.c:26750 SCIP_RETCODE SCIPgetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals) Definition: scip.c:35020 Definition: struct_heur.h:75 void SCIPheurSetData(SCIP_HEUR *heur, SCIP_HEURDATA *heurdata) Definition: heur.c:1068 Definition: type_lp.h:34 SCIP_RETCODE SCIPincludeDefaultPlugins(SCIP *scip) Definition: scipdefplugins.c:27 SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value) Definition: scip.c:4001 Definition: type_var.h:54 SCIP_RETCODE SCIPsetSubscipsOff(SCIP *scip, SCIP_Bool quiet) Definition: scip.c:4382 SCIP_RETCODE SCIPcopyVars(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global) Definition: scip.c:2179 Definition: struct_lp.h:189 SCIP_RETCODE SCIPsetHeurExitsol(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEUREXITSOL((*heurexitsol))) Definition: scip.c:7377 SCIP_RETCODE SCIPsetPresolving(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet) Definition: scip.c:4431 Constraint handler for linear constraints in their most general form, . DINS primal heuristic. SCIP_Longint SCIPheurGetNBestSolsFound(SCIP_HEUR *heur) Definition: heur.c:1293 static SCIP_RETCODE createNewSol(SCIP *scip, SCIP *subscip, SCIP_VAR **subvars, SCIP_HEUR *heur, SCIP_SOL *subsol, SCIP_Bool *success) Definition: heur_dins.c:332 SCIP_RETCODE SCIPdropEvent(SCIP *scip, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int filterpos) Definition: scip.c:36588 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) Definition: cons_linear.c:16099 const char * SCIPeventhdlrGetName(SCIP_EVENTHDLR *eventhdlr) Definition: event.c:278 SCIP_RETCODE SCIPsetHeurFree(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURFREE((*heurfree))) Definition: scip.c:7313 SCIP_BRANCHRULE * SCIPfindBranchrule(SCIP *scip, const char *name) Definition: scip.c:8436 SCIP_RETCODE SCIPchgVarLbGlobal(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound) Definition: scip.c:19972 Definition: type_retcode.h:45 SCIP_RETCODE SCIPsetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals) Definition: scip.c:34885 SCIP_RETCODE SCIPsetBoolParam(SCIP *scip, const char *name, SCIP_Bool value) Definition: scip.c:3938 SCIP_RETCODE SCIPgetVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars) Definition: scip.c:10572 SCIP_RETCODE SCIPgetRealParam(SCIP *scip, const char *name, SCIP_Real *value) Definition: scip.c:3797 Definition: type_paramset.h:53 Definition: objbranchrule.h:33 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) Definition: scip.c:3629 default SCIP plugins static SCIP_RETCODE addLocalBranchingConstraint(SCIP *scip, SCIP *subscip, SCIP_VAR **subvars, SCIP_HEURDATA *heurdata, SCIP_Bool *fixed) Definition: heur_dins.c:254 Definition: struct_event.h:185 SCIP callable library. SCIP_RETCODE SCIPcatchEvent(SCIP *scip, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int *filterpos) Definition: scip.c:36554 |