Changeset 502


Ignore:
Timestamp:
Apr 25, 2007 3:05:20 PM (13 years ago)
Author:
pbonami
Message:

Store CouenneCutGenerator? outside of CouenneInterface?. CouenneCbc? does not compile anymore.

Location:
trunk/Bonmin/experimental/NotConvex
Files:
7 edited

Legend:

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

    r487 r502  
    200200    //Setup Convexifier generators
    201201
    202     CouenneCutGenerator *ecpGen = ci -> couenneCg ();
     202    CouenneCutGenerator *ecpGen = NULL;//ci -> couenneCg ();
    203203
    204204    ecpGen -> setBabPtr (this);
  • trunk/Bonmin/experimental/NotConvex/BonCouenneInterface.cpp

    r487 r502  
    1818/** Default constructor. */
    1919CouenneInterface::CouenneInterface():
    20   AmplInterface(),
    21   couenneCg_(NULL)
     20  AmplInterface()
    2221{}
    2322
    2423/** Copy constructor. */
    2524CouenneInterface::CouenneInterface(const CouenneInterface &other):
    26   AmplInterface(other),
    27   couenneCg_(NULL)
     25  AmplInterface(other)
    2826  {
    2927  }
     
    3634/** Destructor. */
    3735CouenneInterface::~CouenneInterface(){
    38   if(couenneCg_) delete couenneCg_;
    3936}
    4037
     
    5047                                 Ipopt::SmartPtr<Ipopt::RegisteredOptions> roptions){
    5148  AmplInterface::readAmplNlFile(argv, journalist, options, roptions);
    52   aslfg_ = readASLfg (argv);
    53   int addOnlyViolatedOa;
    54   options->GetEnumValue("add_only_violated_oa", addOnlyViolatedOa,"bonmin.");
    55   couenneCg_ = new CouenneCutGenerator
    56     (this, aslfg_, true, CURRENT_ONLY,1);
    5749}
    5850
     
    7062
    7163void
    72 CouenneInterface::extractLinearRelaxation (OsiSolverInterface &si, bool getObj, bool solveNlp) {
     64CouenneInterface::extractLinearRelaxation (OsiSolverInterface &si, CouenneCutGenerator & couenneCg, bool getObj, bool solveNlp) {
    7365
    7466  if (solveNlp)
    7567    initialSolve ();
    7668
    77    // Check that couenneCg_ has been built.
    78    if (couenneCg_ == NULL)
    79      throw CoinError
    80        ("No couenne generator has been built, probably ampl .nl file was not properly read",
    81         "extractLinearRelaxation", "Bonmin::CouenneInterface");
    82 
    8369   int numcols     = getNumCols ();             // number of original variables
    84    int numcolsconv = couenneCg_ -> getnvars (); // number of original+auxiliary variables
     70   int numcolsconv = couenneCg.getnvars (); // number of original+auxiliary variables
    8571
    8672   const double *lb = getColLower ();
     
    9379   // get initial relaxation
    9480   OsiCuts cs;
    95    couenneCg_ -> generateCuts (si, cs);
     81   couenneCg.generateCuts (si, cs);
    9682
    9783   // store all (original + auxiliary) bounds in the relaxation
     
    9985   CouNumber * colUpper = new CouNumber [numcolsconv];
    10086
    101    CouNumber *ll = couenneCg_ -> Problem () -> Lb ();
    102    CouNumber *uu = couenneCg_ -> Problem () -> Ub ();
     87   CouNumber *ll = couenneCg.Problem () -> Lb ();
     88   CouNumber *uu = couenneCg.Problem () -> Ub ();
    10389
    10490   // overwrite original bounds, could be improved within generateCuts
     
    163149
    164150   // some instances have no (or null) objective function, check it here
    165    if (couenneCg_ -> Problem () -> nObjs () > 0)
    166      obj [couenneCg_ -> Problem () -> Obj (0) -> Body () -> Index ()] = 1;
     151   if (couenneCg.Problem () -> nObjs () > 0)
     152     obj [couenneCg.Problem () -> Obj (0) -> Body () -> Index ()] = 1;
    167153
    168154   // Finally, load interface si with the initial LP relaxation
  • trunk/Bonmin/experimental/NotConvex/BonCouenneInterface.hpp

    r481 r502  
    5252   * The put everything in an OsiSolverInterface.
    5353   */
    54   virtual void extractLinearRelaxation(OsiSolverInterface &si, bool getObj = 1, bool solveNlp = 1);
     54  virtual void extractLinearRelaxation(OsiSolverInterface &si,  CouenneCutGenerator & couenneCg, bool getObj = 1, bool solveNlp = 1);
    5555
    56   /** Get the outer approximation constraints at the currently stored optimal point.
    57    (Only get outer-approximations of nonlinear constraints of the problem.)*/
    58   //  virtual void getOuterApproximation(OsiCuts &cs, bool getObj, const double * x2, bool global);
    59 
    60   /** Get the outer approximation constraints at provided point.
    61       If x2 is different from NULL only add cuts violated by x2.
    62    (Only get outer-approximations of nonlinear constraints of the problem.)*/
    63   //  virtual void getOuterApproximation(OsiCuts &cs, const double * x, bool getObj, const double * x2, bool global);
    64 
    65   // This is never called, eliminated
    66   //  void updateCouenneAuxiliryVar(double *x, double * lb, double * ub);
    67 
    68   const CouenneProblem * couenneProb() const{
    69     return couenneCg_->Problem();
    70   }
    71 
    72   CouenneProblem * couenneProb() {
    73     return couenneCg_->Problem();
    74   }
    7556 
    76   /** return ASL interface */
    77   ASL *getASL() {return aslfg_;}
    78 
    79   CouenneCutGenerator * couenneCg()  {
    80     return couenneCg_;}
    81 
    82   const CouenneCutGenerator * couenneCg()  const{
    83     return couenneCg_;}
    84 
    8557  /** To set some application specific defaults. */
    8658  virtual void setAppDefaultOptions(Ipopt::SmartPtr<Ipopt::OptionsList> Options);
    8759
    8860protected:
    89  
    90   /** The cut generator from couenne. */
    91   CouenneCutGenerator *couenneCg_;
    92 
    93   /** The simpler ASL interface (no partially separable information,
    94       no groups, no hassle) */
    95   ASL *aslfg_;
    9661};
    9762
  • trunk/Bonmin/experimental/NotConvex/BonCouenneSetup.cpp

    r493 r502  
    2323    defaultBasicOptions();
    2424   
    25     /* Read the model. */
     25   
     26    /** Change default value for failure behavior so that code doesn't crash when Ipopt does not solve a sub-problem.*/
    2627    options_->SetStringValue("nlp_failure_behavior","fathom","bonmin.");
     28
    2729    gatherParametersValues(options_);
     30   
     31    linearSolver_ = new OsiClpSolverInterface;
    2832    CouenneInterface * ci = new CouenneInterface;
    2933    nonlinearSolver_ = ci;
     34    /* Read the model in various places. */
    3035    ci->readAmplNlFile(argv,journalist(),options(),roptions());
    31     linearSolver_ = new OsiClpSolverInterface;
    32    
     36    ASL * aslfg = readASLfg (argv);
     37   
     38   
     39    /* Initialize Couenne cut generator.*/
     40    CouenneCutGenerator * couenneCg = new CouenneCutGenerator(ci, aslfg, true, CURRENT_ONLY,1);
     41    const CouenneProblem * couenneProb = couenneCg -> Problem();
     42
    3343    Bonmin::BabInfo * extraStuff = new Bonmin::BabInfo(0);
    3444   
     
    4353    options()->GetIntegerValue("lp_log_level",lpLogLevel,"bonmin.");
    4454    linearSolver_->messageHandler()->setLogLevel(lpLogLevel);
    45     ci->extractLinearRelaxation(*linearSolver_);
     55    ci->extractLinearRelaxation(*linearSolver_, *couenneCg);
    4656   
    4757    if(extraStuff->infeasibleNode()){
     
    5464    int numberIntegerObjects = linearSolver_->numberObjects() > 0;
    5565    {
    56       const CouenneProblem * couenneProb = ci->couenneProb();
    5766      int numAuxs = couenneProb->nAuxs();
    5867      OsiObject ** objects = new OsiObject*[numAuxs];
     
    93102      CuttingMethod cg;
    94103      cg.frequency = freq;
    95       CouenneCutGenerator *couenneGen = ci -> couenneCg ();
    96       cg.cgl = couenneGen;
     104      cg.cgl = couenneCg;
    97105      cg.id = "Couenne convexifier cuts";
    98106      cutGenerators().push_back(cg);
     
    111119   
    112120    branchingMethod_ = new CouenneChooseVariable(linearSolver_,
    113                                   const_cast<CouenneProblem *> (ci -> couenneProb ()));
     121                                  const_cast<CouenneProblem *> (couenneProb));
    114122
    115123   
  • trunk/Bonmin/experimental/NotConvex/BonNlpHeuristic.cpp

    r491 r502  
    2020    nlp_(NULL),
    2121    hasCloned_(false),
    22     maxNlpInf_(1e-04){
     22    maxNlpInf_(1e-04),
     23    couenne_(NULL){
    2324  }
    2425 
    25   NlpSolveHeuristic::NlpSolveHeuristic(CbcModel & model, OsiSolverInterface &nlp, bool cloneNlp):
    26   CbcHeuristic(model), nlp_(&nlp), hasCloned_(cloneNlp),maxNlpInf_(1e-04){
     26  NlpSolveHeuristic::NlpSolveHeuristic(CbcModel & model, OsiSolverInterface &nlp, bool cloneNlp, CouenneProblem * couenne):
     27  CbcHeuristic(model), nlp_(&nlp), hasCloned_(cloneNlp),maxNlpInf_(1e-04),
     28  couenne_(couenne){
    2729    if(cloneNlp)
    2830      nlp_ = nlp.clone();
     
    3032 
    3133  NlpSolveHeuristic::NlpSolveHeuristic(const NlpSolveHeuristic & other):
    32   CbcHeuristic(other), nlp_(other.nlp_), hasCloned_(other.hasCloned_),maxNlpInf_(other.maxNlpInf_){
     34  CbcHeuristic(other), nlp_(other.nlp_), hasCloned_(other.hasCloned_),maxNlpInf_(other.maxNlpInf_),
     35  couenne_(other.couenne_){
    3336    if(hasCloned_ && nlp_ != NULL)
    3437      nlp_ = other.nlp_->clone();
     
    5659    }
    5760    maxNlpInf_ = rhs.maxNlpInf_;
     61    couenne_ = rhs.couenne_;
    5862    return *this;
    5963  }
     
    7680  }
    7781 
     82  void
     83  NlpSolveHeuristic::setCouenneProblem(CouenneProblem & couenne){
     84    couenne_ = &couenne;}
    7885  int
    7986  NlpSolveHeuristic::solution( double & objectiveValue, double * newSolution){
     
    141148        (nlp_);
    142149      if(couenne){
    143        couenne->couenneProb()->getAuxs(newSolution);
     150       couenne_->getAuxs(newSolution);
    144151    }
    145152      objectiveValue = obj;
  • trunk/Bonmin/experimental/NotConvex/BonNlpHeuristic.hpp

    r454 r502  
    1212#include "CbcHeuristic.hpp"
    1313#include "BonOsiTMINLPInterface.hpp"
     14#include "CouenneProblem.h"
    1415namespace Bonmin{
    1516  /** An heuristic to call an NlpSolver if all CouenneObjects are close to be satisfied (for other integer objects, rounding is performed, is SOS are not satisfied does not run).
     
    2021    NlpSolveHeuristic();
    2122  /** Constructor with model and Ipopt problems.*/
    22     NlpSolveHeuristic(CbcModel & mip, OsiSolverInterface &nlp, bool cloneNlp = false);
     23    NlpSolveHeuristic(CbcModel & mip, OsiSolverInterface &nlp, bool cloneNlp = false, CouenneProblem * couenne = NULL);
    2324    /** Copy constructor.*/
    2425    NlpSolveHeuristic(const NlpSolveHeuristic &other);
     
    3637    void setNlp(OsiSolverInterface &nlp, bool cloneNlp = true);
    3738   
     39    /** set the couenne problem to use.*/
     40    void setCouenneProblem(CouenneProblem &);
    3841    /** Does nothing. */
    3942    virtual void resetModel(CbcModel * model){}
     
    5457    /** maximum nlp infeasibility under which try to solve problem with Ipopt.*/
    5558    double maxNlpInf_;
     59    /** Pointer to a couenne representation of the problem. */
     60    CouenneProblem * couenne_;
    5661  };
    5762}/* Ends namespace Bonmin. */
  • trunk/Bonmin/experimental/NotConvex/Makefile.am

    r481 r502  
    9494
    9595fun_SOURCES = BonCouenne.cpp \
    96               BonCouenneCbc.hpp \
    97               BonCouenneCbc.cpp \
    9896              BonCouenneSetup.cpp \
    9997              BonCouenneSetup.hpp \
Note: See TracChangeset for help on using the changeset viewer.