# CouenneExprAux.hpp

Go to the documentation of this file.

    00001 /* $Id: CouenneExprAux.hpp 1080 2014-10-30 20:06:40Z 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-10.
    00009  * This file is licensed under the Eclipse Public License (EPL)
    00010  */
    00011
    00012 #ifndef COUENNE_EXPRAUX_HPP
    00013 #define COUENNE_EXPRAUX_HPP
    00014
    00015 #include <iostream>
    00016
    00017 #include "CouenneExprVar.hpp"
    00018
    00019 namespace Couenne {
    00020
    00021 class CouenneCutGenerator;
    00022
    00031 class exprAux: public exprVar {
    00032
    00033  public:
    00034
    00036   enum intType {Unset=-1, Continuous, Integer};
    00037
    00038  protected:
    00039
    00041   expression *image_;
    00042
    00045   expression *lb_;
    00046
    00049   expression *ub_;
    00050
    00054   int rank_;
    00055
    00059   int multiplicity_;
    00060
    00062   enum intType integer_;
    00063
    00066   bool top_level_;
    00067
    00069   enum auxSign sign_;
    00070
    00071  public:
    00072
    00074   inline enum nodeType Type () const
    00075   {return AUX;}
    00076
    00078   exprAux (expression *, int, int, intType = Unset, Domain * = NULL, enum auxSign = expression::AUX_EQ);
    00079
    00081   exprAux (expression *, Domain * = NULL, enum auxSign = expression::AUX_EQ);
    00082
    00084   virtual ~exprAux ();
    00085
    00087   exprAux (const exprAux &, Domain *d = NULL);
    00088
    00090   virtual inline exprVar *clone (Domain *d = NULL) const
    00091   {return new exprAux (*this, d);}
    00092
    00093   inline expression *Lb () {return lb_;}
    00094   inline expression *Ub () {return ub_;}
    00095
    00097   virtual void print (std::ostream & = std::cout,
    00098                       bool = false) const;
    00099
    00101   inline expression *Image () const
    00102   {return image_;}
    00103
    00105   inline void Image (expression *image)
    00106   {image_ = image;}
    00107
    00109   inline CouNumber operator () ()
    00110   {return domain_ -> x (varIndex_);}
    00111
    00114   int DepList (std::set <int> &deplist,
    00115                enum dig_type type = ORIG_ONLY);
    00116
    00118   expression *simplify ();
    00119
    00121   inline int Linearity ()
    00122   {return LINEAR;}
    00123     /*return image_ -> Linearity ();*/
    00124
    00126   //virtual void getBounds (expression *&lb, expression *&ub);
    00127
    00130   void crossBounds ();
    00131
    00133   void generateCuts (//const OsiSolverInterface &,
    00134                      OsiCuts &, const CouenneCutGenerator *,
    00135                      t_chg_bounds * = NULL, int = -1,
    00136                      CouNumber = -COUENNE_INFINITY,
    00137                      CouNumber =  COUENNE_INFINITY);
    00138
    00140   virtual inline int rank ()
    00141     {return rank_;}
    00142
    00144   virtual inline bool isDefinedInteger () {
    00145
    00146     return ((integer_ == Integer) ||
    00147             ((integer_ == Unset) &&
    00148              ((integer_ = ((image_ != NULL) && (image_ -> isInteger ())) ?
    00149                Integer : Continuous) == Integer)));
    00150   }
    00151
    00153   virtual inline bool isInteger () {
    00154
    00155     if (isDefinedInteger ())
    00156       return true;
    00157
    00158     register CouNumber l = lb ();
    00159     return ((l == ub ()) && (COUENNE_round (l) == l));
    00160     //CouNumber l = (*(Lb ())) ();
    00161     //return (::isInteger (l) && (fabs (l - (*(Ub ())) ()) < COUENNE_EPS));
    00162   }
    00163
    00165   virtual inline void setInteger (bool value)
    00166   {integer_ = value ? Integer : Continuous;}
    00167
    00169   inline void increaseMult () {++multiplicity_;}
    00170
    00173   inline void decreaseMult () {--multiplicity_;}
    00174
    00176   inline void zeroMult () {multiplicity_ = 0;}
    00177
    00179   inline int Multiplicity () {return multiplicity_;}
    00180
    00182   inline void linkDomain (Domain *d) {
    00183     domain_ = d;
    00184     if (lb_) lb_ -> linkDomain (d);
    00185     if (ub_) ub_ -> linkDomain (d);
    00186   }
    00187
    00189   bool &top_level ()
    00190   {return top_level_;}
    00191
    00194   CouenneObject *properObject (CouenneCutGenerator *c,
    00195                               CouenneProblem *p,
    00196                               Bonmin::BabSetupBase *base,
    00197                               JnlstPtr jnlst);
    00198
    00200   virtual inline enum auxSign sign () const
    00201   {return sign_;}
    00202 };
    00203
    00204
    00210 struct compExpr {
    00211   inline bool operator () (exprAux* e0, exprAux* e1) const
    00212   {
    00213     return ((e0 -> sign  () < e1 -> sign  ()) ||
    00214             ((e0 -> Image () != NULL) && (e1 -> Image () != NULL) && (e0 -> Image () -> compare (*(e1 -> Image ())) < 0)));
    00215   }
    00216 };
    00217
    00218
    00220 void draw_cuts (OsiCuts &, const CouenneCutGenerator *,
    00221                 int, expression *, expression *);
    00222
    00223 }
    00224
    00225 #endif

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines