32 #define SEPA_NAME "rapidlearning" 33 #define SEPA_DESC "rapid learning heuristic and separator" 34 #define SEPA_PRIORITY -1200000 36 #define SEPA_MAXBOUNDDIST 1.0 37 #define SEPA_USESSUBSCIP TRUE 38 #define SEPA_DELAY FALSE 40 #define DEFAULT_APPLYCONFLICTS TRUE 41 #define DEFAULT_APPLYBDCHGS TRUE 44 #define DEFAULT_APPLYINFERVALS TRUE 45 #define DEFAULT_REDUCEDINFER FALSE 46 #define DEFAULT_APPLYPRIMALSOL TRUE 47 #define DEFAULT_APPLYSOLVED TRUE 49 #define DEFAULT_MAXNVARS 10000 50 #define DEFAULT_MAXNCONSS 10000 52 #define DEFAULT_MINNODES 500 53 #define DEFAULT_MAXNODES 5000 55 #define DEFAULT_CONTVARS FALSE 56 #define DEFAULT_CONTVARSQUOT 0.3 57 #define DEFAULT_LPITERQUOT 0.2 58 #define DEFAULT_COPYCUTS TRUE 104 assert( scip != NULL );
105 assert( subscip != NULL );
106 assert( subvars != NULL );
107 assert( heur != NULL );
108 assert( subsol != NULL );
109 assert( success != NULL );
143 assert(scip != NULL);
144 assert(sepa != NULL);
159 assert(sepa != NULL);
161 assert(scip != NULL);
165 assert(sepadata != NULL);
188 int* oldnconss = NULL;
222 SCIP_CALL(
SCIPcopyConsCompression(scip, subscip, varmapfw, NULL,
"rapid", NULL, NULL, 0,
FALSE,
FALSE,
TRUE, &valid) );
224 if( sepadata->copycuts )
230 for( i = 0; i < nvars; i++ )
258 SCIPdebugMsg(scip,
"unbounded integer variable %s (in [%g,%g]) with objective %g -> skip heuristic\n",
275 for( i = 0; i < nvars; i++ )
281 SCIPdebugMsg(scip,
"Copying SCIP was%s valid.\n", valid ?
"" :
" not");
286 SCIPwarningMessage(scip,
"unfixing parameter lp/solvefreq in subscip of rapidlearning\n");
296 SCIPwarningMessage(scip,
"unfixing parameter nodeselection/dfs/stdpriority in subscip of rapidlearning\n");
324 nodelimit =
MAX(sepadata->minnodes, nodelimit);
325 nodelimit = MIN(sepadata->maxnodes, nodelimit);
365 for( i = 0; i < nvars; ++i)
386 for( i = 0; i < nconshdlrs; ++i)
388 if( conshdlrs[i] != NULL )
412 SCIPdebugMsg(scip,
"proceed solving after the first 20%% of the solution process, since:\n");
435 SCIPdebugMsg(scip,
"do not proceed solving after the first 20%% of the solution process.\n");
442 disabledualreductions =
FALSE;
460 for( i = 0; i < nsubsols && !soladded; ++i )
462 SCIPdebugMsg(scip,
"Try to create new solution by copying subscip solution.\n");
466 disabledualreductions =
TRUE;
470 dualboundchg =
FALSE;
471 if( sepadata->applysolved && !disabledualreductions
492 assert(hashtablesize < INT_MAX/5);
498 for( i = 0; i < nconshdlrs; ++i)
511 for( c = oldnconss[i]; c < nconss; ++c)
517 assert(cons != NULL);
545 if( sepadata->applybdchgs && !disabledualreductions )
546 for( i = 0; i < nvars; ++i )
571 if( sepadata->applyinfervals &&
SCIPgetDepth(scip) == 0 && (!sepadata->reducedinfer || soladded || nbdchgs+nconflicts > 0) )
573 for( i = 0; i < nvars; ++i )
593 if( downinfer+downconflen+downvsids > 0.0 || upinfer+upconflen+upvsids != 0 )
596 if( downinfer+downconflen+downvsids > 0.0 && upinfer+upconflen+upvsids != 0 )
599 SCIP_CALL(
SCIPinitVarBranchStats(scip, vars[i], 0.0, 0.0, downvsids, upvsids, downconflen, upconflen, downinfer, upinfer, 0.0, 0.0) );
603 SCIPdebugMsg(scip,
"Rapidlearning added %d conflicts, changed %d bounds, %s primal solution, %s dual bound improvement.\n",
604 nconflicts, nbdchgs, soladded ?
"found" :
"no", dualboundchg ?
"found" :
"no");
606 SCIPdebugMsg(scip,
"YYY Infervalues initialized on one side: %5.2f %% of variables, %5.2f %% on both sides\n",
610 if( nconflicts > 0 || dualboundchg )
612 else if( nbdchgs > 0 )
616 assert(oldnconss != NULL);
617 assert(conshdlrs != NULL);
618 assert(varmapbw != NULL);
640 assert(sepa != NULL);
641 assert(scip != NULL);
642 assert(result != NULL);
654 assert(sepadata != NULL);
657 if( !sepadata->contvars && ndiscvars !=
SCIPgetNVars(scip) )
719 sepaExeclpRapidlearning, NULL,
722 assert(sepa != NULL);
730 "should the found conflicts be applied in the original SCIP?",
734 "should the found global bound deductions be applied in the original SCIP?",
738 "should the inference values be used as initialization in the original SCIP?",
742 "should the inference values only be used when " SEPA_NAME " found other reductions?",
746 "should the incumbent solution be copied to the original SCIP?",
750 "should a solved status be copied to the original SCIP?",
754 "should rapid learning be applied when there are continuous variables?",
758 "maximal portion of continuous variables to apply rapid learning",
762 "maximal fraction of LP iterations compared to node LP iterations",
766 "maximum problem size (variables) for which rapid learning will be called",
770 "maximum problem size (constraints) for which rapid learning will be called",
774 "maximum number of nodes considered in rapid learning run",
778 "minimum number of nodes considered in rapid learning run",
782 "should all active cuts from cutpool be copied to constraints in subproblem?",
enum SCIP_Result SCIP_RESULT
int SCIPgetNIntVars(SCIP *scip)
#define DEFAULT_REDUCEDINFER
SCIP_RETCODE SCIPsetSeparating(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
SCIP_Real SCIPgetVarAvgInferences(SCIP *scip, SCIP_VAR *var, SCIP_BRANCHDIR dir)
SCIP_RETCODE SCIPtightenVarLb(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound, SCIP_Bool force, SCIP_Bool *infeasible, SCIP_Bool *tightened)
SCIP_STAGE SCIPgetStage(SCIP *scip)
SCIP_Bool SCIPconsIsDynamic(SCIP_CONS *cons)
SCIP_Longint SCIPgetNLPIterations(SCIP *scip)
SCIP_Bool SCIPisFeasLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_CONSHDLR * SCIPfindConshdlr(SCIP *scip, const char *name)
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
#define DEFAULT_CONTVARSQUOT
SCIP_Bool SCIPisPositive(SCIP *scip, SCIP_Real val)
int SCIPgetNOrigVars(SCIP *scip)
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
#define DEFAULT_LPITERQUOT
static SCIP_DECL_SEPAEXECLP(sepaExeclpRapidlearning)
SCIP_RETCODE SCIPgetVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars)
SCIP_CONS ** SCIPconshdlrGetConss(SCIP_CONSHDLR *conshdlr)
SCIP_SOL ** SCIPgetSols(SCIP *scip)
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
SCIP_Real SCIPgetVarVSIDS(SCIP *scip, SCIP_VAR *var, SCIP_BRANCHDIR dir)
SCIP_RETCODE SCIPcopyLimits(SCIP *sourcescip, SCIP *targetscip)
int SCIPgetNActivePricers(SCIP *scip)
SCIP_RETCODE SCIPcopyConsCompression(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, const char *suffix, SCIP_VAR **fixedvars, SCIP_Real *fixedvals, int nfixedvars, SCIP_Bool global, SCIP_Bool enablepricing, SCIP_Bool passmessagehdlr, SCIP_Bool *valid)
SCIP_Bool SCIPisNegative(SCIP *scip, SCIP_Real val)
const char * SCIPsepaGetName(SCIP_SEPA *sepa)
enum SCIP_Retcode SCIP_RETCODE
SCIP_RETCODE SCIPaddVarLocks(SCIP *scip, SCIP_VAR *var, int nlocksdown, int nlocksup)
SCIP_RETCODE SCIPsetPresolving(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
public methods for problem variables
SCIP_RETCODE SCIPtightenVarUb(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound, SCIP_Bool force, SCIP_Bool *infeasible, SCIP_Bool *tightened)
#define SCIPfreeBlockMemory(scip, ptr)
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_RETCODE SCIPsetSepaCopy(SCIP *scip, SCIP_SEPA *sepa, SCIP_DECL_SEPACOPY((*sepacopy)))
SCIP_RETCODE SCIPsetRealParam(SCIP *scip, const char *name, SCIP_Real value)
SCIP_Bool SCIPconsIsRemovable(SCIP_CONS *cons)
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
SCIP_RETCODE SCIPaddIntParam(SCIP *scip, const char *name, const char *desc, int *valueptr, SCIP_Bool isadvanced, int defaultvalue, int minvalue, int maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
SCIP_RETCODE SCIPprintStatistics(SCIP *scip, FILE *file)
int SCIPgetNContVars(SCIP *scip)
#define DEFAULT_APPLYCONFLICTS
SCIP_SEPADATA * SCIPsepaGetData(SCIP_SEPA *sepa)
int SCIPgetNFixedVars(SCIP *scip)
SCIP_RETCODE SCIPchgVarType(SCIP *scip, SCIP_VAR *var, SCIP_VARTYPE vartype, SCIP_Bool *infeasible)
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
int SCIPsepaGetFreq(SCIP_SEPA *sepa)
SCIP_RETCODE SCIPsolve(SCIP *scip)
static SCIP_RETCODE setupAndSolveSubscipRapidlearning(SCIP *scip, SCIP *subscip, SCIP_SEPADATA *sepadata, SCIP_RESULT *result)
SCIP_HEUR * SCIPfindHeur(SCIP *scip, const char *name)
SCIP_Bool SCIPisParamFixed(SCIP *scip, const char *name)
SCIP_RETCODE SCIPaddCons(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPgetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
SCIP_RETCODE SCIPinitVarBranchStats(SCIP *scip, SCIP_VAR *var, SCIP_Real downpscost, SCIP_Real uppscost, SCIP_Real downvsids, SCIP_Real upvsids, SCIP_Real downconflen, SCIP_Real upconflen, SCIP_Real downinfer, SCIP_Real upinfer, SCIP_Real downcutoff, SCIP_Real upcutoff)
#define DEFAULT_APPLYBDCHGS
SCIP_Real SCIPgetDualbound(SCIP *scip)
int SCIPsepaGetNCallsAtNode(SCIP_SEPA *sepa)
SCIP_RETCODE SCIPsetBoolParam(SCIP *scip, const char *name, SCIP_Bool value)
SCIP_STATUS SCIPgetStatus(SCIP *scip)
SCIP_RETCODE SCIPpresolve(SCIP *scip)
SCIP_RETCODE SCIPcopyCuts(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, int *ncutsadded)
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
const char * SCIPconsGetName(SCIP_CONS *cons)
SCIP_Bool SCIPconsIsPropagated(SCIP_CONS *cons)
const char * SCIPvarGetName(SCIP_VAR *var)
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
void SCIPsepaSetData(SCIP_SEPA *sepa, SCIP_SEPADATA *sepadata)
SCIP_RETCODE SCIPunfixParam(SCIP *scip, const char *name)
SCIP_Real SCIPgetVarAvgConflictlength(SCIP *scip, SCIP_VAR *var, SCIP_BRANCHDIR dir)
#define DEFAULT_MAXNCONSS
SCIP_Bool SCIPisFeasLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
int SCIPconshdlrGetNConss(SCIP_CONSHDLR *conshdlr)
SCIP_RETCODE SCIPgetConsCopy(SCIP *sourcescip, SCIP *targetscip, SCIP_CONS *sourcecons, SCIP_CONS **targetcons, SCIP_CONSHDLR *sourceconshdlr, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, const char *name, 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 global, SCIP_Bool *valid)
SCIP_RETCODE SCIPincludeSepaBasic(SCIP *scip, SCIP_SEPA **sepa, const char *name, const char *desc, int priority, int freq, SCIP_Real maxbounddist, SCIP_Bool usessubscip, SCIP_Bool delay, SCIP_DECL_SEPAEXECLP((*sepaexeclp)), SCIP_DECL_SEPAEXECSOL((*sepaexecsol)), SCIP_SEPADATA *sepadata)
SCIP_Longint SCIPsepaGetNCalls(SCIP_SEPA *sepa)
#define SCIPallocBufferArray(scip, ptr, num)
int SCIPgetNImplVars(SCIP *scip)
SCIP_RETCODE SCIPsetObjlimit(SCIP *scip, SCIP_Real objlimit)
int SCIPgetDepth(SCIP *scip)
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)
#define DEFAULT_APPLYINFERVALS
SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value)
SCIP_Bool SCIPconsIsChecked(SCIP_CONS *cons)
SCIP_Bool SCIPconsIsInitial(SCIP_CONS *cons)
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
SCIP_Longint SCIPgetNConflictConssFound(SCIP *scip)
int SCIPgetNSols(SCIP *scip)
SCIP_RETCODE SCIPupdateLocalDualbound(SCIP *scip, SCIP_Real newbound)
SCIP_Real SCIPgetSolOrigObj(SCIP *scip, SCIP_SOL *sol)
SCIP_Longint SCIPgetNConflictConssApplied(SCIP *scip)
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
static SCIP_RETCODE createNewSol(SCIP *scip, SCIP *subscip, SCIP_VAR **subvars, SCIP_HEUR *heur, SCIP_SOL *subsol, SCIP_Bool *success)
int SCIPgetNBinVars(SCIP *scip)
int SCIPgetNVars(SCIP *scip)
static SCIP_DECL_SEPAFREE(sepaFreeRapidlearning)
SCIP_RETCODE SCIPsetSepaFree(SCIP *scip, SCIP_SEPA *sepa, SCIP_DECL_SEPAFREE((*sepafree)))
SCIP_RETCODE SCIPincludeSepaRapidlearning(SCIP *scip)
int SCIPgetNConss(SCIP *scip)
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
SCIP_Real SCIPretransformObj(SCIP *scip, SCIP_Real obj)
SCIP_Bool SCIPisStopped(SCIP *scip)
SCIP_Bool SCIPconsIsEnforced(SCIP_CONS *cons)
SCIP_Bool SCIPconsIsSeparated(SCIP_CONS *cons)
SCIP_RETCODE SCIPcheckCopyLimits(SCIP *sourcescip, SCIP_Bool *success)
#define DEFAULT_APPLYPRIMALSOL
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
SCIP_RETCODE SCIPsetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
SCIP_RETCODE SCIPtransformProb(SCIP *scip)
SCIP_Bool SCIPisLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
SCIP_Real SCIPgetUpperbound(SCIP *scip)
SCIP_RETCODE SCIPhashmapInsert(SCIP_HASHMAP *hashmap, void *origin, void *image)
#define SCIP_CALL_ABORT(x)
#define DEFAULT_APPLYSOLVED
SCIP_VAR * SCIPvarGetTransVar(SCIP_VAR *var)
#define SEPA_MAXBOUNDDIST
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)
static SCIP_DECL_SEPACOPY(sepaCopyRapidlearning)
SCIP_RETCODE SCIPsetLongintParam(SCIP *scip, const char *name, SCIP_Longint value)
struct SCIP_SepaData SCIP_SEPADATA
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)
SCIP_RETCODE SCIPfree(SCIP **scip)
SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)