exprAux.hpp

Go to the documentation of this file.
00001 /* $Id: exprAux.hpp 156 2009-06-16 20:24:38Z pbelotti $
00002  *
00003  * Name:    exprAux.hpp
00004  * Author:  Pietro Belotti
00005  * Purpose: definition of the auxiliary variable class (used in
00006  *          standardization and convexification)
00007  *
00008  * (C) Carnegie-Mellon University, 2006. 
00009  * This file is licensed under the Common Public License (CPL)
00010  */
00011 
00012 #ifndef COUENNE_EXPRAUX_HPP
00013 #define COUENNE_EXPRAUX_HPP
00014 
00015 #include <iostream>
00016 
00017 #include "exprVar.hpp"
00018 
00019 class CouenneCutGenerator;
00020 
00029 class exprAux: public exprVar {
00030 
00031  public:
00032 
00034   enum intType {Unset=-1, Continuous, Integer};
00035 
00036  protected:
00037 
00039   expression *image_;
00040 
00043   expression *lb_;
00044 
00047   expression *ub_;
00048 
00052   int rank_;
00053 
00057   int multiplicity_;
00058 
00060   enum intType integer_;
00061 
00062  public:
00063 
00065   inline enum nodeType Type () const
00066     {return AUX;}
00067 
00069   exprAux (expression *, int, int, intType = Unset, Domain * = NULL);
00070 
00072   exprAux (expression *, Domain * = NULL);
00073 
00075   virtual ~exprAux ();
00076 
00078   exprAux (const exprAux &, Domain *d = NULL);
00079 
00081   virtual inline exprVar *clone (Domain *d = NULL) const
00082   {return new exprAux (*this, d);}
00083 
00084   inline expression *Lb () {return lb_;} 
00085   inline expression *Ub () {return ub_;} 
00086 
00088   virtual void print (std::ostream & = std::cout, 
00089                       bool = false) const;
00090 
00092   inline expression *Image () const
00093     {return image_;}
00094 
00096   inline void Image (expression *image)
00097     {image_ = image;}
00098 
00100   inline CouNumber operator () ()
00101     {return domain_ -> x (varIndex_);}
00102 
00104   inline expression *differentiate (int index) 
00105     {return image_ -> differentiate (index);}
00106 
00109   int DepList (std::set <int> &deplist, 
00110                enum dig_type type = ORIG_ONLY);
00111 
00113   expression *simplify ();
00114 
00116   inline int Linearity ()
00117     {return LINEAR;}
00118     /*return image_ -> Linearity ();*/
00119 
00121   //virtual void getBounds (expression *&lb, expression *&ub);
00122 
00125   void crossBounds ();
00126 
00128   void generateCuts (const OsiSolverInterface &, 
00129                      OsiCuts &, const CouenneCutGenerator *, 
00130                      t_chg_bounds * = NULL, int = -1, 
00131                      CouNumber = -COUENNE_INFINITY, 
00132                      CouNumber =  COUENNE_INFINITY);
00133 
00135   virtual inline int rank ()
00136     {return rank_;} 
00137 
00139   virtual inline bool isDefinedInteger () {
00140 
00141     return ((integer_ == Integer) || 
00142             ((integer_ == Unset) && 
00143             ((integer_ = (image_ -> isInteger ()) ? 
00144               Integer : Continuous) == Integer)));
00145   }
00146 
00148   virtual inline bool isInteger () {
00149 
00150     if (isDefinedInteger ()) 
00151       return true;
00152 
00153     CouNumber l = lb ();
00154     return (::isInteger (l) && (fabs (l - ub ()) < COUENNE_EPS));
00155     //CouNumber l = (*(Lb ())) ();
00156     //return (::isInteger (l) && (fabs (l - (*(Ub ())) ()) < COUENNE_EPS));
00157   }
00158 
00160   virtual inline void setInteger (bool value)
00161   {integer_ = value ? Integer : Continuous;}
00162 
00164   inline void increaseMult () {++multiplicity_;}
00165 
00168   inline void decreaseMult () {--multiplicity_;}
00169 
00171   inline void zeroMult () {multiplicity_ = 0;}
00172 
00174   inline int Multiplicity () {return multiplicity_;}
00175 
00177   inline void linkDomain (Domain *d) {
00178     domain_ = d; 
00179     if (lb_) lb_ -> linkDomain (d);
00180     if (ub_) ub_ -> linkDomain (d);
00181   }
00182 
00183 
00186   CouenneObject properObject (CouenneProblem *p, 
00187                               Bonmin::BabSetupBase *base, 
00188                               JnlstPtr jnlst);
00189 };
00190 
00191 
00197 struct compExpr {
00198   inline bool operator () (exprAux* e0, exprAux* e1) const
00199   {return (e0 -> Image () -> compare (*(e1 -> Image ())) < 0);}
00200 };
00201 
00202 
00204 void draw_cuts (OsiCuts &, const CouenneCutGenerator *, 
00205                 int, expression *, expression *);
00206 
00207 #endif

Generated on Wed Jul 8 03:05:41 2009 for Couenne by  doxygen 1.4.7