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

Go to the documentation of this file.
00001 /* $Id: branchExprAbs.cpp 141 2009-06-03 04:19:19Z pbelotti $ */
00002 /*
00003  * Name:    branchExprAbs.cpp
00004  * Author:  Pietro Belotti
00005  * Purpose: return branch suggestion for exprAbs
00006  *
00007  * (C) Carnegie-Mellon University, 2006-07.
00008  * This file is licensed under the Common Public License (CPL)
00009  */
00010 
00011 #include <math.h>
00012 
00013 #include "CoinHelperFunctions.hpp"
00014 #include "exprAbs.hpp"
00015 #include "CouenneObject.hpp"
00016 
00017 static const double sqrt_2 = sqrt (2.);
00018 
00021 CouNumber exprAbs::selectBranch (const CouenneObject *obj,
00022                                  const OsiBranchingInformation *info,
00023                                  expression * &var,
00024                                  double * &brpts,
00025                                  double * &brDist, // distance of current LP
00026                                                    // point to new convexifications
00027                                  int &way) {
00028   var = argument_;
00029 
00030   int ind = var -> Index ();
00031 
00032   assert ((ind >= 0) && (obj -> Reference () -> Index () >= 0));
00033 
00034   CouNumber x0 = info -> solution_ [ind],
00035             y0 = info -> solution_ [obj -> Reference () -> Index ()];
00036 
00037   brpts = (double *) realloc (brpts, sizeof (double));
00038 
00039   // the best branching point for |x| is 0, as the two subproblems
00040   // will have exact convexifications (lines)
00041   *brpts = 0.;
00042 
00043   way = TWO_RAND; // don't care which subtree to visit first
00044 
00045   // no need to compute two distances for pseudocost, as this object
00046   // will only branch once...
00047 
00048   brDist = (double *) realloc (brDist, 2 * sizeof (double));
00049 
00050   assert ((y0 >= x0) && (y0 >= -x0));
00051 
00052   brDist [0] = (x0 + y0) / sqrt_2;
00053   brDist [1] = (y0 - x0) / sqrt_2;
00054 
00055   // exact distance between current point and the two subsequent
00056   // convexifications
00057   return CoinMin (brDist [0], brDist [1]);
00058 }

Generated on Thu Aug 5 03:02:56 2010 by  doxygen 1.4.7