source: stable/0.2/Couenne/src/problem/fillDependence.cpp @ 159

Last change on this file since 159 was 159, checked in by pbelotti, 11 years ago

created new stable branch 0.2 from trunk (rev. 157)

File size: 1.9 KB
Line 
1/* $Id: fillDependence.cpp 157 2009-06-16 20:31:49Z 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.
8 * This file is licensed under the Common Public License (CPL)
9 */
10
11#include <vector>
12#include <set>
13
14#include "CouenneProblem.hpp"
15
16
17/// fill in inverse dependence structure: for each variable x give set
18/// of auxiliary variables (or better, their indices) whose expression
19/// depends on x
20
21void CouenneProblem::fillDependence (Bonmin::BabSetupBase *base) {
22
23  // initialize vector of empty sets
24  for (int i=nVars (); i--;)
25    dependence_.push_back (std::set <int> ());
26
27  // empty object to fill space for linear-defined auxiliaries and for
28  // originals
29  CouenneObject nullObject;
30
31  for (std::vector <exprVar *>::iterator i = variables_.begin (); 
32       i != variables_.end (); ++i) {
33
34    if (((*i) -> Type () == AUX)                           // consider auxs only
35        && ((*i) -> Image () -> Linearity () > LINEAR)) {  // and nonlinear
36
37      CouenneObject infeasObj = (*i) -> properObject (this, base, jnlst_);
38
39      if (!(infeasObj.Reference ())) // found something that will never be infeasible
40        continue;
41
42      // add object for this variable
43      objects_.push_back (infeasObj);
44
45      std::set <int> deplist;
46
47      // fill the set of independent variables on which the expression
48      // associated with *i depends; if empty (should not happen...), skip
49      if ((*i) -> Image () -> DepList (deplist, STOP_AT_AUX) == 0)
50        continue;
51
52      // build dependence set for this variable
53      for (std::set <int>::iterator j = deplist.begin (); j != deplist.end (); ++j) {
54
55        std::set <int> &obj = dependence_ [*j];
56        int ind = (*i) -> Index ();
57        if (obj.find (ind) == obj.end ())
58          obj.insert (ind);
59      }
60
61    } else objects_.push_back (nullObject); 
62    // null object for original and linear auxiliaries
63  }
64}
Note: See TracBrowser for help on using the repository browser.