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