Changeset 1528


Ignore:
Timestamp:
Jan 2, 2010 8:12:47 AM (9 years ago)
Author:
pbonami
Message:

Reset to good 1.1

Location:
stable/1.1/Bonmin/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • stable/1.1/Bonmin/src/Algorithms/OaGenerators/BonOACutGenerator2.cpp

    r1524 r1528  
    6969    double oaTime;
    7070    b.options()->GetNumericValue("oa_dec_time_limit",oaTime,"bonmin.");
     71    parameter().localSearchNodeLimit_ = INT_MAX;
    7172    parameter().maxLocalSearch_ = INT_MAX;
     73    parameter().maxLocalSearchPerNode_ = INT_MAX;
    7274    parameter().maxLocalSearchTime_ =
    7375      Ipopt::Min(b.getDoubleParameter(BabSetupBase::MaxTime), oaTime);
     
    8183  {
    8284    return (nLocalSearch_<parameters_.maxLocalSearch_ &&
     85        parameters_.localSearchNodeLimit_ > 0 &&
    8386        CoinCpuTime() - timeBegin_ < parameters_.maxLocalSearchTime_);
    8487  }
     
    110113    {
    111114      subMip->performLocalSearch(cutoff, parameters_.subMilpLogLevel_,
    112           (parameters_.maxLocalSearchTime_ + timeBegin_ - CoinCpuTime()) /* time limit */);
     115          (parameters_.maxLocalSearchTime_ + timeBegin_ - CoinCpuTime()) /* time limit */,
     116          parameters_.localSearchNodeLimit_);
    113117      milpBound = subMip->lowBound();
    114118      milpOptimal = subMip->optimal();
     
    206210      //do we perform a new local search ?
    207211      if (milpOptimal && feasible && !isInteger &&
    208           nLocalSearch_ < parameters_.maxLocalSearch_) {
     212          nLocalSearch_ < parameters_.maxLocalSearch_ &&
     213          numberPasses < parameters_.maxLocalSearchPerNode_ &&
     214          parameters_.localSearchNodeLimit_ > 0) {
    209215
    210216        /** do we have a subMip? if not create a new one. */
     
    214220
    215221        subMip->performLocalSearch(cutoff, parameters_.subMilpLogLevel_,
    216             parameters_.maxLocalSearchTime_ + timeBegin_ - CoinCpuTime());
     222            parameters_.maxLocalSearchTime_ + timeBegin_ - CoinCpuTime(),
     223            parameters_.localSearchNodeLimit_);
    217224
    218225        milpBound = subMip->lowBound();
  • stable/1.1/Bonmin/src/Algorithms/OaGenerators/BonOaDecBase.cpp

    r1524 r1528  
    123123      cbcCutoffIncrement_(1e-06),
    124124      cbcIntegerTolerance_(1e-05),
     125      localSearchNodeLimit_(0),
     126      maxLocalSearchPerNode_(0),
    125127      maxLocalSearch_(0),
    126128      maxLocalSearchTime_(3600),
     
    143145      cbcCutoffIncrement_(other.cbcCutoffIncrement_),
    144146      cbcIntegerTolerance_(other.cbcIntegerTolerance_),
     147      localSearchNodeLimit_(other.localSearchNodeLimit_),
     148      maxLocalSearchPerNode_(other.maxLocalSearchPerNode_),
    145149      maxLocalSearch_(other.maxLocalSearch_),
    146150      maxLocalSearchTime_(other.maxLocalSearchTime_),
     
    203207
    204208  void
    205   OaDecompositionBase::SubMipSolver::performLocalSearch(double cutoff, int loglevel, double maxTime)
     209  OaDecompositionBase::SubMipSolver::performLocalSearch(double cutoff, int loglevel, double maxTime,
     210      int maxNodes)
    206211  {
    207212    if (clp_) {
     
    223228      cbc_->setLogLevel(loglevel);
    224229      cbc_->solver()->messageHandler()->setLogLevel(0);
     230      cbc_->setMaximumNodes(maxNodes);
    225231      cbc_->setMaximumSeconds(maxTime);
    226232      cbc_->setCutoff(cutoff);
     
    250256      if (cpx_) {
    251257        CPXENVptr env = cpx_->getEnvironmentPtr();
     258        CPXsetintparam(env, CPX_PARAM_NODELIM, maxNodes);
    252259        CPXsetdblparam(env, CPX_PARAM_TILIM, maxTime);
    253260        CPXsetdblparam(env, CPX_PARAM_CUTUP, cutoff);
  • stable/1.1/Bonmin/src/Algorithms/OaGenerators/BonOaDecBase.hpp

    r1524 r1528  
    6464      void performLocalSearch(double cutoff,
    6565          int loglevel,
    66           double maxTime);
     66          double maxTime,
     67          int maxNodes);
    6768
    6869      /** Returns lower bound. */
     
    273274      /// integer tolerance (has to be the same as Cbc's)
    274275      double cbcIntegerTolerance_;
     276      ///Max number of nodes for local search
     277      int localSearchNodeLimit_;
     278      ///Max number of local searches per node
     279      int maxLocalSearchPerNode_;
    275280      ///Total max number of local searches
    276281      int maxLocalSearch_;
  • stable/1.1/Bonmin/src/CbcBonmin/BonCbc.cpp

    r1524 r1528  
    433433    model_.initialSolve();
    434434
    435     //Added by Claudia
    436     OsiTMINLPInterface * nlpSolver = dynamic_cast<OsiTMINLPInterface *>(model_.solver());
    437     if(nlpSolver->getNewCutoffDecr()!=COIN_DBL_MAX)
    438       model_.setDblParam(CbcModel::CbcCutoffIncrement, nlpSolver->getNewCutoffDecr());
    439 
    440435    // for Couenne
    441436    if (usingCouenne_)
  • stable/1.1/Bonmin/src/Interfaces/BonOsiTMINLPInterface.cpp

    r1525 r1528  
    147147
    148148
    149   roptions->AddStringOption2("dynamic_def_cutoff_decr",
    150       "Do you want to define the parameter cutoff_decr dynamically?",
    151       "no",
    152       "no", "No, define it statically",
    153       "yes","Yes, define it dynamically");
    154   roptions->setOptionExtraInfo("dynamic_def_cutoff_decr",8);
    155 
    156   roptions->AddLowerBoundedNumberOption("coeff_var_threshold",
    157       "Coefficient of variation threshold (for dynamic definition of cutoff_decr).",
    158       0.0,
    159       false,
    160       0.1,
    161       "Coefficient of variation threshold (for dynamic definition of cutoff_decr).");
    162   roptions->setOptionExtraInfo("coeff_var_threshold",8);
    163  
    164   roptions->AddNumberOption("first_perc_for_cutoff_decr",
    165       "The percentage used when, the coeff of variance is smaller than the threshold, to compute the cutoff_decr dynamically.",
    166       -0.02,
    167       "The percentage used when, the coeff of variance is smaller than the threshold, to compute the cutoff_decr dynamically.");
    168   roptions->setOptionExtraInfo("first_perc_for_cutoff_decr",8);
    169 
    170   roptions->AddNumberOption("second_perc_for_cutoff_decr",
    171       "The percentage used when, the coeff of variance is greater than the threshold, to compute the cutoff_decr dynamically.",
    172       -0.05,
    173       "The percentage used when, the coeff of variance is greater than the threshold, to compute the cutoff_decr dynamically.");
    174   roptions->setOptionExtraInfo("second_perc_for_cutoff_decr",8);
    175149
    176150  }
     
    385359    cutStrengthener_(NULL),
    386360    oaMessages_(),
    387     oaHandler_(NULL),
    388     dynamicCutOff_(0),
    389     coeff_var_threshold_(0.1),
    390     first_perc_for_cutoff_decr_(-0.02),
    391     second_perc_for_cutoff_decr_(-0.05),
    392     newCutoffDecr(COIN_DBL_MAX)
    393 
     361    oaHandler_(NULL)
    394362{
    395363   oaHandler_ = new OaMessageHandler;
     
    546514    oaMessages_(),
    547515    oaHandler_(NULL),
    548     strong_branching_solver_(source.strong_branching_solver_),
    549     dynamicCutOff_(source.dynamicCutOff_),
    550     coeff_var_threshold_(source.coeff_var_threshold_),
    551     first_perc_for_cutoff_decr_(source.first_perc_for_cutoff_decr_),
    552     second_perc_for_cutoff_decr_(source.second_perc_for_cutoff_decr_),
    553     newCutoffDecr(source.newCutoffDecr)
     516    strong_branching_solver_(source.strong_branching_solver_)
    554517{
    555518   if(defaultHandler()){
     
    668631      infty_ = rhs.infty_;
    669632      exposeWarmStart_ = rhs.exposeWarmStart_;
    670       newCutoffDecr = rhs.newCutoffDecr;
    671633
    672634    }
     
    709671    strong_branching_solver_ = rhs.strong_branching_solver_;
    710672
    711     dynamicCutOff_ = rhs.dynamicCutOff_;
    712     coeff_var_threshold_ = rhs.coeff_var_threshold_;
    713     first_perc_for_cutoff_decr_ = rhs.first_perc_for_cutoff_decr_;
    714     second_perc_for_cutoff_decr_ = rhs.second_perc_for_cutoff_decr_;
    715 
    716673    freeCachedData();
    717674  }
     
    808765  warmstart_ = NULL;
    809766 
    810   double * of_current = (numsolve > 0) ? new double[numsolve]: NULL;
    811   int num_failed, num_infeas;
    812   double mean, std_dev, var_coeff;
    813   double min = DBL_MAX;
    814   double max = -DBL_MAX;
    815 
    816767  Coin::SmartPtr<SimpleReferencedPtr<CoinWarmStart> > ws_backup = NULL;
    817768  if(!exposeWarmStart_ && keepWarmStart){
     
    839790    <<1
    840791    <<CoinMessageEol;
    841 
    842   num_failed = 0;
    843   num_infeas = 0;
    844   mean = 0;
    845 
    846792  for(int f = 0; f < numsolve ; f++) {
    847793    messageHandler()->message(WARNING_RESOLVING,
     
    869815    <<c<<f+1<<statusAsString()<<getObjValue()<<app_->IterationCount()<<app_->CPUTime()<<CoinMessageEol;
    870816
    871     if(isAbandoned()) {
    872       num_failed++;
    873     }
    874     else if(isProvenPrimalInfeasible()) {
    875        num_infeas++;
    876     }
    877 
    878     else if(isProvenOptimal())
     817
     818    if(isProvenOptimal())
    879819      messageHandler()->message(SOLUTION_FOUND,
    880820          messages_)
     
    891831      <<f+2
    892832      <<CoinMessageEol;
    893 
    894   if(of_current != NULL){
    895     if(isProvenOptimal())
    896     {
    897       of_current[f] = getObjValue();
    898       mean=mean+of_current[f];
    899       if (of_current[f] < min)
    900          min = of_current[f];
    901       else if (of_current[f] > max)
    902          max = of_current[f];
    903     }
    904     else
    905     {
    906       of_current[f] = 0;
    907     }
    908   }
    909 }
    910 
    911 
    912   if(of_current != NULL){
    913      //calculate the mean
    914      mean=mean/(numsolve-num_failed-num_infeas);
    915      
    916      std_dev = 0;
    917      
    918      //calculate the std deviation
    919      for(int i=0; i<numsolve; i++)
    920      {
    921        if(of_current[i]!=0)
    922          std_dev=std_dev+pow(of_current[i]-mean,2);
    923      }
    924      std_dev=pow((std_dev/(numsolve-num_failed-num_infeas)),0.5);
    925      
    926      //calculate coeff of variation
    927      var_coeff=std_dev/mean;
    928   }
    929 
    930 
    931 
     833  }
    932834  setColSolution(point());
    933835  setRowPrice(point() + getNumCols());
    934836  app_->enableWarmStart();
    935 
    936 
    937   if(dynamicCutOff_)
    938   {
    939      if(var_coeff<0.1)
    940      {
    941         setNewCutoffDecr(mean*first_perc_for_cutoff_decr_);
    942      }
    943      else
    944      {
    945         setNewCutoffDecr(mean*second_perc_for_cutoff_decr_);
    946      }
    947   }
    948      
    949837
    950838  optimizationStatus_ = app_->ReOptimizeTNLP(GetRawPtr(problem_to_optimize_));
     
    28482736    app_->options()->GetIntegerValue("num_resolve_at_root", numRetryInitial_,"bonmin.");
    28492737    app_->options()->GetIntegerValue("num_resolve_at_node", numRetryResolve_,"bonmin.");
    2850     app_->options()->GetEnumValue("dynamic_def_cutoff_decr", dynamicCutOff_,"bonmin.");
    2851     app_->options()->GetNumericValue("coeff_var_threshold", coeff_var_threshold_, "bonmin.");
    2852     app_->options()->GetNumericValue("first_perc_for_cutoff_decr", first_perc_for_cutoff_decr_, "bonmin.");
    2853     app_->options()->GetNumericValue("second_perc_for_cutoff_decr", second_perc_for_cutoff_decr_, "bonmin.");
    28542738    app_->options()->GetIntegerValue("num_resolve_at_infeasibles", numRetryInfeasibles_,"bonmin.");
    28552739    app_->options()->GetIntegerValue("num_iterations_suspect", numIterationSuspect_,"bonmin.");
  • stable/1.1/Bonmin/src/Interfaces/BonOsiTMINLPInterface.hpp

    r1524 r1528  
    221221    hasContinuedAfterNlpFailure_ = true;
    222222  }
    223 
    224 
    225   //Added by Claudia
    226  
    227   double getNewCutoffDecr()
    228   {
    229     return newCutoffDecr;
    230   }
    231 
    232   void setNewCutoffDecr(double d)
    233   {
    234     newCutoffDecr = d;
    235   }
    236 
    237 
    238223  /// Did we continue on a failure
    239224  bool hasContinuedOnAFailure()
     
    11581143  /// Number of times problem will be resolved in case of a failure
    11591144  int numRetryUnsolved_;
    1160 
    1161 
    1162   //Added by Claudia
    1163   /// Dynamic cutOff_
    1164   int dynamicCutOff_;
    1165   /// coeff_var_threshold_
    1166   double coeff_var_threshold_;
    1167   /// first_perc_for_cutoff_decr_
    1168   double first_perc_for_cutoff_decr_;
    1169   /// second_perc_for_cutoff_decr_
    1170   double second_perc_for_cutoff_decr_;
    1171  
    1172 
    11731145  /** Messages specific to an OsiTMINLPInterface. */
    11741146  Messages messages_;
     
    12361208  /** OA Message handler. */
    12371209  OaMessageHandler * oaHandler_;
    1238 
    1239   double newCutoffDecr;
    12401210  //@}
    12411211protected:
Note: See TracChangeset for help on using the changeset viewer.