cuts.c
Go to the documentation of this file.
33 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
58 /* =========================================== general static functions =========================================== */
96 SCIPquadprecProdQD(coef, coef, (sol == NULL ? SCIPvarGetLPSol(vars[cutinds[i]]) : SCIPgetSolVal(scip, sol, vars[cutinds[i]])));
102 SCIPquadprecProdQD(coef, coef, (islocal ? SCIPvarGetLbLocal(vars[cutinds[i]]) : SCIPvarGetLbGlobal(vars[cutinds[i]])));
106 SCIPquadprecProdQD(coef, coef, (islocal ? SCIPvarGetUbLocal(vars[cutinds[i]]) : SCIPvarGetUbGlobal(vars[cutinds[i]])));
112 SCIPdebugMsgPrint(scip, " <= %.6f (activity: %g)\n", QUAD_TO_DBL(cutrhs), QUAD_TO_DBL(activity));
130 int*RESTRICT inds, /**< pointer to array with variable problem indices of non-zeros in variable vector */
175 int*RESTRICT inds, /**< pointer to array with variable problem indices of non-zeros in variable vector */
218 * This is the quad precision version of varVecAddScaledRowCoefs() with a quad precision scaling factor.
222 int*RESTRICT inds, /**< pointer to array with variable problem indices of non-zeros in variable vector */
274 int* cutinds, /**< array of the problem indices of variables with a non-zero coefficient in the cut */
332 /** calculates the efficacy norm of the given aggregation row, which depends on the "separating/efficacynorm" parameter */
336 SCIP_Real* vals, /**< array of the non-zero coefficients in the vector; this is a quad precision array! */
337 int* inds, /**< array of the problem indices of variables with a non-zero coefficient in the vector */
394 /** calculates the cut efficacy for the given solution; the cut coefs are stored densely and in quad precision */
399 SCIP_Real* cutcoefs, /**< array of the non-zero coefficients in the cut; this is a quad precision array! */
401 int* cutinds, /**< array of the problem indices of variables with a non-zero coefficient in the cut */
477 int* cutinds, /**< array of the problem indices of variables with a non-zero coefficient in the cut */
570 int* cutinds, /**< array of the problem indices of variables with a non-zero coefficient in the cut */
579 /* loop over non-zeros and remove values below minval; values above QUAD_EPSILON are cancelled with their bound
697 /** change given coefficient to new given value, adjust right hand side using the variables bound;
742 /** change given (quad) coefficient to new given value, adjust right hand side using the variables bound;
787 /** scales the cut and then tightens the coefficients of the given cut based on the maximal activity;
788 * see cons_linear.c consdataTightenCoefs() for details; the cut is given in a semi-sparse quad precision array;
798 int* cutinds, /**< array of the problem indices of variables with a non-zero coefficient in the cut */
820 /* compute maximal activity and maximal absolute coefficient values for all and for integral variables in the cut */
832 SCIP_Real lb = cutislocal ? SCIPvarGetLbLocal(vars[cutinds[i]]) : SCIPvarGetLbGlobal(vars[cutinds[i]]);
850 SCIP_Real ub = cutislocal ? SCIPvarGetUbLocal(vars[cutinds[i]]) : SCIPvarGetUbGlobal(vars[cutinds[i]]);
900 (SCIP_Longint)scip->set->sepa_maxcoefratio, scip->set->sepa_maxcoefratio, &intscalar, &success) );
921 if( chgQuadCoeffWithBound(scip, vars[cutinds[i]], QUAD(val), intval, cutislocal, QUAD(cutrhs)) )
961 SCIP_Real lb = cutislocal ? SCIPvarGetLbLocal(vars[cutinds[i]]) : SCIPvarGetLbGlobal(vars[cutinds[i]]);
971 SCIP_Real ub = cutislocal ? SCIPvarGetUbLocal(vars[cutinds[i]]) : SCIPvarGetUbGlobal(vars[cutinds[i]]);
1044 /* no coefficient tightening can be performed since the precondition doesn't hold for any of the variables */
1050 /* loop over the integral variables and try to tighten the coefficients; see cons_linear for more details */
1065 if( QUAD_TO_DBL(val) < 0.0 && SCIPisLE(scip, maxact + QUAD_TO_DBL(val), QUAD_TO_DBL(*cutrhs)) )
1068 SCIP_Real lb = cutislocal ? SCIPvarGetLbLocal(vars[cutinds[i]]) : SCIPvarGetLbGlobal(vars[cutinds[i]]);
1074 /* if cut is integral, the true coefficient must also be integral; thus round it to exact integral value */
1088 SCIPdebugMsg(scip, "tightened coefficient from %g to %g; rhs changed from %g to %g; the bounds are [%g,%g]\n",
1112 else if( QUAD_TO_DBL(val) > 0.0 && SCIPisLE(scip, maxact - QUAD_TO_DBL(val), QUAD_TO_DBL(*cutrhs)) )
1115 SCIP_Real ub = cutislocal ? SCIPvarGetUbLocal(vars[cutinds[i]]) : SCIPvarGetUbGlobal(vars[cutinds[i]]);
1121 /* if cut is integral, the true coefficient must also be integral; thus round it to exact integral value */
1135 SCIPdebugMsg(scip, "tightened coefficient from %g to %g; rhs changed from %g to %g; the bounds are [%g,%g]\n",
1159 else /* due to sorting we can stop completely if the precondition was not fulfilled for this variable */
1168 /** scales the cut and then tightens the coefficients of the given cut based on the maximal activity;
1169 * see cons_linear.c consdataTightenCoefs() for details; the cut is given in a semi-sparse array;
1177 int* cutinds, /**< array of the problem indices of variables with a non-zero coefficient in the cut */
1199 /* compute maximal activity and maximal absolute coefficient values for all and for integral variables in the cut */
1212 SCIP_Real lb = cutislocal ? SCIPvarGetLbLocal(vars[cutinds[i]]) : SCIPvarGetLbGlobal(vars[cutinds[i]]);
1230 SCIP_Real ub = cutislocal ? SCIPvarGetUbLocal(vars[cutinds[i]]) : SCIPvarGetUbGlobal(vars[cutinds[i]]);
1278 SCIP_CALL( SCIPcalcIntegralScalar(intcoeffs, *cutnnz, -SCIPsumepsilon(scip), SCIPepsilon(scip),
1279 (SCIP_Longint)scip->set->sepa_maxcoefratio, scip->set->sepa_maxcoefratio, &intscalar, &success) );
1339 SCIP_Real lb = cutislocal ? SCIPvarGetLbLocal(vars[cutinds[i]]) : SCIPvarGetLbGlobal(vars[cutinds[i]]);
1348 SCIP_Real ub = cutislocal ? SCIPvarGetUbLocal(vars[cutinds[i]]) : SCIPvarGetUbGlobal(vars[cutinds[i]]);
1408 /* no coefficient tightening can be performed since the precondition doesn't hold for any of the variables */
1414 /* loop over the integral variables and try to tighten the coefficients; see cons_linear for more details */
1432 SCIP_Real lb = cutislocal ? SCIPvarGetLbLocal(vars[cutinds[i]]) : SCIPvarGetLbGlobal(vars[cutinds[i]]);
1438 /* if cut is integral, the true coefficient must also be integral; thus round it to exact integral value */
1452 SCIPdebugMsg(scip, "tightened coefficient from %g to %g; rhs changed from %g to %g; the bounds are [%g,%g]\n",
1478 SCIP_Real ub = cutislocal ? SCIPvarGetUbLocal(vars[cutinds[i]]) : SCIPvarGetUbGlobal(vars[cutinds[i]]);
1484 /* if cut is integral, the true coefficient must also be integral; thus round it to exact integral value */
1498 SCIPdebugMsg(scip, "tightened coefficient from %g to %g; rhs changed from %g to %g; the bounds are [%g,%g]\n",
1521 else /* due to sorting we can stop completely if the precondition was not fulfilled for this variable */
1530 /** perform activity based coefficient tightening on the given cut; returns TRUE if the cut was detected
1540 int* cutinds, /**< array of the problem indices of variables with a non-zero coefficient in the cut */
1574 SCIP_Real lb = cutislocal ? SCIPvarGetLbLocal(vars[cutinds[i]]) : SCIPvarGetLbGlobal(vars[cutinds[i]]);
1592 SCIP_Real ub = cutislocal ? SCIPvarGetUbLocal(vars[cutinds[i]]) : SCIPvarGetUbGlobal(vars[cutinds[i]]);
1619 /* terminate, because coefficient tightening cannot be performed; also excludes the case in which no integral variable is present */
1626 /* loop over the integral variables and try to tighten the coefficients; see cons_linear for more details */
1629 /* due to sorting, we can exit if we reached a continuous variable: all further integral variables have 0 coefficents anyway */
1638 SCIP_Real lb = cutislocal ? SCIPvarGetLbLocal(vars[cutinds[i]]) : SCIPvarGetLbGlobal(vars[cutinds[i]]);
1651 SCIPdebugMsg(scip, "tightened coefficient from %g to %g; rhs changed from %g to %g; the bounds are [%g,%g]\n",
1679 SCIP_Real ub = cutislocal ? SCIPvarGetUbLocal(vars[cutinds[i]]) : SCIPvarGetUbGlobal(vars[cutinds[i]]);
1692 SCIPdebugMsg(scip, "tightened coefficient from %g to %g; rhs changed from %g to %g; the bounds are [%g,%g]\n",
1717 else /* due to sorting we can stop completely if the precondition was not fulfilled for this variable */
1727 /* =========================================== aggregation row =========================================== */
1813 SCIPmessageFPrintInfo(messagehdlr, file, "%+.15g<%s> ", QUAD_TO_DBL(val), SCIPvarGetName(vars[aggrrow->inds[i]]));
1836 SCIP_CALL( SCIPduplicateBlockMemoryArray(scip, &(*aggrrow)->vals, source->vals, QUAD_ARRAY_SIZE(nvars)) );
1847 SCIP_CALL( SCIPduplicateBlockMemoryArray(scip, &(*aggrrow)->rowsinds, source->rowsinds, source->nrows) );
1848 SCIP_CALL( SCIPduplicateBlockMemoryArray(scip, &(*aggrrow)->slacksign, source->slacksign, source->nrows) );
1849 SCIP_CALL( SCIPduplicateBlockMemoryArray(scip, &(*aggrrow)->rowweights, source->rowweights, source->nrows) );
1893 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &aggrrow->rowsinds, aggrrow->rowssize, newsize) );
1894 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &aggrrow->slacksign, aggrrow->rowssize, newsize) );
1895 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &aggrrow->rowweights, aggrrow->rowssize, newsize) );
1913 /* Automatically decide, whether we want to use the left or the right hand side of the row in the summation.
1941 SCIP_CALL( varVecAddScaledRowCoefsQuad(aggrrow->inds, aggrrow->vals, &aggrrow->nnz, row, weight) );
1946 /** Removes a given variable @p var from position @p pos the aggregation row and updates the right-hand side according
1947 * to sign of the coefficient, i.e., rhs -= coef * bound, where bound = lb if coef >= 0 and bound = ub, otherwise.
1949 * @note: The choice of global or local bounds depend on the validity (global or local) of the aggregation row.
1951 * @note: The list of non-zero indices will be updated by swapping the last non-zero index to @p pos.
2011 /** add the objective function with right-hand side @p rhs and scaled by @p scale to the aggregation row */
2162 /** calculates the efficacy norm of the given aggregation row, which depends on the "separating/efficacynorm" parameter
2164 * @return the efficacy norm of the given aggregation row, which depends on the "separating/efficacynorm" parameter
2174 /** Adds one row to the aggregation row. Differs from SCIPaggrRowAddRow() by providing some additional
2185 int negslack, /**< should negative slack variables allowed to be used? (0: no, 1: only for integral rows, 2: yes) */
2198 if( SCIPisFeasZero(scip, weight) || SCIProwIsModifiable(row) || (SCIProwIsLocal(row) && !allowlocal) )
2217 else if( SCIPisInfinity(scip, SCIProwGetRhs(row)) || (weight < 0.0 && ! SCIPisInfinity(scip, -SCIProwGetLhs(row))) )
2222 else if( (weight < 0.0 && !SCIPisInfinity(scip, -row->lhs)) || SCIPisInfinity(scip, row->rhs) )
2263 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &aggrrow->rowsinds, aggrrow->rowssize, newsize) );
2264 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &aggrrow->slacksign, aggrrow->rowssize, newsize) );
2265 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &aggrrow->rowweights, aggrrow->rowssize, newsize) );
2275 SCIP_CALL( varVecAddScaledRowCoefsQuad(aggrrow->inds, aggrrow->vals, &aggrrow->nnz, row, weight) );
2295 int negslack, /**< should negative slack variables allowed to be used? (0: no, 1: only for integral rows, 2: yes) */
2321 SCIP_CALL( addOneRow(scip, aggrrow, rows[rowinds[k]], weights[rowinds[k]], sidetypebasis, allowlocal, negslack, maxaggrlen, &rowtoolong) );
2333 SCIP_CALL( addOneRow(scip, aggrrow, rows[k], weights[k], sidetypebasis, allowlocal, negslack, maxaggrlen, &rowtoolong) );
2358 SCIP_Bool* success /**< pointer to return whether post-processing was succesful or cut is redundant */
2386 SCIP_CALL( cutTightenCoefs(scip, cutislocal, cutcoefs, QUAD(&rhs), cutinds, nnz, &redundant) );
2405 *success = ! removeZeros(scip, minallowedcoef, cutislocal, cutcoefs, QUAD(&rhs), cutinds, nnz);
2427 SCIP_Bool* success /**< pointer to return whether the cleanup was successful or if it is useless */
2443 if( removeZerosQuad(scip, SCIPfeastol(scip), cutislocal, cutcoefs, QUAD(cutrhs), cutinds, nnz) )
2452 SCIP_CALL( cutTightenCoefsQuad(scip, cutislocal, cutcoefs, QUAD(cutrhs), cutinds, nnz, &redundant) );
2473 *success = ! removeZerosQuad(scip, minallowedcoef, cutislocal, cutcoefs, QUAD(cutrhs), cutinds, nnz);
2489 *valid = ! removeZerosQuad(scip, SCIPsumepsilon(scip), useglbbounds ? FALSE : aggrrow->local, aggrrow->vals,
2548 /** gets the array of corresponding variable problem indices for each non-zero in the aggregation row */
2598 /* =========================================== c-MIR =========================================== */
2608 int usevbds, /**< should variable bounds be used in bound transformation? (0: no, 1: only binary, 2: all) */
2609 SCIP_Bool allowlocal, /**< should local information allowed to be used, resulting in a local cut? */
2641 if( bestvlbidx >= 0 && (bestvlb > *bestlb || (*bestlbtype < 0 && SCIPisGE(scip, bestvlb, *bestlb))) )
2645 /* we have to avoid cyclic variable bound usage, so we enforce to use only variable bounds variables of smaller index */
2646 /**@todo this check is not needed for continuous variables; but allowing all but binary variables
2669 int usevbds, /**< should variable bounds be used in bound transformation? (0: no, 1: only binary, 2: all) */
2670 SCIP_Bool allowlocal, /**< should local information allowed to be used, resulting in a local cut? */
2702 if( bestvubidx >= 0 && (bestvub < *bestub || (*bestubtype < 0 && SCIPisLE(scip, bestvub, *bestub))) )
2706 /* we have to avoid cyclic variable bound usage, so we enforce to use only variable bounds variables of smaller index */
2707 /**@todo this check is not needed for continuous variables; but allowing all but binary variables
2724 /** determine the best bounds with respect to the given solution for complementing the given variable */
2730 SCIP_Real boundswitch, /**< fraction of domain up to which lower bound is used in transformation */
2731 int usevbds, /**< should variable bounds be used in bound transformation? (0: no, 1: only binary, 2: all) */
2732 SCIP_Bool allowlocal, /**< should local information allowed to be used, resulting in a local cut? */
2733 SCIP_Bool fixintegralrhs, /**< should complementation tried to be adjusted such that rhs gets fractional? */
2735 int* boundsfortrans, /**< bounds that should be used for transformed variables: vlb_idx/vub_idx,
2738 SCIP_BOUNDTYPE* boundtypesfortrans, /**< type of bounds that should be used for transformed variables;
2744 SCIP_BOUNDTYPE* selectedbound, /**< pointer to store whether the lower bound or the upper bound should be preferred */
2757 assert(SCIPvarGetType(var) == SCIP_VARTYPE_CONTINUOUS || ( boundsfortrans[v] == -2 || boundsfortrans[v] == -1 ));
2788 *bestlb = vlbcoefs[k] * (sol == NULL ? SCIPvarGetLPSol(vlbvars[k]) : SCIPgetSolVal(scip, sol, vlbvars[k])) + vlbconsts[k];
2794 /* find closest upper bound in standard upper bound (and variable upper bounds for continuous variables) */
2795 SCIP_CALL( findBestUb(scip, var, sol, fixintegralrhs ? usevbds : 0, allowlocal && fixintegralrhs, bestub, &simpleub, bestubtype) );
2826 /* we have to avoid cyclic variable bound usage, so we enforce to use only variable bounds variables of smaller index */
2827 *bestub = vubcoefs[k] * (sol == NULL ? SCIPvarGetLPSol(vubvars[k]) : SCIPgetSolVal(scip, sol, vubvars[k])) + vubconsts[k];
2833 /* find closest lower bound in standard lower bound (and variable lower bounds for continuous variables) */
2834 SCIP_CALL( findBestLb(scip, var, sol, fixintegralrhs ? usevbds : 0, allowlocal && fixintegralrhs, bestlb, &simplelb, bestlbtype) );
2843 /* find closest lower bound in standard lower bound (and variable lower bounds for continuous variables) */
2846 /* find closest upper bound in standard upper bound (and variable upper bounds for continuous variables) */
2876 else if( ((*bestlbtype) >= 0 || (*bestubtype) >= 0) && !SCIPisEQ(scip, *bestlb - simplelb, simpleub - *bestub) )
2923 /** performs the bound substitution step with the given variable or simple bounds for the variable with the given problem index */
2934 SCIP_Real boundval, /**< array of best bound to be used for the substitution for each nonzero index */
2936 SCIP_Bool* localbdsused /**< pointer to updated whether a local bound was used for substitution */
3003 /** performs the bound substitution step with the simple bound for the variable with the given problem index */
3011 SCIP_Real boundval, /**< array of best bound to be used for the substitution for each nonzero index */
3013 SCIP_Bool* localbdsused /**< pointer to updated whether a local bound was used for substitution */
3038 * x^\prime_j := x_j - lb_j,& x_j = x^\prime_j + lb_j,& a^\prime_j = a_j,& \mbox{if lb is used in transformation},\\
3039 * x^\prime_j := ub_j - x_j,& x_j = ub_j - x^\prime_j,& a^\prime_j = -a_j,& \mbox{if ub is used in transformation},
3047 * x^\prime_j := x_j - (bl_j\, zl_j + dl_j),& x_j = x^\prime_j + (bl_j\, zl_j + dl_j),& a^\prime_j = a_j,& \mbox{if vlb is used in transf.} \\
3048 * x^\prime_j := (bu_j\, zu_j + du_j) - x_j,& x_j = (bu_j\, zu_j + du_j) - x^\prime_j,& a^\prime_j = -a_j,& \mbox{if vub is used in transf.}
3051 * move the constant terms \f$ a_j\, dl_j \f$ or \f$ a_j\, du_j \f$ to the rhs, and update the coefficient of the VLB variable:
3063 SCIP_Real boundswitch, /**< fraction of domain up to which lower bound is used in transformation */
3065 SCIP_Bool allowlocal, /**< should local information allowed to be used, resulting in a local cut? */
3066 SCIP_Bool fixintegralrhs, /**< should complementation tried to be adjusted such that rhs gets fractional? */
3068 int* boundsfortrans, /**< bounds that should be used for transformed variables: vlb_idx/vub_idx,
3071 SCIP_BOUNDTYPE* boundtypesfortrans, /**< type of bounds that should be used for transformed variables;
3082 SCIP_Bool* freevariable, /**< stores whether a free variable was found in MIR row -> invalid summation */
3083 SCIP_Bool* localbdsused /**< pointer to store whether local bounds were used in transformation */
3113 /* start with continuous variables, because using variable bounds can affect the untransformed integral
3114 * variables, and these changes have to be incorporated in the transformation of the integral variables
3126 SCIP_CALL( determineBestBounds(scip, vars[cutinds[i]], sol, boundswitch, usevbds ? 2 : 0, allowlocal, fixintegralrhs,
3128 bestlbs + i, bestubs + i, bestlbtypes + i, bestubtypes + i, selectedbounds + i, freevariable) );
3150 performBoundSubstitution(scip, cutinds, cutcoefs, QUAD(cutrhs), nnz, varsign[i], boundtype[i], bestlbs[i], v, localbdsused);
3160 performBoundSubstitution(scip, cutinds, cutcoefs, QUAD(cutrhs), nnz, varsign[i], boundtype[i], bestubs[i], v, localbdsused);
3164 /* remove integral variables that now have a zero coefficient due to variable bound usage of continuous variables
3186 /* determine the best bounds for the integral variable, usevbd can be set to 0 here as vbds are only used for continuous variables */
3189 bestlbs + i, bestubs + i, bestlbtypes + i, bestubtypes + i, selectedbounds + i, freevariable) );
3198 /* now perform the bound substitution on the remaining integral variables which only uses standard bounds */
3213 performBoundSubstitutionSimple(scip, cutcoefs, QUAD(cutrhs), boundtype[i], bestlbs[i], v, localbdsused);
3224 performBoundSubstitutionSimple(scip, cutcoefs, QUAD(cutrhs), boundtype[i], bestubs[i], v, localbdsused);
3306 /* prefer larger violations; for equal violations, prefer smaller f0 values since then the possibility that
3309 if( SCIPisGT(scip, violgain, bestviolgain) || (SCIPisGE(scip, violgain, bestviolgain) && newf0 < bestnewf0) )
3337 assert(bestubtypes[besti] < 0); /* cannot switch to a variable bound (would lead to further coef updates) */
3344 assert(bestlbtypes[besti] < 0); /* cannot switch to a variable bound (would lead to further coef updates) */
3365 /** Calculate fractionalities \f$ f_0 := b - down(b), f_j := a^\prime_j - down(a^\prime_j) \f$, and derive MIR cut \f$ \tilde{a} \cdot x' \leq down(b) \f$
3380 * x^\prime_j := x_j - lb_j,& x_j = x^\prime_j + lb_j,& a^\prime_j = a_j,& \hat{a}_j := \tilde{a}_j,& \mbox{if lb was used in transformation}, \\
3381 * x^\prime_j := ub_j - x_j,& x_j = ub_j - x^\prime_j,& a^\prime_j = -a_j,& \hat{a}_j := -\tilde{a}_j,& \mbox{if ub was used in transformation},
3396 * x^\prime_j := x_j - (bl_j \cdot zl_j + dl_j),& x_j = x^\prime_j + (bl_j\, zl_j + dl_j),& a^\prime_j = a_j,& \hat{a}_j := \tilde{a}_j,& \mbox{(vlb)} \\
3397 * x^\prime_j := (bu_j\, zu_j + du_j) - x_j,& x_j = (bu_j\, zu_j + du_j) - x^\prime_j,& a^\prime_j = -a_j,& \hat{a}_j := -\tilde{a}_j,& \mbox{(vub)}
3410 * \hat{a}_{zl_j} := \hat{a}_{zl_j} - \tilde{a}_j\, bl_j = \hat{a}_{zl_j} - \hat{a}_j\, bl_j,& \mbox{or} \\
3420 int*RESTRICT cutinds, /**< array of variables problem indices for non-zero coefficients in cut */
3423 int*RESTRICT boundtype, /**< stores the bound used for transformed variable (vlb/vub_idx or -1 for lb/ub) */
3445 /* Loop backwards to process integral variables first and be able to delete coefficients of integral variables
3453 /*in debug mode check that all continuous variables of the aggrrow come before the integral variables */
3521 /* move the constant term -a~_j * lb_j == -a^_j * lb_j , or a~_j * ub_j == -a^_j * ub_j to the rhs */
3556 /* now process the continuous variables; postpone deletion of zeros untill all continuous variables have been processed */
3604 /* move the constant term -a~_j * lb_j == -a^_j * lb_j , or a~_j * ub_j == -a^_j * ub_j to the rhs */
3711 * The coefficient of the slack variable s_r is equal to the row's weight times the slack's sign, because the slack
3712 * variable only appears in its own row: \f$ a^\prime_r = scale \cdot weight[r] \cdot slacksign[r]. \f$
3714 * Depending on the slacks type (integral or continuous), its coefficient in the cut calculates as follows:
3718 * & \hat{a}_r = \tilde{a}_r = down(a^\prime_r) + (f_r - f_0)/(1 - f_0),& \mbox{if}\qquad f_r > f_0 \\
3724 * Substitute \f$ \hat{a}_r \cdot s_r \f$ by adding \f$ \hat{a}_r \f$ times the slack's definition to the cut.
3868 /** calculates an MIR cut out of the weighted sum of LP rows; The weights of modifiable rows are set to 0.0, because
3871 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3883 SCIP_Real boundswitch, /**< fraction of domain up to which lower bound is used in transformation */
3885 SCIP_Bool allowlocal, /**< should local information allowed to be used, resulting in a local cut? */
3886 SCIP_Bool fixintegralrhs, /**< should complementation tried to be adjusted such that rhs gets fractional? */
3887 int* boundsfortrans, /**< bounds that should be used for transformed variables: vlb_idx/vub_idx,
3890 SCIP_BOUNDTYPE* boundtypesfortrans, /**< type of bounds that should be used for transformed variables;
3896 SCIP_Real* cutcoefs, /**< array to store the non-zero coefficients in the cut if its efficacy improves cutefficacy */
3897 SCIP_Real* cutrhs, /**< pointer to store the right hand side of the cut if its efficacy improves cutefficacy */
3898 int* cutinds, /**< array to store the indices of non-zero coefficients in the cut if its efficacy improves cutefficacy */
3899 int* cutnnz, /**< pointer to store the number of non-zeros in the cut if its efficacy improves cutefficacy */
3901 int* cutrank, /**< pointer to return rank of generated cut or NULL if it improves cutefficacy */
3902 SCIP_Bool* cutislocal, /**< pointer to store whether the generated cut is only valid locally if it improves cutefficacy */
3903 SCIP_Bool* success /**< pointer to store whether the returned coefficients are a valid MIR cut and it improves cutefficacy */
3969 * x'_j := x_j - (bl_j * zl_j + dl_j), x_j == x'_j + (bl_j * zl_j + dl_j), a'_j == a_j, if vlb is used in transf.
3970 * x'_j := (bu_j * zu_j + du_j) - x_j, x_j == (bu_j * zu_j + du_j) - x'_j, a'_j == -a_j, if vub is used in transf.
3971 * move the constant terms "a_j * dl_j" or "a_j * du_j" to the rhs, and update the coefficient of the VLB variable:
3975 SCIP_CALL( cutsTransformMIR(scip, sol, boundswitch, usevbds, allowlocal, fixintegralrhs, FALSE,
3976 boundsfortrans, boundtypesfortrans, minfrac, maxfrac, tmpcoefs, QUAD(&rhs), tmpinds, &tmpnnz, varsign, boundtype, &freevariable, &localbdsused) );
3997 * x'_j := x_j - lb_j, x_j == x'_j + lb_j, a'_j == a_j, a^_j := a~_j, if lb was used in transformation
3998 * x'_j := ub_j - x_j, x_j == ub_j - x'_j, a'_j == -a_j, a^_j := -a~_j, if ub was used in transformation
4005 * x'_j := x_j - (bl_j * zl_j + dl_j), x_j == x'_j + (bl_j * zl_j + dl_j), a'_j == a_j, a^_j := a~_j, (vlb)
4006 * x'_j := (bu_j * zu_j + du_j) - x_j, x_j == (bu_j * zu_j + du_j) - x'_j, a'_j == -a_j, a^_j := -a~_j, (vub)
4034 SCIP_CALL( cutsRoundMIR(scip, tmpcoefs, QUAD(&rhs), tmpinds, &tmpnnz, varsign, boundtype, QUAD(f0)) );
4042 * The coefficient of the slack variable s_r is equal to the row's weight times the slack's sign, because the slack
4046 * Depending on the slacks type (integral or continuous), its coefficient in the cut calculates as follows:
4062 /* remove all nearly-zero coefficients from MIR row and relax the right hand side correspondingly in order to
4065 SCIP_CALL( postprocessCutQuad(scip, tmpislocal, tmpinds, tmpcoefs, &tmpnnz, QUAD(&rhs), success) );
4069 *success = ! removeZerosQuad(scip, SCIPsumepsilon(scip), tmpislocal, tmpcoefs, QUAD(&rhs), tmpinds, &tmpnnz);
4077 SCIP_Real mirefficacy = calcEfficacyDenseStorageQuad(scip, sol, tmpcoefs, QUAD_TO_DBL(rhs), tmpinds, tmpnnz);
4079 if( SCIPisEfficacious(scip, mirefficacy) && (cutefficacy == NULL || mirefficacy > *cutefficacy) )
4204 * Given the aggregation, it is transformed to a mixed knapsack set via complementation (using bounds or variable bounds)
4207 * so one would prefer to have integer coefficients for integer variables which are far away from their bounds in the
4210 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
4222 SCIP_Real boundswitch, /**< fraction of domain up to which lower bound is used in transformation */
4224 SCIP_Bool allowlocal, /**< should local information allowed to be used, resulting in a local cut? */
4226 int* boundsfortrans, /**< bounds that should be used for transformed variables: vlb_idx/vub_idx,
4229 SCIP_BOUNDTYPE* boundtypesfortrans, /**< type of bounds that should be used for transformed variables;
4236 int* cutinds, /**< array to store the problem indices of variables with a non-zero coefficient in the cut */
4238 SCIP_Real* cutefficacy, /**< pointer to store efficacy of best cut; only cuts that are strictly better than the value of
4241 SCIP_Bool* cutislocal, /**< pointer to store whether the generated cut is only valid locally */
4290 /* we only compute bound distance for integer variables; we allocate an array of length aggrrow->nnz to store this, since
4291 * this is the largest number of integer variables. (in contrast to the number of total variables which can be 2 *
4292 * aggrrow->nnz variables: if all are continuous and we use variable bounds to completement, we introduce aggrrow->nnz
4324 * x'_j := x_j - (bl_j * zl_j + dl_j), x_j == x'_j + (bl_j * zl_j + dl_j), a'_j == a_j, if vlb is used in transf.
4325 * x'_j := (bu_j * zu_j + du_j) - x_j, x_j == (bu_j * zu_j + du_j) - x'_j, a'_j == -a_j, if vub is used in transf.
4326 * move the constant terms "a_j * dl_j" or "a_j * du_j" to the rhs, and update the coefficient of the VLB variable:
4331 boundsfortrans, boundtypesfortrans, minfrac, maxfrac, mksetcoefs, QUAD(&mksetrhs), mksetinds, &mksetnnz, varsign, boundtype, &freevariable, &localbdsused) );
4339 SCIPdebug( printCutQuad(scip, sol, mksetcoefs, QUAD(mksetrhs), mksetinds, mksetnnz, FALSE, FALSE) );
4377 SCIP_CALL( SCIPcalcIntegralScalar(deltacands, nbounddist, -QUAD_EPSILON, SCIPsumepsilon(scip), (SCIP_Longint)10000, 10000.0, &intscale, &intscalesuccess) );
4447 * x'_j := x_j - lb_j, x_j == x'_j + lb_j, a'_j == a_j, a^_j := a~_j, if lb was used in transformation
4448 * x'_j := ub_j - x_j, x_j == ub_j - x'_j, a'_j == -a_j, a^_j := -a~_j, if ub was used in transformation
4455 * x'_j := x_j - (bl_j * zl_j + dl_j), x_j == x'_j + (bl_j * zl_j + dl_j), a'_j == a_j, a^_j := a~_j, (vlb)
4456 * x'_j := (bu_j * zu_j + du_j) - x_j, x_j == (bu_j * zu_j + du_j) - x'_j, a'_j == -a_j, a^_j := -a~_j, (vub)
4648 efficacy = computeMIREfficacy(scip, tmpcoefs, tmpvalues, QUAD_TO_DBL(mksetrhs), contactivity, contsqrnorm, deltacands[i], ntmpcoefs, minfrac, maxfrac);
4671 efficacy = computeMIREfficacy(scip, tmpcoefs, tmpvalues, QUAD_TO_DBL(mksetrhs), contactivity, contsqrnorm, delta, ntmpcoefs, minfrac, maxfrac);
4681 /* try to improve efficacy by switching complementation of integral variables that are not at their bounds
4699 SCIP_CALL( findBestLb(scip, vars[mksetinds[k]], sol, 0, allowlocal, &bestlb, &simplebnd, &bestlbtype) );
4704 SCIP_CALL( findBestUb(scip, vars[mksetinds[k]], sol, 0, allowlocal, &bestub, &simplebnd, &bestubtype) );
4724 tmpvalues[k - intstart] = varsign[k] == +1 ? bestub - SCIPgetSolVal(scip, sol, vars[mksetinds[k]]) : SCIPgetSolVal(scip, sol, vars[mksetinds[k]]) - bestlb;
4727 newefficacy = computeMIREfficacy(scip, tmpcoefs, tmpvalues, QUAD_TO_DBL(newrhs), contactivity, contsqrnorm, bestdelta, ntmpcoefs, minfrac, maxfrac);
4739 assert(bestubtype < 0); /* cannot switch to a variable bound (would lead to further coef updates) */
4746 assert(bestlbtype < 0); /* cannot switch to a variable bound (would lead to further coef updates) */
4786 SCIPdebug(printCutQuad(scip, sol, mksetcoefs, QUAD(mksetrhs), mksetinds, mksetnnz, FALSE, FALSE));
4790 SCIP_CALL( cutsRoundMIR(scip, mksetcoefs, QUAD(&mksetrhs), mksetinds, &mksetnnz, varsign, boundtype, QUAD(f0)) );
4793 SCIPdebug(printCutQuad(scip, sol, mksetcoefs, QUAD(mksetrhs), mksetinds, mksetnnz, FALSE, FALSE));
4797 * The coefficient of the slack variable s_r is equal to the row's weight times the slack's sign, because the slack
4801 * Depending on the slacks type (integral or continuous), its coefficient in the cut calculates as follows:
4813 SCIPdebug(printCutQuad(scip, sol, mksetcoefs, QUAD(mksetrhs), mksetinds, mksetnnz, FALSE, FALSE));
4827 SCIPdebugMsg(scip, "efficacy of cmir cut is different than expected efficacy: %f != %f\n", efficacy, bestefficacy);
4834 /* remove all nearly-zero coefficients from MIR row and relax the right hand side correspondingly in order to
4839 SCIP_CALL( postprocessCutQuad(scip, *cutislocal, mksetinds, mksetcoefs, &mksetnnz, QUAD(&mksetrhs), success) );
4843 *success = ! removeZerosQuad(scip, SCIPsumepsilon(scip), *cutislocal, mksetcoefs, QUAD(&mksetrhs), mksetinds, &mksetnnz);
4847 SCIPdebug(printCutQuad(scip, sol, mksetcoefs, QUAD(mksetrhs), mksetinds, mksetnnz, FALSE, FALSE));
4851 mirefficacy = calcEfficacyDenseStorageQuad(scip, sol, mksetcoefs, QUAD_TO_DBL(mksetrhs), mksetinds, mksetnnz);
4906 /* =========================================== flow cover =========================================== */
4918 #define MAXABSVBCOEF 1e+5 /**< maximal absolute coefficient in variable bounds used for snf relaxation */
4935 SCIP_Real d1; /**< right hand side of single-node-flow set plus the sum of all \f$ u_j \f$ for \f$ j \in C^- \f$ */
4936 SCIP_Real d2; /**< right hand side of single-node-flow set plus the sum of all \f$ u_j \f$ for \f$ j \in N^- \f$ */
4938 SCIP_Real mp; /**< smallest variable bound coefficient of variable in \f$ C^{++} (min_{j \in C++} u_j) \f$ */
4942 /** structure that contains all the data that defines the single-node-flow relaxation of an aggregation row */
4954 SCIP_Real* aggrcoefsbin; /**< aggregation coefficient of the original binary var used to define the
4956 SCIP_Real* aggrcoefscont; /**< aggregation coefficient of the original continuous var used to define the
4958 SCIP_Real* aggrconstants; /**< aggregation constant used to define the continuous variable in the relaxed set */
4961 /** get solution value and index of variable lower bound (with binary variable) which is closest to the current LP
4962 * solution value of a given variable; candidates have to meet certain criteria in order to ensure the nonnegativity
4963 * of the variable upper bound imposed on the real variable in the 0-1 single node flow relaxation associated with the
4977 SCIP_Real* closestvlb, /**< pointer to store the LP sol value of the closest variable lower bound */
4978 int* closestvlbidx /**< pointer to store the index of the closest vlb; -1 if no vlb was found */
4986 assert(bestsub == SCIPvarGetUbGlobal(var) || bestsub == SCIPvarGetUbLocal(var)); /*lint !e777*/
5031 /* if the variable is not active the problem index is -1, so we cast to unsigned int before the comparison which
5039 /* check if current variable lower bound l~_i * x_i + d_i imposed on y_j meets the following criteria:
5043 * 0. no other non-binary variable y_k has used a variable bound with x_i to get transformed variable y'_k yet
5091 /** get LP solution value and index of variable upper bound (with binary variable) which is closest to the current LP
5092 * solution value of a given variable; candidates have to meet certain criteria in order to ensure the nonnegativity
5093 * of the variable upper bound imposed on the real variable in the 0-1 single node flow relaxation associated with the
5107 SCIP_Real* closestvub, /**< pointer to store the LP sol value of the closest variable upper bound */
5108 int* closestvubidx /**< pointer to store the index of the closest vub; -1 if no vub was found */
5116 assert(bestslb == SCIPvarGetLbGlobal(var) || bestslb == SCIPvarGetLbLocal(var)); /*lint !e777*/
5161 /* if the variable is not active the problem index is -1, so we cast to unsigned int before the comparison which
5173 * 0. no other non-binary variable y_k has used a variable bound with x_i to get transformed variable y'_k
5221 /** determines the bounds to use for constructing the single-node-flow relaxation of a variable in
5231 int varposinrow, /**< position of variable in the rowinds array for which the bounds should be determined */
5235 SCIP_Bool allowlocal, /**< should local information allowed to be used, resulting in a local cut? */
5236 SCIP_Real boundswitch, /**< fraction of domain up to which lower bound is used in transformation */
5245 SCIP_BOUNDTYPE* selectedbounds, /**< pointer to store the preferred bound for the transformation */
5273 SCIP_CALL( findBestLb(scip, var, sol, 0, allowlocal, &bestslb[varposinrow], &simplebound, &bestslbtype[varposinrow]) );
5274 SCIP_CALL( findBestUb(scip, var, sol, 0, allowlocal, &bestsub[varposinrow], &simplebound, &bestsubtype[varposinrow]) );
5285 SCIPdebugMsg(scip, " %d: %g <%s, idx=%d, lp=%g, [%g(%d),%g(%d)]>:\n", varposinrow, rowcoef, SCIPvarGetName(var), probidx,
5286 solval, bestslb[varposinrow], bestslbtype[varposinrow], bestsub[varposinrow], bestsubtype[varposinrow]);
5288 /* mixed integer set cannot be relaxed to 0-1 single node flow set because both simple bounds are -infinity
5291 if( SCIPisInfinity(scip, -bestslb[varposinrow]) && SCIPisInfinity(scip, bestsub[varposinrow]) )
5297 /* get closest lower bound that can be used to define the real variable y'_j in the 0-1 single node flow
5310 SCIP_CALL( getClosestVlb(scip, var, sol, rowcoefs, binvarused, bestsub[varposinrow], rowcoef, &bestvlb, &bestvlbidx) );
5319 /* get closest upper bound that can be used to define the real variable y'_j in the 0-1 single node flow
5332 SCIP_CALL( getClosestVub(scip, var, sol, rowcoefs, binvarused, bestslb[varposinrow], rowcoef, &bestvub, &bestvubidx) );
5340 SCIPdebugMsg(scip, " bestlb=%g(%d), bestub=%g(%d)\n", bestlb[varposinrow], bestlbtype[varposinrow], bestub[varposinrow], bestubtype[varposinrow]);
5342 /* mixed integer set cannot be relaxed to 0-1 single node flow set because there are no suitable bounds
5353 /* select best upper bound if it is closer to the LP value of y_j and best lower bound otherwise and use this bound
5354 * to define the real variable y'_j with 0 <= y'_j <= u'_j x_j in the 0-1 single node flow relaxation;
5357 if( SCIPisEQ(scip, solval, (1.0 - boundswitch) * bestlb[varposinrow] + boundswitch * bestub[varposinrow]) && bestlbtype[varposinrow] >= 0 )
5361 else if( SCIPisEQ(scip, solval, (1.0 - boundswitch) * bestlb[varposinrow] + boundswitch * bestub[varposinrow])
5366 else if( SCIPisLE(scip, solval, (1.0 - boundswitch) * bestlb[varposinrow] + boundswitch * bestub[varposinrow]) )
5372 assert(SCIPisGT(scip, solval, (1.0 - boundswitch) * bestlb[varposinrow] + boundswitch * bestub[varposinrow]));
5402 /** construct a 0-1 single node flow relaxation (with some additional simple constraints) of a mixed integer set
5409 SCIP_Real boundswitch, /**< fraction of domain up to which lower bound is used in transformation */
5410 SCIP_Bool allowlocal, /**< should local information allowed to be used, resulting in a local cut? */
5417 SCIP_Bool* localbdsused /**< pointer to store whether local bounds were used in transformation */
5440 SCIPdebugMsg(scip, "--------------------- construction of SNF relaxation ------------------------------------\n");
5458 /* array to store whether a binary variable is in the row (-1) or has been used (1) due to variable bound usage */
5472 SCIP_CALL( determineBoundForSNF(scip, sol, vars, rowcoefs, rowinds, i, binvarused, allowlocal, boundswitch,
5473 bestlb, bestub, bestslb, bestsub, bestlbtype, bestubtype, bestslbtype, bestsubtype, selectedbounds, &freevariable) );
5541 /* store for y_j that bestlb is the bound used to define y'_j and that y'_j is the associated real variable
5571 /* store aggregation information for y'_j for transforming cuts for the SNF relaxation back to the problem variables later */
5600 SCIPdebugMsg(scip, " --> bestlb used for trans: ... %s y'_%d + ..., y'_%d <= %g x_%d (=1), rhs=%g-(%g*%g)=%g\n",
5601 snf->transvarcoefs[snf->ntransvars] == 1 ? "+" : "-", snf->ntransvars, snf->ntransvars, snf->transvarvubcoefs[snf->ntransvars],
5602 snf->ntransvars, QUAD_TO_DBL(transrhs) + QUAD_TO_DBL(rowcoeftimesbestsub), QUAD_TO_DBL(rowcoef), bestsub[i], QUAD_TO_DBL(transrhs));
5618 * y'_j = - ( a_j ( y_j - d_j ) + c_j x_j ) with 0 <= y'_j <= - ( a_j l~_j + c_j ) x_j if a_j > 0
5650 /* store aggregation information for y'_j for transforming cuts for the SNF relaxation back to the problem variables later */
5680 SCIPdebugMsg(scip, " --> bestlb used for trans: ... %s y'_%d + ..., y'_%d <= %g x_%d (=%s), rhs=%g-(%g*%g)=%g\n",
5681 snf->transvarcoefs[snf->ntransvars] == 1 ? "+" : "-", snf->ntransvars, snf->ntransvars, snf->transvarvubcoefs[snf->ntransvars],
5682 snf->ntransvars, SCIPvarGetName(vlbvars[bestlbtype[i]]), QUAD_TO_DBL(transrhs) + QUAD_TO_DBL(rowcoeftimesvlbconst), QUAD_TO_DBL(rowcoef),
5725 /* store aggregation information for y'_j for transforming cuts for the SNF relaxation back to the problem variables later */
5754 SCIPdebugMsg(scip, " --> bestub used for trans: ... %s y'_%d + ..., Y'_%d <= %g x_%d (=1), rhs=%g-(%g*%g)=%g\n",
5755 snf->transvarcoefs[snf->ntransvars] == 1 ? "+" : "-", snf->ntransvars, snf->ntransvars, snf->transvarvubcoefs[snf->ntransvars],
5756 snf->ntransvars, QUAD_TO_DBL(transrhs) + QUAD_TO_DBL(rowcoeftimesbestslb), QUAD_TO_DBL(rowcoef), bestslb[i], QUAD_TO_DBL(transrhs));