updateBranchInfo.cpp
Go to the documentation of this file.
1 /* $Id: updateBranchInfo.cpp 490 2011-01-14 16:07:12Z pbelotti $
2  *
3  * Name: updateBranchInfo.cpp
4  * Author: Pietro Belotti
5  * Purpose: get new bounds from parents' bounds + branching rules
6  *
7  * (C) Carnegie-Mellon University, 2006.
8  * This file is licensed under the Eclipse Public License (EPL)
9  */
10 
11 #include "CglCutGenerator.hpp"
12 #include "CouenneTypes.hpp"
13 #include "CouenneProblem.hpp"
14 #include "BonAuxInfos.hpp"
15 
16 namespace Couenne {
17 
18  //#define DEBUG
19 
21 void updateBranchInfo (const OsiSolverInterface &si, CouenneProblem *p,
22  t_chg_bounds *chg_bds, const CglTreeInfo &info) {
23 
24  int ncols = p -> nVars ();
25 
26  if ((info.inTree) && (info.pass==0)) {
27 
28  // We are anywhere in the B&B tree but at the root node. Check,
29  // through the auxiliary information, which bounds have changed
30  // from the parent node.
31 
32  OsiBabSolver *auxinfo = dynamic_cast <OsiBabSolver *> (si.getAuxiliaryInfo ());
33 
34  bool
35  have_parent_lower = false,
36  have_parent_upper = false;
37 
38  if (auxinfo && (auxinfo -> extraCharacteristics () & 2)) {
39 
40  // get previous bounds
41  const double
42  *beforeLower = auxinfo -> beforeLower (),
43  *beforeUpper = auxinfo -> beforeUpper ();
44 
45  if (beforeLower || beforeUpper) {
46 
47  // get current bounds
48  const double
49  *nowLower = p -> Lb (),
50  *nowUpper = p -> Ub (); //si.getColUpper ();
51 
52  if (beforeLower) {
53 
54  have_parent_lower = true;
55 
56  for (int i=0; i < ncols; i++)
57  if (*nowLower++ >= *beforeLower++ + COUENNE_EPS)
58  chg_bds [i].setLower (t_chg_bounds::CHANGED);
59  }
60 
61  if (beforeUpper) {
62 
63  have_parent_upper = true;
64 
65  for (int i=0; i < ncols; i++)
66  if (*nowUpper++ <= *beforeUpper++ - COUENNE_EPS)
67  chg_bds [i].setUpper (t_chg_bounds::CHANGED);
68  }
69  }
70  }
71 
72  // not all bounds are available
73 
74  if (!have_parent_lower ||
75  !have_parent_upper) {
76 
77 #ifdef DEBUG
78  printf ("### Warning: could not access parent node's %sbounds in generateCuts()\n",
79  have_parent_lower ? "upper " : have_parent_upper ? "lower " : "");
80 #endif
81 
82  // have to assume ALL bounds have changed
83  if (!have_parent_lower)
84  for (int i=0; i < ncols; i++)
85  chg_bds [i].setLower (t_chg_bounds::CHANGED);
86 
87  if (!have_parent_upper)
88  for (int i=0; i < ncols; i++)
89  chg_bds [i].setUpper (t_chg_bounds::CHANGED);
90  }
91  }
92 }
93 }
void updateBranchInfo(const OsiSolverInterface &si, CouenneProblem *p, t_chg_bounds *chg, const CglTreeInfo &info)
get new bounds from parents&#39; bounds + branching rules
void fint fint fint real fint real real real real real real real real real fint real fint fint fint real fint fint fint fint * info
status of lower/upper bound of a variable, to be checked/modified in bound tightening ...
void setLower(ChangeStatus lower)
void setUpper(ChangeStatus upper)
Class for MINLP problems with symbolic information.
#define COUENNE_EPS