cons_linear.c
Go to the documentation of this file.
18 * @brief Constraint handler for linear constraints in their most general form, \f$lhs <= a^T x <= rhs\f$.
48 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
93 #define CONSHDLR_ENFOPRIORITY -1000000 /**< priority of the constraint handler for constraint enforcing */
94 #define CONSHDLR_CHECKPRIORITY -1000000 /**< priority of the constraint handler for checking feasibility */
95 #define CONSHDLR_SEPAFREQ 0 /**< frequency for separating cuts; zero means to separate only in the root node */
96 #define CONSHDLR_PROPFREQ 1 /**< frequency for propagating domains; zero means only preprocessing propagation */
97 #define CONSHDLR_EAGERFREQ 100 /**< frequency for using all instead of only the useful constraints in separation,
99 #define CONSHDLR_MAXPREROUNDS -1 /**< maximal number of presolving rounds the constraint handler participates in (-1: no limit) */
100 #define CONSHDLR_DELAYSEPA FALSE /**< should separation method be delayed, if other separators found cuts? */
101 #define CONSHDLR_DELAYPROP FALSE /**< should propagation method be delayed, if other propagators found reductions? */
102 #define CONSHDLR_NEEDSCONS TRUE /**< should the constraint handler be skipped, if no constraints are available? */
104 #define CONSHDLR_PRESOLTIMING (SCIP_PRESOLTIMING_FAST | SCIP_PRESOLTIMING_EXHAUSTIVE) /**< presolving timing of the constraint handler (fast, medium, or exhaustive) */
114 #define DEFAULT_TIGHTENBOUNDSFREQ 1 /**< multiplier on propagation frequency, how often the bounds are tightened */
115 #define DEFAULT_MAXROUNDS 5 /**< maximal number of separation rounds per node (-1: unlimited) */
116 #define DEFAULT_MAXROUNDSROOT -1 /**< maximal number of separation rounds in the root node (-1: unlimited) */
118 #define DEFAULT_MAXSEPACUTSROOT 200 /**< maximal number of cuts separated per separation round in root node */
119 #define DEFAULT_PRESOLPAIRWISE TRUE /**< should pairwise constraint comparison be performed in presolving? */
120 #define DEFAULT_PRESOLUSEHASHING TRUE /**< should hash table be used for detecting redundant constraints in advance */
121 #define DEFAULT_NMINCOMPARISONS 200000 /**< number for minimal pairwise presolving comparisons */
122 #define DEFAULT_MINGAINPERNMINCOMP 1e-06 /**< minimal gain per minimal pairwise presolving comparisons to repeat pairwise
124 #define DEFAULT_SORTVARS TRUE /**< should variables be sorted after presolve w.r.t their coefficient absolute for faster
126 #define DEFAULT_CHECKRELMAXABS FALSE /**< should the violation for a constraint with side 0.0 be checked relative
128 #define DEFAULT_MAXAGGRNORMSCALE 0.0 /**< maximal allowed relative gain in maximum norm for constraint aggregation
130 #define DEFAULT_MAXEASYACTIVITYDELTA 1e6 /**< maximum activity delta to run easy propagation on linear constraint
132 #define DEFAULT_MAXCARDBOUNDDIST 0.0 /**< maximal relative distance from current node's dual bound to primal bound compared
134 #define DEFAULT_SEPARATEALL FALSE /**< should all constraints be subject to cardinality cut generation instead of only
136 #define DEFAULT_AGGREGATEVARIABLES TRUE /**< should presolving search for redundant variables in equations */
137 #define DEFAULT_SIMPLIFYINEQUALITIES TRUE /**< should presolving try to simplify inequalities */
139 #define DEFAULT_SINGLETONSTUFFING TRUE /**< should stuffing of singleton continuous variables be performed? */
140 #define DEFAULT_SINGLEVARSTUFFING FALSE /**< should single variable stuffing be performed, which tries to fulfill
142 #define DEFAULT_DETECTCUTOFFBOUND TRUE /**< should presolving try to detect constraints parallel to the objective
145 #define DEFAULT_DETECTLOWERBOUND TRUE /**< should presolving try to detect constraints parallel to the objective
148 #define DEFAULT_DETECTPARTIALOBJECTIVE TRUE/**< should presolving try to detect subsets of constraints parallel to the
151 #define DEFAULT_RANGEDROWARTCONS TRUE /**< should presolving and propagation extract sub-constraints from ranged rows and equations? */
155 #define DEFAULT_MULTAGGRREMOVE FALSE /**< should multi-aggregations only be performed if the constraint can be
157 #define DEFAULT_MAXMULTAGGRQUOT 1e+03 /**< maximum coefficient dynamism (ie. maxabsval / minabsval) for multiaggregation */
158 #define DEFAULT_MAXDUALMULTAGGRQUOT 1e+20 /**< maximum coefficient dynamism (ie. maxabsval / minabsval) for multiaggregation */
163 #define MAXSCALEDCOEFINTEGER 0 /**< maximal coefficient value after scaling if all variables are of integral
167 #define MAXVALRECOMP 1e+06 /**< maximal abolsute value we trust without recomputing the activity */
168 #define MINVALRECOMP 1e-05 /**< minimal abolsute value we trust without recomputing the activity */
171 #define QUADCONSUPGD_PRIORITY 1000000 /**< priority of the constraint handler for upgrading of quadratic constraints */
172 #define NONLINCONSUPGD_PRIORITY 1000000 /**< priority of the constraint handler for upgrading of nonlinear constraints */
174 /* @todo add multi-aggregation of variables that are in exactly two equations (, if not numerically an issue),
186 SCIP_Real minactivity; /**< minimal value w.r.t. the variable's local bounds for the constraint's
188 SCIP_Real maxactivity; /**< maximal value w.r.t. the variable's local bounds for the constraint's
194 SCIP_Real glbminactivity; /**< minimal value w.r.t. the variable's global bounds for the constraint's
196 SCIP_Real glbmaxactivity; /**< maximal value w.r.t. the variable's global bounds for the constraint's
198 SCIP_Real lastglbminactivity; /**< last global minimal activity which was computed by complete summation
200 SCIP_Real lastglbmaxactivity; /**< last global maximal activity which was computed by complete summation
202 SCIP_Real maxactdelta; /**< maximal activity contribution of a single variable, or SCIP_INVALID if invalid */
203 SCIP_VAR* maxactdeltavar; /**< variable with maximal activity contribution, or NULL if invalid */
210 int minactivityneginf; /**< number of coefficients contributing with neg. infinite value to minactivity */
211 int minactivityposinf; /**< number of coefficients contributing with pos. infinite value to minactivity */
212 int maxactivityneginf; /**< number of coefficients contributing with neg. infinite value to maxactivity */
213 int maxactivityposinf; /**< number of coefficients contributing with pos. infinite value to maxactivity */
214 int minactivityneghuge; /**< number of coefficients contributing with huge neg. value to minactivity */
215 int minactivityposhuge; /**< number of coefficients contributing with huge pos. value to minactivity */
216 int maxactivityneghuge; /**< number of coefficients contributing with huge neg. value to maxactivity */
217 int maxactivityposhuge; /**< number of coefficients contributing with huge pos. value to maxactivity */
218 int glbminactivityneginf;/**< number of coefficients contrib. with neg. infinite value to glbminactivity */
219 int glbminactivityposinf;/**< number of coefficients contrib. with pos. infinite value to glbminactivity */
220 int glbmaxactivityneginf;/**< number of coefficients contrib. with neg. infinite value to glbmaxactivity */
221 int glbmaxactivityposinf;/**< number of coefficients contrib. with pos. infinite value to glbmaxactivity */
222 int glbminactivityneghuge;/**< number of coefficients contrib. with huge neg. value to glbminactivity */
223 int glbminactivityposhuge;/**< number of coefficients contrib. with huge pos. value to glbminactivity */
224 int glbmaxactivityneghuge;/**< number of coefficients contrib. with huge neg. value to glbmaxactivity */
225 int glbmaxactivityposhuge;/**< number of coefficients contrib. with huge pos. value to glbmaxactivity */
232 unsigned int rangedrowpropagated:2; /**< did we perform ranged row propagation on this constraint?
244 unsigned int changed:1; /**< was constraint changed since last aggregation round in preprocessing? */
247 unsigned int upgraded:1; /**< is the constraint upgraded and will it be removed after preprocessing? */
252 unsigned int coefsorted:1; /**< are variables sorted by type and their absolute activity delta? */
254 unsigned int hascontvar:1; /**< does the constraint contain at least one continuous variable? */
255 unsigned int hasnonbinvar:1; /**< does the constraint contain at least one non-binary variable? */
256 unsigned int hasnonbinvalid:1; /**< is the information stored in hasnonbinvar and hascontvar valid? */
257 unsigned int checkabsolute:1; /**< should the constraint be checked w.r.t. an absolute feasibilty tolerance? */
272 SCIP_LINCONSUPGRADE** linconsupgrades; /**< linear constraint upgrade methods for specializing linear constraints */
273 SCIP_Real maxaggrnormscale; /**< maximal allowed relative gain in maximum norm for constraint aggregation
275 SCIP_Real maxcardbounddist; /**< maximal relative distance from current node's dual bound to primal bound compared
277 SCIP_Real mingainpernmincomp; /**< minimal gain per minimal pairwise presolving comparisons to repeat pairwise comparison round */
278 SCIP_Real maxeasyactivitydelta;/**< maximum activity delta to run easy propagation on linear constraint
282 int tightenboundsfreq; /**< multiplier on propagation frequency, how often the bounds are tightened */
289 SCIP_Bool presolpairwise; /**< should pairwise constraint comparison be performed in presolving? */
290 SCIP_Bool presolusehashing; /**< should hash table be used for detecting redundant constraints in advance */
291 SCIP_Bool separateall; /**< should all constraints be subject to cardinality cut generation instead of only
293 SCIP_Bool aggregatevariables; /**< should presolving search for redundant variables in equations */
294 SCIP_Bool simplifyinequalities;/**< should presolving try to cancel down or delete coefficients in inequalities */
296 SCIP_Bool singletonstuffing; /**< should stuffing of singleton continuous variables be performed? */
297 SCIP_Bool singlevarstuffing; /**< should single variable stuffing be performed, which tries to fulfill
300 SCIP_Bool checkrelmaxabs; /**< should the violation for a constraint with side 0.0 be checked relative
302 SCIP_Bool detectcutoffbound; /**< should presolving try to detect constraints parallel to the objective
305 SCIP_Bool detectlowerbound; /**< should presolving try to detect constraints parallel to the objective
308 SCIP_Bool detectpartialobjective;/**< should presolving try to detect subsets of constraints parallel to
310 SCIP_Bool rangedrowpropagation;/**< should presolving and propagation try to improve bounds, detect
313 SCIP_Bool rangedrowartcons; /**< should presolving and propagation extract sub-constraints from ranged rows and equations?*/
316 SCIP_Bool multaggrremove; /**< should multi-aggregations only be performed if the constraint can be
318 SCIP_Real maxmultaggrquot; /**< maximum coefficient dynamism (ie. maxabsval / minabsval) for primal multiaggregation */
319 SCIP_Real maxdualmultaggrquot;/**< maximum coefficient dynamism (ie. maxabsval / minabsval) for dual multiaggregation */
342 PROPRULE_1_RANGEDROW = 3, /**< fixed variables and gcd of all left variables tighten bounds of a
345 };
357 } asbits;
359 } val;
422 /** constructs an inference information out of a propagation rule and a position number, returns info as int */
454 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &conshdlrdata->linconsupgrades, conshdlrdata->linconsupgradessize, newsize) );
456 }
483 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &consdata->eventdata, consdata->varssize, newsize) );
516 }
551 (*conshdlrdata)->eventhdlr = eventhdlr;
573 SCIPfreeBlockMemoryArrayNull(scip, &(*conshdlrdata)->linconsupgrades, (*conshdlrdata)->linconsupgradessize);
597 {
599 SCIPwarningMessage(scip, "Try to add already known upgrade message %p for constraint handler %s.\n", linconsupgd, conshdlrname);
622 SCIP_CALL( conshdlrdataEnsureLinconsupgradesSize(scip, conshdlrdata, conshdlrdata->nlinconsupgrades+1) );
627 conshdlrdata->linconsupgrades[i] = conshdlrdata->linconsupgrades[i-1];
640 /** installs rounding locks for the given variable associated to the given coefficient in the linear constraint */
673 /** removes rounding locks for the given variable associated to the given coefficient in the linear constraint */
915 if( SCIPisConsCompressionEnabled(scip) && SCIPisEQ(scip, SCIPvarGetLbGlobal(var), SCIPvarGetUbGlobal(var)) )
957 /* due to compressed copying, we may have fixed variables contributing to the left and right hand side */
1028 SCIP_CALL( SCIPgetTransformedVars(scip, (*consdata)->nvars, (*consdata)->vars, (*consdata)->vars) );
1100 SCIP_CALL( SCIPwriteVarsLinearsum(scip, file, consdata->vars, consdata->vals, consdata->nvars, TRUE) );
1133 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), file, " [%s] <%s>: ", SCIPconshdlrGetName(SCIPconsGetHdlr(cons)), SCIPconsGetName(cons));
1253 {
1255 bound = (SCIPvarGetBestBoundType(consdata->vars[i]) == SCIP_BOUNDTYPE_LOWER) ? SCIPvarGetLbLocal(consdata->vars[i]) : SCIPvarGetUbLocal(consdata->vars[i]);
1301 bound = (consdata->vals[i] > 0.0 ) ? SCIPvarGetLbLocal(consdata->vars[i]) : SCIPvarGetUbLocal(consdata->vars[i]);
1303 && !SCIPisHugeValue(scip, consdata->vals[i] * bound) && !SCIPisHugeValue(scip, -consdata->vals[i] * bound) )
1328 bound = (consdata->vals[i] > 0.0 ) ? SCIPvarGetUbLocal(consdata->vars[i]) : SCIPvarGetLbLocal(consdata->vars[i]);
1330 && !SCIPisHugeValue(scip, consdata->vals[i] * bound) && !SCIPisHugeValue(scip, -consdata->vals[i] * bound) )
1355 bound = (consdata->vals[i] > 0.0 ) ? SCIPvarGetLbGlobal(consdata->vars[i]) : SCIPvarGetUbGlobal(consdata->vars[i]);
1357 && !SCIPisHugeValue(scip, consdata->vals[i] * bound) && !SCIPisHugeValue(scip, -consdata->vals[i] * bound) )
1382 bound = (consdata->vals[i] > 0.0 ) ? SCIPvarGetUbGlobal(consdata->vars[i]) : SCIPvarGetLbGlobal(consdata->vars[i]);
1384 && !SCIPisHugeValue(scip, consdata->vals[i] * bound) && !SCIPisHugeValue(scip, -consdata->vals[i] * bound) )
1448 /** checks the type of all variables of the constraint and sets hasnonbinvar and hascontvar flags accordingly */
1543 {
1597 SCIP_Bool checkreliability /**< should the reliability of the recalculated activity be checked? */
1649 * lower bound + neg. coef: update maxactivity, positive and negative infinity counters have to be switched
1651 * upper bound + neg. coef: update minactivity, positive and negative infinity counters have to be switched
1705 * lower bound + neg. coef: update maxactivity, positive and negative infinity counters have to be switched
1707 * upper bound + neg. coef: update minactivity, positive and negative infinity counters have to be switched
1775 /* if the bound changed to -infinity, increase the counter for negative infinite contributions */
1803 /* if the bound changed to +infinity, increase the counter for positive infinite contributions */
1828 * but checking here that the bound is not huge again would not handle a change from a huge to an infinite bound
1834 /* if the bound changed to +infinity, increase the counter for positive infinite contributions */
1837 /* if the bound changed to -infinity, increase the counter for negative infinite contributions */
1843 /* if the contribution of this variable is too large and positive, increase the corresponding counter */
1846 /* if the contribution of this variable is too large and negative, increase the corresponding counter */
1861 * but checking here that the bound is not huge again would not handle a change from a huge to an infinite bound
1867 /* if the bound changed to +infinity, increase the counter for positive infinite contributions */
1870 /* if the bound changed to -infinity, increase the counter for negative infinite contributions */
1876 /* if the contribution of this variable is too large and positive, increase the corresponding counter */
1879 /* if the contribution of this variable is too large and negative, increase the corresponding counter */
1931 /* update the activity, if the current value is valid and there was a change in the finite part */
1980 SCIP_Bool checkreliability /**< should the reliability of the recalculated activity be checked? */
1989 consdataUpdateActivities(scip, consdata, var, oldlb, newlb, val, SCIP_BOUNDTYPE_LOWER, FALSE, checkreliability);
1991 assert(!SCIPisInfinity(scip, -consdata->minactivity) && !SCIPisInfinity(scip, consdata->minactivity));
1992 assert(!SCIPisInfinity(scip, -consdata->maxactivity) && !SCIPisInfinity(scip, consdata->maxactivity));
2005 SCIP_Bool checkreliability /**< should the reliability of the recalculated activity be checked? */
2014 consdataUpdateActivities(scip, consdata, var, oldub, newub, val, SCIP_BOUNDTYPE_UPPER, FALSE, checkreliability);
2016 assert(!SCIPisInfinity(scip, -consdata->minactivity) && !SCIPisInfinity(scip, consdata->minactivity));
2017 assert(!SCIPisInfinity(scip, -consdata->maxactivity) && !SCIPisInfinity(scip, consdata->maxactivity));
2029 SCIP_Bool checkreliability /**< should the reliability of the recalculated activity be checked? */
2037 consdataUpdateActivities(scip, consdata, NULL, oldlb, newlb, val, SCIP_BOUNDTYPE_LOWER, TRUE, checkreliability);
2039 assert(!SCIPisInfinity(scip, -consdata->glbminactivity) && !SCIPisInfinity(scip, consdata->glbminactivity));
2040 assert(!SCIPisInfinity(scip, -consdata->glbmaxactivity) && !SCIPisInfinity(scip, consdata->glbmaxactivity));
2052 SCIP_Bool checkreliability /**< should the reliability of the recalculated activity be checked? */
2060 consdataUpdateActivities(scip, consdata, NULL, oldub, newub, val, SCIP_BOUNDTYPE_UPPER, TRUE, checkreliability);
2062 assert(!SCIPisInfinity(scip, -consdata->glbminactivity) && !SCIPisInfinity(scip, consdata->glbminactivity));
2063 assert(!SCIPisInfinity(scip, -consdata->glbmaxactivity) && !SCIPisInfinity(scip, consdata->glbmaxactivity));
2067 /** updates minimum and maximum activity and maximum absolute value for coefficient addition */
2074 SCIP_Bool checkreliability /**< should the reliability of the recalculated activity be checked? */
2110 consdataUpdateActivitiesLb(scip, consdata, var, 0.0, SCIPvarGetLbLocal(var), val, checkreliability);
2111 consdataUpdateActivitiesUb(scip, consdata, var, 0.0, SCIPvarGetUbLocal(var), val, checkreliability);
2112 consdataUpdateActivitiesGlbLb(scip, consdata, 0.0, SCIPvarGetLbGlobal(var), val, checkreliability);
2113 consdataUpdateActivitiesGlbUb(scip, consdata, 0.0, SCIPvarGetUbGlobal(var), val, checkreliability);
2117 /** updates minimum and maximum activity for coefficient deletion, invalidates maximum absolute value if necessary */
2124 SCIP_Bool checkreliability /**< should the reliability of the recalculated activity be checked? */
2167 consdataUpdateActivitiesLb(scip, consdata, var, SCIPvarGetLbLocal(var), 0.0, val, checkreliability);
2168 consdataUpdateActivitiesUb(scip, consdata, var, SCIPvarGetUbLocal(var), 0.0, val, checkreliability);
2169 consdataUpdateActivitiesGlbLb(scip, consdata, SCIPvarGetLbGlobal(var), 0.0, val, checkreliability);
2170 consdataUpdateActivitiesGlbUb(scip, consdata, SCIPvarGetUbGlobal(var), 0.0, val, checkreliability);
2174 /** updates minimum and maximum activity for coefficient change, invalidates maximum absolute value if necessary */
2182 SCIP_Bool checkreliability /**< should the reliability of the recalculated activity be checked? */
2262 /* reset maximal activity delta, so that it will be recalculated on the next real propagation */
2268 /* @todo do something more clever here, e.g. if oldval * newval >= 0, do the update directly */
2367 /** gets minimal activity for constraint and given values of counters for infinite and huge contributions
2368 * and (if needed) delta to subtract from stored finite part of activity in case of a residual activity
2381 SCIP_Bool goodrelax, /**< should a good relaxation be computed or are relaxed acticities ignored, anyway? */
2385 SCIP_Bool* issettoinfinity /**< pointer to store whether minactivity was set to infinity or calculated */
2412 /* if we have neg. huge contributions, we only know that -infty is a relaxation of the minactivity */
2419 /* we do not need a good relaxation and we have positive huge contributions, so we just return -infty as activity */
2450 * times the minimum value counting as "huge" plus finite (and non-huge) part of minactivity - delta
2468 /** gets maximal activity for constraint and given values of counters for infinite and huge contributions
2469 * and (if needed) delta to subtract from stored finite part of activity in case of a residual activity
2482 SCIP_Bool goodrelax, /**< should a good relaxation be computed or are relaxed acticities ignored, anyway? */
2486 SCIP_Bool* issettoinfinity /**< pointer to store whether maxactivity was set to infinity or calculated */
2513 /* if we have pos. huge contributions, we only know that +infty is a relaxation of the maxactivity */
2520 /* we do not need a good relaxation and we have positve huge contributions, so we just return +infty as activity */
2551 * times the minimum value counting as "huge" plus the finite (and non-huge) part of maxactivity minus delta
2578 SCIP_Bool* minisrelax, /**< pointer to store whether the returned minactivity is just a relaxation,
2581 SCIP_Bool* maxisrelax, /**< pointer to store whether the returned maxactivity is just a relaxation,
2584 SCIP_Bool* isminsettoinfinity, /**< pointer to store whether minactivity was set to infinity or calculated */
2585 SCIP_Bool* ismaxsettoinfinity /**< pointer to store whether maxactivity was set to infinity or calculated */
2588 {
2710 SCIP_Bool* minisrelax, /**< pointer to store whether the returned residual minactivity is just a
2713 SCIP_Bool* maxisrelax, /**< pointer to store whether the returned residual maxactivity is just a
2716 SCIP_Bool* isminsettoinfinity, /**< pointer to store whether minresactivity was set to infinity or calculated */
2717 SCIP_Bool* ismaxsettoinfinity /**< pointer to store whether maxresactivity was set to infinity or calculated */
2718 )
2765 /* get/compute minactivity by calling getMinActivity() with updated counters for infinite and huge values
2766 * and contribution of variable set to zero that has to be subtracted from finite part of activity
2803 consdata->minactivityposhuge, consdata->minactivityneghuge, absval * minactbound, FALSE, goodrelax,
2807 /* get/compute maxactivity by calling getMaxActivity() with updated counters for infinite and huge values
2808 * and contribution of variable set to zero that has to be subtracted from finite part of activity
2845 consdata->maxactivityposhuge, consdata->maxactivityneghuge, absval * maxactbound, FALSE, goodrelax,
2857 SCIP_Real* glbminactivity, /**< pointer to store the minimal activity, or NULL, if not needed */
2858 SCIP_Real* glbmaxactivity, /**< pointer to store the maximal activity, or NULL, if not needed */
2859 SCIP_Bool* minisrelax, /**< pointer to store whether the returned minactivity is just a relaxation,
2862 SCIP_Bool* maxisrelax, /**< pointer to store whether the returned maxactivity is just a relaxation,
2865 SCIP_Bool* isminsettoinfinity, /**< pointer to store whether minresactivity was set to infinity or calculated */
2866 SCIP_Bool* ismaxsettoinfinity /**< pointer to store whether maxresactivity was set to infinity or calculated */
2921 SCIP_Real* minresactivity, /**< pointer to store the minimal residual activity, or NULL, if not needed */
2922 SCIP_Real* maxresactivity, /**< pointer to store the maximal residual activity, or NULL, if not needed */
2923 SCIP_Bool* minisrelax, /**< pointer to store whether the returned residual minactivity is just a
2926 SCIP_Bool* maxisrelax, /**< pointer to store whether the returned residual maxactivity is just a
2929 SCIP_Bool* isminsettoinfinity, /**< pointer to store whether minresactivity was set to infinity or calculated */
2930 SCIP_Bool* ismaxsettoinfinity /**< pointer to store whether maxresactivity was set to infinity or calculated */
2931 )
2972 /* get/compute minactivity by calling getMinActivity() with updated counters for infinite and huge values
2973 * and contribution of variable set to zero that has to be subtracted from finite part of activity
2979 getMinActivity(scip, consdata, consdata->glbminactivityposinf - 1, consdata->glbminactivityneginf,
2987 getMinActivity(scip, consdata, consdata->glbminactivityposinf, consdata->glbminactivityneginf - 1,
3020 /* get/compute maxactivity by calling getMaxActivity() with updated counters for infinite and huge values
3021 * and contribution of variable set to zero that has to be subtracted from finite part of activity
3027 getMaxActivity(scip, consdata, consdata->glbmaxactivityposinf, consdata->glbmaxactivityneginf - 1,
3035 getMaxActivity(scip, consdata, consdata->glbmaxactivityposinf - 1, consdata->glbmaxactivityneginf,
3102 else if( (SCIPisInfinity(scip, solval) && negsign) || (SCIPisInfinity(scip, -solval) && !negsign) )
3109 SCIPdebugMsg(scip, "activity of linear constraint: %.15g, %d positive infinity values, %d negative infinity values \n", activity, nposinf, nneginf);
3151 }
3198 /** index comparison method of linear constraints: compares two indices of the variable set in the linear constraint */
3217 }
3237 /** index comparison method of linear constraints: compares two indices of the variable set in the linear constraint */
3256 }
3293 SCIP_Real abscont1 = REALABS(consdata->vals[ind1] * (SCIPvarGetUbGlobal(var1) - SCIPvarGetLbGlobal(var1)));
3294 SCIP_Real abscont2 = REALABS(consdata->vals[ind2] * (SCIPvarGetUbGlobal(var2) - SCIPvarGetLbGlobal(var2)));
3378 * sorts variables of the remaining problem by binaries, integers, implicit integers, and continuous variables,
3402 {
3499 /* the left hand side switched from -infinity to a non-infinite value -> install rounding locks */
3524 /* the left hand side switched from a non-infinite value to -infinity -> remove rounding locks */
3545 /* check whether the left hand side is increased, if and only if that's the case we maybe can propagate, tighten and add more cliques */
3627 /* the right hand side switched from infinity to a non-infinite value -> install rounding locks */
3652 /* the right hand side switched from a non-infinite value to infinity -> remove rounding locks */
3673 /* check whether the right hand side is decreased, if and only if that's the case we maybe can propagate, tighten and add more cliques */
3721 assert(!SCIPvarIsRelaxationOnly(var) || (!SCIPconsIsChecked(cons) && !SCIPconsIsEnforced(cons)));
3836 consdata->indexsorted = consdata->indexsorted && (consdataCompVar((void*)consdata, consdata->nvars-2, consdata->nvars-1) <= 0);
3842 consdata->coefsorted = consdata->coefsorted && (consdataCompVarProp((void*)consdata, consdata->nvars-2, consdata->nvars-1) <= 0);
3888 var = consdata->vars[pos];
3933 /* if at most one variable is left, the activities should be recalculated (to correspond exactly to the bounds
3945 /* if the variable defining the maximal activity delta was removed from the constraint, the maximal activity
4093 SCIPwarningMessage(scip, "skipped scaling for linear constraint <%s> to avoid numerical troubles (scalar: %.15g)\n",
4104 /* because SCIPisScalingIntegral uses another integrality check as SCIPfeasFloor, we add an additional 0.5 before
4112 SCIPwarningMessage(scip, "coefficient %.15g of variable <%s> in linear constraint <%s> scaled to zero (scalar: %.15g)\n",
4134 /* because SCIPisScalingIntegral uses another integrality check as SCIPfeasFloor, we add an additional 0.5 before
4146 /* because SCIPisScalingIntegral uses another integrality check as SCIPfeasCeil, we subtract 0.5 before ceiling up
4208 * Apply the following rules in the given order, until the sign of the factor is determined. Later rules only apply,
4213 * 4. the number of positive coefficients must not be smaller than the number of negative coefficients
4216 * Try to identify a rational representation of the fractional coefficients, and multiply all coefficients
4307 SCIPdebugMsg(scip, "divide linear constraint with %g, because all coefficients are in absolute value the same\n", maxabsval);
4349 epsilon = SCIPepsilon(scip) * 0.9; /* slightly decrease epsilon to be safe in rational conversion below */
4358 maxmult = MIN(maxmult, (SCIP_Longint) (MAXSCALEDCOEFINTEGER / MAX(maxabsval, 1.0))); /*lint !e835*/
4384 /* 3. the absolute value of the right hand side must be greater than that of the left hand side */
4393 /* 4. the number of positive coefficients must not be smaller than the number of negative coefficients */
4446 /* it might be that we have really big coefficients, but all are integral, in that case we want to divide them by
4466 SCIPdebugMsg(scip, "scale linear constraint with %" SCIP_LONGINT_FORMAT " to make coefficients integral\n", scm);
4515 /* since the lhs/rhs is not respected for gcd calculation it can happen that we detect infeasibility */
4518 if( SCIPisEQ(scip, consdata->lhs, consdata->rhs) && !SCIPisFeasIntegral(scip, consdata->rhs / gcd) )
4530 SCIPdebugMsg(scip, "divide linear constraint by greatest common divisor %" SCIP_LONGINT_FORMAT "\n", gcd);
4603 /* if the variable defining the maximal activity delta was removed from the constraint, the maximal activity
4676 /* if an unmodifiable row has been added to the LP, then we cannot apply fixing anymore (cannot change a row)
4677 * this should not happen, as applyFixings is called in addRelaxation() before creating and adding a row
4679 assert(consdata->row == NULL || !SCIProwIsInLP(consdata->row) || SCIProwIsModifiable(consdata->row));
4832 if( SCIPisEQ(scip, lhssubtrahend, consdata->lhs) && SCIPisFeasGE(scip, REALABS(lhssubtrahend), 1.0) )
4848 if( SCIPisEQ(scip, rhssubtrahend, consdata->rhs ) && SCIPisFeasGE(scip, REALABS(rhssubtrahend), 1.0) )
4862 /* if aggregated variables have been replaced, multiple entries of the same variable are possible and we have
4881 /** for each variable in the linear constraint, except the inferred variable, adds one bound to the conflict analysis'
4882 * candidate store (bound depends on sign of coefficient and whether the left or right hand side was the reason for the
4883 * inference variable's bound change); the conflict analysis can be initialized with the linear constraint being the
4891 SCIP_BDCHGIDX* bdchgidx, /**< bound change index (time stamp of bound change), or NULL for current time */
4920 /* for each variable, add the bound to the conflict queue, that is responsible for the minimal or maximal
4921 * residual value, depending on whether the left or right hand side is responsible for the bound change:
4926 /* if the variable is integral we only need to add reason bounds until the propagation could be applied */
4939 /* calculate the minimal and maximal global activity of all other variables involved in the constraint */
4944 consdataGetGlbActivityResiduals(scip, consdata, infervar, vals[inferpos], FALSE, &minresactivity, NULL,
4947 consdataGetGlbActivityResiduals(scip, consdata, infervar, vals[inferpos], FALSE, NULL, &maxresactivity,
4961 if( (reasonisrhs && !isminsettoinfinity && !minisrelax) || (!reasonisrhs && !ismaxsettoinfinity && !maxisrelax) ) /*lint !e644*/
4968 /* calculate the residual capacity that would be left, if the variable would be set to one more / one less
5023 /* rhs is reason and coeff is positive, or lhs is reason and coeff is negative -> lower bound */
5025 rescap -= vals[i] * (SCIPgetVarLbAtIndex(scip, vars[i], bdchgidx, FALSE) - SCIPvarGetLbGlobal(vars[i]));
5029 /* lhs is reason and coeff is positive, or rhs is reason and coeff is negative -> upper bound */
5031 rescap -= vals[i] * (SCIPgetVarUbAtIndex(scip, vars[i], bdchgidx, FALSE) - SCIPvarGetUbGlobal(vars[i]));
5051 /* rhs is reason and coeff is positive, or lhs is reason and coeff is negative -> lower bound is responsible */
5056 /* lhs is reason and coeff is positive, or rhs is reason and coeff is negative -> upper bound is responsible */
5064 /** for each variable in the linear ranged row constraint, except the inferred variable, adds the bounds of all fixed
5065 * variables to the conflict analysis' candidate store; the conflict analysis can be initialized
5066 * with the linear constraint being the conflict detecting constraint by using NULL as inferred variable
5073 SCIP_BDCHGIDX* bdchgidx, /**< bound change index (time stamp of bound change), or NULL for current time */
5105 if( !SCIPisEQ(scip, SCIPgetVarLbAtIndex(scip, vars[v], bdchgidx, FALSE), SCIPvarGetLbGlobal(vars[v])) )
5111 if( !SCIPisEQ(scip, SCIPgetVarUbAtIndex(scip, vars[v], bdchgidx, FALSE), SCIPvarGetUbGlobal(vars[v])) )
5121 if( SCIPisEQ(scip, SCIPgetVarLbAtIndex(scip, vars[v], bdchgidx, FALSE), SCIPgetVarUbAtIndex(scip, vars[v], bdchgidx, FALSE)) )
5123 /* add all bounds of fixed variables which lead to the boundchange of the given inference variable */
5180 /** resolves a propagation on the given variable by supplying the variables needed for applying the corresponding
5191 SCIP_BDCHGIDX* bdchgidx, /**< bound change index (time stamp of bound change), or NULL for current time */
5192 SCIP_RESULT* result /**< pointer to store the result of the propagation conflict resolving call */
5233 /* the bound of the variable was tightened, because the minimal or maximal residual activity of the linear
5234 * constraint (only taking the other variables into account) didn't leave enough space for a larger
5243 /* the bound of the variable was tightened, because the minimal or maximal residual activity of the linear
5244 * constraint (only taking the other variables into account) didn't leave enough space for a larger
5253 /* the bound of the variable was tightened, because some variables were already fixed and the leftover only allow
5265 SCIPerrorMessage("invalid inference information %d in linear constraint <%s> at position %d for %s bound of variable <%s>\n",
5276 /** analyzes conflicting bounds on given constraint, and adds conflict constraint to problem */
5285 if( (SCIPgetStage(scip) != SCIP_STAGE_SOLVING && !SCIPinProbing(scip)) || !SCIPisConflictAnalysisApplicable(scip) )
5291 /* add the conflicting bound for each variable of infeasible constraint to conflict candidate queue */
5319 + consdata->maxactivityneghuge
5339 SCIP_Bool force /**< should a possible bound change be forced even if below bound strengthening tolerance */
5363 SCIPdebugMsg(scip, "linear constraint <%s>: tighten <%s>, old bds=[%.15g,%.15g], val=%.15g, activity=[%.15g,%.15g], sides=[%.15g,%.15g] -> newub=%.15g\n",
5364 SCIPconsGetName(cons), SCIPvarGetName(var), lb, oldub, consdata->vals[pos], consdata->minactivity, consdata->maxactivity, consdata->lhs, consdata->rhs, newub);
5369 SCIP_CALL( SCIPinferVarUbCons(scip, var, newub, cons, getInferInt(proprule, pos), force, &infeasible, &tightened) );
5408 SCIP_Bool force /**< should a possible bound change be forced even if below bound strengthening tolerance */
5432 SCIPdebugMsg(scip, "linear constraint <%s>: tighten <%s>, old bds=[%.15g,%.15g], val=%.15g, activity=[%.15g,%.15g], sides=[%.15g,%.15g] -> newlb=%.15g\n",
5433 SCIPconsGetName(cons), SCIPvarGetName(var), oldlb, ub, consdata->vals[pos], consdata->minactivity, consdata->maxactivity, consdata->lhs, consdata->rhs, newlb);
5438 SCIP_CALL( SCIPinferVarLbCons(scip, var, newlb, cons, getInferInt(proprule, pos), force, &infeasible, &tightened) );
5474 SCIP_Bool force /**< should a possible bound change be forced even if below bound strengthening tolerance */
5534 /* min activity should be valid at this point (if this is not true, then some decisions might be wrong!) */
5537 /* if the minactivity is larger than the right hand side by feasibility epsilon, the constraint is infeasible */
5549 /* if the slack is zero in tolerances (or negative, but not enough to make the constraint infeasible), we set
5594 /* if the maxactivity is smaller than the left hand side by feasibility epsilon, the constraint is infeasible */
5605 /* if the slack is zero in tolerances (or negative, but not enough to make the constraint infeasible), we set
5641 /* min activity should be valid at this point (if this is not true, then some decisions might be wrong!) */
5644 /* if the minactivity is larger than the right hand side by feasibility epsilon, the constraint is infeasible */
5656 /* if the slack is zero in tolerances (or negative, but not enough to make the constraint infeasible), we set
5699 /* if the maxactivity is smaller than the left hand side by feasibility epsilon, the constraint is infeasible */
5711 /* if the slack is zero in tolerances (or negative, but not enough to make the constraint infeasible), we set
5743 /** analyzes conflicting bounds on given ranged row constraint, and adds conflict constraint to problem */
5766 if( (SCIPgetStage(scip) != SCIP_STAGE_SOLVING && !SCIPinProbing(scip)) || !SCIPisConflictAnalysisApplicable(scip) )
5772 /* add the conflicting fixed variables of this ranged row constraint to conflict candidate queue */
5786 * Check ranged rows for possible solutions, possibly detect infeasibility, fix variables due to having only one possible
5787 * solution, tighten bounds if having only two possible solutions or add constraints which propagate a subset of
5872 addartconss = conshdlrdata->rangedrowartcons && SCIPgetDepth(scip) < 1 && !SCIPinProbing(scip) && !SCIPinRepropagation(scip);
5877 /* we are not allowed to add artificial constraints during propagation; if nothing changed on this constraint since
5878 * the last rangedrowpropagation, we can stop; otherwise, we mark this constraint to be rangedrowpropagated without
5896 if( SCIPisEQ(scip, SCIPvarGetLbLocal(consdata->vars[v]), SCIPvarGetUbLocal(consdata->vars[v])) )
5925 * coefficient so that all variables in this group will have a gcd greater than 1, this group will be implicitly
5928 * the second group will contain all left unfixed variables and will be saved as infcheckvars with corresponding
5929 * coefficients as infcheckvals, the order of these variables should be the same as in the consdata object
5932 /* find first integral variables with integral coefficient greater than 1, thereby collecting all other unfixed
5942 /* partition the variables, do not change the order of collection, because it might be used later on */
5946 if( !SCIPisEQ(scip, SCIPvarGetLbLocal(consdata->vars[v]), SCIPvarGetUbLocal(consdata->vars[v])) )
5974 while( v < consdata->nvars && SCIPisEQ(scip, SCIPvarGetLbLocal(consdata->vars[v]), SCIPvarGetUbLocal(consdata->vars[v])) );
5988 assert(!SCIPisEQ(scip, SCIPvarGetLbLocal(consdata->vars[v]), SCIPvarGetUbLocal(consdata->vars[v])));
5989 assert(SCIPisIntegral(scip, consdata->vals[v]) && SCIPvarGetType(consdata->vars[v]) != SCIP_VARTYPE_CONTINUOUS && REALABS(consdata->vals[v]) > 1.5);
5996 /* go on to partition the variables, do not change the order of collection, because it might be used later on;
6000 if( SCIPisEQ(scip, SCIPvarGetLbLocal(consdata->vars[v]), SCIPvarGetUbLocal(consdata->vars[v])) )