Ignore:
Timestamp:
Nov 8, 2006 2:10:36 PM (13 years ago)
Author:
forrest
Message:

fix compare

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cbc/src/CbcCompareActual.cpp

    r356 r485  
    5959CbcCompareDepth::test (CbcNode * x, CbcNode * y)
    6060{
    61   return x->depth() < y->depth();
     61  int testX = x->depth();
     62  int testY = y->depth();
     63  if (testX!=testY)
     64    return testX < testY;
     65  else
     66    return equalityTest(x,y); // so ties will be broken in consistent manner
    6267}
    6368// Create C++ lines to get to current state
     
    112117CbcCompareObjective::test (CbcNode * x, CbcNode * y)
    113118{
    114   return x->objectiveValue() > y->objectiveValue();
     119  double testX = x->objectiveValue();
     120  double testY = y->objectiveValue();
     121  if (testX!=testY)
     122    return testX > testY;
     123  else
     124    return equalityTest(x,y); // so ties will be broken in consistent manner
    115125}
    116126// Create C++ lines to get to current state
     
    209219  }
    210220#else
    211   if (weight_==-1.0&&(y->depth()>7||x->depth()>7)) {
     221  if ((weight_==-1.0&&(y->depth()>7||x->depth()>7))||weight_==-3.0) {
     222    int adjust =  (weight_==-3.0) ? 10000 : 0;
    212223    // before solution
    213     /* printf("x %d %d %g, y %d %d %g\n",
     224    /*printf("x %d %d %g, y %d %d %g\n",
    214225       x->numberUnsatisfied(),x->depth(),x->objectiveValue(),
    215226       y->numberUnsatisfied(),y->depth(),y->objectiveValue()); */
    216     if (x->numberUnsatisfied() > y->numberUnsatisfied())
     227    if (x->numberUnsatisfied() > y->numberUnsatisfied()+adjust) {
    217228      return true;
    218     else if (x->numberUnsatisfied() < y->numberUnsatisfied())
     229    } else if (x->numberUnsatisfied() < y->numberUnsatisfied()-adjust) {
    219230      return false;
    220     else
    221       return x->depth() < y->depth();
     231    } else {
     232      int depthX = x->depth();
     233      int depthY = y->depth();
     234      if (depthX!=depthY)
     235        return depthX < depthY;
     236      else
     237        return equalityTest(x,y); // so ties will be broken in consistent manner
     238    }
    222239  } else {
     240    // always choose *smallest* depth if <= 7
     241    int depthX = x->depth();
     242    int depthY = y->depth();
     243    if (depthX<=7||depthY<=7) {
     244      if (depthX!=depthY) {
     245        return depthX < depthY;
     246      }
     247    }
    223248    // after solution
    224249    double weight = CoinMax(weight_,0.0);
    225     return x->objectiveValue()+ weight*x->numberUnsatisfied() >
    226       y->objectiveValue() + weight*y->numberUnsatisfied();
     250    double testX =  x->objectiveValue()+ weight*x->numberUnsatisfied();
     251    double testY = y->objectiveValue() + weight*y->numberUnsatisfied();
     252    if (testX!=testY)
     253      return testX > testY;
     254    else
     255      return equalityTest(x,y); // so ties will be broken in consistent manner
    227256  }
    228257#endif
     
    344373CbcCompareEstimate::test (CbcNode * x, CbcNode * y)
    345374{
    346   return x->guessedObjectiveValue() >  y->guessedObjectiveValue() ;
     375  double testX = x->guessedObjectiveValue();
     376  double testY = y->guessedObjectiveValue();
     377  if (testX!=testY)
     378    return testX > testY;
     379  else
     380    return equalityTest(x,y); // so ties will be broken in consistent manner
    347381}
    348382
     
    355389  fprintf(fp,"3  cbcModel->setNodeComparison(compare);\n");
    356390}
    357 
Note: See TracChangeset for help on using the changeset viewer.