presolve.c
Go to the documentation of this file.
21 /* all general presolving methods (not working on any specific kind of data(, e.g. consdata) should be implemented here */
23 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
43 /** collect variable bound information for a variable set reduction and global implication; only variable which have the
57 SCIP_Real* newbounds, /**< array of implied bounds(, size is two times number of variables, first
160 /* @todo if implvars[x] is aggregated, we could transform the variable into the active representation */
161 if( idx < 0 || SCIPisFeasEQ(scip, SCIPvarGetLbGlobal(implvars[w]), SCIPvarGetUbGlobal(implvars[w])) )
183 /* set variable 'var' with bound implies other set variable 'implvars[w]' with corresponding bound
214 else if( SCIPisFeasLT(scip, implcoefs[w] * SCIPvarGetUbGlobal(implvars[w]) + implconsts[w], bounds[pos]) )
220 /* set variable 'var' with bound implies other set variable 'implvars[w]' with corresponding bound so
226 SCIPvarGetName(var), ">=", bounds[pos], SCIPvarGetName(implvars[w]), "<=", newub, bounds[issetvar[idx] - 1] );
275 /* set variable 'var' with bound implies other set variable 'implvars[w]' with corresponding bound
306 else if( SCIPisFeasLT(scip, implcoefs[w]*SCIPvarGetLbGlobal(implvars[w]) + implconsts[w], bounds[pos]) )
312 /* set variable 'var' with bound implies other set variable 'implvars[w]' with corresponding bound so
318 SCIPvarGetName(var), ">=", bounds[pos], SCIPvarGetName(implvars[w]), ">=", newlb, bounds[issetvar[idx] - 1] );
397 /* @todo if implvars[x] is aggregated, we could transform the variable into the active representation */
398 if( idx < 0 || SCIPisFeasEQ(scip, SCIPvarGetLbGlobal(implvars[w]), SCIPvarGetUbGlobal(implvars[w])) )
448 else if( SCIPisFeasGT(scip, implcoefs[w]*SCIPvarGetLbGlobal(implvars[w]) + implconsts[w], bounds[pos]) )
457 SCIPvarGetName(var), "<=", bounds[pos], SCIPvarGetName(implvars[w]), ">=", newlb, bounds[issetvar[idx] - 1]);
536 else if( SCIPisFeasGT(scip, implcoefs[w]*SCIPvarGetUbGlobal(implvars[w]) + implconsts[w], bounds[pos]) )
545 SCIPvarGetName(var), "<=", bounds[pos], SCIPvarGetName(implvars[w]), "<=", newub, bounds[issetvar[idx] - 1]);
581 /** collect non-binary implication data for variable set reduction and global bound implications; only variable which
582 * have the vartype SCIP_VARTYPE_BINARY have implications, otherwise the implications are saved as variable bounds
596 SCIP_Real* newbounds, /**< array of implied bounds(, size is two times number of variables, first
604 int* ncountnonzeros, /**< pointer to store the number of non-zero entries in the counts array */
671 /* @todo if implvars[x] is aggregated, we could transform the variable into the active representation */
672 if( idx < 0 || SCIPisFeasEQ(scip, SCIPvarGetLbGlobal(implvars[w]), SCIPvarGetUbGlobal(implvars[w])) )
681 /* set variable 'var' with bound implies other set variable 'implvars[w]' with a non-worse bound than the
701 /* the implied upper bound on a binary variable should not be trivial, otherwise we might globally fix
746 /* set variable 'var' with bound implies other set variable 'implvars[w]' with a non-worse bound than the
766 /* the implied lower bound on a binary variable should not be trivial, otherwise we might globally fix
769 * @note is is possible that the implied bound is greater than one, when the implied variable has
811 /** collect clique data on binary variables for variable set reduction and global bound implications */
823 SCIP_Real* newbounds, /**< array of implied bounds(, size is two times number of variables, first
831 int* ncountnonzeros, /**< pointer to store the number of non-zero entries in the counts array */
839 int* foundbin, /**< pointer to store the lowest index of a binary implication variable when found */
902 if( clqvars[w] == var || SCIPvarGetLbGlobal(clqvars[w]) > 0.5 || SCIPvarGetUbGlobal(clqvars[w]) < 0.5 )
913 /* set variable 'var' with bound implies other set variable 'clqvars[w]' with corresponding set bound so we can
954 /** try to reduce the necessary variable in a set of variables with corresponding bounds and boundtypes for which one
963 * by (global) implication data (cliques, implications, and variable bounds) we have also the following implications
970 * Because of the last implication x4 is redundant, because x1 >= 1 would also be fulfilled in the variable set, so we
972 * Also, the both other implications and x3 >= 1 (in the given variable set) all imply exactly x3 >= 1, so we tighten
980 SCIP_Bool* boundtypes, /**< boundtypes array (TRUE == SCIP_BOUNDTYPE_UPPER, FALSE == SCIP_BOUNDTYPE_LOWER)
982 SCIP_Bool* redundants, /**< array which be filled and then indicate if a variable in the set is redundant */
987 SCIP_Bool* setredundant, /**< pointer to store if we found a global reduction on a variable which was part
990 SCIP_Bool fullshortening /**< do we want to try the shortening procedure over the whole set (which might be expensive) */
993 SCIP_Real* newbounds; /* array saving all overall implied global bounds, first nprobvars for lower bound, second
996 SCIP_Real* lastbounds;/* temporary array to remember last implied bounds before taken the current variable into
1002 int* issetvar; /* array for mapping from a problem variable to the position in the variable set (,pos + 1 in
1006 int* counts; /* array saving number of implication by set variables, first nprobvars for lower bound, second
1009 int* implidx; /* temporary array to remember all indices of implied variables by the current set variable
1077 /* check if implied binary variables exist, because for these variables the implications can be stored in the
1115 collectBinaryCliqueData(var, varidx, v, *nredvars, value, bounds, boundtypes, newbounds, counts, countnonzeros,
1120 /* only variable which have the vartype SCIP_VARTYPE_BINARY have implications, otherwise the implications are
1123 * we only check binary to non-binary implications if we can detect further implications which either lead to
1126 if( SCIPvarGetType(var) == SCIP_VARTYPE_BINARY && ((usebin && implbinvarsexist) || usenonbin) )
1128 collectNonBinaryImplicationData(scip, var, varidx, v, *nredvars, value, bounds, boundtypes, newbounds, counts,
1129 countnonzeros, &ncountnonzeros, issetvar, nprobvars, &foundbin, &foundnonbin, implidx, &nimplidx, lastbounds);
1133 * we only check the variable bounds if we can detect further implications which either lead to global reductions
1136 else if( SCIPvarGetType(var) != SCIP_VARTYPE_BINARY && ((usebin && implbinvarsexist) || usenonbin) )
1138 collectNonBinaryVBoundData(scip, var, varidx, v, *nredvars, bounds, boundtypes, newbounds, counts, countnonzeros,
1139 &ncountnonzeros, issetvar, nprobvars, &foundbin, &foundnonbin, implidx, &nimplidx, lastbounds);
1142 /* reduce implication counters on all variables which are implied by a variable now marked as redundant */
1147 SCIPdebugMsg(scip, "marked variable <%s> as redundant variable in variable set\n", SCIPvarGetName(var));
1152 /* correct implication counters and bounds, if the redundant variable implies other variables we need to reduce
1173 if( !SCIPvarIsBinary(probvars[implidx[w] - nprobvars]) && lastbounds[w] != SCIP_INVALID )/*lint !e777*/
1182 /* check if we want to shorten the whole set of variables, or terminate early if we did not find any further
1243 SCIPdebugMsg(scip, "mark redundant variable <%s> to be removed from variable set\n", SCIPvarGetName(var));
1260 SCIPdebugMsg(scip, "variable set led to global reductions (in %s)\n", SCIPprobGetName(scip->transprob));
1299 SCIPdebugMsg(scip, "can tighten lower bound variable %s [%g, %g] to %g\n", SCIPvarGetName(probvar),
1302 /* the new lower bound is greater than the global upper bound => the problem is global infeasible */
1335 scip->transprob, scip->origprob, scip->tree, scip->reopt, scip->lp, scip->branchcand, scip->eventqueue,
1350 SCIPdebugMsg(scip, "can tighten upper bound variable %s [%g, %g] to %g\n", SCIPvarGetName(probvar),
1353 /* the new upper bound is small than the global upper bound => the problem is global infeasible */
1366 scip->transprob, scip->origprob, scip->tree, scip->reopt, scip->lp, scip->branchcand, scip->eventqueue,
static void collectNonBinaryVBoundData(SCIP *scip, SCIP_VAR *var, int varidx, int pos, int nredvars, SCIP_Real *bounds, SCIP_Bool *boundtypes, SCIP_Real *newbounds, int *counts, int *countnonzeros, int *ncountnonzeros, int *issetvar, int nvars, int *foundbin, int *foundnonbin, int *implidx, int *nimplidx, SCIP_Real *lastbounds)
Definition: presolve.c:47
SCIP_Bool SCIPisFeasEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip_numerics.c:851
internal methods for branch and bound tree
SCIP_Bool SCIPisFeasLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip_numerics.c:864
Definition: struct_scip.h:58
public methods for memory management
public methods for implications, variable bounds, and cliques
SCIP_CLIQUE ** SCIPvarGetCliques(SCIP_VAR *var, SCIP_Bool varfixing)
Definition: var.c:17707
Definition: struct_var.h:198
SCIP_Bool SCIPisFeasGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip_numerics.c:903
Definition: type_var.h:53
public methods for problem variables
public methods for numerical tolerances
public methods for the branch-and-bound tree
#define SCIPallocCleanBufferArray(scip, ptr, num)
Definition: scip_mem.h:148
internal methods for storing and manipulating the main problem
SCIP_Bool SCIPisLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip_numerics.c:529
Definition: type_lp.h:47
Definition: type_retcode.h:33
SCIP main data structure.
SCIP_Bool SCIPisFeasGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip_numerics.c:890
SCIP_Bool SCIPisFeasLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip_numerics.c:877
methods commonly used for presolving
SCIP_BOUNDTYPE * SCIPvarGetImplTypes(SCIP_VAR *var, SCIP_Bool varfixing)
Definition: var.c:17654
datastructures for block memory pools and memory buffers
SCIP_Real * SCIPvarGetImplBounds(SCIP_VAR *var, SCIP_Bool varfixing)
Definition: var.c:17668
SCIP_VAR ** SCIPvarGetImplVars(SCIP_VAR *var, SCIP_Bool varfixing)
Definition: var.c:17639
SCIP_Bool SCIPisGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip_numerics.c:555
SCIP_RETCODE SCIPnodeAddBoundchg(SCIP_NODE *node, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, SCIP_VAR *var, SCIP_Real newbound, SCIP_BOUNDTYPE boundtype, SCIP_Bool probingchange)
Definition: tree.c:2021
Definition: type_lp.h:48
public methods for message output
Definition: struct_implics.h:66
public methods for message handling
SCIP_RETCODE SCIPshrinkDisjunctiveVarSet(SCIP *scip, SCIP_VAR **vars, SCIP_Real *bounds, SCIP_Bool *boundtypes, SCIP_Bool *redundants, int nvars, int *nredvars, int *nglobalred, SCIP_Bool *setredundant, SCIP_Bool *glbinfeas, SCIP_Bool fullshortening)
Definition: presolve.c:975
static void collectNonBinaryImplicationData(SCIP *scip, SCIP_VAR *var, int varidx, int pos, int nredvars, SCIP_Bool value, SCIP_Real *bounds, SCIP_Bool *boundtypes, SCIP_Real *newbounds, int *counts, int *countnonzeros, int *ncountnonzeros, int *issetvar, int nvars, int *foundbin, int *foundnonbin, int *implidx, int *nimplidx, SCIP_Real *lastbounds)
Definition: presolve.c:585
Definition: objbenders.h:33
SCIP_RETCODE SCIPcleanupCliques(SCIP *scip, SCIP_Bool *infeasible)
Definition: scip_var.c:7440
static void collectBinaryCliqueData(SCIP_VAR *var, int varidx, int pos, int nredvars, SCIP_Bool value, SCIP_Real *bounds, SCIP_Bool *boundtypes, SCIP_Real *newbounds, int *counts, int *countnonzeros, int *ncountnonzeros, int *issetvar, int nvars, int *foundbin, int *implidx, int *nimplidx)
Definition: presolve.c:813
memory allocation routines