branchExprSinCos.cpp
Go to the documentation of this file.
1 /* $Id: branchExprSinCos.cpp 708 2011-06-23 14:04:59Z pbelotti $
2  *
3  * Name: branchExprSinCos.cpp
4  * Author: Pietro Belotti
5  * Purpose: return branch gain and branch object for sines/cosines
6  *
7  * (C) Carnegie-Mellon University, 2006-11.
8  * This file is licensed under the Eclipse Public License (EPL)
9  */
10 
11 #include <math.h>
12 
13 #include "CouenneFunTriplets.hpp"
14 #include "CouenneExprSin.hpp"
15 #include "CouenneObject.hpp"
17 
18 namespace Couenne {
19 
20 static inline double oppcos (double x) {return -cos (x);}
21 static inline double oppsin (double x) {return -sin (x);}
22 static inline double oppasin (double x) {return asin (-x);}
23 
24 
27  const OsiBranchingInformation *info,
28  expression *&var,
29  double * &brpts,
30  double * &brDist, // distance of current LP
31  // point to new convexifications
32  int &way,
33  enum cou_trig type) {
34 
35  exprVar *ref = obj -> Reference ();
36 
37  var = ref -> Image () -> Argument ();
38 
39  assert (var -> Index () >= 0);
40  assert (ref -> Index () >= 0);
41 
42  CouNumber l, u,
43  x0 = info -> solution_ [var -> Index ()],
44  y0 = info -> solution_ [ref -> Index ()];
45 
46  var -> getBounds (l,u);
47 
49  (type == COU_SINE) ? (unary_function) cos : oppsin,
50  (type == COU_SINE) ? oppsin : oppcos,
51  (type == COU_SINE) ? (unary_function) acos : oppasin);
52 
53  brpts = (double *) realloc (brpts, sizeof (double));
54  brDist = (double *) realloc (brDist, 2*sizeof (double));
55  *brpts = obj -> getBrPoint (&ft, x0, l, u, info);
56 
57  return (brDist [0] = brDist [1] = y0 - ((type == COU_SINE) ? sin(x0) : cos(x0)));
58 }
59 
60 }
void fint fint fint real fint real real real real real real real real real fint real fint fint fint real fint fint fint fint * info
OsiObject for auxiliary variables $w=f(x)$.
static double oppcos(double x)
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
static double oppsin(double x)
ULong * x0
Definition: OSdtoa.cpp:1776
CouNumber(* unary_function)(CouNumber)
unary function, used in all exprUnary
cou_trig
specify which trigonometric function is dealt with in trigEnvelope
double CouNumber
main number type in Couenne
variable-type operator
static double oppasin(double x)
Expression base class.
CouExpr & cos(CouExpr &e)
CouExpr & sin(CouExpr &e)
void fint fint fint real fint real * x