SPxId SPxFastRT::minSelect( int& nr, Real& val, Real& stab, Real& bestDelta, Real max) { Real best = infinity; bestDelta = 0.0; iscoid = true; int indc = minSelect(val, stab, best, bestDelta, max, thesolver->coPvec(), thesolver->lcBound(), thesolver->ucBound(), 0, 1); iscoid = false; int indp = minSelect(val, stab, best, bestDelta, max, thesolver->pVec(), thesolver->lpBound(), thesolver->upBound(), 0, 1); if (indp >= 0) { nr = indp; return thesolver->id(indp); } if (indc >= 0) { nr = indc; return thesolver->coId(indc); } nr = -1; return SPxId(); }
SPxId SPxFastRT::maxDelta( int& nr, Real& max, /* on return: maximum step length */ Real& maxabs) /* on return: maximum absolute value in delta vector */ { /* The following cause side effects on coPvec and pVec - both changes may be needed later in maxSelect(). We can therefore not move the first function after the (indp >= 0) check. */ iscoid = true; int indc = maxDelta(max, maxabs, thesolver->coPvec(), thesolver->lcBound(), thesolver->ucBound(), 0, 1); iscoid = false; int indp = maxDelta(max, maxabs, thesolver->pVec(), thesolver->lpBound(), thesolver->upBound(), 0, 1); if (indp >= 0) { nr = indp; return thesolver->id(indp); } if (indc >= 0) { nr = indc; return thesolver->coId(indc); } nr = -1; return SPxId(); }
SPxId SPxFastRT::minDelta( int& nr, Real& max, Real& maxabs) { /* The following cause side effects on coPvec and pVec - both changes may be needed later in minSelect(). We can therefore not move the first function after the (indp >= 0) check. */ iscoid = true; const int indc = minDelta(max, maxabs, thesolver->coPvec(), thesolver->lcBound(), thesolver->ucBound(), 0, 1); iscoid = false; const int indp = minDelta(max, maxabs, thesolver->pVec(), thesolver->lpBound(), thesolver->upBound(), 0, 1); if (indp >= 0) { nr = indp; return thesolver->id(indp); } if (indc >= 0) { nr = indc; return thesolver->coId(indc); } nr = -1; return SPxId(); }
SPxId SPxWeightPR::selectEnter() { const Vector& rTest = (solver()->rep() == SPxSolver::ROW) ? solver()->test() : solver()->coTest(); const Vector& cTest = (solver()->rep() == SPxSolver::ROW) ? solver()->coTest() : solver()->test(); const SPxBasis::Desc& ds = solver()->basis().desc(); Real best = infinity; SPxId lastId; Real x; int i; for (i = solver()->nRows() - 1; i >= 0; --i) { x = rTest[i]; if (x < -theeps) { x *= -x; switch (ds.rowStatus(i)) { case SPxBasis::Desc::P_ON_LOWER : case SPxBasis::Desc::D_ON_LOWER : x *= 1 + rPenalty[i]; break; case SPxBasis::Desc::P_ON_UPPER : case SPxBasis::Desc::D_ON_UPPER : x *= 1 - rPenalty[i]; break; case SPxBasis::Desc::P_FREE : case SPxBasis::Desc::D_FREE : return SPxId(solver()->rId(i)); case SPxBasis::Desc::D_ON_BOTH : if (solver()->pVec()[i] > solver()->upBound()[i]) x *= 1 + rPenalty[i]; else x *= 1 - rPenalty[i]; break; case SPxBasis::Desc::D_UNDEFINED : case SPxBasis::Desc::P_FIXED : default: throw SPxInternalCodeException("XWGTPR01 This should never happen."); } if (x < best) { best = x; lastId = solver()->rId(i); } } } for (i = solver()->nCols() - 1; i >= 0; --i) { x = cTest[i]; if (x < -theeps) { x *= -x; switch (ds.colStatus(i)) { case SPxBasis::Desc::P_ON_LOWER : case SPxBasis::Desc::D_ON_LOWER : x *= 1 + cPenalty[i]; break; case SPxBasis::Desc::P_ON_UPPER : case SPxBasis::Desc::D_ON_UPPER : x *= 1 - cPenalty[i]; break; case SPxBasis::Desc::P_FREE : case SPxBasis::Desc::D_FREE : return SPxId(solver()->cId(i)); case SPxBasis::Desc::D_ON_BOTH : if (solver()->coPvec()[i] > solver()->ucBound()[i]) x *= 1 + cPenalty[i]; else x *= 1 - cPenalty[i]; break; case SPxBasis::Desc::P_FIXED : case SPxBasis::Desc::D_UNDEFINED : default: throw SPxInternalCodeException("XWGTPR02 This should never happen."); } if (x < best) { best = x; lastId = solver()->cId(i); } } } assert(isConsistent()); return lastId; }