Changeset 115


Ignore:
Timestamp:
Apr 29, 2009 5:37:05 PM (13 years ago)
Author:
pbelotti
Message:

fix right value of objective computed in checkNLP -- numerics can make a bound interval infeasible. Some cleanup

Location:
trunk/Couenne/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Couenne/src/bound_tightening/operators/impliedBounds-exprSum.cpp

    r112 r115  
    238238  CouNumber *uc = (CouNumber *) malloc (maxind   * sizeof (CouNumber));
    239239
    240   for (register int i = maxind; i--;) {
     240  CoinCopyN (l, maxind, lc);
     241  CoinCopyN (u, maxind, uc);
     242
     243  /*for (register int i = maxind; i--;) {
    241244    *lc++ = *l++;
    242245    *uc++ = *u++;
     
    246249
    247250  lc -= maxind; uc -= maxind;
    248   l  -= maxind; u  -= maxind;
     251  l  -= maxind; u  -= maxind;*/
    249252
    250253  // Update lowers in I1 and uppers in I2
  • trunk/Couenne/src/main/BonCouenneInterface.cpp

    r103 r115  
    228228      // re-check optimality in case resolve () was called
    229229      if (isProvenOptimal () &&
     230          (obj < p -> getCutOff ()) && // first check (before re-computing)
    230231          p -> checkNLP (solution, obj, true) && // true for recomputing obj
    231           (obj < p -> getCutOff ())) {
     232          (obj < p -> getCutOff ())) { // second check (real object might be different)
    232233
    233234        // tell caller there is an initial solution to be fed to the initHeuristic
     
    235236
    236237        // set cutoff to take advantage of bound tightening
     238        //printf ("new cutoff %g from BonCouenneInterface\n", obj);
    237239        p -> setCutOff (obj);
    238240
  • trunk/Couenne/src/main/BonNlpHeuristic.cpp

    r1 r115  
    319319            else if (t > *ub) t = *ub;
    320320          }
    321 
     321         
     322          //printf ("new cutoff %g from BonNlpHeuristic\n", obj);
    322323          couenne_ -> setCutOff (obj);
    323324          foundSolution = true;
  • trunk/Couenne/src/problem/CouenneRestoreUnused.cpp

    r103 r115  
    5454
    5555  if (x)
    56     domain_.push (nVars(), x, NULL, NULL);
     56    domain_.push (nVars(), x, NULL, NULL, false); // no need for another copy
    5757
    5858  for (int i=0; i<nUnusedOriginals_; i++) {
  • trunk/Couenne/src/problem/checkNLP.cpp

    r112 r115  
    1717  const int wrong_obj  = 2;
    1818
    19   /*printf ("checking solution: [%g] ", obj);
     19  /*printf ("checking solution: [%.12e] ", obj);
    2020  for (int i=0; i<nOrigVars_; i++)
    21     printf ("%g ", solution [i]);
     21    printf ("%.12e ", solution [i]);
    2222    printf ("\n");*/
    2323
     
    5555  /*printf ("checknlp: %d vars -------------------\n", domain_.current () -> Dimension ());
    5656  for (int i=0; i<domain_.current () -> Dimension (); i++)
    57     printf ("%4d %20g [%20g %20g]\n",
     57    printf ("%4d %.12e [%.12e %.12e]\n",
    5858    i, domain_.x (i), domain_.lb (i), domain_.ub (i));*/
    5959
    6060  expression *objBody = Obj (0) -> Body ();
    6161
    62   CouNumber realobj = (*(objBody -> Image () ? objBody -> Image () : objBody)) ();
     62  // BUG: if Ipopt solution violates bounds of original variables and
     63  // objective depends on originals, we may have a "computed object"
     64  // out of bounds
     65
     66  //CouNumber realobj = (*(objBody -> Image () ? objBody -> Image () : objBody)) ();
     67  CouNumber realobj = obj;
     68
     69  if (objBody)
     70    realobj =
     71      (objBody -> Index () >= 0) ?
     72      sol [objBody -> Index ()] :
     73      (*(objBody -> Image () ? objBody -> Image () : objBody)) ();
     74
     75  /*printf ("%.12e %.12e %.12e ------------------------------\n",
     76          realobj, sol [objBody -> Index ()],
     77          (*(objBody -> Image () ? objBody -> Image () : objBody)) ());*/
    6378
    6479  bool retval = true;
     
    7489                      realobj, obj, realobj - obj);
    7590
    76       if (recompute)
    77         obj = realobj;
    78       else
     91      if (!recompute)
    7992        throw wrong_obj;
    8093    }
    8194
    82     //printf ("recomputed: %g\n", obj);
     95    if (recompute)
     96      obj = realobj;
     97
     98    //printf ("recomputed: %.12e\n", obj);
    8399
    84100    for (int i=0; i < nOrigVars_; i++) {
     
    118134        variables_ [i] -> print (); printf (" := ");
    119135        variables_ [i] -> Image () -> print ();
    120         printf (" --- %g = %g [%g]; {",
     136        printf (" --- %.12e = %.12e [%.12e]; {",
    121137                (*(variables_ [i])) (),
    122138                (*(variables_ [i] -> Image ())) (),
     
    124140                (*(variables_ [i] -> Image ())) ());
    125141        for (int j=0; j<nVars (); j++)
    126           printf ("%.6f ", (*(variables_ [j])) ());
     142          printf ("%.12e ", (*(variables_ [j])) ());
    127143        printf ("}\n");
    128144        }*/
     
    179195
    180196    case wrong_obj:
    181       retval = true;
     197      retval = false;
    182198      break;
    183199
  • trunk/Couenne/src/problem/problem.cpp

    r112 r115  
    156156        X (index) =  // addresses of x[] and X() are equal
    157157          CoinMax (l, CoinMin (u, (*(var -> Image ())) ()));
    158 
    159158      }
    160159    } else X (index) = 0.;
     
    268267    if (Var (indobj) -> isInteger ())
    269268      pcutoff_    -> setCutOff (floor (cutoff + COUENNE_EPS));
    270     else pcutoff_ -> setCutOff (cutoff + SafeCutoff * fabs (1. + cutoff));
     269    else pcutoff_ -> setCutOff (cutoff + SafeCutoff * (1. + fabs(cutoff)));
    271270  }
    272271} // tolerance needed to retain feasibility
Note: See TracChangeset for help on using the changeset viewer.