Couenne  0.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
32 CouNumber trigSelBranch (const CouenneObject *obj,
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 
77  void getBounds (expression *&, expression *&);
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
Cut Generator for linear convexifications.
OsiObject for auxiliary variables $w=f(x)$.
status of lower/upper bound of a variable, to be checked/modified in bound tightening ...
virtual bool isInteger()
is this expression integer?
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
expression * clone(Domain *d=NULL) const
cloning method
virtual void closestFeasible(expression *varind, expression *vardep, CouNumber &left, CouNumber &right) const
closest feasible points in function in both directions
void getBounds(expression *&, expression *&)
Get lower and upper bound of an expression (if any)
virtual enum expr_type code()
code for comparisons
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
expression * argument_
single argument taken by this expression
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&#39;s arguments...
CouNumber gradientNorm(const double *x)
return l-2 norm of gradient at given point
bool trigImpliedBound(enum cou_trig, int, int, CouNumber *, CouNumber *, t_chg_bounds *)
generalized implied bound procedure for sine/cosine
expression class for unary functions (sin, log, etc.)
std::string printOp() const
print operator
virtual bool isCuttable(CouenneProblem *problem, int index) const
can this expression be further linearized or are we on its concave (&quot;bad&quot;) side
exprSin(expression *al)
Constructors, destructor.
virtual int Index() const
Return index of variable (only valid for exprVar and exprAux)
auxSign
&quot;sign&quot; of the constraint defining an auxiliary.
CouNumber(* unary_function)(CouNumber)
unary function, used in all exprUnary
Class for MINLP problems with symbolic information.
#define COUENNE_EPS
bool impliedBound(int index, CouNumber *l, CouNumber *u, t_chg_bounds *chg, enum auxSign=expression::AUX_EQ)
implied bound processing
cou_trig
specify which trigonometric function is dealt with in trigEnvelope
CouNumber modulo(register CouNumber a, register CouNumber b)
normalize angle within [0,b] (typically, pi or 2pi)
double CouNumber
main number type in Couenne
expression * differentiate(int index)
differentiation
#define COUENNE_INFINITY
expr_type
code returned by the method expression::code()
Expression base class.
CouExpr & cos(CouExpr &e)
CouExpr & sin(CouExpr &e)
unary_function F()
the operator itself (e.g. sin, log...)
Define a dynamic point+bounds, with a way to save and restore previous points+bounds through a LIFO s...