branchExprAbs.cpp
Go to the documentation of this file.
1 /* $Id: branchExprAbs.cpp 712 2011-06-25 11:26:01Z pbelotti $
2  *
3  * Name: branchExprAbs.cpp
4  * Author: Pietro Belotti
5  * Purpose: return branch suggestion for exprAbs
6  *
7  * (C) Carnegie-Mellon University, 2006-11.
8  * This file is licensed under the Eclipse Public License (EPL)
9  */
10 
11 #include <math.h>
12 
13 // apparently unknown to OS
14 #ifndef M_SQRT2l
15 #define M_SQRT2l (sqrt (2.))
16 #endif
17 
18 #include "CoinHelperFunctions.hpp"
19 #include "CouenneExprAbs.hpp"
20 #include "CouenneObject.hpp"
21 
22 using namespace Couenne;
23 
24 //static const double sqrt_2 = sqrt (2.);
25 
29  const OsiBranchingInformation *info,
30  expression * &var,
31  double * &brpts,
32  double * &brDist, // distance of current LP
33  // point to new convexifications
34  int &way) {
35  var = argument_;
36 
37  int ind = var -> Index ();
38 
39  assert ((ind >= 0) && (obj -> Reference () -> Index () >= 0));
40 
41  CouNumber x0 = info -> solution_ [ind],
42  y0 = info -> solution_ [obj -> Reference () -> Index ()];
43 
44  brpts = (double *) realloc (brpts, sizeof (double));
45 
46  // the best branching point for |x| is 0, as the two subproblems
47  // will have exact convexifications (lines)
48  *brpts = 0.;
49 
50  way = TWO_RAND; // don't care which subtree to visit first
51 
52  // no need to compute two distances for pseudocost, as this object
53  // will only branch once...
54 
55  brDist = (double *) realloc (brDist, 2 * sizeof (double));
56 
57  assert ((y0 >= x0 - COUENNE_EPS) &&
58  (y0 >= -x0 - COUENNE_EPS));
59 
60  brDist [0] = (x0 + y0) / M_SQRT2l;
61  brDist [1] = (y0 - x0) / M_SQRT2l;
62 
63  // exact distance between current point and the two subsequent
64  // convexifications
65  return CoinMin (brDist [0], brDist [1]);
66 }
#define M_SQRT2l
void fint fint fint real fint real real real real real real real real real fint real fint fint fint real fint fint fint fint * info
OsiObject for auxiliary variables $w=f(x)$.
virtual CouNumber selectBranch(const CouenneObject *obj, const OsiBranchingInformation *info, expression *&var, double *&brpts, double *&brDist, int &way)
set up branching object by evaluating many branching points for each expression&#39;s arguments ...
expression * argument_
single argument taken by this expression
ULong * x0
Definition: OSdtoa.cpp:1776
virtual int Index() const
Return index of variable (only valid for exprVar and exprAux)
#define COUENNE_EPS
double CouNumber
main number type in Couenne
Expression base class.