/home/coin/SVN-release/OS-2.2.0/Couenne/src/branch/operators/branchExprSinCos.cpp

Go to the documentation of this file.
00001 /* $Id: branchExprSinCos.cpp 141 2009-06-03 04:19:19Z pbelotti $ */
00002 /*
00003  * Name:    branchExprSinCos.cpp
00004  * Author:  Pietro Belotti
00005  * Purpose: return branch gain and branch object for sines/cosines
00006  *
00007  * (C) Carnegie-Mellon University, 2006-07.
00008  * This file is licensed under the Common Public License (CPL)
00009  */
00010 
00011 #include <math.h>
00012 
00013 #include "funtriplets.hpp"
00014 #include "exprSin.hpp"
00015 #include "CouenneObject.hpp"
00016 #include "CouenneBranchingObject.hpp"
00017 
00018 static inline double oppcos  (double x) {return -cos (x);}
00019 static inline double oppsin  (double x) {return -sin (x);}
00020 static inline double oppasin (double x) {return asin (-x);}
00021 
00022 
00024 CouNumber trigSelBranch (const CouenneObject *obj, 
00025                          const OsiBranchingInformation *info,
00026                          expression *&var,
00027                          double * &brpts, 
00028                          double * &brDist, // distance of current LP
00029                                            // point to new convexifications
00030                          int &way,
00031                          enum cou_trig type) {
00032 
00033   exprVar *ref = obj -> Reference ();
00034 
00035   var = ref -> Image () -> Argument ();
00036 
00037   assert (var -> Index () >= 0);
00038   assert (ref -> Index () >= 0);
00039 
00040   CouNumber l, u,
00041     x0 = info -> solution_ [var -> Index ()],
00042     y0 = info -> solution_ [ref -> Index ()];
00043 
00044   var -> getBounds (l,u);
00045                                  
00046   simpletriplet ft ((type == COU_SINE) ? (unary_function) sin    : (unary_function) cos, 
00047                     (type == COU_SINE) ? (unary_function) cos    : oppsin, 
00048                     (type == COU_SINE) ?                  oppsin : oppcos, 
00049                     (type == COU_SINE) ? (unary_function) acos   : oppasin);
00050 
00051   brpts  = (double *) realloc (brpts,    sizeof (double));
00052   brDist = (double *) realloc (brDist, 2*sizeof (double));
00053   *brpts = obj -> getBrPoint (&ft, x0, l, u);
00054 
00055   return (brDist [0] = brDist [1] = y0 - ((type == COU_SINE) ? sin(x0) : cos(x0)));
00056 }

Generated on Thu Aug 5 03:02:56 2010 by  doxygen 1.4.7