00001
00002
00003
00004
00005
00006
00007
00008
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,
00031
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 }