void SPxSolver::computeTest() { METHOD( "SPxSolver::computeTest()" ); const SPxBasis::Desc& ds = desc(); Real pricingTol = leavetol(); infeasibilitiesCo.clear(); int ninfeasibilities = 0; for(int i = 0; i < coDim(); ++i) { SPxBasis::Desc::Status stat = ds.status(i); if(isBasic(stat)) theTest[i] = 0.0; else { theTest[i] = test(i, stat); if( remainingRoundsEnterCo == 0 ) { if( theTest[i] < -pricingTol ) { assert(infeasibilitiesCo.size() < infeasibilitiesCo.max()); infeasibilitiesCo.addIdx(i); isInfeasibleCo[i] = true; ++ninfeasibilities; } else isInfeasibleCo[i] = false; if( ninfeasibilities > sparsityThresholdEnterCo ) { MSG_INFO2( spxout << "IENTER04 too many infeasibilities for sparse pricing" << std::endl; ) remainingRoundsEnterCo = DENSEROUNDS; sparsePricingEnterCo = false; ninfeasibilities = 0; } } }
/* This methods assumes correctly setup vectors |pVec| and |coPvec| and bound vectors for leaving simplex. Then it checks all values of |pVec| and |coPvec| to obey these bounds and enlarges them if neccessary. */ void SPxSolver::shiftPvec() { METHOD( "SPxSolver::shiftPvec()" ); /* the allowed tolerance is (rep() == ROW) ? feastol() : opttol() because thePvec is the primal vector in ROW and the * dual vector in COLUMN representation; this is equivalent to leavetol() */ Random mult(10.0 * leavetol(), 100.0 * leavetol()); Real allow = leavetol() - epsilon(); int i, tmp; assert(type() == LEAVE); assert(allow > 0.0); for (i = dim() - 1; i >= 0; --i) { tmp = !isBasic(coId(i)); if ((*theCoUbound)[i] + allow <= (*theCoPvec)[i] && tmp) { if ((*theCoUbound)[i] != (*theCoLbound)[i]) shiftUCbound(i, (*theCoPvec)[i] + Real(mult)); else { shiftUCbound(i, (*theCoPvec)[i]); (*theCoLbound)[i] = (*theCoUbound)[i]; } } else if ((*theCoLbound)[i] - allow >= (*theCoPvec)[i] && tmp) { if ((*theCoUbound)[i] != (*theCoLbound)[i]) shiftLCbound(i, (*theCoPvec)[i] - Real(mult)); else { shiftLCbound(i, (*theCoPvec)[i]); (*theCoUbound)[i] = (*theCoLbound)[i]; } } } for (i = coDim() - 1; i >= 0; --i) { tmp = !isBasic(id(i)); if ((*theUbound)[i] + allow <= (*thePvec)[i] && tmp) { if ((*theUbound)[i] != (*theLbound)[i]) shiftUPbound(i, (*thePvec)[i] + Real(mult)); else { shiftUPbound(i, (*thePvec)[i]); (*theLbound)[i] = (*theUbound)[i]; } } else if ((*theLbound)[i] - allow >= (*thePvec)[i] && tmp) { if ((*theUbound)[i] != (*theLbound)[i]) shiftLPbound(i, (*thePvec)[i] - Real(mult)); else { shiftLPbound(i, (*thePvec)[i]); (*theUbound)[i] = (*theLbound)[i]; } } } #ifndef NDEBUG testBounds(); MSG_DEBUG( spxout << "DSHIFT02 shiftPvec: OK" << std::endl; ) #endif }
void SPxSolver::qualRedCostViolation(Real& maxviol, Real& sumviol) const { maxviol = 0.0; sumviol = 0.0; int i; // TODO: y = c_B * B^-1 => coSolve(y, c_B) // redcost = c_N - yA_N // solve system "x = e_i^T * B^-1" to get i'th row of B^-1 // DVector y( nRows() ); // basis().coSolve( x, spx->unitVector( i ) ); // DVector rdcost( nCols() ); #if 0 // un-const if (lastUpdate() > 0) factorize(); computePvec(); if (type() == ENTER) computeTest(); #endif if (type() == ENTER) { for(i = 0; i < dim(); ++i) { Real x = coTest()[i]; if (x < 0.0) { sumviol -= x; if (x < maxviol) maxviol = x; } } for(i = 0; i < coDim(); ++i) { Real x = test()[i]; if (x < 0.0) { sumviol -= x; if (x < maxviol) maxviol = x; } } } else { assert(type() == LEAVE); for(i = 0; i < dim(); ++i) { Real x = fTest()[i]; if (x < 0.0) { sumviol -= x; if (x < maxviol) maxviol = x; } } } maxviol *= -1; }