// Returns true if y better than x bool CbcCompareUser::test (CbcNode * x, CbcNode * y) { if (weight_==-1.0&&(y->depth()>7||x->depth()>7)) { // before solution /* printf("x %d %d %g, y %d %d %g\n", x->numberUnsatisfied(),x->depth(),x->objectiveValue(), y->numberUnsatisfied(),y->depth(),y->objectiveValue()); */ if (x->numberUnsatisfied() > y->numberUnsatisfied()) { return true; } else if (x->numberUnsatisfied() < y->numberUnsatisfied()) { return false; } else { int testX = x->depth(); int testY = y->depth(); if (testX!=testY) return testX < testY; else return equalityTest(x,y); // so ties will be broken in consistent manner } } else { // after solution double weight = CoinMax(weight_,0.0); double testX = x->objectiveValue()+ weight*x->numberUnsatisfied(); double testY = y->objectiveValue() + weight*y->numberUnsatisfied(); if (testX!=testY) return testX > testY; else return equalityTest(x,y); // so ties will be broken in consistent manner } }
void HsQMLAutoListModel::handleInequality( const QJSValue& a, Model& model, int i) { if (!equalityTest(a, model[i].mValue)) { model[i].mValue = a; QModelIndex idx = createIndex(i, 0); dataChanged(idx, idx); } }
// Returns true if y better than x bool CbcCompareObjective::test (CbcNode * x, CbcNode * y) { double testX = x->objectiveValue(); double testY = y->objectiveValue(); if (testX != testY) return testX > testY; else return equalityTest(x, y); // so ties will be broken in consistent manner }
// Returns true if y better than x bool CbcCompareDefault::test (CbcNode * x, CbcNode * y) { if (startNodeNumber_ >= 0) { // Diving int nX = x->nodeNumber(); int nY = y->nodeNumber(); if (nY == startNodeNumber_) return true; else if (nX == startNodeNumber_) return false; if (nX >= afterNodeNumber_ && nY < afterNodeNumber_) return false; else if (nY >= afterNodeNumber_ && nX < afterNodeNumber_) return true; // treat as depth first int depthX = x->depth(); int depthY = y->depth(); if (depthX != depthY) { return depthX < depthY; } else { double weight = CoinMax(weight_, 1.0e-9); double testX = x->objectiveValue() + weight * x->numberUnsatisfied(); double testY = y->objectiveValue() + weight * y->numberUnsatisfied(); if (testX != testY) return testX > testY; else return equalityTest(x, y); // so ties will be broken in consistent manner } } if (!weight_) { double testX = x->objectiveValue() + 1.0e-9 * x->numberUnsatisfied(); double testY = y->objectiveValue() + 1.0e-9 * y->numberUnsatisfied(); if (testX != testY) return testX > testY; else return equalityTest(x, y); // so ties will be broken in consistent manner } //weight_=0.0; if ((weight_ == -1.0 && (y->depth() > breadthDepth_ && x->depth() > breadthDepth_)) || weight_ == -3.0 || weight_ == -2.0) { int adjust = (weight_ == -3.0) ? 10000 : 0; // before solution /*printf("x %d %d %g, y %d %d %g\n", x->numberUnsatisfied(),x->depth(),x->objectiveValue(), y->numberUnsatisfied(),y->depth(),y->objectiveValue()); */ if (x->numberUnsatisfied() > y->numberUnsatisfied() + adjust) { return true; } else if (x->numberUnsatisfied() < y->numberUnsatisfied() - adjust) { return false; } else { int depthX = x->depth(); int depthY = y->depth(); if (depthX != depthY) return depthX < depthY; else return equalityTest(x, y); // so ties will be broken in consistent manner } } else { // always choose *greatest* depth if both <= breadthDepth_ otherwise <= breadthDepth_ if just one int depthX = x->depth(); int depthY = y->depth(); /*if ((depthX==4&&depthY==5)||(depthX==5&&depthY==4)) printf("X %x depth %d, Y %x depth %d, breadth %d\n", x,depthX,y,depthY,breadthDepth_);*/ if (depthX <= breadthDepth_ || depthY <= breadthDepth_) { if (depthX <= breadthDepth_ && depthY <= breadthDepth_) { if (depthX != depthY) { return depthX < depthY; } } else { assert (depthX != depthY) ; return depthX < depthY; } } // after solution ? #define THRESH2 0.999 #define TRY_THIS 0 #if TRY_THIS==0 double weight = CoinMax(weight_, 1.0e-9); double testX = x->objectiveValue() + weight * x->numberUnsatisfied(); double testY = y->objectiveValue() + weight * y->numberUnsatisfied(); #elif TRY_THIS==1 /* compute what weight would have to be to hit target then reverse sign as large weight good */ double target = (1.0 - THRESH2) * bestPossible_ + THRESH2 * cutoff_; double weight; weight = (target - x->objectiveValue()) / static_cast<double>(x->numberUnsatisfied()); double testX = - weight; weight = (target - y->objectiveValue()) / static_cast<double>(y->numberUnsatisfied()); double testY = - weight; #elif TRY_THIS==2 // Use estimates double testX = x->guessedObjectiveValue(); double testY = y->guessedObjectiveValue(); #elif TRY_THIS==3 #define THRESH 0.95 // Use estimates double testX = x->guessedObjectiveValue(); double testY = y->guessedObjectiveValue(); if (x->objectiveValue() - bestPossible_ > THRESH*(cutoff_ - bestPossible_)) testX *= 2.0; // make worse if (y->objectiveValue() - bestPossible_ > THRESH*(cutoff_ - bestPossible_)) testY *= 2.0; // make worse #endif if (testX != testY) return testX > testY; else return equalityTest(x, y); // so ties will be broken in consistent manner } }