Couenne  0.5.8
CouenneExprSin.hpp
Go to the documentation of this file.
1 /* $Id: CouenneExprSin.hpp 615 2011-06-08 20:36:24Z pbelotti $
2  *
3  * Name: exprSin.hpp
4  * Author: Pietro Belotti
5  * Purpose: definition of the sine of a function
6  *
7  * (C) Carnegie-Mellon University, 2006-10.
8  * This file is licensed under the Eclipse Public License (EPL)
9  */
10 
11 #ifndef COUENNE_EXPRSIN_HPP
12 #define COUENNE_EXPRSIN_HPP
13 
14 #include <math.h>
15 #include <assert.h>
16 
17 #include "CouenneExprUnary.hpp"
18 #include "CouenneExprConst.hpp"
19 
20 namespace Couenne {
21 
24 
25 
27 inline CouNumber modulo (register CouNumber a, register CouNumber b)
28  {return a - b * floor (a/b);}
29 
30 
33  const OsiBranchingInformation *info,
34  expression * &var,
35  double * &brpts,
36  double * &brDist, // distance of current LP
37  // point to new convexifications
38  int &way,
39  enum cou_trig type);
40 
41 
43 bool trigImpliedBound (enum cou_trig, int, int, CouNumber *, CouNumber *, t_chg_bounds *);
44 
45 
47 class exprSin: public exprUnary {
48 
49  public:
50 
53  exprUnary (al) {} //< non-leaf expression, with argument list
54 
56  expression *clone (Domain *d = NULL) const
57  {return new exprSin (argument_ -> clone (d));}
58 
60  inline unary_function F ()
61  {return sin;}
62 
64  std::string printOp () const
65  {return "sin";}
66 
68  inline CouNumber gradientNorm (const double *x) {
69  return (argument_ -> Index () < 0) ?
70  0. : fabs (cos (x [argument_ -> Index ()]));
71  }
72 
74  expression *differentiate (int index);
75 
78 
80  void getBounds (CouNumber &lb, CouNumber &ub);
81 
83  void generateCuts (expression *w, //const OsiSolverInterface &si,
84  OsiCuts &cs, const CouenneCutGenerator *cg,
85  t_chg_bounds * = NULL, int = -1,
88 
90  virtual enum expr_type code ()
91  {return COU_EXPRSIN;}
92 
94  bool impliedBound (int index, CouNumber *l, CouNumber *u, t_chg_bounds *chg, enum auxSign = expression::AUX_EQ) {
95 
96  bool impl = trigImpliedBound (COU_SINE, index, argument_ -> Index (), l, u, chg);
97 
98  if (impl && argument_ -> isInteger ()) {
99 
100  int ind = argument_ -> Index ();
101  assert (ind >= 0);
102  l [ind] = ceil (l [ind] - COUENNE_EPS);
103  u [ind] = floor (u [ind] + COUENNE_EPS);
104  }
105 
106  return impl;
107  }
108 
111  virtual CouNumber selectBranch (const CouenneObject *obj,
112  const OsiBranchingInformation *info,
113  expression * &var,
114  double * &brpts,
115  double * &brDist, // distance of current LP
116  // point to new convexifications
117  int &way)
118 
119  {return trigSelBranch (obj, info, var, brpts, brDist, way, COU_SINE);}
120 
122  virtual void closestFeasible (expression *varind, expression *vardep,
123  CouNumber& left, CouNumber& right) const;
124 
127  virtual bool isCuttable (CouenneProblem *problem, int index) const
128  {return false;}
129 };
130 
131 }
132 
133 #endif
Couenne::t_chg_bounds
status of lower/upper bound of a variable, to be checked/modified in bound tightening
Definition: CouenneTypes.hpp:67
Couenne::unary_function
CouNumber(* unary_function)(CouNumber)
unary function, used in all exprUnary
Definition: CouenneTypes.hpp:103
Couenne::sin
CouExpr & sin(CouExpr &e)
Couenne::exprSin::generateCuts
void generateCuts(expression *w, OsiCuts &cs, const CouenneCutGenerator *cg, t_chg_bounds *=NULL, int=-1, CouNumber=-COUENNE_INFINITY, CouNumber=COUENNE_INFINITY)
generate equality between *this and *w
Couenne::exprSin::clone
expression * clone(Domain *d=NULL) const
cloning method
Definition: CouenneExprSin.hpp:56
Couenne::exprUnary::argument_
expression * argument_
single argument taken by this expression
Definition: CouenneExprUnary.hpp:38
Couenne::exprSin::getBounds
void getBounds(expression *&, expression *&)
Get lower and upper bound of an expression (if any)
Couenne::expr_type
expr_type
code returned by the method expression::code()
Definition: CouenneTypes.hpp:40
COUENNE_INFINITY
#define COUENNE_INFINITY
Definition: CouennePrecisions.hpp:32
Couenne::exprUnary
expression class for unary functions (sin, log, etc.)
Definition: CouenneExprUnary.hpp:33
Couenne::expression::AUX_EQ
@ AUX_EQ
Definition: CouenneExpression.hpp:55
Couenne::exprUnary::isInteger
virtual bool isInteger()
is this expression integer?
Couenne::CouenneCutGenerator
Cut Generator for linear convexifications.
Definition: CouenneCutGenerator.hpp:49
Couenne::exprSin::exprSin
exprSin(expression *al)
Constructors, destructor.
Definition: CouenneExprSin.hpp:52
Couenne
general include file for different compilers
Definition: CouenneAggrProbing.hpp:24
Couenne::exprSin::gradientNorm
CouNumber gradientNorm(const double *x)
return l-2 norm of gradient at given point
Definition: CouenneExprSin.hpp:68
Couenne::trigImpliedBound
bool trigImpliedBound(enum cou_trig, int, int, CouNumber *, CouNumber *, t_chg_bounds *)
generalized implied bound procedure for sine/cosine
Couenne::exprSin::printOp
std::string printOp() const
print operator
Definition: CouenneExprSin.hpp:64
Couenne::exprSin::selectBranch
virtual CouNumber selectBranch(const CouenneObject *obj, const OsiBranchingInformation *info, expression *&var, double *&brpts, double *&brDist, int &way)
Set up branching object by evaluating many branching points for each expression's arguments.
Definition: CouenneExprSin.hpp:111
Couenne::exprSin::isCuttable
virtual bool isCuttable(CouenneProblem *problem, int index) const
can this expression be further linearized or are we on its concave ("bad") side
Definition: CouenneExprSin.hpp:127
Couenne::CouenneObject
OsiObject for auxiliary variables $w=f(x)$.
Definition: CouenneObject.hpp:57
COUENNE_EPS
#define COUENNE_EPS
Definition: CouennePrecisions.hpp:19
Index
int Index
Couenne::COU_EXPRSIN
@ COU_EXPRSIN
Definition: CouenneTypes.hpp:51
Couenne::CouNumber
double CouNumber
main number type in Couenne
Definition: CouenneTypes.hpp:100
OsiCuts
Couenne::COU_COSINE
@ COU_COSINE
Definition: CouenneExprSin.hpp:23
CouenneExprUnary.hpp
Couenne::expression::auxSign
auxSign
"sign" of the constraint defining an auxiliary.
Definition: CouenneExpression.hpp:55
Couenne::modulo
CouNumber modulo(register CouNumber a, register CouNumber b)
normalize angle within [0,b] (typically, pi or 2pi)
Definition: CouenneExprSin.hpp:27
Couenne::trigSelBranch
CouNumber trigSelBranch(const CouenneObject *obj, const OsiBranchingInformation *info, expression *&var, double *&brpts, double *&brDist, int &way, enum cou_trig type)
generalized procedure for both sine and cosine
Couenne::exprSin::closestFeasible
virtual void closestFeasible(expression *varind, expression *vardep, CouNumber &left, CouNumber &right) const
closest feasible points in function in both directions
OsiBranchingInformation
CouenneExprConst.hpp
Couenne::cos
CouExpr & cos(CouExpr &e)
Couenne::cou_trig
cou_trig
specify which trigonometric function is dealt with in trigEnvelope
Definition: CouenneExprSin.hpp:23
Couenne::exprSin::impliedBound
bool impliedBound(int index, CouNumber *l, CouNumber *u, t_chg_bounds *chg, enum auxSign=expression::AUX_EQ)
implied bound processing
Definition: CouenneExprSin.hpp:94
Couenne::exprSin
class for
Definition: CouenneExprSin.hpp:47
Couenne::COU_SINE
@ COU_SINE
Definition: CouenneExprSin.hpp:23
Couenne::exprSin::code
virtual enum expr_type code()
code for comparisons
Definition: CouenneExprSin.hpp:90
Couenne::CouenneProblem
Class for MINLP problems with symbolic information.
Definition: CouenneProblem.hpp:169
Couenne::exprSin::getBounds
void getBounds(CouNumber &lb, CouNumber &ub)
Get value of lower and upper bound of an expression (if any)
Couenne::expression
Expression base class.
Definition: CouenneExpression.hpp:48
Couenne::exprSin::F
unary_function F()
the operator itself (e.g. sin, log...)
Definition: CouenneExprSin.hpp:60
Couenne::expression::Index
virtual int Index() const
Return index of variable (only valid for exprVar and exprAux)
Definition: CouenneExpression.hpp:73
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
Couenne::exprSin::differentiate
expression * differentiate(int index)
differentiation