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

Go to the documentation of this file.
00001 /* $Id: branchExprSinCos.cpp 708 2011-06-23 14:04:59Z 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-11.
00008  * This file is licensed under the Eclipse Public License (EPL)
00009  */
00010 
00011 #include <math.h>
00012 
00013 #include "CouenneFunTriplets.hpp"
00014 #include "CouenneExprSin.hpp"
00015 #include "CouenneObject.hpp"
00016 #include "CouenneBranchingObject.hpp"
00017 
00018 namespace Couenne {
00019 
00020 static inline double oppcos  (double x) {return -cos (x);}
00021 static inline double oppsin  (double x) {return -sin (x);}
00022 static inline double oppasin (double x) {return asin (-x);}
00023 
00024 
00026 CouNumber trigSelBranch (const CouenneObject *obj, 
00027                          const OsiBranchingInformation *info,
00028                          expression *&var,
00029                          double * &brpts, 
00030                          double * &brDist, // distance of current LP
00031                                            // point to new convexifications
00032                          int &way,
00033                          enum cou_trig type) {
00034 
00035   exprVar *ref = obj -> Reference ();
00036 
00037   var = ref -> Image () -> Argument ();
00038 
00039   assert (var -> Index () >= 0);
00040   assert (ref -> Index () >= 0);
00041 
00042   CouNumber l, u,
00043     x0 = info -> solution_ [var -> Index ()],
00044     y0 = info -> solution_ [ref -> Index ()];
00045 
00046   var -> getBounds (l,u);
00047                                  
00048   simpletriplet ft ((type == COU_SINE) ? (unary_function) sin    : (unary_function) cos, 
00049                     (type == COU_SINE) ? (unary_function) cos    : oppsin, 
00050                     (type == COU_SINE) ?                  oppsin : oppcos, 
00051                     (type == COU_SINE) ? (unary_function) acos   : oppasin);
00052 
00053   brpts  = (double *) realloc (brpts,    sizeof (double));
00054   brDist = (double *) realloc (brDist, 2*sizeof (double));
00055   *brpts = obj -> getBrPoint (&ft, x0, l, u, info);
00056 
00057   return (brDist [0] = brDist [1] = y0 - ((type == COU_SINE) ? sin(x0) : cos(x0)));
00058 }
00059 
00060 }

Generated on Thu Nov 10 03:05:43 2011 by  doxygen 1.4.7