source: branches/Couenne/Couenne/src/convex/operators/conv-exprDiv.cpp @ 480

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

fixed exprPow::standardize. Introduced better convexification for expr{Sin,Cos}.

File size: 2.1 KB
Line 
1/*
2 * Name:    conv-exprDiv.cpp
3 * Author:  Pietro Belotti
4 * Purpose: standardization and convexification methods for divisions
5 *
6 * This file is licensed under the Common Public License (CPL)
7 */
8
9#include <CouenneTypes.h>
10#include <exprOp.h>
11#include <exprDiv.h>
12#include <exprClone.h>
13#include <exprMul.h>
14#include <CouenneProblem.h>
15#include <CouenneCutGenerator.h>
16
17// Create standard formulation of this expression
18exprAux *exprDiv::standardize (CouenneProblem *p) {
19
20  exprOp::standardize (p);
21  return p -> addAuxiliary (this);
22}
23
24
25// generate convexification cut for constraint w = x/y
26
27void exprDiv::generateCuts (exprAux *w, const OsiSolverInterface &si, 
28                            OsiCuts &cs, const CouenneCutGenerator *cg) {
29
30  // TODO: Use method on Tawarmalani-Sahinidis //////////////////////////////
31
32  // get bounds of numerator and denominator
33
34  expression *yle, *yue;
35
36  arglist_ [1] -> getBounds (yle, yue);
37
38  CouNumber yl = (*yle) (), 
39            yu = (*yue) ();
40
41  // if the denominator's bound interval has 0 as internal point,
42  // there is no convexification
43
44  if ((yl < - COUENNE_EPS) && 
45      (yu >   COUENNE_EPS)) 
46    return;
47
48  expression *xle, *xue, *wle, *wue;
49
50  arglist_ [0] -> getBounds (xle, xue);
51  w            -> getBounds (wle, wue);
52
53  expression *xe = arglist_ [0];
54  expression *ye = arglist_ [1];
55
56  CouNumber wl = (*wle) (), wu = (*wue) ();
57
58  delete yle; delete yue;
59  delete wle; delete wue;
60  delete xle; delete xue;
61
62  // Add McCormick convexification cuts. Reduce w = x/y to x = wy and
63  // apply the same rule as for multiplications:
64  //
65  // 1) x >= yl w + wl y - yl wl
66  // 2) x >= yu w + wu y - yu wu
67  //
68  // 3) x <= yl w + wu y - yl wu
69  // 4) x <= yu w + wl y - yu wl
70
71  int xi = xe -> Index (),
72      wi = w  -> Index (),
73      yi = ye -> Index ();
74
75  if (is_boundbox_regular (yl, wl)) cg -> createCut (cs, yl*wl, -1, xi, -1., wi, yl, yi, wl);
76  if (is_boundbox_regular (yu, wu)) cg -> createCut (cs, yu*wu, -1, xi, -1., wi, yu, yi, wu);
77  if (is_boundbox_regular (yl, wu)) cg -> createCut (cs, yl*wu, +1, xi, -1., wi, yl, yi, wu);
78  if (is_boundbox_regular (yu, wl)) cg -> createCut (cs, yu*wl, +1, xi, -1., wi, yu, yi, wl);
79}
Note: See TracBrowser for help on using the repository browser.