Changeset 554


Ignore:
Timestamp:
May 28, 2007 9:30:15 AM (12 years ago)
Author:
pbonami
Message:

Add code to pass solution just found by Ipopt to Couenne. Add an option to set the number of cut passes at regular node (default is 1 for Bonmin 2 for Couenne).

Location:
trunk/Bonmin
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Bonmin/experimental/NotConvex/BonCouenneSetup.cpp

    r533 r554  
    164164                                  const_cast<CouenneProblem *> (couenneProb));
    165165
    166    
     166    if(intParam_[NumCutPasses] < 2)
     167    intParam_[NumCutPasses] = 2;
    167168}
    168169 
  • trunk/Bonmin/experimental/NotConvex/BonNlpHeuristic.cpp

    r519 r554  
    9393    OsiSolverInterface * solver = model_->solver();
    9494   
    95     Bonmin::BabInfo * babInfo = dynamic_cast<Bonmin::BabInfo *> (solver->getAuxiliaryInfo());
     95    OsiAuxInfo * auxInfo = solver->getAuxiliaryInfo();
     96    BabInfo * babInfo = dynamic_cast<BabInfo *> (auxInfo);
     97    if(babInfo){
     98    babInfo->setHasNlpSolution(false);
    9699    if(babInfo && babInfo->infeasibleNode()){
    97100      return 0;
    98101    }
    99    
    100    
     102    }
     103
    101104    if(numberSolvePerLevel_ > -1){
    102105      if(numberSolvePerLevel_ == 0) return 0 ;
     
    156159    double obj = (nlp_->isProvenOptimal()) ? nlp_->getObjValue(): DBL_MAX;
    157160    bool foundSolution = obj < objectiveValue;
    158     if(foundSolution)//Better solution found update
     161//    if(foundSolution)//Better solution found update
    159162    {
    160163  //    newSolution = new double [solver->getNumCols()];
     
    167170       couenne_->getAuxs(newSolution);
    168171    }
     172      if(babInfo){
     173      babInfo->setNlpSolution(newSolution,model_->solver()->getNumCols(), obj);
     174        babInfo->setHasNlpSolution(true);
     175      }
    169176      objectiveValue = obj;
    170177  }
  • trunk/Bonmin/src/Algorithms/BonBabSetupBase.cpp

    r514 r554  
    2828  0 /* SpecialOption*/,
    2929  0 /* DisableSos.*/,
     30  1 /* numCutPasses.*/
    3031};
    3132
     
    189190  options->GetIntegerValue("iteration_limit",intParam_[MaxIterations],"bonmin.");
    190191  options->GetEnumValue("sos_constraints",intParam_[DisableSos],"bonmin.");
     192  options->GetIntegerValue("num_cut_passes",intParam_[NumCutPasses],"bonmin.");
    191193 
    192194  options->GetNumericValue("cutoff_decr",doubleParam_[CutoffDecr],"bonmin.");
     
    353355                             "osi-simple", "Osi method to do simple branching",
    354356                             "osi-strong", "Osi method to do strong branching","");
     357 
     358  roptions->AddLowerBoundedIntegerOption("num_cut_passes",
     359                                         "Set the maximum number of cut passes at regular nodes of the branch-and-cut.",
     360                                         0,INT_MAX,
     361                                         "");
    355362 
    356363}
  • trunk/Bonmin/src/Algorithms/BonBabSetupBase.hpp

    r511 r554  
    6464      SpecialOption /** Spetial option in particular for Cbc. */,
    6565      DisableSos /** Consider or not SOS constraints.*/,
     66      NumCutPasses/** Number of cut passes at nodes.*/,
    6667      NumberIntParam /** Dummy end to size table*/
    6768    };
  • trunk/Bonmin/src/CbcBonmin/BonAuxInfos.cpp

    r481 r554  
    1010#include "BonAuxInfos.hpp"
    1111
     12namespace Bonmin{
     13  /** Default constructor.*/
     14  BabInfo::BabInfo(int type):
     15  OsiBabSolver(type),
     16  babPtr_(NULL),
     17  infeasibleNode_(false),
     18  nlpSolution_(NULL),
     19  numcols_(0),
     20  hasNlpSolution_(false){
     21  }
     22 
     23  /** Constructor from OsiBabSolver.*/
     24  BabInfo::BabInfo(const OsiBabSolver &other):
     25  OsiBabSolver(other),
     26  babPtr_(NULL),
     27  infeasibleNode_(false),
     28  nlpSolution_(NULL),
     29  numcols_(0),
     30  hasNlpSolution_(false){
     31  }
     32 
     33  /** Copy constructor.*/
     34  BabInfo::BabInfo(const BabInfo &other):
     35  OsiBabSolver(other),
     36  babPtr_(other.babPtr_),
     37  infeasibleNode_(other.infeasibleNode_),
     38  nlpSolution_(NULL),
     39  numcols_(other.numcols_),
     40  hasNlpSolution_(other.hasNlpSolution_){
     41    if(other.nlpSolution_!=NULL){
     42      assert(numcols_ > 0);
     43      nlpSolution_ = new double[numcols_ + 1];
     44      CoinCopyN(other.nlpSolution_, numcols_+1, nlpSolution_);
     45    }
     46  }
     47 
     48  /** Destructor.*/
     49  BabInfo::~BabInfo(){
     50    if(nlpSolution_ != NULL)
     51      delete [] nlpSolution_;
     52  }
     53 
     54/** Virtual copy constructor.*/
     55OsiAuxInfo *
     56  BabInfo::clone() const{
     57  return new BabInfo(*this);}
     58 
     59  /** Pass a solution found by an nlp solver.*/
     60  void
     61  BabInfo::setNlpSolution(const double * sol, int numcols, double objValue){
     62    if(numcols_ < numcols){
     63      delete [] nlpSolution_;
     64      nlpSolution_ = NULL;}
     65    if(nlpSolution_ == NULL){
     66      nlpSolution_ = new double[numcols + 1];
     67      numcols_ = numcols;
     68    }
     69    CoinCopyN(sol,  numcols, nlpSolution_);
     70    nlpSolution_[numcols] = objValue;
     71  }
     72 
     73}/* end namespace Bonmin*/
  • trunk/Bonmin/src/CbcBonmin/BonAuxInfos.hpp

    r495 r554  
    1515
    1616namespace Bonmin {
     17  /** Bonmin class for passing info between components of branch-and-cuts.*/
    1718class BabInfo : public OsiBabSolver {
    1819public:
    19   BabInfo(int type):
    20   OsiBabSolver(type),
    21   babPtr_(NULL),
    22   infeasibleNode_(false){}
     20  /** Default constructor.*/
     21  BabInfo(int type);
     22
     23  /** Constructor from OsiBabSolver.*/
     24  BabInfo(const OsiBabSolver &other);
     25
     26  /** Copy constructor.*/
     27  BabInfo(const BabInfo &other);
    2328 
    24   BabInfo(const OsiBabSolver &other):
    25   OsiBabSolver(other){
    26   }
    27   BabInfo(const BabInfo &other):
    28   OsiBabSolver(other),
    29   babPtr_(other.babPtr_),
    30   infeasibleNode_(other.infeasibleNode_){
    31   }
     29  /** Destructor.*/
     30  virtual ~BabInfo();
    3231 
    33   OsiAuxInfo * clone() const{
    34     return new BabInfo(*this);}
     32  /** Virtual copy constructor.*/
     33  virtual OsiAuxInfo * clone() const;
     34 
     35  /** Set pointer to the branch-and-bound algorithm (to access CbcModel).*/
    3536  void setBabPtr(Bab2 * babPtr){
    3637    babPtr_ = babPtr;}
    3738 
     39  /** Pointer to the branch-and-bound algorithm (to access CbcModel).*/
    3840  Bab2 * babPtr(){
    3941    return babPtr_;}
    4042 
     43  /** Declare the node to be feasible.*/
    4144  void setFeasibleNode(){
    4245    infeasibleNode_ = false;}
    4346 
     47  /** Declare the node to be infeasible.*/
    4448  void setInfeasibleNode(){
    4549    infeasibleNode_ = true;}
    4650 
     51  /** Say if current node is found feasible by cut generators.*/
    4752  bool infeasibleNode(){
    4853    return infeasibleNode_;}
     54 
     55  /** Get solution found by nlp solver (or NULL if none found).*/
     56  const double * nlpSolution(){
     57    if(hasNlpSolution_)
     58      return nlpSolution_;
     59    else
     60      return NULL;
     61  }
     62   
     63  /** Pass a solution found by an nlp solver.*/
     64  void setNlpSolution(const double * sol, int numcols, double objValue);
     65 
     66  /** Say if has an nlp solution*/
     67  void setHasNlpSolution(bool b){
     68    hasNlpSolution_ = b;}
    4969protected:
    5070  /** Pointer to branch-and-bound algorithm.*/
     
    5272  /** Say if current node was found infeasible during cut generation*/
    5373  bool infeasibleNode_;
     74  /** nlp solution found by heuristic if any.*/
     75  double * nlpSolution_;
     76  /** numcols_ gives the size of nlpSolution_.*/
     77  int numcols_;
     78  /** say if has a solution.*/
     79  bool hasNlpSolution_;
    5480 
    5581  };
  • trunk/Bonmin/src/CbcBonmin/BonCbc2.cpp

    r536 r554  
    118118 
    119119 
    120     model_.setMaximumCutPasses(1);
     120    model_.setMaximumCutPasses(s.getIntParameter(BabSetupBase::NumCutPasses));
    121121   
    122122    //Setup cutting plane methods
Note: See TracChangeset for help on using the changeset viewer.