Changeset 591


Ignore:
Timestamp:
May 31, 2011 1:03:03 PM (9 years ago)
Author:
pbelotti
Message:

probing now applied even in absence of NLP solution

Location:
trunk/Couenne/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Couenne/src/bound_tightening/aggressiveBT.cpp

    r589 r591  
    3030}
    3131
    32 #define MAX_ABT_ITER           1  // max # aggressive BT iterations
     32#define MAX_ABT_ITER           4  // max # aggressive BT iterations
    3333#define THRES_ABT_IMPROVED     0  // only continue ABT if at least these bounds have improved
    3434#define THRES_ABT_ORIG       100  // only do ABT on auxiliaries if they are less originals than this
     
    6363                                   Bonmin::BabInfo * babInfo) const {
    6464
    65   Jnlst () -> Printf (J_ITERSUMMARY, J_BOUNDTIGHTENING, "Aggressive FBBT\n");
     65  Jnlst () -> Printf (J_ITERSUMMARY, J_BOUNDTIGHTENING, "Probing\n");
    6666
    6767  if (info.level <= 0 && !(info.inTree))  {
     
    8989  double dist = 1e50;
    9090
    91   const std::list<SmartPtr<const CouenneInfo::NlpSolution> >& solList =
    92     couInfo->NlpSolutions();
    93 
    94   for (std::list<SmartPtr<const CouenneInfo::NlpSolution> >::const_iterator
    95          i = solList.begin();
    96        i != solList.end(); i++) {
    97     assert(nOrigVars_ == (*i)->nVars());
    98     const double thisDist = distanceToBound(nOrigVars_, (*i)->solution(), olb, oub);
    99     if (thisDist < dist) {
    100       closestSol = *i;
    101       dist = thisDist;
     91  if (couInfo) {
     92
     93    const std::list<SmartPtr<const CouenneInfo::NlpSolution> >& solList =
     94      couInfo->NlpSolutions();
     95
     96    for (std::list<SmartPtr<const CouenneInfo::NlpSolution> >::const_iterator
     97           i = solList.begin();
     98         i != solList.end(); i++) {
     99      assert(nOrigVars_ == (*i)->nVars());
     100      const double thisDist = distanceToBound(nOrigVars_, (*i)->solution(), olb, oub);
     101      if (thisDist < dist) {
     102        closestSol = *i;
     103        dist = thisDist;
     104      }
    102105    }
    103106  }
    104107
    105108  jnlst_ -> Printf (J_VECTOR, J_BOUNDTIGHTENING, "best dist = %e\n", dist);
     109
     110  bool haveNLPsol = false;
    106111
    107112  // If this solution is not sufficiently inside the bounds, we solve the NLP now
     
    150155
    151156      if (nlp->isProvenOptimal()) {
    152         closestSol = new CouenneInfo::NlpSolution
    153           (nOrigVars_, nlp->getColSolution(), nlp->getObjValue());
    154         couInfo->addSolution(closestSol);
    155         dist = 0.;
     157
     158        if (couInfo) {
     159          closestSol = new CouenneInfo::NlpSolution
     160            (nOrigVars_, nlp->getColSolution(), nlp->getObjValue());
     161          couInfo->addSolution(closestSol);
     162          dist = 0.;
     163          haveNLPsol = true;     
     164        }
    156165      }
    157166      else {
     
    164173  int nTotImproved = 0;
    165174
    166   if (!retval && (dist < 1e10)) {
    167 
     175  // Probing can also run on an LP point.
     176
     177  //if (true || (retval && (dist < 1e10))) {
     178
     179  {
    168180    retval = true;
    169181
     
    172184    // through getAuxs()
    173185
    174     double *X = new double [ncols];
    175     CoinCopyN (closestSol->solution(), nOrigVars_, X);
    176     getAuxs (X);
     186    double *X = NULL;
     187
     188    if (haveNLPsol) {
     189
     190      X = new double [ncols];
     191      CoinCopyN (closestSol -> solution(), nOrigVars_, X);
     192      getAuxs (X);
     193    } else X = domain () -> x ();
    177194
    178195    // create a new, fictitious, bound bookkeeping structure
     
    300317    }
    301318
    302     delete [] X;
     319    if (haveNLPsol)
     320      delete [] X;
    303321    delete [] f_chg;
    304322   
    305   } else
    306 
    307     if ((dist > 1e10) && !retval)
    308       jnlst_ -> Printf(J_ITERSUMMARY, J_BOUNDTIGHTENING, "TODO: Don't have point for ABT\n");
     323  } // else
     324
     325    // if ((dist > 1e10) && !retval)
     326    //   jnlst_ -> Printf(J_ITERSUMMARY, J_BOUNDTIGHTENING, "TODO: Don't have point for ABT\n");
    309327
    310328  delete [] olb;
  • trunk/Couenne/src/bound_tightening/fake_tightening.cpp

    r490 r591  
    3333                      CouNumber  ub) {
    3434
    35   if   (lb < -COUENNE_INFINITY / 10) {
    36     if (ub >  COUENNE_INFINITY / 10) { // ]-inf,+inf[
    37 
    38       if (fabs (x) < COUENNE_EPS) return (direction ? AGGR_MUL : - AGGR_MUL);
    39       else                        return (direction ? AGGR_MUL : - AGGR_MUL) * fabs (x);
     35#define LARGE_BOUND 1e10
     36
     37  if   (lb < -LARGE_BOUND) {
     38    if (ub >  LARGE_BOUND) { // ]-inf,+inf[
     39
     40      return (!direction ? -sqrt (-lb) : sqrt (ub));
     41
     42      //if (fabs (x) < COUENNE_EPS) return (direction ? AGGR_MUL : - AGGR_MUL);
     43      //else                        return (direction ? AGGR_MUL : - AGGR_MUL) * fabs (x);
    4044
    4145    } else { // ]-inf,u]
    4246
    43       if      (x < -COUENNE_EPS) return (direction ? CoinMin (0., (x+ub)/2) : AGGR_MUL * x);
    44       else if (x >  COUENNE_EPS) return (direction ? (x + (ub-x)/AGGR_DIV) : 0);
    45       else                       return (direction ? (ub/AGGR_DIV) : -AGGR_MUL);
     47      if (!direction)
     48        return -sqrt (-lb); // try to tighten interval from a very large value
     49
     50      if      (x < -COUENNE_EPS) return (CoinMin (0., (x+ub)/2));
     51      else if (x >  COUENNE_EPS) return ((x + (ub-x)/AGGR_DIV));
     52      else                       return ((ub/AGGR_DIV));
     53
     54      // if      (x < -COUENNE_EPS) return (direction ? CoinMin (0., (x+ub)/2) : AGGR_MUL * x);
     55      // else if (x >  COUENNE_EPS) return (direction ? (x + (ub-x)/AGGR_DIV) : 0);
     56      // else                       return (direction ? (ub/AGGR_DIV) : -AGGR_MUL);
    4657    }
    4758  }
    4859  else {
    49     if (ub >  COUENNE_INFINITY / 10) { // [l,+inf[
    50 
    51       if      (x < -COUENNE_EPS) return (direction ? 0 : (x - (x-lb) / AGGR_DIV));
    52       else if (x >  COUENNE_EPS) return (direction ? (AGGR_MUL * x) : CoinMax (0.,(x+lb)/2));
    53       else                       return (direction ? AGGR_MUL : lb/AGGR_DIV);
     60    if (ub >  LARGE_BOUND) { // [l,+inf[
     61
     62      if (direction)
     63        return sqrt (ub);
     64
     65      if      (x < -COUENNE_EPS) return ((x - (x-lb) / AGGR_DIV));
     66      else if (x >  COUENNE_EPS) return (CoinMax (0.,(x+lb)/2));
     67      else                       return (lb/AGGR_DIV);
     68
     69      // if      (x < -COUENNE_EPS) return (direction ? 0 : (x - (x-lb) / AGGR_DIV));
     70      // else if (x >  COUENNE_EPS) return (direction ? (AGGR_MUL * x) : CoinMax (0.,(x+lb)/2));
     71      // else                       return (direction ? AGGR_MUL : lb/AGGR_DIV);
     72
    5473    } else // [l,u]
    5574      return (direction ? (x + (ub-x) / AGGR_DIV) : x - (x-lb) / AGGR_DIV);
  • trunk/Couenne/src/branch/CouenneBranchingObject.cpp

    r587 r591  
    1414#include "OsiRowCut.hpp"
    1515
    16 //#include "CouenneSolverInterface.hpp"
    1716#include "CouenneCutGenerator.hpp"
    1817
  • trunk/Couenne/src/branch/CouenneVarObject.cpp

    r577 r591  
    9292        (u >   LARGE_VALUE) &&
    9393        (fabs (brpt) > LARGE_VALUE / 10))
    94       brpt = 0;
    95 
    96     if (l < - COUENNE_INFINITY) l = - 2 * fabs (brpt);
    97     if (u >   COUENNE_INFINITY) u =   2 * fabs (brpt);
     94      brpt = 0.;
     95
     96    if (l < - COUENNE_INFINITY) l = -1. - 2 * fabs (brpt);
     97    if (u >   COUENNE_INFINITY) u = +1. + 2 * fabs (brpt);
    9898
    9999    CouNumber width = lp_clamp_ * (u-l);
     
    288288    }
    289289
     290#define LARGE_VALUE 1e8
     291    if ((l < - LARGE_VALUE) &&
     292        (u >   LARGE_VALUE) &&
     293        (fabs (bestPt) > LARGE_VALUE / 10))
     294      bestPt = 0.;
     295
    290296    brPts  = (double *) realloc (brPts, sizeof (double));
    291297    *brPts = bestPt;
  • trunk/Couenne/src/branch/operators/branchExprMul.cpp

    r522 r591  
    117117  else { // both are bounded
    118118
    119     //way = TWO_RAND;
     119    // Check if, though bounded, they are a bit too large
    120120
    121121    CouNumber delta = (yu-yl) - (xu-xl);
     
    136136        (-ub/lb >= THRES_ZERO_SYMM))
    137137      // interval is fairly symmetric around 0, branch on it
     138      *brpts = 0.;
     139
     140#define LARGE_VALUE 1e8
     141
     142    else if ((lb < - LARGE_VALUE) &&
     143             (ub >   LARGE_VALUE) &&
     144             (fabs (pt) > LARGE_VALUE / 10))
    138145      *brpts = 0.;
    139146
  • trunk/Couenne/src/convex/generateCuts.cpp

    r587 r591  
    492492    sparse2dense (ncols, chg_bds, changed, nchanged);
    493493
    494     double *nlpSol;
     494    double *nlpSol = NULL;
    495495
    496496    //--------------------------------------------
    497497
    498     if (babInfo && ((nlpSol = const_cast <double *> (babInfo -> nlpSolution ())))) {
     498    if (true) {
     499
     500      if (babInfo)
     501        nlpSol = const_cast <double *> (babInfo -> nlpSolution ());
    499502
    500503      // Aggressive Bound Tightening ////////////////////////////////
     
    536539
    537540      // fill originals with nlp values
    538       CoinCopyN (nlpSol, problem_ -> nOrigVars (), problem_ -> domain () -> x ());
     541      if (nlpSol) {
     542        CoinCopyN (nlpSol, problem_ -> nOrigVars (), problem_ -> domain () -> x ());
    539543      //problem_ -> initAuxs ();
    540544
    541545      problem_ -> getAuxs (problem_ -> domain () -> x ());
     546      }
    542547
    543548      if (jnlst_ -> ProduceOutput (J_VECTOR, J_CONVEXIFYING)) {
     
    560565
    561566      //    if (!firstcall_) // keep solution if called from extractLinearRelaxation()
    562       babInfo -> setHasNlpSolution (false); // reset it after use //AW HERE
     567      if (babInfo)
     568        babInfo -> setHasNlpSolution (false); // reset it after use //AW HERE
    563569
    564570    } else {
  • trunk/Couenne/src/expression/operators/bounds/CouenneExprBMul.hpp

    r560 r591  
    1 /* $Id$ */
    2 /*
     1/* $Id$
     2 *
    33 * Name:    exprBMul.hpp
    44 * Author:  Pietro Belotti
     
    2020
    2121#define MUL_ZERO 1e-20
    22 #define MUL_INF  1e+20
     22#define MUL_INF  sqrt (COIN_DBL_MAX)
    2323
    2424/// product that avoids NaN's
Note: See TracChangeset for help on using the changeset viewer.