/home/coin/SVN-release/OS-2.4.2/Couenne/src/branch/infeasibility.cpp

Go to the documentation of this file.
00001 /* $Id: infeasibility.cpp 694 2011-06-18 20:13:17Z stefan $
00002  *
00003  * Name:    infeasibility.cpp
00004  * Authors: Pietro Belotti, Carnegie Mellon University
00005  * Purpose: Compute infeasibility of a variable, looking at all expressions it appears in
00006  *
00007  * (C) Carnegie-Mellon University, 2008-10.
00008  * This file is licensed under the Eclipse Public License (EPL)
00009  */
00010 
00011 #include "CoinHelperFunctions.hpp"
00012 
00013 #include "CouenneProblem.hpp"
00014 #include "CouenneVarObject.hpp"
00015 
00016 using namespace Ipopt;
00017 using namespace Couenne;
00018 
00020 const CouNumber weiMin = 0.8; // for minimum of infeasibilities of nonlinear objects
00021 const CouNumber weiMax = 1.3; //     maximum
00022 const CouNumber weiSum = 0.1; //     sum
00023 const CouNumber weiAvg = 0.0; //     average
00024 
00025 
00029 double CouenneVarObject::infeasibility (const OsiBranchingInformation *info, int &way) const {
00030 
00031   assert (reference_);
00032   int index = reference_ -> Index ();
00033 
00034   /*printf ("===INFEAS %d = %g [%g,%g]\n", 
00035           index, 
00036           info -> solution_ [index], 
00037           info -> lower_ [index],
00038           info -> upper_ [index]);*/
00039 
00040   /*if (info -> lower_ [index] >= 
00041       info -> upper_ [index] - CoinMin (COUENNE_EPS, feas_tolerance_))
00042     return (reference_ -> isInteger ()) ? 
00043     intInfeasibility (info -> solution_ [index]) : 0.;*/
00044 
00045   problem_ -> domain () -> push 
00046     (problem_ -> nVars (),
00047      info -> solution_, 
00048      info -> lower_, 
00049      info -> upper_,
00050      false);
00051 
00053 
00054   CouNumber retval = checkInfeasibility (info);
00055 
00057 
00058   if (//(retval > CoinMin (COUENNE_EPS, feas_tolerance_)) &&
00059       (jnlst_ -> ProduceOutput (J_DETAILED, J_BRANCHING))) {
00060 
00061     const std::set <int> &dependence = problem_ -> Dependence () [index];
00062 
00063     printf ("infeasVar x%d %-10g [", reference_ -> Index (), retval);
00064     reference_             -> print (); 
00065     if ((dependence.size () == 0) && (reference_ -> Image ())) { // if no list, print image
00066       printf (" := ");
00067       reference_ -> Image () -> print ();
00068     }
00069     printf ("]\n");
00070   }
00071 
00072   // add term to stop branching on very tiny intervals
00073 
00074   // Compute the up and down estimates here
00075   // TODO: We probably only have to do that if pseudo costs option has
00076   // been chosen
00077 
00078   const CouenneObject *obj_ignored = NULL; // only care about it in CouenneVarObject.cpp
00079 
00080   CouNumber brkPt = computeBranchingPoint (info, way, obj_ignored);
00081 
00082   if (pseudoMultType_ != PROJECTDIST)
00083     setEstimates (info, &retval, &brkPt);
00084 
00085   if (jnlst_ -> ProduceOutput (J_DETAILED, J_BRANCHING)) {
00086     printf("index = %d up = %e down = %e bounds [%e,%e] brpt = %e inf = %e\n", 
00087            index, upEstimate_, downEstimate_, 
00088            info -> lower_ [index],
00089            info -> upper_ [index], brkPt, retval);
00090   }
00091 
00092   problem_ -> domain () -> pop (); // domain not used below
00093 
00094   retval = ((retval <= CoinMin (COUENNE_EPS, feas_tolerance_)) ? 0. : retval);
00095 
00096   int refInd = reference_ -> Index ();  
00097 
00098   if (reference_ -> isInteger ()) {
00099     CouNumber intinfeas = intInfeasibility (info -> solution_ [refInd],
00100                                             info -> lower_    [refInd],
00101                                             info -> upper_    [refInd]);
00102     if ((intinfeas > retval) && 
00103         (intinfeas > info -> integerTolerance_)) 
00104       retval = intinfeas;
00105   }
00106 
00107   //printf ("infVar x%d ==> returning %g\n", reference_ -> Index (), (reference_ -> isInteger ()) ? 
00108   //CoinMax (retval, intInfeasibility (info -> solution_ [reference_ -> Index ()])) :
00109   //retval);
00110 
00111   jnlst_ -> Printf (J_DETAILED, J_BRANCHING, 
00112                     "infVar x%d ==> returning %e\n", reference_ -> Index (), (reference_ -> isInteger ()) ? 
00113                     CoinMax (retval, intInfeasibility (info -> solution_ [refInd],
00114                                                        info -> lower_    [refInd],
00115                                                        info -> upper_    [refInd])) :
00116                     retval);
00117 
00118   return retval;
00119 
00120   // (reference_ -> isInteger ()) ? 
00121   //   CoinMax (retval, intInfeasibility (info -> solution_ [reference_ -> Index ()])) :
00122   //   retval;
00123 }
00124 
00125 
00128 double CouenneVarObject::checkInfeasibility (const OsiBranchingInformation * info) const {
00129 
00130   int index = reference_ -> Index ();
00131 
00132   const std::set <int> &dependence = problem_ -> Dependence () [index];
00133 
00134   if (dependence.size () == 0) { // this is a top level auxiliary,
00135                                  // nowhere an independent
00136 
00137     // check first if this variable is fixed. If so, it's useless to branch on it
00138     if (fabs (info -> upper_ [index] - 
00139               info -> lower_ [index]) / 
00140         (1. + fabs (info -> solution_ [index])) < COUENNE_EPS)
00141       return 0.;
00142 
00143     // otherwise, return a nonzero infeasibility, if necessary. It
00144     // might make sense to branch on it
00145     const CouenneObject *obj = problem_ -> Objects () [reference_ -> Index ()];
00146 
00147     double retval = (obj -> Reference ()) ? 
00148       (1. - 1. / (1. + info -> upper_ [index] - info -> lower_ [index])) *
00149       weiSum * obj -> checkInfeasibility (info) : 0.;
00150 
00151     return retval;
00152 
00153     /*return (reference_ -> isInteger ()) ? 
00154       CoinMax (retval, intInfeasibility (info -> solution_ [reference_ -> Index ()])) :
00155       retval;*/
00156 
00157   } else {
00158 
00159     CouNumber 
00160       infsum = 0.,
00161       infmax = 0.,
00162       infmin = COIN_DBL_MAX;
00163 
00164     for (std::set <int>::const_iterator i = dependence.begin ();
00165          i != dependence.end (); ++i) {
00166 
00167       // *i is the index of an auxiliary that depends on reference_
00168 
00169       const CouenneObject *obj = problem_ -> Objects () [*i];
00170       CouNumber infeas = (obj -> Reference ()) ? obj -> checkInfeasibility (info) : 0.;
00171 
00172       if (infeas > infmax) infmax = infeas;
00173       if (infeas < infmin) infmin = infeas;
00174       infsum += infeas;
00175     }
00176 
00177     double retval = 
00178       ((infmax < 1.e20) ? // avoid returning zero infeasibility in
00179                           // almost fixed variables that are at some
00180                           // denominator (see example triv1.nl from
00181                           // Stefano Coniglio)
00182 
00183                           // 1e20 is probably too optimistic, expect
00184                           // instances that fail (i.e. give -9.99e+12)
00185                           // for much smaller values
00186 
00187       // neglect it if variable has small bound interval (check
00188       // x84=x83/x5 in csched1.nl)
00189        (1. - 1. / (1. + info -> upper_ [index] - info -> lower_ [index])) : 1.) *
00190       // to consider maximum, minimum, and sum/avg of the infeasibilities
00191       (weiSum * infsum + 
00192        weiAvg * (infsum / CoinMax (1., (CouNumber) dependence.size ())) + 
00193        weiMin * infmin + 
00194        weiMax * infmax);
00195 
00196     return retval;
00197 
00198     /*return (reference_ -> isInteger ()) ? 
00199       CoinMax (retval, intInfeasibility (info -> solution_ [reference_ -> Index ()])) :
00200       retval;*/
00201   }
00202 }

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