fillDependence.cpp
Go to the documentation of this file.
1 /* $Id: fillDependence.cpp 1080 2014-10-30 20:06:40Z pbelotti $
2  *
3  * Name: fillDependence.cpp
4  * Author: Pietro Belotti
5  * Purpose: fill in inverse dependence structure, for CouenneObject
6  *
7  * (C) Carnegie-Mellon University, 2008-09.
8  * This file is licensed under the Eclipse Public License (EPL)
9  */
10 
11 #include <vector>
12 #include <set>
13 
14 #include "CouenneObject.hpp"
15 #include "CouenneProblem.hpp"
16 
17 using namespace Couenne;
18 
22 
24 
25  // initialize vector of empty sets
26  for (int i=nVars (); i--;)
27  dependence_.push_back (std::set <int> ());
28 
29  for (std::vector <exprVar *>::iterator i = variables_.begin ();
30  i != variables_.end (); ++i) {
31 
32  if (((*i) -> Type () == AUX) // consider auxs only
33  && ((*i) -> Multiplicity () > 0)
34  && ((*i) -> Image () -> Linearity () > LINEAR)) { // and nonlinear
35 
36  CouenneObject *infeasObj = (*i) -> properObject (cg, this, base, jnlst_);
37 
38  if (!(infeasObj -> Reference ())) // found something that will never be infeasible
39  continue;
40 
41  // add object for this variable
42  objects_.push_back (infeasObj);
43 
44  std::set <int> deplist;
45 
46  // fill the set of independent variables on which the expression
47  // associated with *i depends; if empty (should not happen...), skip
48  if ((*i) -> Image () -> DepList (deplist, STOP_AT_AUX) == 0)
49  continue;
50 
51  // build dependence set for this variable
52  for (std::set <int>::iterator j = deplist.begin (); j != deplist.end (); ++j) {
53 
54  std::set <int> &obj = dependence_ [*j];
55  int ind = (*i) -> Index ();
56  if (obj.find (ind) == obj.end ())
57  obj.insert (ind);
58  }
59 
60  } else objects_.push_back (new CouenneObject ());
61  // null object for original and linear auxiliaries
62  }
63 }
Cut Generator for linear convexifications.
int nVars() const
Total number of variables.
OsiObject for auxiliary variables $w=f(x)$.
std::vector< std::set< int > > dependence_
inverse dependence structure: for each variable x give set of auxiliary variables (or better...
static char * j
Definition: OSdtoa.cpp:3622
std::vector< CouenneObject * > objects_
vector of pointer to CouenneObjects.
A class to have all elements necessary to setup a branch-and-bound.
std::vector< exprVar * > variables_
Variables (original, auxiliary, and defined)
JnlstPtr jnlst_
SmartPointer to the Journalist.
void fillDependence(Bonmin::BabSetupBase *base, CouenneCutGenerator *=NULL)
fill dependence_ structure