source: trunk/Couenne/src/main/BonCouenneSetup.hpp @ 972

Last change on this file since 972 was 804, checked in by pbelotti, 8 years ago

passing CouenneTNLP instead of Bonmin::TMINLP in non-AMPL -- testing before allowing construction of own problem

  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
1/* $Id: BonCouenneSetup.hpp 804 2012-01-30 23:40:42Z tkr $ */
2// (C) Copyright International Business Machines Corporation 2007
3// All Rights Reserved.
4// This code is published under the Eclipse Public License (EPL).
5//
6// Authors :
7// Pierre Bonami, International Business Machines Corporation
8//
9// Date : 04/18/2007
10
11#ifndef BonCouenneSetup_H
12#define BonCouenneSetup_H
13
14#include "BonBabSetupBase.hpp"
15#include "BonBonminSetup.hpp"
16#include "CbcFeasibilityBase.hpp"
17
18#include "CouenneTNLP.hpp"
19
20struct ASL;
21
22namespace Bonmin{
23  class Bab;
24}
25
26namespace Couenne {
27
28  class CouenneInterface;
29  class CouenneCutGenerator;
30  class CouenneProblem;
31  class CouenneTNLP;
32
33  class SmartAsl : public Ipopt::ReferencedObject{
34  public:
35    ASL * asl;
36    SmartAsl():
37      Ipopt::ReferencedObject(),
38      asl(NULL)
39    {}
40    virtual ~SmartAsl();
41  };
42
43  class CouenneSetup : public Bonmin::BonminSetup{
44  public:
45    /** Default constructor*/
46    CouenneSetup():
47    BonminSetup(),
48    aslfg_(NULL),
49    CouennePtr_ (NULL),
50    displayStats_ (false),
51    couenneProb_ (NULL),
52    couenneProb_is_own_(true) {}
53
54    /** Copy constructor.*/
55    CouenneSetup(const CouenneSetup& other):
56      BonminSetup(other),
57      aslfg_(NULL),
58      displayStats_ (other.displayStats_),
59      couenneProb_ (other.couenneProb_) {}
60   
61    /** virtual copy constructor.*/
62    virtual Bonmin::BabSetupBase * clone () const
63    {return new CouenneSetup (*this);}
64   
65    /// destructor
66    virtual ~CouenneSetup();
67
68    /** Initialize from command line arguments. */
69    bool InitializeCouenne(char ** argv = NULL, 
70                           CouenneProblem *couenneProb = NULL,
71                           Ipopt::SmartPtr<Bonmin::TMINLP> tminlp = NULL,
72                           CouenneInterface *ci = NULL,
73                           Bonmin::Bab *bb = NULL);
74   
75    /** register the options */
76    virtual void registerOptions();
77    /** Register all Couenne options.*/
78    static void registerAllOptions(Ipopt::SmartPtr<Bonmin::RegisteredOptions> roptions);
79   
80    /** Get the basic options if don't already have them.*/
81    virtual void readOptionsFile(){
82      if (readOptions_) return;
83      Bonmin::BabSetupBase::readOptionsFile ("couenne.opt");
84    }
85
86    /// return pointer to cut generator (used to get pointer to problem)
87    CouenneCutGenerator *couennePtr () const
88    {return CouennePtr_;}
89
90    /// true if one wants to display statistics at the end of program
91    bool displayStats () 
92    {return displayStats_;}
93
94    /// add cut generators
95    void addMilpCutGenerators ();
96
97    /// modify parameter (used for MaxTime)
98    inline void setDoubleParameter (const DoubleParameter &p, const double val)
99    {doubleParam_ [p] = val;}
100
101    /// modify parameter (used for MaxTime)
102    inline double getDoubleParameter (const DoubleParameter &p) const
103    {return doubleParam_ [p];}
104
105    void setNodeComparisonMethod (Bonmin::BabSetupBase::NodeComparison c)
106    {nodeComparisonMethod_ = c;}
107
108private:
109    Ipopt::SmartPtr<SmartAsl> aslfg_;
110
111    /// hold a reference to Couenne cut generator to delete it at
112    /// last. The alternative would be to clone it every time the
113    /// CouenneSolverInterface is cloned (that is, at each call of
114    /// Optimality-based bound tightening).
115    CouenneCutGenerator *CouennePtr_;
116
117    /// true if one wants to display statistics at the end of program
118    bool displayStats_;
119
120    /// MINLP formulation
121    CouenneProblem *couenneProb_;
122   
123    /// whether the couenneProb_ has been created by Couenne, and thus will be deleted by Couenne
124    bool couenneProb_is_own_;
125  };
126}
127
128#endif
Note: See TracBrowser for help on using the repository browser.