00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef COUENNE_EXPRCONST_HPP
00012 #define COUENNE_EXPRCONST_HPP
00013
00014 #include <iostream>
00015
00016 #include "CouenneTypes.hpp"
00017 #include "expression.hpp"
00018
00019
00021
00022 class exprConst: public expression {
00023
00024 private:
00025
00027 CouNumber value_;
00028
00029 public:
00030
00032 inline enum nodeType Type () const
00033 {return CONST;}
00034
00036 inline CouNumber Value () const
00037 {return value_;}
00038
00040 exprConst (CouNumber value):
00041 value_ (value) {}
00042
00044 exprConst (const exprConst &e, Domain *d = NULL)
00045 {value_ = e.value_;}
00046
00048 virtual inline expression *clone (Domain *d = NULL) const
00049 {return new exprConst (value_);}
00050
00052 void print (std::ostream &out = std::cout,
00053 bool = false) const
00054 {out << value_;}
00055
00057 inline CouNumber operator() ()
00058 {return value_;}
00059
00061 inline expression *differentiate (int)
00062 {return new exprConst (0.);}
00063
00065 inline int dependsOn (int *ind, int n, enum dig_type type = STOP_AT_AUX)
00066 {return 0;}
00067
00069 inline int Linearity ()
00070 {return ((fabs (value_) < COUENNE_EPS) ? ZERO: CONSTANT);}
00071
00073 inline void getBounds (expression *&lower, expression *&upper) {
00074 lower = new exprConst (value_);
00075 upper = new exprConst (value_);
00076 }
00077
00079 inline void getBounds (CouNumber &lower, CouNumber &upper)
00080 {lower = upper = value_;}
00081
00083 void generateCuts (expression *, const OsiSolverInterface &,
00084 OsiCuts &, const CouenneCutGenerator *,
00085 t_chg_bounds * = NULL, int = -1,
00086 CouNumber = -COUENNE_INFINITY,
00087 CouNumber = COUENNE_INFINITY);
00088
00090 virtual inline enum expr_type code ()
00091 {return COU_EXPRCONST;}
00092
00094 virtual inline bool isInteger ()
00095 {return ::isInteger (value_);}
00096
00098 virtual inline int rank ()
00099 {return 0;}
00100 };
00101
00102 #endif