genRowCuts.cpp
Go to the documentation of this file.
1 /* $Id: genRowCuts.cpp 592 2011-06-01 10:40:25Z pbelotti $
2  *
3  * Name: genRowCuts.cpp
4  * Author: Pietro Belotti
5  * Purpose: generate Row Cuts for current convexification
6  *
7  * (C) Carnegie-Mellon University, 2006-09.
8  * This file is licensed under the Eclipse Public License (EPL)
9  */
10 
11 #include "CglCutGenerator.hpp"
12 #include "CouenneCutGenerator.hpp"
13 #include "CouenneProblem.hpp"
14 #include "CouenneExprVar.hpp"
15 
16 using namespace Couenne;
17 
19 void CouenneCutGenerator::genRowCuts (const OsiSolverInterface &si,
20  OsiCuts &cs,
21  int nchanged,
22  int *changed,
23  t_chg_bounds *chg) const {
24 
25  // TODO: make nchanged and changed useful
26  // TODO: pass have_NLP to all
27 
28  // For each auxiliary variable, create convexification cut (or set
29  // of cuts) and add it to cs
30 
31  // do NOT project current point into new bounding box! it prevents
32  // convexification cuts that are violated by current point
33 
34  /*for (int i=0, j = problem_ -> nVars (); j--; i++) {
35 
36  CouNumber &x = problem_ -> X (i),
37  lb = problem_ -> Lb (i),
38  ub = problem_ -> Ub (i);
39 
40  if (x < lb) x = lb;
41  else if (x > ub) x = ub;
42  }*/
43 
44  if (firstcall_)
45  for (int i=0, j = problem_ -> nVars (); j--; i++) {
46 
47  if (CoinCpuTime () > problem_ -> getMaxCpuTime ())
48  break;
49 
50  exprVar *var = problem_ -> Var (i);
51 
52  if ((var -> Multiplicity () > 0) &&
53  (var -> Type () == AUX)) {
54 
55  var -> generateCuts (cs, this, chg);
56  }
57  }
58  else { // chg_bds contains the indices of the variables whose bounds
59  // have changed (a -1 follows the last element)
60 
61  for (int i = 0, j = problem_ -> nVars (); j--; i++) {
62 
63  // TODO: check if list contains all and only aux's to cut
64 
65  /*expression * image = problem_ -> Aux (i) -> Image ();
66 
67  if ((image -> dependsOn (changed, nchanged)) &&
68  (image -> Linearity () > LINEAR)) {
69  printf (" ");
70  problem_ -> Aux (i) -> print ();
71  printf (" : = ");
72  image -> print ();
73  printf ("\n");
74  }
75  */
76  // cut only if:
77 
78  /*if ( (image -> Linearity () > LINEAR) // 1) expression is non linear
79  && (image -> dependsOn (changed, nchanged) // 2) it depends on changed variables
80  || have_NLP
81  || info.pass > 0)) {
82  */
83 
84  exprVar *var = problem_ -> Var (problem_ -> evalOrder (i));
85 
86  if ((var -> Type () == AUX) &&
87  (var -> Multiplicity () > 0) &&
88  (var -> Image () -> Linearity () > LINEAR)) {
89 
90  if (CoinCpuTime () > problem_ -> getMaxCpuTime ())
91  break;
92 
93  var -> generateCuts (cs, this, chg);
94  }
95  }
96  }
97 }
bool firstcall_
True if no convexification cuts have been generated yet for this problem.
status of lower/upper bound of a variable, to be checked/modified in bound tightening ...
static char * j
Definition: OSdtoa.cpp:3622
void genRowCuts(const OsiSolverInterface &, OsiCuts &cs, int, int *, t_chg_bounds *=NULL) const
generate OsiRowCuts for current convexification
Definition: genRowCuts.cpp:19
CouenneProblem * problem_
pointer to symbolic repr. of constraint, variables, and bounds
variable-type operator
void generateCuts(const OsiSolverInterface &, OsiCuts &, const CglTreeInfo=CglTreeInfo()) const
the main CglCutGenerator