conv-exprOpp.cpp
Go to the documentation of this file.
1 /* $Id: conv-exprOpp.cpp 490 2011-01-14 16:07:12Z pbelotti $
2  *
3  * Name: conv-exprOpp.cpp
4  * Author: Pietro Belotti
5  * Purpose: methods to convexify opposite of expressions
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 "CouenneExprOpp.hpp"
15 #include "CouenneExprConst.hpp"
16 #include "CouenneExprVar.hpp"
17 
18 #include "CouenneProblem.hpp"
19 
20 using namespace Couenne;
21 
22 // generate equality between *this and *w
23 void exprOpp::generateCuts (expression *w, //const OsiSolverInterface &si,
24  OsiCuts &cs, const CouenneCutGenerator *cg,
25  t_chg_bounds *chg,
26  int wind, CouNumber lb, CouNumber ub) {
27 
28  // If wind = -1 then this is the normal procedure (see below,
29  // "easy..."). Otherwise, there is a constraint of the form -x <= b
30  // that was translated into auxiliary w = -x and w <= b. wind is w's
31  // index (which we have to single out)
32 
33  if (wind >= 0) {
34 
35  int xind = argument_ -> Index ();
36 
37  if (xind < 0) {
38  printf ("#### invalid index for exprOpp::gencuts()\n");
39  exit (-1);
40  }
41 
42  OsiColCut *cut = new OsiColCut;
43 
44  CouNumber
45  &xlb = cg -> Problem () -> Lb (xind),
46  &xub = cg -> Problem () -> Ub (xind);
47 
48  if (-ub > xlb) xlb = -ub;
49  if (-lb < xub) xub = -lb;
50 
51  cut -> setLbs (1, &xind, &xlb);
52  cut -> setUbs (1, &xind, &xub);
53 
54  cs.insert (cut);
55 
56  delete (cut);
57  }
58  else // easy...
59 
60  if (cg -> isFirst ()) {
61 
62  int wi = w -> Index ();
63  cg -> createCut (cs, 0., cg -> Problem () -> Var (wi) -> sign (), wi, 1., argument_->Index (), 1.);
64  }
65 }
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
expression * argument_
single argument taken by this expression
virtual int Index() const
Return index of variable (only valid for exprVar and exprAux)
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