Couenne
0.2
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
Couenne
src
expression
operators
bounds
CouenneExprBCos.hpp
Go to the documentation of this file.
1
/* $Id: CouenneExprBCos.hpp 748 2011-07-28 16:13:32Z pbelotti $ */
2
/*
3
* Name: exprBCos.hpp
4
* Author: Pietro Belotti
5
* Purpose: definition of operators to compute lower/upper bounds of cosines
6
*
7
* (C) Carnegie-Mellon University, 2006.
8
* This file is licensed under the Eclipse Public License (EPL)
9
*/
10
11
#ifndef COUENNE_EXPRBCOS_HPP
12
#define COUENNE_EXPRBCOS_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
exprLBCos
:
public
exprOp
{
28
29
public
:
30
32
exprLBCos
(
expression
*lb,
expression
*ub):
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
exprLBCos
(
arglist_
[0] ->
clone
(d),
41
arglist_
[1] ->
clone
(d));}
42
44
CouNumber
operator ()
();
45
47
enum
pos
printPos
()
const
48
{
return
PRE
;}
49
51
std::string
printOp
()
const
52
{
return
"LB_Cos"
;}
53
};
54
55
57
58
inline
CouNumber
exprLBCos::operator ()
() {
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.5) <
// 2) there is a pi + 2k pi between l and u
68
floor (u/pi2 - 0.5)))
69
return
-1.;
70
71
return
CoinMin (
cos
(l),
cos
(u));
72
}
73
74
76
79
80
class
exprUBCos
:
public
exprOp
{
81
82
public
:
83
85
exprUBCos
(
expression
*lb,
expression
*ub):
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
exprUBCos
(
arglist_
[0] ->
clone
(d),
94
arglist_
[1] ->
clone
(d));}
95
97
CouNumber
operator ()
();
98
100
std::string
printOp
()
const
101
{
return
"UB_Cos"
;}
102
104
enum
pos
printPos
()
const
105
{
return
PRE
;}
106
};
107
108
110
111
inline
CouNumber
exprUBCos::operator ()
() {
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) <
// 2) there is a 3/2 pi + 2k pi between l and u
121
floor (u/pi2)))
122
return
1.;
123
124
return
CoinMax (
cos
(l),
cos
(u));
125
}
126
127
}
128
129
#endif
Couenne::exprLBCos::printPos
enum pos printPos() const
print position (PRE, INSIDE, POST)
Definition:
CouenneExprBCos.hpp:47
Couenne::exprUBCos::printPos
enum pos printPos() const
print position (PRE, INSIDE, POST)
Definition:
CouenneExprBCos.hpp:104
Couenne::pos
pos
position where the operator should be printed when printing the expression
Definition:
CouenneTypes.hpp:30
Couenne::PRE
Definition:
CouenneTypes.hpp:30
Couenne::exprUBCos::exprUBCos
exprUBCos(expression *lb, expression *ub)
Constructors, destructor.
Definition:
CouenneExprBCos.hpp:85
M_PI
#define M_PI
Definition:
CouenneExprBCos.hpp:19
Couenne::exprLBCos::clone
expression * clone(Domain *d=NULL) const
cloning method
Definition:
CouenneExprBCos.hpp:39
Couenne::exprUBCos::clone
expression * clone(Domain *d=NULL) const
cloning method
Definition:
CouenneExprBCos.hpp:92
Couenne::exprUBCos::operator()
CouNumber operator()()
function for the evaluation of the expression
Definition:
CouenneExprBCos.hpp:111
Couenne::exprUBCos
class to compute lower bound of a cosine based on the bounds of its arguments
Definition:
CouenneExprBCos.hpp:80
Couenne::exprLBCos::exprLBCos
exprLBCos(expression *lb, expression *ub)
Constructors, destructor.
Definition:
CouenneExprBCos.hpp:32
Couenne::exprOp::arglist_
expression ** arglist_
argument list is an array of pointers to other expressions
Definition:
CouenneExprOp.hpp:35
Couenne::CouNumber
double CouNumber
main number type in Couenne
Definition:
CouenneTypes.hpp:100
Couenne::exprLBCos::printOp
std::string printOp() const
print operator
Definition:
CouenneExprBCos.hpp:51
Couenne::exprLBCos::operator()
CouNumber operator()()
function for the evaluation of the expression
Definition:
CouenneExprBCos.hpp:58
Couenne::exprOp
general n-ary operator-type expression: requires argument list.
Definition:
CouenneExprOp.hpp:31
Couenne::expression
Expression base class.
Definition:
CouenneExpression.hpp:48
Couenne::cos
CouExpr & cos(CouExpr &e)
Couenne::exprLBCos
class to compute lower bound of a cosine based on the bounds of its arguments
Definition:
CouenneExprBCos.hpp:27
CouenneExprOp.hpp
Couenne::exprUBCos::printOp
std::string printOp() const
print operator
Definition:
CouenneExprBCos.hpp:100
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
Generated by
1.8.5