00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include <math.h>
00012
00013
00014 #ifndef M_SQRT2l
00015 #define M_SQRT2l (sqrt (2.))
00016 #endif
00017
00018 #include "CoinHelperFunctions.hpp"
00019 #include "CouenneExprAbs.hpp"
00020 #include "CouenneObject.hpp"
00021
00022 using namespace Couenne;
00023
00024
00025
00028 CouNumber exprAbs::selectBranch (const CouenneObject *obj,
00029 const OsiBranchingInformation *info,
00030 expression * &var,
00031 double * &brpts,
00032 double * &brDist,
00033
00034 int &way) {
00035 var = argument_;
00036
00037 int ind = var -> Index ();
00038
00039 assert ((ind >= 0) && (obj -> Reference () -> Index () >= 0));
00040
00041 CouNumber x0 = info -> solution_ [ind],
00042 y0 = info -> solution_ [obj -> Reference () -> Index ()];
00043
00044 brpts = (double *) realloc (brpts, sizeof (double));
00045
00046
00047
00048 *brpts = 0.;
00049
00050 way = TWO_RAND;
00051
00052
00053
00054
00055 brDist = (double *) realloc (brDist, 2 * sizeof (double));
00056
00057 assert ((y0 >= x0 - COUENNE_EPS) &&
00058 (y0 >= -x0 - COUENNE_EPS));
00059
00060 brDist [0] = (x0 + y0) / M_SQRT2l;
00061 brDist [1] = (y0 - x0) / M_SQRT2l;
00062
00063
00064
00065 return CoinMin (brDist [0], brDist [1]);
00066 }