# source:trunk/Couenne/src/problem/fillDependence.cpp@39

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

Merging some of the latest changes from Bonmin/branches/Couenne: added Complementarity objects, disjunctive cuts, SOS (these don't work yet). Fixed some output. Improved cut-optimum checking. Sparser initial problem by replacing constraints ax-b>=0, w=ax-b with equivalent w>=0, w=ax-b. Fixed some bugs in new getBounds.

File size: 1.9 KB
Line
1/*
2 * Name:    fillDependence.cpp
3 * Author:  Pietro Belotti
4 * Purpose: fill in inverse dependence structure, for CouenneObject
5 *
6 * (C) Carnegie-Mellon University, 2008.
8 */
9
10#include <vector>
11#include <set>
12
13#include "CouenneProblem.hpp"
14
15
16/// fill in inverse dependence structure: for each variable x give set
17/// of auxiliary variables (or better, their indices) whose expression
18/// depends on x
19
20void CouenneProblem::fillDependence (Bonmin::BabSetupBase *base) {
21
22  // initialize vector of empty sets
23  for (int i=nVars (); i--;)
24    dependence_.push_back (std::set <int> ());
25
26  // empty object to fill space for linear-defined auxiliaries and for
27  // originals
28  CouenneObject nullObject;
29
30  for (std::vector <exprVar *>::iterator i = variables_.begin ();
31       i != variables_.end (); ++i) {
32
33    if (((*i) -> Type () == AUX)                           // consider auxs only
34        && ((*i) -> Image () -> Linearity () > LINEAR)) {  // and nonlinear
35
36      CouenneObject *infeasObj = (*i) -> properObject (this, base, jnlst_);
37
38      if (!infeasObj) // found something that will never be infeasibl
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 (nullObject));
61    // null object for original and linear auxiliaries
62  }
63}
Note: See TracBrowser for help on using the repository browser.