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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.");
Note: See TracChangeset for help on using the changeset viewer.