Couenne  0.5.8
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 
28  CouNumber value_;
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
Couenne::t_chg_bounds
status of lower/upper bound of a variable, to be checked/modified in bound tightening
Definition: CouenneTypes.hpp:67
Couenne::exprConst::Linearity
int Linearity()
get a measure of "how linear" the expression is (see CouenneTypes.h)
Definition: CouenneExprConst.hpp:70
Couenne::exprConst::Type
enum nodeType Type() const
node type
Definition: CouenneExprConst.hpp:33
Couenne::expr_type
expr_type
code returned by the method expression::code()
Definition: CouenneTypes.hpp:40
Couenne::isInteger
bool isInteger(CouNumber x)
is this number integer?
Definition: CouenneExpression.hpp:309
COUENNE_INFINITY
#define COUENNE_INFINITY
Definition: CouennePrecisions.hpp:32
Couenne::exprConst::getBounds
void getBounds(CouNumber &lower, CouNumber &upper)
Get value of lower and upper bound of an expression (if any)
Definition: CouenneExprConst.hpp:80
Couenne::COU_EXPRCONST
@ COU_EXPRCONST
Definition: CouenneTypes.hpp:42
Couenne::CouenneCutGenerator
Cut Generator for linear convexifications.
Definition: CouenneCutGenerator.hpp:49
Couenne::exprConst::exprConst
exprConst(CouNumber value)
Constructor.
Definition: CouenneExprConst.hpp:41
Couenne::CONST
@ CONST
Definition: CouenneTypes.hpp:20
Couenne::exprConst::differentiate
expression * differentiate(int)
differentiation
Definition: CouenneExprConst.hpp:62
Couenne
general include file for different compilers
Definition: CouenneAggrProbing.hpp:24
Couenne::exprConst::code
virtual enum expr_type code()
code for comparisons
Definition: CouenneExprConst.hpp:91
Couenne::STOP_AT_AUX
@ STOP_AT_AUX
Definition: CouenneTypes.hpp:62
Couenne::exprConst::isInteger
virtual bool isInteger()
is this expression integer?
Definition: CouenneExprConst.hpp:95
Couenne::dig_type
dig_type
type of digging when filling the dependence list
Definition: CouenneTypes.hpp:62
COUENNE_EPS
#define COUENNE_EPS
Definition: CouennePrecisions.hpp:19
Couenne::exprConst::print
void print(std::ostream &out=std::cout, bool=false) const
I/O.
Definition: CouenneExprConst.hpp:53
Couenne::CONSTANT
@ CONSTANT
Definition: CouenneTypes.hpp:23
Couenne::CouNumber
double CouNumber
main number type in Couenne
Definition: CouenneTypes.hpp:100
OsiCuts
Couenne::exprConst::exprConst
exprConst(const exprConst &e, Domain *d=NULL)
Copy constructor.
Definition: CouenneExprConst.hpp:45
Couenne::exprConst::operator()
CouNumber operator()()
return constant's value
Definition: CouenneExprConst.hpp:58
CouenneTypes.hpp
Couenne::exprConst
constant-type operator
Definition: CouenneExprConst.hpp:23
CouenneExpression.hpp
Couenne::nodeType
nodeType
type of a node in an expression tree
Definition: CouenneTypes.hpp:20
Couenne::exprConst::Value
CouNumber Value() const
value of expression
Definition: CouenneExprConst.hpp:37
Couenne::exprConst::dependsOn
int dependsOn(int *ind, int n, enum dig_type type=STOP_AT_AUX)
dependence on variable set
Definition: CouenneExprConst.hpp:66
Couenne::ZERO
@ ZERO
Definition: CouenneTypes.hpp:23
Couenne::exprConst::rank
virtual int rank()
used in rank-based branching variable choice
Definition: CouenneExprConst.hpp:99
Couenne::exprConst::generateCuts
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
Couenne::exprConst::getBounds
void getBounds(expression *&lower, expression *&upper)
Get lower and upper bound of an expression (if any)
Definition: CouenneExprConst.hpp:74
Couenne::expression
Expression base class.
Definition: CouenneExpression.hpp:48
Couenne::exprConst::clone
virtual expression * clone(Domain *d=NULL) const
Cloning method.
Definition: CouenneExprConst.hpp:49
Couenne::Domain
Define a dynamic point+bounds, with a way to save and restore previous points+bounds through a LIFO s...
Definition: CouenneDomain.hpp:104