exprExp.cpp
Go to the documentation of this file.
1 /* $Id: exprExp.cpp 560 2011-04-17 10:01:15Z stefan $
2  *
3  * Name: exprExp.cpp
4  * Author: Pietro Belotti
5  * Purpose: definition of the exponential
6  *
7  * (C) Carnegie-Mellon University, 2006-10.
8  * This file is licensed under the Eclipse Public License (EPL)
9  */
10 
11 #include "CouenneExprExp.hpp"
12 #include "CouenneExprClone.hpp"
13 #include "CouenneExprMul.hpp"
14 #include "CouenneProblem.hpp"
15 
16 #include "CoinFinite.hpp"
17 
18 using namespace Couenne;
19 
20 // differentiation
22 
23  return new exprMul (new exprExp (new exprClone (argument_)),
24  argument_ -> differentiate (index));
25 }
26 
27 
28 // Get expressions of lower and upper bound of an expression (if any)
30 
31  expression *lba, *uba;
32  argument_ -> getBounds (lba, uba);
33 
34  lb = new exprExp (lba);
35  ub = new exprExp (uba);
36 }
37 
38 
39 // Get value of lower and upper bound of an expression (if any)
41 
42  CouNumber lba, uba;
43  argument_ -> getBounds (lba, uba);
44 
45  lb = exp (lba);
46  ub = exp (uba);
47 }
48 
49 
52 bool exprExp::impliedBound (int wind, CouNumber *l, CouNumber *u, t_chg_bounds *chg, enum auxSign sign) {
53 
54  bool resU, resL = resU = false;
55  int ind = argument_ -> Index ();
56 
57  CouNumber b;
58 
59  if ((b = sign == expression::AUX_GEQ ? 0. : l [wind]) > 0.) // lower bound
60  resL = updateBound (-1, l + ind, argument_->isInteger () ? ceil (log (b)) : log (b));
61 
62  if ((b = sign == expression::AUX_LEQ ? COIN_DBL_MAX : u [wind]) < COIN_DBL_MAX / 10.) { // upper bound
63 
64  if ((b >= -0.) && (b < COUENNE_EPS)) // to prevent infeasibilities due to numerics
65  b = COUENNE_EPS;
66 
67  resU = updateBound ( 1, u + ind, argument_ -> isInteger () ? floor (log (b)) : log (b));
68  }
69 
70  if (b < - COUENNE_EPS) {
71  // make it infeasible
72  resU = updateBound ( 1, u + ind, -1.) || true;
73  resL = updateBound (-1, l + ind, 1.) || true;
74  }
75 
76  if (resL) chg [ind].setLower (t_chg_bounds::CHANGED);
77  if (resU) chg [ind].setUpper (t_chg_bounds::CHANGED);
78 
79  return (resL || resU);
80 }
81 
82 
85 bool exprExp::isCuttable (CouenneProblem *problem, int index) const {
86 
87  double
88  x = problem -> X (argument_ -> Index ()),
89  y = problem -> X (index);
90 
91  return (y <= exp (x));
92 }
bool updateBound(register int sign, register CouNumber *dst, register CouNumber src)
updates maximum violation.
virtual bool isInteger()
is this expression integer?
Definition: exprUnary.cpp:79
CouExpr & log(CouExpr &e)
status of lower/upper bound of a variable, to be checked/modified in bound tightening ...
void setLower(ChangeStatus lower)
expression * argument_
single argument taken by this expression
void setUpper(ChangeStatus upper)
virtual int Index() const
Return index of variable (only valid for exprVar and exprAux)
CouExpr & exp(CouExpr &e)
auxSign
&quot;sign&quot; of the constraint defining an auxiliary.
expression * differentiate(int index)
Differentiation.
Definition: exprExp.cpp:21
exprExp(expression *al)
Constructor.
virtual bool isCuttable(CouenneProblem *problem, int index) const
can this expression be further linearized or are we on its concave (&quot;bad&quot;) side
Definition: exprExp.cpp:85
Class for MINLP problems with symbolic information.
expression clone (points to another expression)
#define COUENNE_EPS
double CouNumber
main number type in Couenne
void getBounds(expression *&, expression *&)
Get lower and upper bound of an expression (if any)
Definition: exprExp.cpp:29
Expression base class.
class for the exponential,
bool impliedBound(int, CouNumber *, CouNumber *, t_chg_bounds *, enum auxSign=expression::AUX_EQ)
Implied bound processing.
Definition: exprExp.cpp:52
return b
Definition: OSdtoa.cpp:1719
virtual bool isInteger()
is this expression integer?
void fint fint fint real fint real * x
class for multiplications,