Ignore:
Timestamp:
Jul 26, 2011 5:31:51 AM (8 years ago)
Author:
forrest
Message:

changes for advanced use of Clp

File:
1 edited

Legend:

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

    r1761 r1769  
    224224          }
    225225     }
     226}
     227// Refresh - assuming regions OK
     228void
     229ClpNonLinearCost::refresh()
     230{
     231     int numberTotal = numberRows_ + numberColumns_;
     232     numberInfeasibilities_ = 0;
     233     sumInfeasibilities_ = 0.0;
     234     largestInfeasibility_ = 0.0;
     235     double infeasibilityCost = model_->infeasibilityCost();
     236     double primalTolerance = model_->currentPrimalTolerance();
     237     double * cost = model_->costRegion();
     238     double * upper = model_->upperRegion();
     239     double * lower = model_->lowerRegion();
     240     double * solution = model_->solutionRegion();
     241     for (int iSequence = 0; iSequence < numberTotal; iSequence++) {
     242       cost2_[iSequence] = cost[iSequence];
     243       double value = solution[iSequence];
     244       double lowerValue = lower[iSequence];
     245       double upperValue = upper[iSequence];
     246       if (value - upperValue <= primalTolerance) {
     247         if (value - lowerValue >= -primalTolerance) {
     248           // feasible
     249           status_[iSequence] = static_cast<unsigned char>(CLP_FEASIBLE | (CLP_SAME << 4));
     250           bound_[iSequence] = 0.0;
     251         } else {
     252           // below
     253           double infeasibility = lowerValue - value - primalTolerance;
     254           sumInfeasibilities_ += infeasibility;
     255           largestInfeasibility_ = CoinMax(largestInfeasibility_, infeasibility);
     256           cost[iSequence] -= infeasibilityCost;
     257           numberInfeasibilities_++;
     258           status_[iSequence] = static_cast<unsigned char>(CLP_BELOW_LOWER | (CLP_SAME << 4));
     259           bound_[iSequence] = upperValue;
     260           upper[iSequence] = lowerValue;
     261           lower[iSequence] = -COIN_DBL_MAX;
     262         }
     263       } else {
     264         // above
     265         double infeasibility = value - upperValue - primalTolerance;
     266         sumInfeasibilities_ += infeasibility;
     267         largestInfeasibility_ = CoinMax(largestInfeasibility_, infeasibility);
     268         cost[iSequence] += infeasibilityCost;
     269         numberInfeasibilities_++;
     270         status_[iSequence] = static_cast<unsigned char>(CLP_ABOVE_UPPER | (CLP_SAME << 4));
     271         bound_[iSequence] = lowerValue;
     272         lower[iSequence] = upperValue;
     273         upper[iSequence] = COIN_DBL_MAX;
     274       }
     275     }
     276     //     checkInfeasibilities(model_->primalTolerance());
     277     
    226278}
    227279// Refreshes costs always makes row costs zero
Note: See TracChangeset for help on using the changeset viewer.