/home/coin/SVN-release/OS-2.4.0/Couenne/src/branch/operators/branchExprAbs.cpp

Go to the documentation of this file.
00001 /* $Id: branchExprAbs.cpp 712 2011-06-25 11:26:01Z pbelotti $
00002  *
00003  * Name:    branchExprAbs.cpp
00004  * Author:  Pietro Belotti
00005  * Purpose: return branch suggestion for exprAbs
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 // apparently unknown to OS
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 //static const double sqrt_2 = sqrt (2.);
00025 
00028 CouNumber exprAbs::selectBranch (const CouenneObject *obj,
00029                                  const OsiBranchingInformation *info,
00030                                  expression * &var,
00031                                  double * &brpts,
00032                                  double * &brDist, // distance of current LP
00033                                                    // point to new convexifications
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   // the best branching point for |x| is 0, as the two subproblems
00047   // will have exact convexifications (lines)
00048   *brpts = 0.;
00049 
00050   way = TWO_RAND; // don't care which subtree to visit first
00051 
00052   // no need to compute two distances for pseudocost, as this object
00053   // will only branch once...
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   // exact distance between current point and the two subsequent
00064   // convexifications
00065   return CoinMin (brDist [0], brDist [1]);
00066 }

Generated on Thu Sep 22 03:05:56 2011 by  doxygen 1.4.7