Couenne  0.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CouenneExprBSin.hpp
Go to the documentation of this file.
1 /* $Id: CouenneExprBSin.hpp 748 2011-07-28 16:13:32Z pbelotti $ */
2 /*
3  * Name: exprBSin.hpp
4  * Author: Pietro Belotti
5  * Purpose: definition of operators to compute lower/upper bounds of sines
6  *
7  * (C) Carnegie-Mellon University, 2006.
8  * This file is licensed under the Eclipse Public License (EPL)
9  */
10 
11 #ifndef COUENNE_EXPRBSIN_HPP
12 #define COUENNE_EXPRBSIN_HPP
13 
14 #include "CouenneExprOp.hpp"
15 #include "CoinHelperFunctions.hpp"
16 
17 #include <math.h>
18 #ifndef M_PI
19 # define M_PI 3.14159265358979323846
20 #endif
21 
22 namespace Couenne {
23 
26 
27 class exprLBSin: public exprOp {
28 
29  public:
30 
33  exprOp (new expression * [2], 2) {
34  arglist_ [0] = lb;
35  arglist_ [1] = ub;
36  } //< non-leaf expression, with argument list
37 
39  expression *clone (Domain *d = NULL) const
40  {return new exprLBSin (arglist_ [0] -> clone (d),
41  arglist_ [1] -> clone (d));}
42 
45 
47  enum pos printPos () const
48  {return PRE;}
49 
51  std::string printOp () const
52  {return "LB_Sin";}
53 };
54 
55 
57 
59 
60  register CouNumber
61  l = (*(arglist_ [0])) (),
62  u = (*(arglist_ [1])) ();
63 
64  CouNumber pi2 = 2 * M_PI;
65 
66  if ((u - l >= pi2) || // 1) interval spans whole cycle
67  (floor (l/pi2 - 0.75) < // 2) there is a 3/2 pi + 2k pi between l and u
68  floor (u/pi2 - 0.75)))
69  return -1.;
70 
71  return CoinMin (sin (l), sin (u));
72 }
73 
74 
76 
79 
80 class exprUBSin: public exprOp {
81 
82  public:
83 
86  exprOp (new expression * [2], 2) {
87  arglist_ [0] = lb;
88  arglist_ [1] = ub;
89  } //< non-leaf expression, with argument list
90 
92  expression *clone (Domain *d = NULL) const
93  {return new exprUBSin (arglist_ [0] -> clone (d),
94  arglist_ [1] -> clone (d));}
95 
98 
100  std::string printOp () const
101  {return "UB_Sin";}
102 
104  enum pos printPos () const
105  {return PRE;}
106 };
107 
108 
110 
112 
113  register CouNumber
114  l = (*(arglist_ [0])) (),
115  u = (*(arglist_ [1])) ();
116 
117  CouNumber pi2 = 2 * M_PI;
118 
119  if ((u - l >= pi2) || // 1) interval spans whole cycle
120  (floor (l/pi2 - 0.25) < // 2) there is a pi/2 + 2k pi between l and u
121  floor (u/pi2 - 0.25)))
122  return 1.;
123 
124  return CoinMax (sin (l), sin (u));
125 }
126 
127 }
128 
129 #endif
class to compute lower bound of a sine based on the bounds on its arguments
std::string printOp() const
print operator
exprUBSin(expression *lb, expression *ub)
Constructors, destructor.
pos
position where the operator should be printed when printing the expression
enum pos printPos() const
print position (PRE, INSIDE, POST)
class to compute lower bound of a sine based on the bounds on its arguments
exprLBSin(expression *lb, expression *ub)
Constructors, destructor.
#define M_PI
CouNumber operator()()
function for the evaluation of the expression
enum pos printPos() const
print position (PRE, INSIDE, POST)
expression ** arglist_
argument list is an array of pointers to other expressions
CouNumber operator()()
function for the evaluation of the expression
double CouNumber
main number type in Couenne
expression * clone(Domain *d=NULL) const
cloning method
general n-ary operator-type expression: requires argument list.
std::string printOp() const
print operator
Expression base class.
expression * clone(Domain *d=NULL) const
cloning method
CouExpr & sin(CouExpr &e)
Define a dynamic point+bounds, with a way to save and restore previous points+bounds through a LIFO s...