# CouenneExprConst.hpp

Go to the documentation of this file.

    00001 /* $Id: CouenneExprConst.hpp 490 2011-01-14 16:07:12Z pbelotti $
    00002  *
    00003  * Name:    exprConst.hpp
    00004  * Author:  Pietro Belotti
    00005  * Purpose: definition of the class exprConst
    00006  *
    00007  * (C) Carnegie-Mellon University, 2006-09.
    00008  * This file is licensed under the Eclipse Public License (EPL)
    00009  */
    00010
    00011 #ifndef COUENNE_EXPRCONST_HPP
    00012 #define COUENNE_EXPRCONST_HPP
    00013
    00014 #include <iostream>
    00015
    00016 #include "CouenneTypes.hpp"
    00017 #include "CouenneExpression.hpp"
    00018
    00019 namespace Couenne {
    00020
    00022
    00023 class exprConst: public expression {
    00024
    00025 private:
    00026
    00028   CouNumber value_;
    00029
    00030 public:
    00031
    00033   inline enum nodeType Type () const
    00034   {return CONST;}
    00035
    00037   inline CouNumber Value () const
    00038   {return value_;}
    00039
    00041   exprConst (CouNumber value):
    00042     value_ (value) {}
    00043
    00045   exprConst (const exprConst &e, Domain *d = NULL)
    00046   {value_ = e.value_;}
    00047
    00049   virtual inline expression *clone (Domain *d = NULL) const
    00050   {return new exprConst (value_);}
    00051
    00053   void print (std::ostream &out = std::cout,
    00054               bool = false) const
    00055   {out << value_;}
    00056
    00058   inline CouNumber operator() ()
    00059   {return value_;}
    00060
    00062   inline expression *differentiate (int)
    00063   {return new exprConst (0.);}
    00064
    00066   inline int dependsOn (int *ind, int n, enum dig_type type = STOP_AT_AUX)
    00067   {return 0;}
    00068
    00070   inline int Linearity ()
    00071   {return ((fabs (value_) < COUENNE_EPS) ? ZERO: CONSTANT);}
    00072
    00074   inline void getBounds (expression *&lower, expression *&upper) {
    00075     lower = new exprConst (value_);
    00076     upper = new exprConst (value_);
    00077   }
    00078
    00080   inline void getBounds (CouNumber &lower, CouNumber &upper)
    00081   {lower = upper = value_;}
    00082
    00084   void generateCuts (expression *, //const OsiSolverInterface &,
    00085                      OsiCuts &, const CouenneCutGenerator *,
    00086                      t_chg_bounds * = NULL, int = -1,
    00087                      CouNumber = -COUENNE_INFINITY,
    00088                      CouNumber =  COUENNE_INFINITY);
    00089
    00091   virtual inline enum expr_type code ()
    00092   {return COU_EXPRCONST;}
    00093
    00095   virtual inline bool isInteger ()
    00096   {return Couenne::isInteger (value_);}
    00097
    00099   virtual inline int rank ()
    00100   {return 0;}
    00101 };
    00102
    00103 }
    00104
    00105 #endif

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines