Couenne  0.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CouenneExprConst.hpp
Go to the documentation of this file.
1 /* $Id: CouenneExprConst.hpp 490 2011-01-14 16:07:12Z pbelotti $
2  *
3  * Name: exprConst.hpp
4  * Author: Pietro Belotti
5  * Purpose: definition of the class exprConst
6  *
7  * (C) Carnegie-Mellon University, 2006-09.
8  * This file is licensed under the Eclipse Public License (EPL)
9  */
10 
11 #ifndef COUENNE_EXPRCONST_HPP
12 #define COUENNE_EXPRCONST_HPP
13 
14 #include <iostream>
15 
16 #include "CouenneTypes.hpp"
17 #include "CouenneExpression.hpp"
18 
19 namespace Couenne {
20 
22 
23 class exprConst: public expression {
24 
25 private:
26 
29 
30 public:
31 
33  inline enum nodeType Type () const
34  {return CONST;}
35 
37  inline CouNumber Value () const
38  {return value_;}
39 
41  exprConst (CouNumber value):
42  value_ (value) {}
43 
45  exprConst (const exprConst &e, Domain *d = NULL)
46  {value_ = e.value_;}
47 
49  virtual inline expression *clone (Domain *d = NULL) const
50  {return new exprConst (value_);}
51 
53  void print (std::ostream &out = std::cout,
54  bool = false) const
55  {out << value_;}
56 
59  {return value_;}
60 
62  inline expression *differentiate (int)
63  {return new exprConst (0.);}
64 
66  inline int dependsOn (int *ind, int n, enum dig_type type = STOP_AT_AUX)
67  {return 0;}
68 
70  inline int Linearity ()
71  {return ((fabs (value_) < COUENNE_EPS) ? ZERO: CONSTANT);}
72 
74  inline void getBounds (expression *&lower, expression *&upper) {
75  lower = new exprConst (value_);
76  upper = new exprConst (value_);
77  }
78 
80  inline void getBounds (CouNumber &lower, CouNumber &upper)
81  {lower = upper = value_;}
82 
84  void generateCuts (expression *, //const OsiSolverInterface &,
85  OsiCuts &, const CouenneCutGenerator *,
86  t_chg_bounds * = NULL, int = -1,
89 
91  virtual inline enum expr_type code ()
92  {return COU_EXPRCONST;}
93 
95  virtual inline bool isInteger ()
96  {return Couenne::isInteger (value_);}
97 
99  virtual inline int rank ()
100  {return 0;}
101 };
102 
103 }
104 
105 #endif
Cut Generator for linear convexifications.
int Linearity()
get a measure of &quot;how linear&quot; the expression is (see CouenneTypes.h)
virtual bool isInteger()
is this expression integer?
status of lower/upper bound of a variable, to be checked/modified in bound tightening ...
CouNumber Value() const
value of expression
constant-type operator
void getBounds(expression *&lower, expression *&upper)
Get lower and upper bound of an expression (if any)
void print(std::ostream &out=std::cout, bool=false) const
I/O.
virtual expression * clone(Domain *d=NULL) const
Cloning method.
virtual int rank()
used in rank-based branching variable choice
CouNumber operator()()
return constant&#39;s value
virtual enum expr_type code()
code for comparisons
exprConst(CouNumber value)
Constructor.
#define COUENNE_EPS
CouNumber value_
the value of this constant
exprConst(const exprConst &e, Domain *d=NULL)
Copy constructor.
double CouNumber
main number type in Couenne
int dependsOn(int *ind, int n, enum dig_type type=STOP_AT_AUX)
dependence on variable set
nodeType
type of a node in an expression tree
#define COUENNE_INFINITY
dig_type
type of digging when filling the dependence list
void generateCuts(expression *, OsiCuts &, const CouenneCutGenerator *, t_chg_bounds *=NULL, int=-1, CouNumber=-COUENNE_INFINITY, CouNumber=COUENNE_INFINITY)
generate convexification cut for constraint w = this
expr_type
code returned by the method expression::code()
enum nodeType Type() const
node type
void getBounds(CouNumber &lower, CouNumber &upper)
Get value of lower and upper bound of an expression (if any)
Expression base class.
expression * differentiate(int)
differentiation
Define a dynamic point+bounds, with a way to save and restore previous points+bounds through a LIFO s...
bool isInteger(CouNumber x)
is this number integer?