1 /* $Id$
2  *
3  * Name:    CouenneTypes.hpp
4  * Author:  Pietro Belotti
5  * Purpose: define number types used throughout the code
6  *
7  * (C) Carnegie-Mellon University, 2006-07
8  * This file is licensed under the Eclipse Public License (EPL)
9  */
10 
11 #ifndef COUENNE_TYPES_H
12 #define COUENNE_TYPES_H
13 
14 /** general include file for different compilers */
15 #include "CoinPragma.hpp"
16 
17 namespace Couenne {
18 
19 /** type of a node in an expression tree */
20 enum nodeType       {CONST=0, VAR, UNARY, N_ARY, COPY, AUX, EMPTY};
21 
22 /** linearity of an expression, as returned by the method Linearity() */
23 enum linearity_type {ZERO=0, CONSTANT, LINEAR, QUADRATIC, NONLINEAR};
24 
25 /** position where the operator should be printed when printing the expression
26  *
27  *  For instance, it is INSIDE for exprSum, exprMul, exprDiv, while it
28  *  is PRE for exprLog, exprSin, exprExp...
29  **/
30 enum pos            {PRE=0, POST, INSIDE, NONE};
31 
32 /** sign of constraint */
33 enum con_sign       {COUENNE_EQ, COUENNE_LE, COUENNE_GE, COUENNE_RNG};
34 
35 /** position and number of convexification cuts added for a lower
36     convex (upper concave) envelope */
37 enum conv_type      {CURRENT_ONLY, UNIFORM_GRID, AROUND_CURPOINT};
38 
39 /** code returned by the method expression::code() */
40 enum expr_type {/*COU_EXPRAUX,  COU_EXPRCLONE, COU_EXPRCOPY, */
41                 COU_EXPRESSION, /***** variables, constants **************/
42 		COU_EXPRCONST, COU_EXPRVAR, COU_EXPRLBOUND, COU_EXPRUBOUND,
43 		/*COU_EXPRIVAR, */
44 		COU_EXPROP,     /***** n-ary operators *******************/
45 		COU_EXPRSUB,  COU_EXPRSUM, COU_EXPRGROUP, COU_EXPRQUAD,
46 		COU_EXPRMIN,  COU_EXPRMUL, COU_EXPRTRILINEAR, COU_EXPRPOW, COU_EXPRSIGNPOW, COU_EXPRMAX, COU_EXPRDIV,
47 		/*COU_EXPRBDIV,  COU_EXPRBMUL,*/
48 		COU_EXPRUNARY,  /***** unary operators *******************/
49 		COU_EXPRCOS,  COU_EXPRABS,
50 		COU_EXPREXP,  COU_EXPRINV,   COU_EXPRLOG,
51 		COU_EXPROPP,   COU_EXPRSIN, COU_EXPRFLOOR,
52 		COU_EXPRCEIL, MAX_COU_EXPR_CODE
53 		};
54 
55 /** convexity type of an expression */
56 enum convexity {UNSET, NONCONVEX, CONVEX, CONCAVE, AFFINE, CONV_LINEAR, CONV_CONSTANT, CONV_ZERO};
57 
58 /** monotonicity type of an expression */
59 enum monotonicity {MON_UNSET, NONMONOTONE, NDECREAS, NINCREAS, INCLIN, DECLIN, MON_CONST, MON_ZERO};
60 
61 /** type of digging when filling the dependence list */
62 enum dig_type {ORIG_ONLY, STOP_AT_AUX, TAG_AND_RECURSIVE, COUNT};
63 
64 /** status of lower/upper bound of a variable, to be checked/modified
65     in bound tightening */
66 class t_chg_bounds
67 {
68 public:
69   enum ChangeStatus {
70     UNCHANGED=0,
71     CHANGED=1,
72     EXACT=2
73   };
74 
t_chg_bounds()75   t_chg_bounds():
76     lower_(UNCHANGED),
77     upper_(UNCHANGED)
78   {}
t_chg_bounds(const t_chg_bounds & src)79   t_chg_bounds(const t_chg_bounds& src):
80     lower_(src.lower_),
81     upper_(src.upper_)
82   {}
lower() const83   inline const char& lower() const {return lower_;}
upper() const84   inline const char& upper() const {return upper_;}
setLower(ChangeStatus lower)85   inline void setLower(ChangeStatus lower) {lower_ = lower;}
setUpper(ChangeStatus upper)86   inline void setUpper(ChangeStatus upper) {upper_ = upper;}
setLowerBits(char lower)87   inline void setLowerBits(char lower) {lower_ |= lower;}
setUpperBits(char upper)88   inline void setUpperBits(char upper) {upper_ |= upper;}
operator =(const t_chg_bounds & src)89   t_chg_bounds operator=(const t_chg_bounds&src) {
90     lower_ = src.lower_;
91     upper_ = src.upper_;
92     return *this;
93   }
94 private:
95   char lower_;
96   char upper_;
97 };
98 
99 /** main number type in Couenne */
100 typedef double CouNumber;
101 
102 /** unary function, used in all exprUnary */
103 typedef CouNumber (*unary_function) (CouNumber);
104 
105 }
106 
107 #endif
108