|
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
presol_components.c
Go to the documentation of this file.
29 * @todo solve all components with less than given size, count number of components with nodelimit reached;
30 * if all components could be solved within nodelimit (or all but x), continue solving components in
34 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
42 #define PRESOL_PRIORITY -9200000 /**< priority of the presolver (>= 0: before, < 0: after constraint handlers); combined with propagators */
43 #define PRESOL_MAXROUNDS -1 /**< maximal number of presolving rounds the presolver participates in (-1: no limit) */
44 #define PRESOL_DELAY TRUE /**< should presolver be delayed, if other presolvers found reductions? */
46 #define DEFAULT_WRITEPROBLEMS FALSE /**< should the single components be written as an .lp-file? */
47 #define DEFAULT_MAXINTVARS 500 /**< maximum number of integer (or binary) variables to solve a subproblem directly (-1: no solving) */
49 #define DEFAULT_INTFACTOR 1.0 /**< the weight of an integer variable compared to binary variables */
50 #define DEFAULT_RELDECREASE 0.2 /**< percentage by which the number of variables has to be decreased after the last component solving
52 #define DEFAULT_FEASTOLFACTOR 1.0 /**< default value for parameter to increase the feasibility tolerance in all sub-SCIPs */
69 SCIP_Real reldecrease; /** percentage by which the number of variables has to be decreased after the last component solving
75 int maxintvars; /** maximum number of integer (or binary) variables to solve a subproblem directly (-1: no solving) */
138 /** statistics: categorize the component with the given number of binary and integer variables */
153 /* check into which category the component belongs by looking at the number of discrete variables */
163 /* number of discrete variables greater than all limits, so component belongs to last category */
221 /** copies a connected component consisting of the given constraints and variables into a sub-SCIP
264 SCIPverbMessage(scip, SCIP_VERBLEVEL_FULL, NULL, "build sub-SCIP for component %d: %d vars (%d bin, %d int, %d cont), %d conss\n",
267 SCIPdebugMessage("build sub-SCIP for component %d: %d vars (%d bin, %d int, %d cont), %d conss\n",
271 /* stop if the problem has too many integer variables; only if the problems should be written we have to build it anyway */
272 if( presoldata->maxintvars != -1 && (nbinvars + presoldata->intfactor * nintvars > presoldata->maxintvars)
276 SCIPverbMessage(scip, SCIP_VERBLEVEL_FULL, NULL, "--> not created (too many integer variables)\n");
290 /* substract the memory already used by the main SCIP and the estimated memory usage of external software */
297 /* abort if no time is left or not enough memory to create a copy of SCIP, including external memory usage */
298 if( timelimit <= 0.0 || memorylimit <= (1.0 * nvars / SCIPgetNVars(scip)) * (1.0 * nconss / SCIPgetNConss(scip)) *
311 /* copy plugins, we omit pricers (because we do not run if there are active pricers) and dialogs */
358 SCIP_CALL( SCIPsetRealParam(subscip, "numerics/feastol", feastol * presoldata->feastolfactor) );
405 SCIP_CALL( SCIPgetConsCopy(scip, subscip, conss[i], &newcons, SCIPconsGetHdlr(conss[i]), varmap, consmap, name,
424 /* the following asserts are not true, because some aggregations in the original scip instance could not get resolved
425 * inside some constraints, so the copy (subscip) will have also some inactive variables which were copied
428 /* there might be less variables in the subscip, because variables might be cancelled out during copying constraint
435 /* In extended debug mode, we want to be informed if the number of variables was reduced during copying.
436 * This might happen, since the components presolver uses SCIPgetConsVars() and then SCIPgetActiveVars() to get the
437 * active representation, while SCIPgetConsCopy() might use SCIPgetProbvarLinearSum() and this might cancel out some
438 * of the active variables and cannot be avoided. However, we want to notice it and check whether the constraint
444 SCIPinfoMessage(scip, NULL, "copying component %d reduced number of variables: %d -> %d\n", compnr, nvars, SCIPgetNVars(subscip));
448 if( presoldata->maxintvars == -1 || (SCIPgetNBinVars(subscip) + presoldata->intfactor * SCIPgetNIntVars(subscip) <= presoldata->maxintvars) )
456 * hence, the return code is caught and a warning is printed, only when more debugging is enabled, SCIP will stop
463 SCIPwarningMessage(scip, "Error while solving subproblem in components presolver; sub-SCIP terminated with code <%d>\n", retcode);
491 SCIPdebugMessage("--> solved to optimality: time=%.2f, solution is%s feasible\n", SCIPgetSolvingTime(subscip), feasible ? "" : " not");
515 /* checking a solution is done with a relative tolerance of feasibility epsilon, if we really want to
516 * change the bounds of the variables by fixing them, the old bounds must not be violated by more than
517 * the absolute epsilon; therefore, we change the fixing values, if needed, and mark that the solution
555 /* the solution value of at least one variable is feasible with a relative tolerance of feasibility epsilon,
556 * but infeasible with an absolute tolerance of epsilon; try to set the variables to the bounds and check
563 SCIPdebugMessage("solution violates bounds by more than epsilon, check the corrected solution...\n");
579 /* check the solution; integrality and bounds should be fulfilled and do not have to be checked */
595 SCIPdebugMessage("--> corrected solution has a different objective value (old=%16.9g, corrected=%16.9g)\n",
634 else if( SCIPgetStatus(subscip) == SCIP_STATUS_UNBOUNDED || SCIPgetStatus(subscip) == SCIP_STATUS_INFORUNBD )
644 /* transfer global fixings to the original problem; we can only do this, if we did not find a solution in the
645 * subproblem, because otherwise, the primal bound might lead to dual reductions that cannot be transferred to
646 * the original problem without also transferring the possibly suboptimal solution (which is currently not
661 SCIP_CALL( SCIPtightenVarLb(scip, vars[i], SCIPvarGetLbGlobal((SCIP_VAR*)SCIPhashmapGetImage(varmap, vars[i])), FALSE,
667 SCIP_CALL( SCIPtightenVarUb(scip, vars[i], SCIPvarGetUbGlobal((SCIP_VAR*)SCIPhashmapGetImage(varmap, vars[i])), FALSE,
673 SCIPdebugMessage("--> tightened %d bounds of variables due to global bounds in the sub-SCIP\n", ntightened);
696 int* firstvaridxpercons, /**< array to store for each constraint the index in the local vars array
765 /* it looks strange if returning the number of variables was successful but not returning the variables */
766 SCIPwarningMessage(scip, "constraint <%s> returned number of variables but returning variables failed\n", SCIPconsGetName(conss[c]));
772 /* check if returned variables are consistent with the number of variables that were returned */
801 /* we add only one directed edge, because the other direction is automatically added for component computation */
869 assert(v == 0 || conscomponents[v] == conscomponents[v-1] || conscomponents[v] == conscomponents[v-1]+1);
884 /* define file name depending on instance name, number of presolver calls and number of components */
898 SCIPinfoMessage(scip, file, "set terminal pdf\nset output \"%s.pdf\"\nunset xtics\nunset ytics\n\n", outname);
899 SCIPinfoMessage(scip, file, "unset border\nunset key\nset style fill solid 1.0 noborder\nset size ratio -1\n");
932 SCIPinfoMessage(scip, file, "%d %d 0.5\n", nvars - varidx[SCIPvarGetProbindex(var)], nconss - c);
965 int* firstvaridxpercons, /**< array with index of first variable in vars array for each constraint */
997 /* hashmap mapping from original constraints to constraints in the sub-SCIPs (for performance reasons) */
1013 SCIP_CALL( printStructure(scip, vars, conss, components, conscomponent, nvars, nconss, ncomponents) );
1070 SCIPinfoMessage(scip, NULL, "presol component detected component with a single constraint:\n");
1077 SCIP_CALL( copyAndSolveComponent(scip, presoldata, consmap, comp, compconss, ncompconss, compvars,
1149 /* the presolver should be executed only if it didn't run so far or the number of variables was significantly reduced
1208 * that value is used as an estimate of the number of arcs incident to the variable's node in the digraph
1264 compsize[c] = (int)((1000 * (nbinvars + presoldata->intfactor * nintvars) + (950.0 * ncontvars)/nvars));
1270 /* now, we need the reverse direction, i.e., for each component number, we store its new number
1280 /* create subproblems from independent components and solve them in dependence of their size */
1281 SCIP_CALL( splitProblem(scip, presoldata, conss, vars, fixvals, nconss, nvars, components, ncomponents, firstvaridxpercons,
1313 SCIPdebugMessage("%d components, %d solved, %d deleted constraints, %d deleted variables, result = %d\n",
1316 SCIPstatisticMessage("%d components, %d solved, %d deleted constraints, %d deleted variables, result = %d\n",
1411 SCIP_CALL( SCIPincludePresolBasic(scip, &presol, PRESOL_NAME, PRESOL_DESC, PRESOL_PRIORITY, PRESOL_MAXROUNDS,
1414 /* currently, the components presolver is not copied; if a copy callback is added, we need to avoid recursion
1432 "maximum number of integer (or binary) variables to solve a subproblem directly (-1: unlimited)",
1444 "percentage by which the number of variables has to be decreased after the last component solving to allow running again (1.0: do not run again)",
1448 "factor to increase the feasibility tolerance of the main SCIP in all sub-SCIPs, default value 1.0",
SCIP_RETCODE SCIPfixVar(SCIP *scip, SCIP_VAR *var, SCIP_Real fixedval, SCIP_Bool *infeasible, SCIP_Bool *fixed) Definition: scip.c:20784 void SCIPpresolSetData(SCIP_PRESOL *presol, SCIP_PRESOLDATA *presoldata) Definition: presol.c:474 SCIP_RETCODE SCIPincludePresolComponents(SCIP *scip) Definition: presol_components.c:1401 Definition: struct_presol.h:36 Definition: type_result.h:33 SCIP_RETCODE SCIPgetConsVars(SCIP *scip, SCIP_CONS *cons, SCIP_VAR **vars, int varssize, SCIP_Bool *success) Definition: scip.c:23975 Definition: struct_scip.h:52 void SCIPwarningMessage(SCIP *scip, const char *formatstr,...) Definition: scip.c:1206 SCIP_RETCODE SCIPdigraphComputeUndirectedComponents(SCIP_DIGRAPH *digraph, int minsize, int *components, int *ncomponents) Definition: misc.c:5788 static SCIP_DECL_PRESOLFREE(presolFreeComponents) Definition: presol_components.c:1333 Definition: type_result.h:49 Definition: type_result.h:38 SCIP_RETCODE SCIPsetPresolCopy(SCIP *scip, SCIP_PRESOL *presol, SCIP_DECL_PRESOLCOPY((*presolcopy))) Definition: scip.c:5948 Definition: struct_var.h:196 void SCIPsplitFilename(char *filename, char **path, char **name, char **extension, char **compression) Definition: misc.c:7768 Definition: type_stat.h:54 SCIP_RETCODE SCIPsetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real val) Definition: scip.c:31639 SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize) Definition: misc.c:1864 SCIP_RETCODE SCIPsetLongintParam(SCIP *scip, const char *name, SCIP_Longint value) Definition: scip.c:3869 SCIP_RETCODE SCIPdigraphSetSizes(SCIP_DIGRAPH *digraph, int *sizes) Definition: misc.c:5450 Definition: type_var.h:53 SCIP_RETCODE SCIPsetRealParam(SCIP *scip, const char *name, SCIP_Real value) Definition: scip.c:3914 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 *success) Definition: scip.c:2212 static SCIP_RETCODE copyAndSolveComponent(SCIP *scip, SCIP_PRESOLDATA *presoldata, SCIP_HASHMAP *consmap, int compnr, SCIP_CONS **conss, int nconss, SCIP_VAR **vars, SCIP_Real *fixvals, int nvars, int nbinvars, int nintvars, int *nsolvedprobs, int *ndeletedvars, int *ndeletedconss, SCIP_RESULT *result) Definition: presol_components.c:226 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:3442 SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var) Definition: scip.c:31775 static SCIP_DECL_PRESOLEXEC(presolExecComponents) Definition: presol_components.c:1387 void SCIPdigraphGetComponent(SCIP_DIGRAPH *digraph, int compidx, int **nodes, int *nnodes) Definition: misc.c:5977 static SCIP_RETCODE splitProblem(SCIP *scip, SCIP_PRESOLDATA *presoldata, SCIP_CONS **conss, SCIP_VAR **vars, SCIP_Real *fixvals, int nconss, int nvars, int *components, int ncomponents, int *firstvaridxpercons, int *nsolvedprobs, int *ndeletedvars, int *ndeletedconss, SCIP_RESULT *result) Definition: presol_components.c:956 void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin) Definition: misc.c:1923 Definition: type_message.h:46 SCIP_RETCODE SCIPprintCons(SCIP *scip, SCIP_CONS *cons, FILE *file) Definition: scip.c:23934 SCIP_RETCODE SCIPcheckSolOrig(SCIP *scip, SCIP_SOL *sol, SCIP_Bool *feasible, SCIP_Bool printreason, SCIP_Bool completely) Definition: scip.c:33227 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:3388 SCIP_Bool SCIPhashmapExists(SCIP_HASHMAP *hashmap, void *origin) Definition: misc.c:1966 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:3414 void SCIPsortIntPtr(int *intarray, void **ptrarray, int len) SCIP_RETCODE SCIPdigraphCreate(SCIP_DIGRAPH **digraph, int nnodes) Definition: misc.c:5326 Definition: struct_misc.h:101 SCIP_RETCODE SCIPcopyParamSettings(SCIP *sourcescip, SCIP *targetscip) Definition: scip.c:3005 SCIP_RETCODE SCIPcheckSol(SCIP *scip, SCIP_SOL *sol, SCIP_Bool printreason, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *feasible) Definition: scip.c:33181 Definition: type_result.h:35 Definition: struct_cons.h:36 static SCIP_RETCODE presolComponents(SCIP *scip, SCIP_PRESOL *presol, int *nfixedvars, int *ndelconss, SCIP_RESULT *result) Definition: presol_components.c:1107 void SCIPsortIntInt(int *intarray1, int *intarray2, int len) SCIP_RETCODE SCIPsetPresolInit(SCIP *scip, SCIP_PRESOL *presol, SCIP_DECL_PRESOLINIT((*presolinit))) Definition: scip.c:5980 static SCIP_DECL_PRESOLINIT(presolInitComponents) Definition: presol_components.c:1349 Definition: type_stat.h:51 SCIP_Bool SCIPisFeasEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2) Definition: scip.c:38648 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:8453 Definition: type_retcode.h:33 SCIP_RETCODE SCIPdigraphAddArc(SCIP_DIGRAPH *digraph, int startnode, int endnode, void *data) Definition: misc.c:5544 SCIP_RETCODE SCIPgetActiveVars(SCIP *scip, SCIP_VAR **vars, int *nvars, int varssize, int *requiredsize) Definition: scip.c:15706 SCIP_RETCODE SCIPtightenVarLb(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound, SCIP_Bool force, SCIP_Bool *infeasible, SCIP_Bool *tightened) Definition: scip.c:18371 SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value) Definition: scip.c:3824 SCIP_RETCODE SCIPsetPresolFree(SCIP *scip, SCIP_PRESOL *presol, SCIP_DECL_PRESOLFREE((*presolfree))) Definition: scip.c:5964 Definition: type_var.h:54 Definition: type_set.h:38 components presolver SCIP_RETCODE SCIPsetPresolExit(SCIP *scip, SCIP_PRESOL *presol, SCIP_DECL_PRESOLEXIT((*presolexit))) Definition: scip.c:5996 void SCIPverbMessage(SCIP *scip, SCIP_VERBLEVEL msgverblevel, FILE *file, const char *formatstr,...) Definition: scip.c:1256 Definition: type_retcode.h:39 void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...) Definition: scip.c:1239 SCIP_RETCODE SCIPcreateOrigSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur) Definition: scip.c:31072 SCIP_Bool SCIPisFeasLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2) Definition: scip.c:38686 SCIP_RETCODE SCIPwriteOrigProblem(SCIP *scip, const char *filename, const char *extension, SCIP_Bool genericnames) Definition: scip.c:8926 SCIP_RETCODE SCIPgetConsNVars(SCIP *scip, SCIP_CONS *cons, int *nvars, SCIP_Bool *success) Definition: scip.c:24019 SCIP_RETCODE SCIPtightenVarUb(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound, SCIP_Bool force, SCIP_Bool *infeasible, SCIP_Bool *tightened) Definition: scip.c:18477 SCIP_Bool SCIPisFeasGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2) Definition: scip.c:38724 SCIP_RETCODE SCIPsetBoolParam(SCIP *scip, const char *name, SCIP_Bool value) Definition: scip.c:3779 SCIP_RETCODE SCIPcopyPlugins(SCIP *sourcescip, SCIP *targetscip, SCIP_Bool copyreaders, SCIP_Bool copypricers, SCIP_Bool copyconshdlrs, SCIP_Bool copyconflicthdlrs, SCIP_Bool copypresolvers, SCIP_Bool copyrelaxators, SCIP_Bool copyseparators, SCIP_Bool copypropagators, SCIP_Bool copyheuristics, SCIP_Bool copyeventhdlrs, SCIP_Bool copynodeselectors, SCIP_Bool copybranchrules, SCIP_Bool copydisplays, SCIP_Bool copydialogs, SCIP_Bool copynlpis, SCIP_Bool passmessagehdlr, SCIP_Bool *valid) Definition: scip.c:1422 SCIP_RETCODE SCIPgetRealParam(SCIP *scip, const char *name, SCIP_Real *value) Definition: scip.c:3638 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:3470 static SCIP_RETCODE fillDigraph(SCIP *scip, SCIP_DIGRAPH *digraph, SCIP_CONS **conss, int nconss, int *firstvaridxpercons, SCIP_Bool *success) Definition: presol_components.c:692 Definition: struct_misc.h:171 SCIP_RETCODE SCIPincludePresolBasic(SCIP *scip, SCIP_PRESOL **presolptr, const char *name, const char *desc, int priority, int maxrounds, SCIP_Bool delay, SCIP_DECL_PRESOLEXEC((*presolexec)), SCIP_PRESOLDATA *presoldata) Definition: scip.c:5913 Definition: type_stat.h:52 Definition: type_result.h:39 Definition: type_stat.h:53 |