Changeset 1988


Ignore:
Timestamp:
Jun 2, 2012 4:45:08 AM (7 years ago)
Author:
pbonami
Message:

Merge changes from trunk

Location:
stable/1.6/Bonmin/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • stable/1.6/Bonmin/src

  • stable/1.6/Bonmin/src/Algorithms/OaGenerators/BonFpForMinlp.cpp

    r1731 r1988  
    145145      <<dist<<CoinMessageEol;
    146146
    147       if(dist < 1e-05){
     147      if(dist < 1e-06){
    148148         fixIntegers(*nlp_,branch_info, parameters_.cbcIntegerTolerance_, objects_, nObjects_);
    149149
  • stable/1.6/Bonmin/src/Interfaces/BonOsiTMINLPInterface.cpp

    r1982 r1988  
    242242      " than this.");
    243243  roptions->setOptionExtraInfo("very_tiny_element",119);
     244
     245  roptions->AddLowerBoundedNumberOption("oa_rhs_relax","Value by which to relax OA cut",
     246      -0.,0,1e-8,
     247      "RHS of OA constraints will be relaxed by this amount times the absolute value of the initial rhs if it is >= 1 (otherwise by this amount)."
     248      );
     249  roptions->setOptionExtraInfo("oa_rhs_relax",119);
    244250
    245251  roptions->AddLowerBoundedIntegerOption("oa_cuts_log_level",
     
    403409    tiny_(1e-8),
    404410    veryTiny_(1e-20),
     411    rhsRelax_(tiny_),
    405412    infty_(1e100),
    406413    warmStartMode_(None),
     
    566573    tiny_(source.tiny_),
    567574    veryTiny_(source.veryTiny_),
     575    rhsRelax_(source.rhsRelax_),
    568576    infty_(source.infty_),
    569577    warmStartMode_(source.warmStartMode_),
     
    682690      tiny_ = rhs.tiny_;
    683691      veryTiny_ = rhs.veryTiny_;
     692      rhsRelax_ = rhs.rhsRelax_;
    684693      infty_ = rhs.infty_;
    685694      warmStartMode_ = rhs.warmStartMode_;
     
    17251734{
    17261735  linearizer_ = linearizer->clone();
    1727   linearizer_->set_tols(tiny_, veryTiny_, infty_);
     1736  linearizer_->set_tols(tiny_, veryTiny_, rhsRelax_, infty_);
    17281737  linearizer_->set_model(GetRawPtr(problem_));
    17291738}
     
    20322041      newCut.setGloballyValidAsInteger(1);
    20332042    }
    2034     //if(fabs(lb[cutIdx]) < tiny_) lb[cutIdx] = 0;
    2035     //if(fabs(ub[cutIdx]) < tiny_) ub[cutIdx] = 0;
     2043    if(lb[cutIdx] > infty) lb[cutIdx] -= rhsRelax_*std::max(fabs(lb[cutIdx]), 1.);
     2044    if(ub[cutIdx] < infty) ub[cutIdx] += rhsRelax_*std::max(fabs(ub[cutIdx]), 1.);
    20362045    newCut.setLb(lb[cutIdx]);
    20372046    newCut.setUb(ub[cutIdx]);
     
    24932502  }
    24942503 
     2504
     2505  //Relax rhs's by tiny_
    24952506  for(int i = 0 ; i < rowLow.size() ; i++){
    2496      if(fabs(rowLow[i]) < tiny_) rowLow[i] = 0.;
    2497      if(fabs(rowUp[i]) < tiny_) rowUp[i] = 0.;
     2507     if(rowLow[i] > infty) rowLow[i] -= rhsRelax_*std::max(fabs(rowLow[i]), 1.);
     2508     if(rowUp[i] < infty) rowUp[i] += rhsRelax_*std::max(fabs(rowUp[i]), 1.);
    24982509  }
    24992510
     
    25232534  }
    25242535
     2536  //si.writeMpsNative("Toto.mps", NULL, NULL, 1);
    25252537}
    25262538
     
    25332545  assert(numcols == si.getNumCols() );
    25342546  vector<double> obj(numcols);
    2535       problem_to_optimize_->eval_grad_f(numcols, x, 1,obj());
    2536       //add variable alpha
    2537       //(alpha should be empty in the matrix with a coefficient of -1 and unbounded)
    2538       CoinPackedVector a;
    2539       si.addCol(a,-si.getInfinity(), si.getInfinity(), 1.);
     2547  problem_to_optimize_->eval_grad_f(numcols, x, 1,obj());
     2548  //add variable alpha
     2549  //(alpha should be empty in the matrix with a coefficient of -1 and unbounded)
     2550  CoinPackedVector a;
     2551  si.addCol(a,-si.getInfinity(), si.getInfinity(), 1.);
    25402552 
    2541       // Now get the objective cuts
    2542       // get the gradient, pack it and add the cut
    2543       double ub;
    2544       problem_to_optimize_->eval_f(numcols, x, 1, ub);
    2545       ub*=-1;
    2546       double lb = -1e300;
    2547       CoinPackedVector objCut;
    2548       CoinPackedVector * v = &objCut;
    2549       v->reserve(numcols+1);
    2550       for(int i = 0; i<numcols ; i++) {
    2551        if(si.getNumRows())
    2552        {
    2553         if(cleanNnz(obj[i],colLower[i], colUpper[i],
    2554             -getInfinity(), 0,
    2555             x[i],
    2556             lb,
    2557             ub, tiny_, veryTiny_, infty_)) {
    2558           v->insert(i,obj[i]);
    2559           lb += obj[i] * x[i];
    2560           ub += obj[i] * x[i];
    2561         }
     2553  // Now get the objective cuts
     2554  // get the gradient, pack it and add the cut
     2555  double ub;
     2556  problem_to_optimize_->eval_f(numcols, x, 1, ub);
     2557  ub*=-1;
     2558  double lb = -1e300;
     2559  CoinPackedVector objCut;
     2560  CoinPackedVector * v = &objCut;
     2561  v->reserve(numcols+1);
     2562  for(int i = 0; i<numcols ; i++) {
     2563    if(si.getNumRows())
     2564    {
     2565     if(cleanNnz(obj[i],colLower[i], colUpper[i],
     2566         -getInfinity(), 0,
     2567         x[i],
     2568         lb,
     2569         ub, tiny_, veryTiny_, infty_)) {
     2570       v->insert(i,obj[i]);
     2571       lb += obj[i] * x[i];
     2572       ub += obj[i] * x[i];
     2573     }
     2574    }
     2575    else //Unconstrained problem can not put clean coefficient
     2576    {
     2577       if(cleanNnz(obj[i],colLower[i], colUpper[i],
     2578        -getInfinity(), 0,
     2579        x[i],
     2580        lb,
     2581        ub, 1e-03, 1e-08, infty_)) {
     2582      v->insert(i,obj[i]);
     2583      lb += obj[i] * x[i];
     2584      ub += obj[i] * x[i];
    25622585       }
    2563        else //Unconstrained problem can not put clean coefficient
    2564        {
    2565            if(cleanNnz(obj[i],colLower[i], colUpper[i],
    2566             -getInfinity(), 0,
    2567             x[i],
    2568             lb,
    2569             ub, 1e-03, 1e-08, infty_)) {
    2570           v->insert(i,obj[i]);
    2571           lb += obj[i] * x[i];
    2572           ub += obj[i] * x[i];
    2573            }
    2574        }
    2575       }
    2576     v->insert(numcols,-1);
    2577     si.addRow(objCut, lb, ub);
    2578     }
     2586    }
     2587  }
     2588  v->insert(numcols,-1);
     2589  si.addRow(objCut, lb, ub);
     2590}
    25792591
    25802592/** Add a collection of linear cuts to problem formulation.*/
     
    29772989    app_->options()->GetNumericValue("tiny_element",tiny_,app_->prefix());
    29782990    app_->options()->GetNumericValue("very_tiny_element",veryTiny_,app_->prefix());
     2991    app_->options()->GetNumericValue("oa_rhs_relax",rhsRelax_,app_->prefix());
    29792992    app_->options()->GetNumericValue("random_point_perturbation_interval",max_perturbation_,app_->prefix());
    29802993    app_->options()->GetEnumValue("random_point_type",randomGenerationType_,app_->prefix());
  • stable/1.6/Bonmin/src/Interfaces/BonOsiTMINLPInterface.hpp

    r1967 r1988  
    10811081
    10821082  /// Get values of tiny_ and very_tiny_
    1083   void get_tolerances(double &tiny, double&very_tiny, double &infty){
     1083  void get_tolerances(double &tiny, double&very_tiny, double &rhsRelax, double &infty){
    10841084    tiny = tiny_;
    10851085    very_tiny = veryTiny_;
     1086    rhsRelax = rhsRelax_;
    10861087    infty = infty_;
    10871088  }
     
    12721273  /** Value for small non-zero element which we will take the risk to ignore in OA cuts.*/
    12731274  double veryTiny_;
     1275  /** Amount by which to relax OA constraints RHSes*/
     1276  double rhsRelax_;
    12741277  /** Value for infinity. */
    12751278  double infty_;
  • stable/1.6/Bonmin/src/Interfaces/BonTMINLP2OsiLP.hpp

    r1983 r1988  
    4444    virtual TMINLP2OsiLP * clone() const = 0;
    4545
    46    void set_tols(double tiny, double very_tiny, double infty){
     46   void set_tols(double tiny, double very_tiny, double rhs_relax, double infty){
    4747     tiny_ = tiny;
    4848     very_tiny_ = very_tiny;
     49     rhs_relax_ = rhs_relax;
    4950     infty_ = infty;
    5051   }
     
    9293   /** If constraint coefficient is below this, we neglect it.*/
    9394   double very_tiny_;
     95   /** Amount by which to relax OA constraints RHSes*/
     96   double rhs_relax_;
    9497   /** infinity.*/
    9598   double infty_;
Note: See TracChangeset for help on using the changeset viewer.