Changeset 1769 for trunk


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

changes for advanced use of Clp

Location:
trunk/Clp
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Clp/examples/Makefile.in

    r1747 r1769  
    2222
    2323# CHANGEME: Additional libraries
    24 ADDLIBS =
     24ADDLIBS = -lOsi -lOsiClp
    2525
    2626# CHANGEME: Additional flags for compilation (e.g., include flags)
  • trunk/Clp/src/ClpEventHandler.hpp

    r1761 r1769  
    5353          looksEndInPrimal, // About to declare victory (or defeat)
    5454          endInPrimal, // Victory (or defeat)
     55          beforeStatusOfProblemInPrimal,
     56          startOfStatusOfProblemInPrimal,
    5557          complicatedPivotOut, // in modifyCoefficients
    5658          noCandidateInDual, // tentative end
    5759          looksEndInDual, // About to declare victory (or defeat)
    5860          endInDual, // Victory (or defeat)
     61          beforeStatusOfProblemInDual,
     62          startOfStatusOfProblemInDual,
     63          startOfIterationInDual,
     64          updateDualsInDual,
     65          endOfCreateRim,
    5966          noTheta // At end (because no pivot)
    6067     };
  • 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
  • trunk/Clp/src/ClpNonLinearCost.hpp

    r1665 r1769  
    150150     /// Puts feasible bounds into lower and upper
    151151     void feasibleBounds();
     152     /// Refresh - assuming regions OK
     153     void refresh();
    152154     /** Sets bounds and cost for one variable
    153155         Returns change in cost
  • trunk/Clp/src/ClpSimplex.cpp

    r1761 r1769  
    39313931          }
    39323932     }
     3933#ifdef CLP_USER_DRIVEN
     3934     eventHandler_->event(ClpEventHandler::endOfCreateRim);
     3935#endif
    39333936     return goodMatrix;
    39343937}
     
    83588361}
    83598362
     8363/* Get a clean factorization - i.e. throw out singularities
     8364    may do more later */
     8365int
     8366ClpSimplex::cleanFactorization(int ifValuesPass)
     8367{
     8368  int status = internalFactorize(ifValuesPass ? 10 : 0);
     8369  if (status < 0) {
     8370    return 1; // some error
     8371  } else {
     8372    firstFree_=0;
     8373    return 0;
     8374  }
     8375}
    83608376
    83618377void
  • trunk/Clp/src/ClpSimplex.hpp

    r1761 r1769  
    729729     */
    730730     void unpackPacked(CoinIndexedVector * rowArray, int sequence);
     731#ifndef CLP_USER_DRIVEN
    731732protected:
     733#endif
    732734     /**
    733735         This does basis housekeeping and does values for in/out variables.
     
    766768     void setValuesPassAction(double incomingInfeasibility,
    767769                              double allowedInfeasibility);
     770     /** Get a clean factorization - i.e. throw out singularities
     771         may do more later */
     772     int cleanFactorization(int ifValuesPass);
    768773     //@}
    769774     /**@name most useful gets and sets */
     
    875880     //@}
    876881
     882#ifndef CLP_USER_DRIVEN
    877883protected:
     884#endif
    878885     /**@name protected methods */
    879886     //@{
  • trunk/Clp/src/ClpSimplexPrimal.cpp

    r1761 r1769  
    895895          int status = eventHandler_->event(ClpEventHandler::goodFactorization);
    896896          if (status >= 0) {
    897             numberThrownOut=status;
    898           } else {
    899             numberThrownOut = gutsOfSolution(NULL, NULL, (firstFree_ >= 0));
     897            lastSumInfeasibility = COIN_DBL_MAX;
    900898          }
    901 #else
     899#endif
    902900          numberThrownOut = gutsOfSolution(NULL, NULL, (firstFree_ >= 0));
    903 #endif
    904901          double sumInfeasibility =  nonLinearCost_->sumInfeasibilities();
    905902          int reason2 = 0;
     
    31633160          if (pivotRow_ >= numberRows_)
    31643161               pivotRow_ = -1;
     3162#ifdef CLP_USER_DRIVEN
     3163          if (theta_<0.0) {
     3164            if (theta_>=-1.0e-12)
     3165              theta_=0.0;
     3166            //else
     3167            //printf("negative theta %g\n",theta_);
     3168          }
     3169#endif
    31653170          updatePrimalsInPrimal(rowArray_[1], theta_, objectiveChange, ifValuesPass);
    31663171          pivotRow_ = savePivot;
Note: See TracChangeset for help on using the changeset viewer.