11 #include "CoinHelperFunctions.hpp"
19 using namespace Couenne;
23 const OsiBranchingInformation *
info,
36 const OsiBranchingInformation *
info,
50 wi = obj -> Reference () ->
Index ();
57 x0 = info -> solution_ [ind],
58 l = info -> lower_ [ind],
59 u = info -> upper_ [ind];
68 else if (x0 > u) x0 = u;
75 brDist = (
double *) realloc (brDist, 2 *
sizeof (
double));
84 brDist = (
double *) realloc (brDist, 2 *
sizeof (
double));
98 if (y0 < pow (x0, k)) {
100 brpts = (
double *) realloc (brpts,
sizeof (
double));
107 y0 -= pow (*brpts, k);
109 return (brDist [0] = brDist [1] = sqrt (x0*x0 + y0*y0));
133 brpts = (
double *) realloc (brpts,
sizeof (
double));
137 return (brDist [0] = brDist [1] = fabs (y0 - pow (x0,k)));
158 brpts = (
double *) realloc (brpts,
sizeof (
double));
168 return CoinMin (brDist [0] = x0 - *brpts,
184 return CoinMin (brDist [1] = *brpts - x0,
195 *brpts = obj -> getBrPoint (&ft, x0, l, u, info);
208 CoinMin (brDist [0] =
projectSeg (x0, y0, l,
safe_pow (l, k,
issignpower_), *brpts,
safe_pow (*brpts, k,
issignpower_), 0),
209 brDist [1] =
projectSeg (x0, y0, *brpts,
safe_pow (*brpts, k,
issignpower_), u,
safe_pow (u, k,
issignpower_), 0));
227 brpts = (
double *) realloc (brpts,
sizeof (
double));
241 if (((y0 > 0) && (y0 < pow0)) ||
242 ((y0 < 0) && (y0 > pow0))) {
245 return (brDist [0] = brDist [1] = fabs (pow0 - y0));
251 return (brDist [0] = brDist [1] = (y0 > 0) ?
252 projectSeg (x0, y0, x0, CoinMax (pow0, 0.), *brpts, y0, 0) :
253 projectSeg (x0, y0, x0, CoinMin (pow0, 0.), *brpts, y0, 0));
261 *brpts = obj -> getBrPoint (&pt, x0, l, u, info);
272 brDist [1] = sqrt (brDist [0] * brDist [0] + (x0 - *brpts) * (x0 - *brpts));
277 brDist [0] = sqrt (brDist [1] * brDist [1] + (x0 - *brpts) * (x0 - *brpts));
301 if (((x0 > 0.) && (y0 > pow0)) ||
302 ((x0 < 0.) && (y0 < pow0))) {
307 return (brDist [0] = brDist [1] = fabs (pow0 - y0));
315 return (brDist [0] = brDist [1] = (x0 > 0) ?
316 projectSeg (x0,y0,x0, pow0, CoinMax (0., pow (y0, 1./k)), y0, 0) :
317 projectSeg (x0,y0,x0, pow0, CoinMin (0., pow (y0, 1./k)), y0, 0));
325 *brpts = obj -> getBrPoint (&pt, x0, l, u, info);
330 if (y0 > pow0) *brpts = -*brpts;
331 else if (y0 < pow0) *brpts = -*brpts;
335 brDist [0] = y0 -
safe_pow (*brpts, k);
336 brDist [1] = sqrt (brDist [0] * brDist [0] + (x0 - *brpts) * (x0 - *brpts));
340 brDist [1] = y0 -
safe_pow (*brpts, k);
341 brDist [0] = sqrt (brDist [1] * brDist [1] + (x0 - *brpts) * (x0 - *brpts));
344 return CoinMax (brDist [0], brDist [1]);
364 y0 -= pow (*brpts, k);
366 return (brDist [0] = brDist [1] = sqrt (x0*x0 + y0*y0));
375 *brpts = 0.5 * (x0 + pow (y0, 1. / k));
378 *brpts = obj -> getBrPoint (&pt, x0, l, u, info);
390 CoinMin (projL, *brpts - x0) :
391 CoinMin (projL,
projectSeg (x0,y0, *brpts, powbpt, u, pow(u,k), -1)));
403 *brpts = 0.5 * (x0 + pow (y0, 1. / k));
406 *brpts = obj -> getBrPoint (&pt, x0, l, u, info);
415 powbpt = pow (*brpts, k),
416 projL =
projectSeg (x0, y0, l, pow (l, k), *brpts, powbpt, +1);
419 CoinMin (projL, powbpt - y0) :
420 CoinMin (projL,
projectSeg (x0, y0, *brpts, powbpt, u, pow (u,k), +1)));
430 y0 -= pow (*brpts, k);
432 return (brDist [0] = brDist [1] = sqrt (x0*x0 + y0*y0));
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's arguments ...
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)$.
CouNumber negPowSelectBranch(const CouenneObject *obj, const OsiBranchingInformation *info, double *&brpts, double *&brDist, int &way, CouNumber k, CouNumber x0, CouNumber y0, CouNumber l, CouNumber u)
generic approach for negative powers (commom with exprInv::selectBranch())
CouNumber powNewton(CouNumber xc, CouNumber yc, unary_function f, unary_function fp, unary_function fpp)
find proper tangent point to add deepest tangent cut
virtual enum nodeType Type() const
Node type.
virtual int Index() const
Return index of variable (only valid for exprVar and exprAux)
bool issignpower_
do we mean a signed power function: sign(arg0) * |arg0|^arg1 (assumes that arg1 is constant) ...
CouNumber projectSeg(CouNumber x0, CouNumber y0, CouNumber x1, CouNumber y1, CouNumber x2, CouNumber y2, int sign, CouNumber *xp=NULL, CouNumber *yp=NULL)
Compute projection of point (x0, y0) on the segment defined by two points (x1,y1), (x2, y2) – sign provided by parameter sign.
expression ** arglist_
argument list is an array of pointers to other expressions
double CouNumber
main number type in Couenne
CouNumber safe_pow(CouNumber base, CouNumber exponent, bool signpower=false)
compute power and check for integer-and-odd inverse exponent
virtual CouNumber Value() const
value (empty)