Changeset 1524


Ignore:
Timestamp:
Dec 30, 2009 9:28:34 PM (10 years ago)
Author:
pbonami
Message:

Remove some unused option in OA add Claudi d'Ambrosio code

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

Legend:

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

    r1522 r1524  
    6969    double oaTime;
    7070    b.options()->GetNumericValue("oa_dec_time_limit",oaTime,"bonmin.");
    71     parameter().localSearchNodeLimit_ = INT_MAX;
    7271    parameter().maxLocalSearch_ = INT_MAX;
    73     parameter().maxLocalSearchPerNode_ = INT_MAX;
    7472    parameter().maxLocalSearchTime_ =
    7573      Ipopt::Min(b.getDoubleParameter(BabSetupBase::MaxTime), oaTime);
     
    8381  {
    8482    return (nLocalSearch_<parameters_.maxLocalSearch_ &&
    85         parameters_.localSearchNodeLimit_ > 0 &&
    8683        CoinCpuTime() - timeBegin_ < parameters_.maxLocalSearchTime_);
    8784  }
     
    113110    {
    114111      subMip->performLocalSearch(cutoff, parameters_.subMilpLogLevel_,
    115           (parameters_.maxLocalSearchTime_ + timeBegin_ - CoinCpuTime()) /* time limit */,
    116           parameters_.localSearchNodeLimit_);
     112          (parameters_.maxLocalSearchTime_ + timeBegin_ - CoinCpuTime()) /* time limit */);
    117113      milpBound = subMip->lowBound();
    118114      milpOptimal = subMip->optimal();
     
    210206      //do we perform a new local search ?
    211207      if (milpOptimal && feasible && !isInteger &&
    212           nLocalSearch_ < parameters_.maxLocalSearch_ &&
    213           numberPasses < parameters_.maxLocalSearchPerNode_ &&
    214           parameters_.localSearchNodeLimit_ > 0) {
     208          nLocalSearch_ < parameters_.maxLocalSearch_) {
    215209
    216210        /** do we have a subMip? if not create a new one. */
     
    220214
    221215        subMip->performLocalSearch(cutoff, parameters_.subMilpLogLevel_,
    222             parameters_.maxLocalSearchTime_ + timeBegin_ - CoinCpuTime(),
    223             parameters_.localSearchNodeLimit_);
     216            parameters_.maxLocalSearchTime_ + timeBegin_ - CoinCpuTime());
    224217
    225218        milpBound = subMip->lowBound();
  • stable/1.1/Bonmin/src/Algorithms/OaGenerators/BonOaDecBase.cpp

    r1520 r1524  
    123123      cbcCutoffIncrement_(1e-06),
    124124      cbcIntegerTolerance_(1e-05),
    125       localSearchNodeLimit_(0),
    126       maxLocalSearchPerNode_(0),
    127125      maxLocalSearch_(0),
    128126      maxLocalSearchTime_(3600),
     
    145143      cbcCutoffIncrement_(other.cbcCutoffIncrement_),
    146144      cbcIntegerTolerance_(other.cbcIntegerTolerance_),
    147       localSearchNodeLimit_(other.localSearchNodeLimit_),
    148       maxLocalSearchPerNode_(other.maxLocalSearchPerNode_),
    149145      maxLocalSearch_(other.maxLocalSearch_),
    150146      maxLocalSearchTime_(other.maxLocalSearchTime_),
     
    207203
    208204  void
    209   OaDecompositionBase::SubMipSolver::performLocalSearch(double cutoff, int loglevel, double maxTime,
    210       int maxNodes)
     205  OaDecompositionBase::SubMipSolver::performLocalSearch(double cutoff, int loglevel, double maxTime)
    211206  {
    212207    if (clp_) {
     
    228223      cbc_->setLogLevel(loglevel);
    229224      cbc_->solver()->messageHandler()->setLogLevel(0);
    230       cbc_->setMaximumNodes(maxNodes);
    231225      cbc_->setMaximumSeconds(maxTime);
    232226      cbc_->setCutoff(cutoff);
     
    256250      if (cpx_) {
    257251        CPXENVptr env = cpx_->getEnvironmentPtr();
    258         CPXsetintparam(env, CPX_PARAM_NODELIM, maxNodes);
    259252        CPXsetdblparam(env, CPX_PARAM_TILIM, maxTime);
    260253        CPXsetdblparam(env, CPX_PARAM_CUTUP, cutoff);
  • stable/1.1/Bonmin/src/Algorithms/OaGenerators/BonOaDecBase.hpp

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

    r1435 r1524  
    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
    435440    // for Couenne
    436441    if (usingCouenne_)
  • stable/1.1/Bonmin/src/Interfaces/BonOsiTMINLPInterface.cpp

    r1521 r1524  
    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);
    149175
    150176  }
     
    359385    cutStrengthener_(NULL),
    360386    oaMessages_(),
    361     oaHandler_(NULL)
     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
    362394{
    363395   oaHandler_ = new OaMessageHandler;
     
    514546    oaMessages_(),
    515547    oaHandler_(NULL),
    516     strong_branching_solver_(source.strong_branching_solver_)
     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)
    517554{
    518555   if(defaultHandler()){
     
    631668      infty_ = rhs.infty_;
    632669      exposeWarmStart_ = rhs.exposeWarmStart_;
     670      newCutoffDecr = rhs.newCutoffDecr;
    633671
    634672    }
     
    671709    strong_branching_solver_ = rhs.strong_branching_solver_;
    672710
     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
    673716    freeCachedData();
    674717  }
     
    765808  warmstart_ = NULL;
    766809 
     810  double * of_current = new double[numsolve];
     811  int num_failed, num_infeas;
     812  double mean, std_dev, var_coeff;
     813  double min = DBL_MAX;
     814  double max = -DBL_MAX;
     815
    767816  Coin::SmartPtr<SimpleReferencedPtr<CoinWarmStart> > ws_backup = NULL;
    768817  if(!exposeWarmStart_ && keepWarmStart){
     
    790839    <<1
    791840    <<CoinMessageEol;
     841
     842  num_failed = 0;
     843  num_infeas = 0;
     844  mean = 0;
     845
    792846  for(int f = 0; f < numsolve ; f++) {
    793847    messageHandler()->message(WARNING_RESOLVING,
     
    815869    <<c<<f+1<<statusAsString()<<getObjValue()<<app_->IterationCount()<<app_->CPUTime()<<CoinMessageEol;
    816870
    817 
    818     if(isProvenOptimal())
     871    if(isAbandoned()) {
     872      num_failed++;
     873    }
     874    else if(isProvenPrimalInfeasible()) {
     875       num_infeas++;
     876    }
     877
     878    else if(isProvenOptimal())
    819879      messageHandler()->message(SOLUTION_FOUND,
    820880          messages_)
     
    831891      <<f+2
    832892      <<CoinMessageEol;
    833   }
     893
     894
     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//calculate the mean
     913mean=mean/(numsolve-num_failed-num_infeas);
     914
     915std_dev = 0;
     916
     917//calculate the std deviation
     918for(int i=0; i<numsolve; i++)
     919{
     920  if(of_current[i]!=0)
     921    std_dev=std_dev+pow(of_current[i]-mean,2);
     922}
     923std_dev=pow((std_dev/(numsolve-num_failed-num_infeas)),0.5);
     924
     925//calculate coeff of variation
     926var_coeff=std_dev/mean;
     927
     928
     929
     930
    834931  setColSolution(point());
    835932  setRowPrice(point() + getNumCols());
    836933  app_->enableWarmStart();
     934
     935
     936  if(dynamicCutOff_)
     937  {
     938     if(var_coeff<0.1)
     939     {
     940        setNewCutoffDecr(mean*first_perc_for_cutoff_decr_);
     941     }
     942     else
     943     {
     944        setNewCutoffDecr(mean*second_perc_for_cutoff_decr_);
     945     }
     946  }
     947     
    837948
    838949  optimizationStatus_ = app_->ReOptimizeTNLP(GetRawPtr(problem_to_optimize_));
     
    27362847    app_->options()->GetIntegerValue("num_resolve_at_root", numRetryInitial_,"bonmin.");
    27372848    app_->options()->GetIntegerValue("num_resolve_at_node", numRetryResolve_,"bonmin.");
     2849    app_->options()->GetEnumValue("dynamic_def_cutoff_decr", dynamicCutOff_,"bonmin.");
     2850    app_->options()->GetNumericValue("coeff_var_threshold", coeff_var_threshold_, "bonmin.");
     2851    app_->options()->GetNumericValue("first_perc_for_cutoff_decr", first_perc_for_cutoff_decr_, "bonmin.");
     2852    app_->options()->GetNumericValue("second_perc_for_cutoff_decr", second_perc_for_cutoff_decr_, "bonmin.");
    27382853    app_->options()->GetIntegerValue("num_resolve_at_infeasibles", numRetryInfeasibles_,"bonmin.");
    27392854    app_->options()->GetIntegerValue("num_iterations_suspect", numIterationSuspect_,"bonmin.");
  • stable/1.1/Bonmin/src/Interfaces/BonOsiTMINLPInterface.hpp

    r1255 r1524  
    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
    223238  /// Did we continue on a failure
    224239  bool hasContinuedOnAFailure()
     
    11431158  /// Number of times problem will be resolved in case of a failure
    11441159  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
    11451173  /** Messages specific to an OsiTMINLPInterface. */
    11461174  Messages messages_;
     
    12081236  /** OA Message handler. */
    12091237  OaMessageHandler * oaHandler_;
     1238
     1239  double newCutoffDecr;
    12101240  //@}
    12111241protected:
Note: See TracChangeset for help on using the changeset viewer.