00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "CoinHelperFunctions.hpp"
00012
00013 #include "exprExp.hpp"
00014 #include "CouenneObject.hpp"
00015 #include "CouenneBranchingObject.hpp"
00016 #include "projections.hpp"
00017 #include "funtriplets.hpp"
00018
00019
00022 CouNumber exprExp::selectBranch (const CouenneObject *obj,
00023 const OsiBranchingInformation *info,
00024 expression *&var,
00025 double * &brpts,
00026 double * &brDist,
00027
00028 int &way) {
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 var = argument_;
00046
00047 brDist = (double *) realloc (brDist, 2 * sizeof (double));
00048 brpts = (double *) realloc (brpts, sizeof (double));
00049
00050 int
00051 ind = var -> Index (),
00052 wi = obj -> Reference () -> Index ();
00053
00054 assert ((ind >= 0) && (wi >= 0));
00055
00056 CouNumber y0 = info -> solution_ [wi],
00057 x0 = info -> solution_ [ind],
00058 l = info -> lower_ [ind],
00059 u = info -> upper_ [ind];
00060
00061
00062
00063 if (y0 < exp (x0)) {
00064
00065
00066
00067
00068 *brpts = obj -> midInterval (powNewton (x0, y0, exp, exp, exp), l, u);
00069
00070 way = TWO_RAND;
00071
00072 y0 -= exp (*brpts);
00073 x0 -= *brpts;
00074
00075 return sqrt (brDist [0] = brDist [1] = sqrt (x0*x0 + y0*y0));
00076 }
00077
00078
00079
00080 if ((l < -COUENNE_INFINITY) &&
00081 (u > COUENNE_INFINITY)) {
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098 *brpts = 0.5 * (x0 + log (y0));
00099 way = TWO_RAND;
00100
00101 return CoinMin (brDist [0] = log (y0) - x0,
00102 brDist [1] = y0 - exp (x0));
00103 }
00104
00105
00106
00107 if (l < - COUENNE_INFINITY) {
00108
00109 *brpts = obj -> midInterval (x0, l, u);
00110
00111 way = TWO_RIGHT;
00112 return CoinMin (brDist [0] = y0 - exp (x0),
00113 brDist [1] = projectSeg (x0, y0, *brpts, exp (*brpts), u, exp (u), -1));
00114 }
00115
00116 if (u > COUENNE_INFINITY) {
00117
00118 *brpts = obj -> midInterval (log (y0), l, u);
00119
00120 way = TWO_LEFT;
00121 return CoinMin (brDist [0] = projectSeg (x0, y0, l, exp (l), *brpts, exp (*brpts), -1),
00122 brDist [1] = log (y0) - x0);
00123
00124 }
00125
00126
00127
00128 simpletriplet ft (exp, exp, exp, log);
00129 *brpts = obj -> getBrPoint (&ft, x0, l, u);
00130
00131 way = TWO_RAND;
00132
00133
00134 return CoinMin (brDist [0] = projectSeg (x0, y0, l, exp (l), *brpts, exp (*brpts), -1),
00135 brDist [1] = projectSeg (x0, y0, *brpts, exp (*brpts), u, exp (u), -1));
00136 }