source: branches/Couenne/Couenne/src/convex/operators/conv-exprLog.cpp @ 525

Last change on this file since 525 was 525, checked in by pbelotti, 13 years ago

implied bounds: fix some of the infinity handling

File size: 1.6 KB
Line 
1/*
2 * Name:    conv-exprLog.cpp
3 * Author:  Pietro Belotti
4 * Purpose: convexification and bounding methods for the logarithm operator
5 *
6 * This file is licensed under the Common Public License (CPL)
7 */
8
9#include <CouenneTypes.h>
10#include <exprLog.h>
11#include <exprInv.h>
12#include <exprPow.h>
13#include <exprConst.h>
14
15#include <CouenneProblem.h>
16#include <CouenneCutGenerator.h>
17
18
19#define LOG_STEP 10
20#define LOG_MININF 1e-50
21
22// generate convexification cut for constraint w = this
23
24void exprLog::generateCuts (exprAux *aux, const OsiSolverInterface &si, 
25                            OsiCuts &cs, const CouenneCutGenerator *cg) {
26
27  expression *le, *ue;
28
29  argument_ -> getBounds (le, ue);
30
31  CouNumber x = (cg -> isFirst ()) ? 
32                 1 : powNewton ((*argument_) (), (*aux) (), log, inv, oppInvSqr),
33            l = (*le) (),
34            u = (*ue) ();
35
36  int w_ind = aux       -> Index ();
37  int x_ind = argument_ -> Index ();
38
39  // fix lower bound
40
41  if (l < LOG_MININF) l = LOG_MININF;
42  else   // lower segment (only put if lower bound is far enough from
43         // zero and upper is finite)
44    if (u < COUENNE_INFINITY - 1) { 
45
46      CouNumber dx   = u-l;
47      CouNumber logu = log (u);
48      CouNumber dw   = logu - log (l);
49
50      cg -> createCut (cs, dx*logu - u*dw, +1, w_ind, dx, x_ind, -dw);
51    }
52
53  // fix bound interval (unless you like infinite coefficients)
54
55  if      (x < l) x = l;
56  else if (x > u) x = u;
57
58  if (u > 1e5 * log (COUENNE_INFINITY) - 1)
59    u = x + (LOG_STEP << cg -> nSamples ());
60
61  // add upper envelope
62
63  cg -> addEnvelope (cs, -1, log, inv, w_ind, x_ind, x, l, u, true);
64
65  delete le;
66  delete ue;
67}
Note: See TracBrowser for help on using the repository browser.