conv-exprSub.cpp
Go to the documentation of this file.
1 /* $Id: conv-exprSub.cpp 490 2011-01-14 16:07:12Z pbelotti $
2  *
3  * Name: exprSub.cpp
4  * Author: Pietro Belotti
5  * Purpose: convexification methods for the Subtraction class
6  *
7  * (C) Carnegie-Mellon University, 2006-10.
8  * This file is licensed under the Eclipse Public License (EPL)
9  */
10 
11 #include "CouenneCutGenerator.hpp"
12 
13 #include "CouenneTypes.hpp"
14 #include "CouenneExprSub.hpp"
15 #include "CouenneExprOpp.hpp"
16 #include "CouenneExprAux.hpp"
17 
18 using namespace Couenne;
19 
20 // generate equality between *this and *w
21 void exprSub::generateCuts (expression *w, //const OsiSolverInterface &si,
22  OsiCuts &cs, const CouenneCutGenerator *cg,
23  t_chg_bounds *chg,
24  int wind, CouNumber lb, CouNumber ub) {
25 
26  if (!(cg -> isFirst ()))
27  return;
28 
29  // only add one cut at the beginning
30 
31  expression *x = arglist_ [0];
32  expression *y = arglist_ [1];
33 
34  int wi = w -> Index ();
35  int xi = x -> Index ();
36  int yi = y -> Index ();
37 
38  // If this aux is fixed, don't write
39  //
40  // "- w + ax = -b" but just
41  //
42  // "ax = -b+ w0"
43  //
44  // with w0 its constant value
45 
46  CouNumber vlb, vub;
47  w -> getBounds (vlb, vub);
48  bool uselessAux = (vub < vlb + COUENNE_EPS);
49 
50  // TODO: generalize to sign!= ::EQ
51 
52  if ((wind >= 0) || uselessAux) {
53  wi = -1; // do not insert w's index if specified as input
54  lb = ub = vlb;
55  }
56  else lb = ub = 0;
57 
58  if (xi < 0) {
59  CouNumber x0 = x -> Value ();
60  lb -= x0;
61  ub -= x0;
62  }
63 
64  if (yi < 0) {
65  CouNumber y0 = y -> Value ();
66  lb += y0;
67  ub += y0;
68  }
69 
70  enum auxSign sign = cg -> Problem () -> Var (w -> Index ()) -> sign ();
71 
72  if (sign == expression::AUX_GEQ) lb = -COIN_DBL_MAX;
73  else if (sign == expression::AUX_LEQ) ub = COIN_DBL_MAX;
74 
75  cg -> createCut (cs, lb, ub, wi, -1., xi, 1., yi, -1., true);
76 }
Cut Generator for linear convexifications.
status of lower/upper bound of a variable, to be checked/modified in bound tightening ...
virtual void generateCuts(expression *, OsiCuts &, const CouenneCutGenerator *, t_chg_bounds *=NULL, int=-1, CouNumber=-COUENNE_INFINITY, CouNumber=COUENNE_INFINITY)
Special version for linear constraints.
ULong * x0
Definition: OSdtoa.cpp:1776
virtual int Index() const
Return index of variable (only valid for exprVar and exprAux)
auxSign
&quot;sign&quot; of the constraint defining an auxiliary.
#define COUENNE_EPS
expression ** arglist_
argument list is an array of pointers to other expressions
void getBounds(expression *&, expression *&)
Get lower and upper bound of an expression (if any)
Definition: exprSub.cpp:89
double CouNumber
main number type in Couenne
Expression base class.
void fint fint fint real fint real real real real real real real real * w
virtual CouNumber Value() const
value (empty)
void fint fint fint real fint real * x