/home/coin/SVN-release/OS-2.4.2/Couenne/src/convex/updateBranchInfo.cpp

Go to the documentation of this file.
00001 /* $Id: updateBranchInfo.cpp 490 2011-01-14 16:07:12Z pbelotti $
00002  *
00003  * Name:    updateBranchInfo.cpp
00004  * Author:  Pietro Belotti
00005  * Purpose: get new bounds from parents' bounds + branching rules
00006  *
00007  * (C) Carnegie-Mellon University, 2006. 
00008  * This file is licensed under the Eclipse Public License (EPL)
00009  */
00010 
00011 #include "CglCutGenerator.hpp"
00012 #include "CouenneTypes.hpp"
00013 #include "CouenneProblem.hpp"
00014 #include "BonAuxInfos.hpp"
00015 
00016 namespace Couenne {
00017 
00018   //#define DEBUG
00019 
00021 void updateBranchInfo (const OsiSolverInterface &si, CouenneProblem *p, 
00022                        t_chg_bounds *chg_bds, const CglTreeInfo &info) {
00023 
00024   int ncols = p -> nVars ();
00025 
00026   if ((info.inTree) && (info.pass==0)) {
00027 
00028     // We are anywhere in the B&B tree but at the root node. Check,
00029     // through the auxiliary information, which bounds have changed
00030     // from the parent node.
00031 
00032     OsiBabSolver *auxinfo = dynamic_cast <OsiBabSolver *> (si.getAuxiliaryInfo ());
00033 
00034     bool 
00035       have_parent_lower = false,
00036       have_parent_upper = false;
00037 
00038     if (auxinfo && (auxinfo -> extraCharacteristics () & 2)) {
00039 
00040       // get previous bounds
00041       const double 
00042         *beforeLower = auxinfo -> beforeLower (),
00043         *beforeUpper = auxinfo -> beforeUpper ();
00044 
00045       if (beforeLower || beforeUpper) {
00046 
00047         // get current bounds
00048         const double 
00049           *nowLower = p -> Lb (),
00050           *nowUpper = p -> Ub (); //si.getColUpper ();
00051 
00052         if (beforeLower) {
00053 
00054           have_parent_lower = true;
00055 
00056           for (int i=0; i < ncols; i++)
00057             if (*nowLower++ >= *beforeLower++ + COUENNE_EPS)
00058               chg_bds [i].setLower (t_chg_bounds::CHANGED);
00059         }
00060 
00061         if (beforeUpper) {
00062 
00063           have_parent_upper = true;
00064 
00065           for (int i=0; i < ncols; i++)
00066             if (*nowUpper++ <= *beforeUpper++ - COUENNE_EPS)
00067               chg_bds [i].setUpper (t_chg_bounds::CHANGED);
00068         }
00069       } 
00070     }
00071 
00072     // not all bounds are available
00073 
00074     if (!have_parent_lower || 
00075         !have_parent_upper) {
00076 
00077 #ifdef DEBUG
00078       printf ("### Warning: could not access parent node's %sbounds in generateCuts()\n",
00079               have_parent_lower ? "upper " : have_parent_upper ? "lower " : "");
00080 #endif
00081 
00082       // have to assume ALL bounds have changed
00083       if (!have_parent_lower) 
00084         for (int i=0; i < ncols; i++) 
00085           chg_bds [i].setLower (t_chg_bounds::CHANGED);
00086 
00087       if (!have_parent_upper) 
00088         for (int i=0; i < ncols; i++) 
00089           chg_bds [i].setUpper (t_chg_bounds::CHANGED);
00090     }
00091   }
00092 }
00093 }

Generated on Wed Nov 30 03:03:59 2011 by  doxygen 1.4.7