/home/coin/SVN-release/OS-2.2.0/Couenne/src/expression/exprAux.hpp

Go to the documentation of this file.
00001 /* $Id: exprAux.hpp 272 2009-11-20 22:21:50Z 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-09.
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 
00064   bool top_level_;
00065 
00066  public:
00067 
00069   inline enum nodeType Type () const
00070   {return AUX;}
00071 
00073   exprAux (expression *, int, int, intType = Unset, Domain * = NULL);
00074 
00076   exprAux (expression *, Domain * = NULL);
00077 
00079   virtual ~exprAux ();
00080 
00082   exprAux (const exprAux &, Domain *d = NULL);
00083 
00085   virtual inline exprVar *clone (Domain *d = NULL) const
00086   {return new exprAux (*this, d);}
00087 
00088   inline expression *Lb () {return lb_;} 
00089   inline expression *Ub () {return ub_;} 
00090 
00092   virtual void print (std::ostream & = std::cout, 
00093                       bool = false) const;
00094 
00096   inline expression *Image () const
00097   {return image_;}
00098 
00100   inline void Image (expression *image)
00101   {image_ = image;}
00102 
00104   inline CouNumber operator () ()
00105   {return domain_ -> x (varIndex_);}
00106 
00108   inline expression *differentiate (int index) 
00109   {return image_ -> differentiate (index);}
00110 
00113   int DepList (std::set <int> &deplist, 
00114                enum dig_type type = ORIG_ONLY);
00115 
00117   expression *simplify ();
00118 
00120   inline int Linearity ()
00121   {return LINEAR;}
00122     /*return image_ -> Linearity ();*/
00123 
00125   //virtual void getBounds (expression *&lb, expression *&ub);
00126 
00129   void crossBounds ();
00130 
00132   void generateCuts (//const OsiSolverInterface &, 
00133                      OsiCuts &, const CouenneCutGenerator *, 
00134                      t_chg_bounds * = NULL, int = -1, 
00135                      CouNumber = -COUENNE_INFINITY, 
00136                      CouNumber =  COUENNE_INFINITY);
00137 
00139   virtual inline int rank ()
00140     {return rank_;} 
00141 
00143   virtual inline bool isDefinedInteger () {
00144 
00145     return ((integer_ == Integer) || 
00146             ((integer_ == Unset) && 
00147             ((integer_ = (image_ -> isInteger ()) ? 
00148               Integer : Continuous) == Integer)));
00149   }
00150 
00152   virtual inline bool isInteger () {
00153 
00154     if (isDefinedInteger ()) 
00155       return true;
00156 
00157     CouNumber l = lb ();
00158     return (::isInteger (l) && (fabs (l - ub ()) < COUENNE_EPS));
00159     //CouNumber l = (*(Lb ())) ();
00160     //return (::isInteger (l) && (fabs (l - (*(Ub ())) ()) < COUENNE_EPS));
00161   }
00162 
00164   virtual inline void setInteger (bool value)
00165   {integer_ = value ? Integer : Continuous;}
00166 
00168   inline void increaseMult () {++multiplicity_;}
00169 
00172   inline void decreaseMult () {--multiplicity_;}
00173 
00175   inline void zeroMult () {multiplicity_ = 0;}
00176 
00178   inline int Multiplicity () {return multiplicity_;}
00179 
00181   inline void linkDomain (Domain *d) {
00182     domain_ = d; 
00183     if (lb_) lb_ -> linkDomain (d);
00184     if (ub_) ub_ -> linkDomain (d);
00185   }
00186 
00188   bool &top_level () 
00189   {return top_level_;}
00190 
00193   CouenneObject *properObject (CouenneCutGenerator *c,
00194                               CouenneProblem *p, 
00195                               Bonmin::BabSetupBase *base, 
00196                               JnlstPtr jnlst);
00197 };
00198 
00199 
00205 struct compExpr {
00206   inline bool operator () (exprAux* e0, exprAux* e1) const
00207   {return (e0 -> Image () -> compare (*(e1 -> Image ())) < 0);}
00208 };
00209 
00210 
00212 void draw_cuts (OsiCuts &, const CouenneCutGenerator *, 
00213                 int, expression *, expression *);
00214 
00215 #endif

Generated on Thu Aug 5 03:02:56 2010 by  doxygen 1.4.7