Couenne 0.5.8
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"
16
17#include <math.h>
18#ifndef M_PI
19# define M_PI 3.14159265358979323846
20#endif
21
22namespace Couenne {
23
26
27class 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
80class 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
T CoinMin(const T x1, const T x2)
T CoinMax(const T x1, const T x2)
#define M_PI
Define a dynamic point+bounds, with a way to save and restore previous points+bounds through a LIFO s...
class to compute lower bound of a sine based on the bounds on its arguments
expression * clone(Domain *d=NULL) const
cloning method
exprLBSin(expression *lb, expression *ub)
Constructors, destructor.
enum pos printPos() const
print position (PRE, INSIDE, POST)
std::string printOp() const
print operator
CouNumber operator()()
function for the evaluation of the expression
general n-ary operator-type expression: requires argument list.
expression ** arglist_
argument list is an array of pointers to other expressions
class to compute lower bound of a sine based on the bounds on its arguments
exprUBSin(expression *lb, expression *ub)
Constructors, destructor.
CouNumber operator()()
function for the evaluation of the expression
expression * clone(Domain *d=NULL) const
cloning method
std::string printOp() const
print operator
enum pos printPos() const
print position (PRE, INSIDE, POST)
Expression base class.
general include file for different compilers
pos
position where the operator should be printed when printing the expression
double CouNumber
main number type in Couenne
CouExpr & sin(CouExpr &e)