|
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_TIMING SCIP_PRESOLTIMING_EXHAUSTIVE /* timing of the presolver (fast, medium, or exhaustive) */
46 #define DEFAULT_WRITEPROBLEMS FALSE /**< should the single components be written as an .cip-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,
428 /* the following asserts are not true, because some aggregations in the original scip instance could not get resolved
429 * inside some constraints, so the copy (subscip) will have also some inactive variables which were copied
432 /* there might be less variables in the subscip, because variables might be cancelled out during copying constraint
439 /* In extended debug mode, we want to be informed if the number of variables was reduced during copying.
440 * This might happen, since the components presolver uses SCIPgetConsVars() and then SCIPgetActiveVars() to get the
441 * active representation, while SCIPgetConsCopy() might use SCIPgetProbvarLinearSum() and this might cancel out some
442 * of the active variables and cannot be avoided. However, we want to notice it and check whether the constraint
448 SCIPinfoMessage(scip, NULL, "copying component %d reduced number of variables: %d -> %d\n", compnr, nvars, SCIPgetNVars(subscip));
452 if( presoldata->maxintvars == -1 || (SCIPgetNBinVars(subscip) + presoldata->intfactor * SCIPgetNIntVars(subscip) <= presoldata->maxintvars) )
460 * hence, the return code is caught and a warning is printed, only when more debugging is enabled, SCIP will stop
467 SCIPwarningMessage(scip, "Error while solving subproblem in components presolver; sub-SCIP terminated with code <%d>\n", retcode);
495 SCIPdebugMessage("--> solved to optimality: time=%.2f, solution is%s feasible\n", SCIPgetSolvingTime(subscip), feasible ? "" : " not");
519 /* checking a solution is done with a relative tolerance of feasibility epsilon, if we really want to
520 * change the bounds of the variables by fixing them, the old bounds must not be violated by more than
521 * the absolute epsilon; therefore, we change the fixing values, if needed, and mark that the solution
559 /* the solution value of at least one variable is feasible with a relative tolerance of feasibility epsilon,
560 * but infeasible with an absolute tolerance of epsilon; try to set the variables to the bounds and check
567 SCIPdebugMessage("solution violates bounds by more than epsilon, check the corrected solution...\n");
583 /* check the solution; integrality and bounds should be fulfilled and do not have to be checked */
599 SCIPdebugMessage("--> corrected solution has a different objective value (old=%16.9g, corrected=%16.9g)\n",
638 else if( SCIPgetStatus(subscip) == SCIP_STATUS_UNBOUNDED || SCIPgetStatus(subscip) == SCIP_STATUS_INFORUNBD )
648 /* transfer global fixings to the original problem; we can only do this, if we did not find a solution in the
649 * subproblem, because otherwise, the primal bound might lead to dual reductions that cannot be transferred to
650 * the original problem without also transferring the possibly suboptimal solution (which is currently not
665 SCIP_CALL( SCIPtightenVarLb(scip, vars[i], SCIPvarGetLbGlobal((SCIP_VAR*)SCIPhashmapGetImage(varmap, vars[i])), FALSE,
671 SCIP_CALL( SCIPtightenVarUb(scip, vars[i], SCIPvarGetUbGlobal((SCIP_VAR*)SCIPhashmapGetImage(varmap, vars[i])), FALSE,
677 SCIPdebugMessage("--> tightened %d bounds of variables due to global bounds in the sub-SCIP\n", ntightened);
700 int* firstvaridxpercons, /**< array to store for each constraint the index in the local vars array
769 /* it looks strange if returning the number of variables was successful but not returning the variables */
770 SCIPwarningMessage(scip, "constraint <%s> returned number of variables but returning variables failed\n", SCIPconsGetName(conss[c]));
776 /* check if returned variables are consistent with the number of variables that were returned */
805 /* we add only one directed edge, because the other direction is automatically added for component computation */
873 assert(v == 0 || conscomponents[v] == conscomponents[v-1] || conscomponents[v] == conscomponents[v-1]+1);
888 /* define file name depending on instance name, number of presolver calls and number of components */
902 SCIPinfoMessage(scip, file, "set terminal pdf\nset output \"%s.pdf\"\nunset xtics\nunset ytics\n\n", outname);
903 SCIPinfoMessage(scip, file, "unset border\nunset key\nset style fill solid 1.0 noborder\nset size ratio -1\n");
936 SCIPinfoMessage(scip, file, "%d %d 0.5\n", nvars - varidx[SCIPvarGetProbindex(var)], nconss - c);
969 int* firstvaridxpercons, /**< array with index of first variable in vars array for each constraint */
1002 /* hashmap mapping from original constraints to constraints in the sub-SCIPs (for performance reasons) */
1018 SCIP_CALL( printStructure(scip, vars, conss, components, conscomponent, nvars, nconss, ncomponents) );
1078 SCIPinfoMessage(scip, NULL, "presol component detected component with a single constraint:\n");
1085 SCIP_CALL( copyAndSolveComponent(scip, presoldata, consmap, comp, compconss, ncompconss, compvars,
1157 /* the presolver should be executed only if it didn't run so far or the number of variables was significantly reduced
1216 * that value is used as an estimate of the number of arcs incident to the variable's node in the digraph
1272 compsize[c] = (int)((1000 * (nbinvars + presoldata->intfactor * nintvars) + (950.0 * ncontvars)/nvars));
1278 /* now, we need the reverse direction, i.e., for each component number, we store its new number
1288 /* create subproblems from independent components and solve them in dependence of their size */
1289 SCIP_CALL( splitProblem(scip, presoldata, conss, vars, fixvals, nconss, nvars, components, ncomponents, firstvaridxpercons,
1321 SCIPdebugMessage("%d components, %d solved, %d deleted constraints, %d deleted variables, result = %d\n",
1324 SCIPstatisticMessage("%d components, %d solved, %d deleted constraints, %d deleted variables, result = %d\n",
1419 SCIP_CALL( SCIPincludePresolBasic(scip, &presol, PRESOL_NAME, PRESOL_DESC, PRESOL_PRIORITY, PRESOL_MAXROUNDS,
1422 /* currently, the components presolver is not copied; if a copy callback is added, we need to avoid recursion
1440 "maximum number of integer (or binary) variables to solve a subproblem directly (-1: unlimited)",
1452 "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)",
1456 "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:22764 void SCIPpresolSetData(SCIP_PRESOL *presol, SCIP_PRESOLDATA *presoldata) Definition: presol.c:476 SCIP_RETCODE SCIPincludePresolComponents(SCIP *scip) Definition: presol_components.c:1409 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:26265 Definition: struct_scip.h:53 void SCIPwarningMessage(SCIP *scip, const char *formatstr,...) Definition: scip.c:1220 SCIP_RETCODE SCIPdigraphComputeUndirectedComponents(SCIP_DIGRAPH *digraph, int minsize, int *components, int *ncomponents) Definition: misc.c:6072 static SCIP_DECL_PRESOLFREE(presolFreeComponents) Definition: presol_components.c:1341 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:6195 Definition: struct_var.h:196 void SCIPsplitFilename(char *filename, char **path, char **name, char **extension, char **compression) Definition: misc.c:8358 Definition: type_stat.h:55 SCIP_RETCODE SCIPsetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real val) Definition: scip.c:34453 SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize) Definition: misc.c:2052 SCIP_RETCODE SCIPsetLongintParam(SCIP *scip, const char *name, SCIP_Longint value) Definition: scip.c:4015 SCIP_RETCODE SCIPdigraphSetSizes(SCIP_DIGRAPH *digraph, int *sizes) Definition: misc.c:5715 Definition: type_var.h:53 SCIP_RETCODE SCIPsetRealParam(SCIP *scip, const char *name, SCIP_Real value) Definition: scip.c:4078 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:2334 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:3570 SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var) Definition: scip.c:34593 static SCIP_DECL_PRESOLEXEC(presolExecComponents) Definition: presol_components.c:1395 void SCIPdigraphGetComponent(SCIP_DIGRAPH *digraph, int compidx, int **nodes, int *nnodes) Definition: misc.c:6261 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:960 void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin) Definition: misc.c:2111 Definition: type_message.h:46 SCIP_RETCODE SCIPprintCons(SCIP *scip, SCIP_CONS *cons, FILE *file) Definition: scip.c:26224 SCIP_RETCODE SCIPcheckSolOrig(SCIP *scip, SCIP_SOL *sol, SCIP_Bool *feasible, SCIP_Bool printreason, SCIP_Bool completely) Definition: scip.c:36080 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:3516 SCIP_Bool SCIPhashmapExists(SCIP_HASHMAP *hashmap, void *origin) Definition: misc.c:2154 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:3542 void SCIPsortIntPtr(int *intarray, void **ptrarray, int len) SCIP_RETCODE SCIPdigraphCreate(SCIP_DIGRAPH **digraph, int nnodes) Definition: misc.c:5591 Definition: struct_misc.h:101 SCIP_RETCODE SCIPcopyParamSettings(SCIP *sourcescip, SCIP *targetscip) Definition: scip.c:3133 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:36034 Definition: type_result.h:35 SCIP_RETCODE SCIPwriteParams(SCIP *scip, const char *filename, SCIP_Bool comments, SCIP_Bool onlychanged) Definition: scip.c:4264 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:1115 void SCIPsortIntInt(int *intarray1, int *intarray2, int len) SCIP_RETCODE SCIPsetPresolInit(SCIP *scip, SCIP_PRESOL *presol, SCIP_DECL_PRESOLINIT((*presolinit))) Definition: scip.c:6227 static SCIP_DECL_PRESOLINIT(presolInitComponents) Definition: presol_components.c:1357 Definition: type_stat.h:52 SCIP_Bool SCIPisFeasEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2) Definition: scip.c:41515 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:9095 Definition: type_retcode.h:33 SCIP_RETCODE SCIPdigraphAddArc(SCIP_DIGRAPH *digraph, int startnode, int endnode, void *data) Definition: misc.c:5809 SCIP_RETCODE SCIPgetActiveVars(SCIP *scip, SCIP_VAR **vars, int *nvars, int varssize, int *requiredsize) Definition: scip.c:17548 SCIP_RETCODE SCIPtightenVarLb(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound, SCIP_Bool force, SCIP_Bool *infeasible, SCIP_Bool *tightened) Definition: scip.c:20259 SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value) Definition: scip.c:3970 SCIP_RETCODE SCIPsetPresolFree(SCIP *scip, SCIP_PRESOL *presol, SCIP_DECL_PRESOLFREE((*presolfree))) Definition: scip.c:6211 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:6243 void SCIPverbMessage(SCIP *scip, SCIP_VERBLEVEL msgverblevel, FILE *file, const char *formatstr,...) Definition: scip.c:1270 Definition: type_retcode.h:39 void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...) Definition: scip.c:1253 SCIP_RETCODE SCIPcreateOrigSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur) Definition: scip.c:33828 SCIP_Bool SCIPisFeasLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2) Definition: scip.c:41541 SCIP_RETCODE SCIPwriteOrigProblem(SCIP *scip, const char *filename, const char *extension, SCIP_Bool genericnames) Definition: scip.c:9586 SCIP_RETCODE SCIPgetConsNVars(SCIP *scip, SCIP_CONS *cons, int *nvars, SCIP_Bool *success) Definition: scip.c:26309 SCIP_RETCODE SCIPtightenVarUb(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound, SCIP_Bool force, SCIP_Bool *infeasible, SCIP_Bool *tightened) Definition: scip.c:20365 SCIP_Bool SCIPisFeasGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2) Definition: scip.c:41567 SCIP_RETCODE SCIPsetBoolParam(SCIP *scip, const char *name, SCIP_Bool value) Definition: scip.c:3907 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:1482 SCIP_RETCODE SCIPgetRealParam(SCIP *scip, const char *name, SCIP_Real *value) Definition: scip.c:3766 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:3598 static SCIP_RETCODE fillDigraph(SCIP *scip, SCIP_DIGRAPH *digraph, SCIP_CONS **conss, int nconss, int *firstvaridxpercons, SCIP_Bool *success) Definition: presol_components.c:696 Definition: struct_misc.h:171 Definition: type_stat.h:53 SCIP_RETCODE SCIPincludePresolBasic(SCIP *scip, SCIP_PRESOL **presolptr, const char *name, const char *desc, int priority, int maxrounds, SCIP_PRESOLTIMING timing, SCIP_DECL_PRESOLEXEC((*presolexec)), SCIP_PRESOLDATA *presoldata) Definition: scip.c:6160 Definition: type_result.h:39 Definition: type_stat.h:54 |