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

Go to the documentation of this file.
00001 /* $Id: updateBranchInfo.cpp 141 2009-06-03 04:19:19Z 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 Common Public License (CPL)
00009  */
00010 
00011 #include "CglCutGenerator.hpp"
00012 #include "CouenneTypes.hpp"
00013 #include "CouenneProblem.hpp"
00014 #include "BonAuxInfos.hpp"
00015 
00016 //#define DEBUG
00017 
00019 void updateBranchInfo (const OsiSolverInterface &si, CouenneProblem *p, 
00020                        t_chg_bounds *chg_bds, const CglTreeInfo &info) {
00021 
00022   int ncols = p -> nVars ();
00023 
00024   if ((info.inTree) && (info.pass==0)) {
00025 
00026     // we are anywhere in the B&B tree but at the root node. Check,
00027     // through the auxiliary information, which bounds have changed
00028     // from the parent node.
00029 
00030     OsiBabSolver *auxinfo = dynamic_cast <OsiBabSolver *> (si.getAuxiliaryInfo ());
00031 
00032     bool 
00033       have_parent_lower = false,
00034       have_parent_upper = false;
00035 
00036     if (auxinfo && (auxinfo -> extraCharacteristics () & 2)) {
00037 
00038       // get previous bounds
00039       const double * beforeLower = auxinfo -> beforeLower ();
00040       const double * beforeUpper = auxinfo -> beforeUpper ();
00041 
00042       if (beforeLower || beforeUpper) {
00043 
00044         // get currentbounds
00045         const double * nowLower = si.getColLower ();
00046         const double * nowUpper = si.getColUpper ();
00047 
00048         if (beforeLower) {
00049 
00050           have_parent_lower = true;
00051           for (int i=0; i < ncols; i++)
00052             if (nowLower [i] >= beforeLower [i] + COUENNE_EPS)
00053               chg_bds [i].setLower (t_chg_bounds::CHANGED);
00054         }
00055 
00056         if (beforeUpper) {
00057 
00058           have_parent_upper = true;
00059           for (int i=0; i < ncols; i++)
00060             if (nowUpper [i] <= beforeUpper [i] - COUENNE_EPS)
00061               chg_bds [i].setUpper (t_chg_bounds::CHANGED);
00062         }
00063       } 
00064     }
00065 
00066     // not all bounds are available
00067 
00068     if (!have_parent_lower || 
00069         !have_parent_upper) {
00070 
00071 #ifdef DEBUG
00072       printf ("### Warning: could not access parent node's %sbounds in generateCuts()\n",
00073               have_parent_lower ? "upper " : have_parent_upper ? "lower " : "");
00074 #endif
00075 
00076       // have to assume ALL bounds have changed
00077       if (!have_parent_lower) 
00078         for (int i=0; i < ncols; i++) 
00079           chg_bds [i].setLower (t_chg_bounds::CHANGED);
00080 
00081       if (!have_parent_upper) 
00082         for (int i=0; i < ncols; i++) 
00083           chg_bds [i].setUpper (t_chg_bounds::CHANGED);
00084     }
00085   }
00086 
00087   //p -> domain () -> pop ();
00088 }

Generated on Mon Aug 3 03:02:19 2009 by  doxygen 1.4.7