Ignore:
Timestamp:
Sep 13, 2012 12:31:33 PM (7 years ago)
Author:
forrest
Message:

fix a few problems with Aboca

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Clp/src/AbcSimplexPrimal.cpp

    r1878 r1879  
    737737  double lastSumInfeasibility = COIN_DBL_MAX;
    738738  int lastNumberInfeasibility = 1;
     739#ifndef CLP_CAUTION
     740#define CLP_CAUTION 1
     741#endif
     742#if CLP_CAUTION
     743  double lastAverageInfeasibility = sumDualInfeasibilities_ /
     744    static_cast<double>(numberDualInfeasibilities_ + 1);
     745#endif
    739746  if (numberIterations_&&type) {
    740747    lastSumInfeasibility = abcNonLinearCost_->sumInfeasibilities();
    741748    lastNumberInfeasibility = abcNonLinearCost_->numberInfeasibilities();
     749  } else {
     750    lastAverageInfeasibility=1.0e10;
    742751  }
    743752  bool ifValuesPass=(stateOfProblem_&VALUES_PASS)!=0;
     
    810819    // put back original costs and then check
    811820    // createRim(4); // costs do not change
    812 #ifndef CLP_CAUTION
    813 #define CLP_CAUTION 1
    814 #endif
    815 #if CLP_CAUTION
    816     double lastAverageInfeasibility = sumDualInfeasibilities_ /
    817       static_cast<double>(numberDualInfeasibilities_ + 10);
    818 #endif
    819821    if (ifValuesPass&&numberIterations_==baseIteration_) {
    820822      abcNonLinearCost_->checkInfeasibilities(primalTolerance_);
     
    12201222  // we may wish to say it is optimal even if infeasible
    12211223  bool alwaysOptimal = (specialOptions_ & 1) != 0;
     1224#if CLP_CAUTION
     1225  // If twice nearly there ...
     1226  if (lastAverageInfeasibility<2.0*dualTolerance_) {
     1227    double averageInfeasibility = sumDualInfeasibilities_ /
     1228      static_cast<double>(numberDualInfeasibilities_ + 1);
     1229    printf("last av %g now %g\n",lastAverageInfeasibility,
     1230           averageInfeasibility);
     1231    if (averageInfeasibility<2.0*dualTolerance_)
     1232      sumOfRelaxedDualInfeasibilities_ = 0.0;
     1233  }
     1234#endif
    12221235  // give code benefit of doubt
    12231236  if (sumOfRelaxedDualInfeasibilities_ == 0.0 &&
     
    12701283      //may need infeasiblity cost changed
    12711284      // we can see if we can construct a ray
    1272       // make up a new objective
    1273       double saveWeight = infeasibilityCost_;
    1274       // save nonlinear cost as we are going to switch off costs
    1275       AbcNonLinearCost * nonLinear = abcNonLinearCost_;
    12761285      // do twice to make sure Primal solution has settled
    12771286      // put non-basics to bounds in case tolerance moved
     
    12801289      abcNonLinearCost_->checkInfeasibilities(0.0);
    12811290      gutsOfPrimalSolution(3);
    1282      
    1283       infeasibilityCost_ = 1.0e100;
    12841291      // put back original costs
    12851292      CoinAbcMemcpy(abcCost_,costSaved_,numberTotal_);;
    12861293      abcNonLinearCost_->checkInfeasibilities(primalTolerance_);
     1294      gutsOfPrimalSolution(3);
    12871295      // may have fixed infeasibilities - double check
    12881296      if (abcNonLinearCost_->numberInfeasibilities() == 0) {
    12891297        // carry on
    12901298        problemStatus_ = -1;
    1291         infeasibilityCost_ = saveWeight;
    12921299        abcNonLinearCost_->checkInfeasibilities(primalTolerance_);
    12931300      } else {
    1294         abcNonLinearCost_ = NULL;
    1295         // scale
    1296         int i;
    1297         for (i = 0; i < numberRows_ + numberColumns_; i++)
    1298           abcCost_[i] *= 1.0e-95;
    1299         gutsOfPrimalSolution(3);
    1300         abcNonLinearCost_ = nonLinear;
    1301         infeasibilityCost_ = saveWeight;
    13021301        if ((infeasibilityCost_ >= 1.0e18 ||
    1303              numberDualInfeasibilities_ == 0) && perturbation_ == 101) {
     1302             numberDualInfeasibilities_ == 0) && perturbation_ == 101
     1303            && (specialOptions_&8192)==0) {
    13041304          goToDual = unPerturb(); // stop any further perturbation
    13051305#ifndef TRY_ABC_GUS
     
    13071307            goToDual = false;
    13081308#endif
    1309           abcNonLinearCost_->checkInfeasibilities(primalTolerance_);
    13101309          numberDualInfeasibilities_ = 1; // carry on
    13111310          problemStatus_ = -1;
    13121311        } else if (numberDualInfeasibilities_ == 0 && largestDualError_ > 1.0e-2
    13131312#ifndef TRY_ABC_GUS
    1314                    &&(moreSpecialOptions_ & 256) == 0
     1313                   &&((moreSpecialOptions_ & 256) == 0&&(specialOptions_ & 8192) == 0)
     1314#else
     1315                   &&(specialOptions_ & 8192) == 0
    13151316#endif
    13161317                   ) {
    13171318          goToDual = true;
    1318           abcFactorization_->pivotTolerance(CoinMax(0.9, abcFactorization_->pivotTolerance()));
     1319          abcFactorization_->pivotTolerance(CoinMax(0.5, abcFactorization_->pivotTolerance()));
    13191320        }
    13201321        if (!goToDual) {
     
    13471348            // put back original costs and then check
    13481349            CoinAbcMemcpy(abcCost_,costSaved_,numberTotal_);;
    1349 #ifndef TRY_ABC_GUS
    13501350            abcNonLinearCost_->checkInfeasibilities(0.0);
    13511351            gutsOfPrimalSolution(3);
    13521352            problemStatus_ = -1; //continue
     1353#ifndef TRY_ABC_GUS
    13531354            goToDual = false;
    13541355#else
    1355             goToDual=true;
     1356            if((specialOptions_&8192)==0&&!sumOfRelaxedDualInfeasibilities_)
     1357              goToDual=true;
    13561358#endif
    13571359          } else {
     
    13671369#ifndef TRY_ABC_GUS
    13681370        if ((numberRows_ > 20000 || numberDualInfeasibilities_) && !numberTimesOptimal_)
     1371#else
     1372          if ((specialOptions_&8192)!=0)
     1373#endif
    13691374          goToDual = false; // Better to carry on a bit longer
    1370 #endif
    13711375        lastCleaned_ = -1; // carry on
    13721376      }
     
    15181522    moreSpecialOptions_ &= ~16; // clear check accuracy flag
    15191523#ifndef TRY_ABC_GUS
    1520   if ((moreSpecialOptions_ & 256) != 0||saveSum)
     1524  if ((moreSpecialOptions_ & 256) != 0||saveSum||(specialOptions_ & 8192) != 0)
     1525    goToDual=false;
     1526#else
     1527  if ((specialOptions_ & 8192) != 0)
    15211528    goToDual=false;
    15221529#endif
     
    33293336          sequenceOut_ = -1;
    33303337          sequenceIn_=-1;
     3338          if (abcFactorization_->pivots()<10&&abcFactorization_->pivotTolerance()<0.25)
     3339            abcFactorization_->saferTolerances(1.0,-1.03);
    33313340          break;
    33323341        } else {
     
    33443353            // Make safer?
    33453354            double tolerance=abcFactorization_->pivotTolerance();
    3346             abcFactorization_->saferTolerances (-0.99, -1.03);
     3355            abcFactorization_->saferTolerances (1.0, -1.03);
    33473356#endif
    33483357            abcProgress_.clearBadTimes();
Note: See TracChangeset for help on using the changeset viewer.