Changeset 748


Ignore:
Timestamp:
Jul 28, 2011 12:13:32 PM (9 years ago)
Author:
pbelotti
Message:

avoid strange case of addSegment when x1=x2. Update bounds in OsiRowCut?-turned-OsiColCut? only when tightening

Location:
trunk/Couenne/src
Files:
9 edited

Legend:

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

    r732 r748  
    9292    for (std::list<SmartPtr<const CouenneInfo::NlpSolution> >::const_iterator
    9393           i = solList.begin();
    94          i != solList.end(); ++i) {
     94         i  != solList.end(); ++i) {
    9595
    9696      assert (nOrigVars_ == (*i)->nVars());
     
    229229
    230230        if (CoinCpuTime () > maxCpuTime_) {
    231           maxTimeReached = true; // avoids getrusage...
     231          maxTimeReached = true; // avoids getrusage after loop...
    232232          break;
    233233        }
  • trunk/Couenne/src/bound_tightening/fake_tightening.cpp

    r732 r748  
    129129          (!direction && (inner < outer))) {
    130130
    131         // fictitious interval is empty
    132 
    133         // apply bound
     131        // fictitious interval is empty, hence useless to check.
     132
     133        // apply new (valid, tightened) bound
    134134        if (direction) {oub[index] = Ub (index) = fb; chg_bds[index].setUpper(t_chg_bounds::CHANGED);}
    135135        else           {olb[index] = Lb (index) = fb; chg_bds[index].setLower(t_chg_bounds::CHANGED);}
     
    140140          return -1;
    141141
    142         // restore initial bound
     142        CoinCopyN (Lb (), ncols, olb);
     143        CoinCopyN (Ub (), ncols, oub);
     144
     145        // restore initial bound.
    143146        CoinCopyN (chg_bds, ncols, f_chg);
    144         CoinCopyN (olb, ncols, Lb ());
    145         CoinCopyN (oub, ncols, Ub ());
     147        //CoinCopyN (olb, ncols, Lb ());
     148        //CoinCopyN (oub, ncols, Ub ());
    146149
    147150        break;
     
    244247      } else {
    245248
    246         olb [index] = Lb (index) = intvar ? ceil (fb - COUENNE_EPS) : fb;
     249        olb [index] = Lb (index) = intvar ? ceil  (fb - COUENNE_EPS) : fb;
    247250        chg_bds [index]. setLower (t_chg_bounds::CHANGED);
    248251      }
     
    251254
    252255      tightened = true;
    253         //}
     256      //}
    254257
    255258      // restore initial bound
  • trunk/Couenne/src/convex/CouenneCutGenerator.cpp

    r726 r748  
    121121      jnlst_->Printf(J_WARNING, J_CONVEXIFYING,
    122122                     "warning, discontinuity of %e over an interval of %e\n", y2-y1, x2-x1);
    123     else return createCut (cs, y2, (int) 0, wi, 1.);
     123    //else return createCut (cs, y2, (int) 0, wi, 1.);
    124124  }
    125125
  • trunk/Couenne/src/convex/createCuts.cpp

    r694 r748  
    1 /* $Id$ */
    2 /*
     1/* $Id$
     2 *
    33 * Name:    createCuts.cpp
    44 * Author:  Pietro Belotti
     
    157157              &curU = problem_ -> Ub (i1);
    158158
    159     if (uu < COUENNE_INFINITY) {
     159    if ((uu < COUENNE_INFINITY) &&
     160        (uu < curU - COUENNE_EPS)) {
     161
    160162      cut -> setUbs (1, &i1, &uu);
    161       if (uu < curU - COUENNE_EPS) {
    162         curU = uu; // TODO: chg_bds
    163       }
    164     }
    165 
    166     if (ll > -COUENNE_INFINITY) {
     163      curU = uu; // TODO: chg_bds
     164    }
     165
     166    if ((ll > -COUENNE_INFINITY) &&
     167        (ll > curL + COUENNE_EPS)) {
    167168      cut -> setLbs (1, &i1, &ll);
    168       if (ll > curL + COUENNE_EPS) {
    169         curL = ll; // idem
    170       }
     169      curL = ll; // idem
    171170    }
    172171
  • trunk/Couenne/src/convex/operators/conv-exprSinCos.cpp

    r490 r748  
    2323#include "CouenneProblem.hpp"
    2424
    25 //#include "CouenneExpression.hpp"
    26 
    2725#include "CouenneExprSin.hpp"
    2826#include "CouenneExprCos.hpp"
     
    196194        *s1 = ((ncuts += cg -> addSegment (cs, wi, xi, x0, sin (rx0), x1,       sin (rx1), up)) > 0);
    197195    } else     
    198       if (sign != -up) 
     196      if (sign != -up)
    199197        ncuts += cg -> addSegment (cs, wi, xi, x0, sin (rx0), base+tpt, sin (tpt), up);
    200198  } else {
     
    208206      if (up * (sin (rx1) - sinrx0 - cosrx0 * (rx1-rx0)) < 0) {
    209207        // (b,sinb) below tangent --> tangent
    210         if (sign != up) 
     208        if (sign != up)
    211209          ncuts += cg -> addTangent (cs, wi, xi, x0, sinrx0, cosrx0, -up);
    212210      } else {    // up: either chord or leaning plane
     
    217215            *s0 = ((ncuts += cg->addSegment (cs, wi, xi, x0, sin(rx0), x1,       sin(rx1), -up)) > 0);
    218216        } else
    219           if (sign != up) 
     217          if (sign != up)
    220218            ncuts += cg->addSegment (cs, wi, xi, x0, sin(rx0), base+tpt, sin(tpt), -up);
    221219      }
     
    223221      CouNumber searchpt = M_PI_2 * (2 + 3*left - up);
    224222      tpt = trigNewton (rx0, searchpt, searchpt + left * M_PI_2);
    225       if (sign != up) 
     223      if (sign != up)
    226224        ncuts += cg -> addSegment (cs, wi, xi, x0, sin (rx0), base + tpt, sin (tpt), -up);
    227225    }
     
    231229        (left * (rx1 - (tpt = trigNewton (rx0, (2 +   left - up) * M_PI_2,
    232230                                               (2 + 2*left - up) * M_PI_2))) < 0)) {
    233       if (!*s1 && (sign != -up)) 
     231      if (!*s1 && (sign != -up))
    234232        *s1 = ((ncuts += cg -> addSegment (cs, wi, xi, x0, sin (rx0), x1, sin (rx1), up)) > 0);
    235233    } else
    236       if (sign != -up) 
     234      if (sign != -up)
    237235        ncuts += cg -> addSegment (cs, wi, xi, x0, sin (rx0), base + tpt, sin (tpt), up);
    238236  }
  • trunk/Couenne/src/expression/operators/bounds/CouenneExprBCos.hpp

    r490 r748  
    6464  CouNumber pi2 = 2 * M_PI;
    6565 
    66   if ((u - l > pi2) ||       // 1) interval spans whole cycle
     66  if ((u - l >= pi2) ||       // 1) interval spans whole cycle
    6767      (floor (l/pi2 - 0.5) < // 2) there is a pi + 2k pi between l and u
    6868       floor (u/pi2 - 0.5)))
     
    117117  CouNumber pi2 = 2 * M_PI;
    118118
    119   if ((u - l > pi2) || // 1) interval spans whole cycle
     119  if ((u - l >= pi2) || // 1) interval spans whole cycle
    120120      (floor (l/pi2) < // 2) there is a 3/2 pi + 2k pi between l and u
    121121       floor (u/pi2)))
  • trunk/Couenne/src/expression/operators/bounds/CouenneExprBSin.hpp

    r490 r748  
    6464  CouNumber pi2 = 2 * M_PI;
    6565 
    66   if ((u - l > pi2) ||        // 1) interval spans whole cycle
     66  if ((u - l >= pi2) ||        // 1) interval spans whole cycle
    6767      (floor (l/pi2 - 0.75) < // 2) there is a 3/2 pi + 2k pi between l and u
    6868       floor (u/pi2 - 0.75)))
     
    117117  CouNumber pi2 = 2 * M_PI;
    118118
    119   if ((u - l > pi2) ||        // 1) interval spans whole cycle
     119  if ((u - l >= pi2) ||       // 1) interval spans whole cycle
    120120      (floor (l/pi2 - 0.25) < // 2) there is a pi/2 + 2k pi between l and u
    121121       floor (u/pi2 - 0.25)))
  • trunk/Couenne/src/expression/operators/exprCos.cpp

    r490 r748  
    5050  argument_ -> getBounds (l, u);
    5151
    52   if ((u - l > pi2) ||       // 1) interval spans whole cycle
     52  if ((u - l >= pi2) ||      // 1) interval spans whole cycle
    5353      (floor (l/pi2 - 0.5) < // 2) there is a pi + 2k pi between l and u
    5454       floor (u/pi2 - 0.5)))
     
    5656  else lb = CoinMin (cos (l), cos (u));
    5757
    58   if ((u - l > pi2) || // 1) interval spans whole cycle
    59       (floor (l/pi2) < // 2) there is a 3/2 pi + 2k pi between l and u
     58  if ((u - l >= pi2) || // 1) interval spans whole cycle
     59      (floor (l/pi2) <  // 2) there is a 3/2 pi + 2k pi between l and u
    6060       floor (u/pi2)))
    6161    ub = 1.;
  • trunk/Couenne/src/expression/operators/exprSin.cpp

    r490 r748  
    5050  argument_ -> getBounds (l, u);
    5151
    52   if ((u - l > pi2) ||        // 1) interval spans whole cycle
     52  if ((u - l >= pi2) ||       // 1) interval spans whole cycle
    5353      (floor (l/pi2 - 0.75) < // 2) there is a pi + 2k pi between l and u
    5454       floor (u/pi2 - 0.75)))
     
    5656  else lb = CoinMin (sin (l), sin (u));
    5757
    58   if ((u - l > pi2) ||        // 1) interval spans whole cycle
     58  if ((u - l >= pi2) ||       // 1) interval spans whole cycle
    5959      (floor (l/pi2 - 0.25) < // 2) there is a 3/2 pi + 2k pi between l and u
    6060       floor (u/pi2 - 0.25)))
Note: See TracChangeset for help on using the changeset viewer.