lp.c
Go to the documentation of this file.
32 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
504 /* we do not save the farkas coefficient, since it can be recomputed; thus, we invalidate it here */
507 /* if the column was created after performing the storage (possibly during probing), we treat it as implicitly zero;
592 /* if the row was created after performing the storage (possibly during probing), we treat it as basic;
642 #ifdef SCIP_MORE_DEBUG /* enable this to check the sortings within rows (for debugging, very slow!) */
763 /* recompute the loose objective value from scratch, if it was marked to be unreliable before */
792 /* we are only interested in variables with a finite impact, because the infinity counters should be correct */
805 /* recompute the pseudo solution value from scratch, if it was marked to be unreliable before */
829 /* we are only interested in variables with a finite impact, because the infinity counters should be correct */
847 /* recompute the global pseudo solution value from scratch, if it was marked to be unreliable before */
871 /* we are only interested in variables with a finite impact, because the infinity counters should be correct */
953 /** sorts column entries of linked rows currently in the LP such that lower row indices precede higher ones */
984 /** sorts column entries of unlinked rows or rows currently not in the LP such that lower row indices precede higher
1001 SCIPsortPtrRealInt((void**)(&(col->rows[col->nlprows])), &(col->vals[col->nlprows]), &(col->linkpos[col->nlprows]), SCIProwComp, col->len - col->nlprows);
1017 /** sorts row entries of linked columns currently in the LP such that lower column indices precede higher ones */
1032 SCIPsortIntPtrIntReal(row->cols_index, (void**)row->cols, row->linkpos, row->vals, row->nlpcols);
1048 /** sorts row entries of unlinked columns or columns currently not in the LP such that lower column indices precede
1067 SCIPsortIntPtrIntReal(&(row->cols_index[row->nlpcols]), (void**)(&(row->cols[row->nlpcols])), &(row->linkpos[row->nlpcols]), &(row->vals[row->nlpcols]), row->len - row->nlpcols);
1085 /** searches coefficient in part of the column, returns position in col vector or -1 if not found */
1160 /** searches coefficient in part of the row, returns position in col vector or -1 if not found */
1252 /** moves a coefficient in a column to a different place, and updates all corresponding data structures */
1348 /** moves a coefficient in a row to a different place, and updates all corresponding data structures */
1469 if( (row->eventfilter->len > 0 && (row->eventfilter->eventmask & SCIP_EVENTTYPE_ROWCOEFCHANGED) != 0) )
1474 SCIP_CALL( SCIPeventqueueAdd(eventqueue, blkmem, set, NULL, NULL, NULL, row->eventfilter, &event) );
1497 if( (row->eventfilter->len > 0 && (row->eventfilter->eventmask & SCIP_EVENTTYPE_ROWCONSTCHANGED)) )
1502 SCIP_CALL( SCIPeventqueueAdd(eventqueue, blkmem, set, NULL, NULL, NULL, row->eventfilter, &event) );
1526 if( (row->eventfilter->len > 0 && !(row->eventfilter->eventmask & SCIP_EVENTTYPE_ROWSIDECHANGED)) )
1531 SCIP_CALL( SCIPeventqueueAdd(eventqueue, blkmem, set, NULL, NULL, NULL, row->eventfilter, &event) );
1537 #ifdef SCIP_MORE_DEBUG /* enable this to check links between columns and rows in LP data structure (for debugging, very slow!) */
1703 /*assert(colSearchCoef(col, row) == -1);*/ /* this assert would lead to slight differences in the solution process */
1713 /* if the row is in current LP and is linked to the column, we have to insert it at the end of the linked LP rows
1727 /* in case the coefficient is integral w.r.t. numerics we explicitly round the coefficient to an integral value */
1738 /* if the column is in current LP, we have to link it to the row, because otherwise, the primal information
1743 /* this call might swap the current row with the first non-LP/not linked row, s.t. insertion position
1765 /* if the column is in current LP, now both conditions, row->cols[linkpos]->lppos >= 0 and row->linkpos[linkpos] >= 0
1797 SCIPsetDebugMsg(set, "added coefficient %g * <%s> at position %d (%d/%d) to column <%s> (nunlinked=%d)\n",
1831 /* if row is a linked LP row, move last linked LP coefficient to position of empty slot (deleted coefficient) */
1867 /* in case the coefficient is integral w.r.t. numerics we explicitly round the coefficient to an integral value */
1913 /* Euclidean norm, sum norm, and objective function scalar product only take LP columns into account */
1998 /* Euclidean norm, sum norm, and objective function scalar product only take LP columns into account */
2049 /*assert(rowSearchCoef(row, col) == -1);*/ /* this assert would lead to slight differences in the solution process */
2064 /* if the column is in current LP and is linked to the row, we have to insert it at the end of the linked LP columns
2078 /* in case the coefficient is integral w.r.t. numerics we explicitly round the coefficient to an integral value */
2091 /* if the row is in current LP, we have to link it to the column, because otherwise, the dual information
2096 /* this call might swap the current column with the first non-LP/not linked column, s.t. insertion position
2118 /* if the row is in current LP, now both conditions, col->rows[linkpos]->lppos >= 0 and col->linkpos[linkpos] >= 0
2159 SCIPsetDebugMsg(set, "added coefficient %g * <%s> at position %d (%d/%d) to row <%s> (nunlinked=%d)\n",
2197 SCIPerrorMessage("cannot delete a coefficient from the locked unmodifiable row <%s>\n", row->name);
2204 /* if column is a linked LP column, move last linked LP coefficient to position of empty slot (deleted coefficient) */
2250 SCIPerrorMessage("cannot change a coefficient of the locked unmodifiable row <%s>\n", row->name);
2254 /* in case the coefficient is integral w.r.t. numerics we explicitly round the coefficient to an integral value */
2365 /* this call might swap the current row with the first non-LP/not linked row, but this is of no harm */
2370 assert(col->nlprows == 0 || col->rows[col->nlprows-1]->cols[col->linkpos[col->nlprows-1]] == col);
2371 assert(col->nlprows == 0 || col->rows[col->nlprows-1]->linkpos[col->linkpos[col->nlprows-1]] == col->nlprows-1);
2447 /* this call might swap the current column with the first non-LP/not linked column, but this is of no harm */
2452 assert(row->nlpcols == 0 || row->cols[row->nlpcols-1]->rows[row->linkpos[row->nlpcols-1]] == row);
2453 assert(row->nlpcols == 0 || row->cols[row->nlpcols-1]->linkpos[row->linkpos[row->nlpcols-1]] == row->nlpcols-1);
2569 /** checks, that parameter of type int in LP solver has the given value, ignoring unknown parameters */
2594 /** checks, that parameter of type SCIP_Bool in LP solver has the given value, ignoring unknown parameters */
2605 /** checks, that parameter of type SCIP_Real in LP solver has the given value, ignoring unknown parameters */
2636 #define lpCutoffDisabled(set) (set->lp_disablecutoff == 1 || (set->nactivepricers > 0 && set->lp_disablecutoff == 2))
2656 /* We disabled the objective limit in the LP solver or we want so solve exactly and thus cannot rely on the LP
2657 * solver's objective limit handling, so we return here and do not apply the objective limit. */
2674 /* check whether the parameter was actually changed or already was at the boundary of the LP solver's parameter range */
2713 /* check whether the parameter was actually changed or already was at the boundary of the LP solver's parameter range */
2756 /* check whether the parameter was actually changed or already was at the boundary of the LP solver's parameter range */
2799 /* check whether the parameter was actually changed or already was at the boundary of the LP solver's parameter range */
2868 /* We might only set lp->solved to false if fastmip is turned off, since the latter should be the more
3037 /** sets the pricing strategy of the LP solver (given the character representation of the strategy) */
3197 /* we don't check this parameter because SoPlex will always return its current random seed, not the initial one */
3408 SCIPmessageFPrintInfo(messagehdlr, file, "(obj: %.15g) [%.15g,%.15g], ", col->obj, col->lb, col->ub);
3422 /** sorts column entries such that LP rows precede non-LP rows and inside both parts lower row indices precede higher ones
3478 SCIPerrorMessage("coefficient for row <%s> doesn't exist in column <%s>\n", row->name, SCIPvarGetName(col->var));
3594 SCIP_CALL( rowChgCoefPos(row, blkmem, set, eventqueue, lp, col->linkpos[pos], col->vals[pos] + incval) );
3629 * @note: Here we only consider cancellations which can occur during decreasing the oldvalue to newvalue; not the
3668 if( SCIPsetIsLT(set, lp->objsqrnorm, 0.0) || isNewValueUnreliable(set, lp->objsqrnorm, oldvalue) )
3674 /* due to numerical troubles it still can appear that lp->objsqrnorm is a little bit smaller than 0 */
3700 SCIPsetDebugMsg(set, "changing objective value of column <%s> from %f to %f\n", SCIPvarGetName(col->var), col->obj, newobj);
3716 /* in any case, when the sign of the objective (and thereby the best bound) changes, the variable has to enter the
3730 /* update original objective value, as long as we are not in diving or probing and changed objective values */
3759 SCIPsetDebugMsg(set, "changing lower bound of column <%s> from %f to %f\n", SCIPvarGetName(col->var), col->lb, newlb);
3775 /* in any case, when the best bound is zero and gets changed, the variable has to enter the LP and the LP has to be
3804 SCIPsetDebugMsg(set, "changing upper bound of column <%s> from %f to %f\n", SCIPvarGetName(col->var), col->ub, newub);
3820 /* in any case, when the best bound is zero and gets changed, the variable has to enter the LP and the LP has to be
4018 /** calculates the Farkas coefficient y^T A_i of a column i using the given dual Farkas vector y */
4147 /** gets the Farkas value of a column in last LP (which must be infeasible), i.e. the Farkas coefficient y^T A_i times
4300 SCIP_Bool* downvalid, /**< stores whether the returned down value is a valid dual bound, or NULL;
4358 /* if a loose variables has an infinite best bound, the LP bound is -infinity and no gain can be achieved */
4385 retcode = SCIPlpiStrongbranchInt(lp->lpi, col->lpipos, col->primsol, itlim, down == NULL ? NULL : &sbdown, up == NULL ? NULL : &sbup, &sbdownvalid, &sbupvalid, &iter);
4389 retcode = SCIPlpiStrongbranchFrac(lp->lpi, col->lpipos, col->primsol, itlim, down == NULL ? NULL : &sbdown, up == NULL ? NULL : &sbup, &sbdownvalid, &sbupvalid, &iter);
4422 iter = stat->ndualresolvelps > 0 ? (int)(2*stat->ndualresolvelpiterations / stat->ndualresolvelps)
4424 : stat->nprimalresolvelps > 0 ? (int)(2*stat->nprimalresolvelpiterations / stat->nprimalresolvelps)
4484 SCIP_Bool* downvalid, /**< stores whether the returned down values are valid dual bounds, or NULL;
4557 /* if a loose variables has an infinite best bound, the LP bound is -infinity and no gain can be achieved */
4585 SCIPsetDebugMsg(set, "performing strong branching on %d variables with %d iterations\n", ncols, itlim);
4589 retcode = SCIPlpiStrongbranchesInt(lp->lpi, lpipos, nsubcols, primsols, itlim, sbdown, sbup, sbdownvalid, sbupvalid, &iter);
4591 retcode = SCIPlpiStrongbranchesFrac(lp->lpi, lpipos, nsubcols, primsols, itlim, sbdown, sbup, sbdownvalid, sbupvalid, &iter);
4660 iter = stat->ndualresolvelps > 0 ? (int)(2*stat->ndualresolvelpiterations / stat->ndualresolvelps)
4662 : stat->nprimalresolvelps > 0 ? (int)(2*stat->nprimalresolvelpiterations / stat->nprimalresolvelps)
4694 * keep in mind, that the returned old values may have nothing to do with the current LP solution
4700 SCIP_Bool* downvalid, /**< stores whether the returned down value is a valid dual bound, or NULL;
4704 SCIP_Real* solval, /**< stores LP solution value of column at last strong branching call, or NULL */
4724 /** if strong branching was already applied on the column at the current node, returns the number of LPs solved after
4739 /** marks a column to be not removable from the LP in the current node because it became obsolete */
4749 /* lpRemoveObsoleteCols() does not remove a column if the node number stored in obsoletenode equals the current node number */
4887 /** checks, whether the given scalar scales the given value to an integral number with error in the given bounds */
4892 SCIP_Real mindelta, /**< minimal relative allowed difference of scaled coefficient s*c and integral i */
4893 SCIP_Real maxdelta, /**< maximal relative allowed difference of scaled coefficient s*c and integral i */
4926 * if the row's activity is proven to be integral, the sides are automatically rounded to the next integer
4937 SCIP_Bool integralcontvars, /**< should the coefficients of the continuous variables also be made integral,
4939 SCIP_Real minrounddelta, /**< minimal relative difference of scaled coefficient s*c and integral i,
4941 SCIP_Real maxrounddelta /**< maximal relative difference of scaled coefficient s*c and integral i
4965 SCIPsetDebugMsg(set, "scale row <%s> with %g (tolerance=[%g,%g])\n", row->name, scaleval, minrounddelta, maxrounddelta);
4973 /* scale the row coefficients, thereby recalculating whether the row's activity is always integral;
4974 * if the row coefficients are rounded to the nearest integer value, calculate the maximal activity difference,
4986 /* get local or global bounds for column, depending on the local or global feasibility of the row */
5050 /* scale the row sides, and move the constant to the sides; relax the sides with accumulated delta in order
5087 for( c = 0; c < row->len && SCIPcolIsIntegral(row->cols[c]) && SCIPsetIsIntegral(set, row->vals[c]); ++c )
5111 void* origin, /**< pointer to constraint handler or separator who created the row (NULL if unkown) */
5113 SCIP_Bool modifiable, /**< is row modifiable during node processing (subject to column generation)? */
5123 * in case, for example, lhs > rhs but they are equal with tolerances, one could pass lhs=rhs=lhs+rhs/2 to
5315 SCIPmessageFPrintInfo(messagehdlr, file, "%+.15g<%s> ", row->vals[i], SCIPvarGetName(row->cols[i]->var));
5335 SCIPdebugMessage("capture row <%s> with nuses=%d and nlocks=%u\n", row->name, row->nuses, row->nlocks);
5353 SCIPsetDebugMsg(set, "release row <%s> with nuses=%d and nlocks=%u\n", (*row)->name, (*row)->nuses, (*row)->nlocks);
5365 /** locks an unmodifiable row, which forbids further changes; has no effect on modifiable rows */
5375 SCIPdebugMessage("lock row <%s> with nuses=%d and nlocks=%u\n", row->name, row->nuses, row->nlocks);
5380 /** unlocks a lock of an unmodifiable row; a row with no sealed lock may be modified; has no effect on modifiable rows */
5390 SCIPdebugMessage("unlock row <%s> with nuses=%d and nlocks=%u\n", row->name, row->nuses, row->nlocks);
5440 SCIPerrorMessage("coefficient for column <%s> doesn't exist in row <%s>\n", SCIPvarGetName(col->var), row->name);