예제 #1
0
void DependencyDigraph::breakCycles() {
    //    int broken = 0;
    //    std::cout << cycles.size() << std::endl;
    //    debug;
    //    std::vector<std::shared_ptr < invariantNode>> Broken;
    for (unsigned cycle = 0; cycle < cycles.size(); cycle++) {

        if (brokenCycles[cycle]) {
            //            std::cout << "continue" << std::endl;
            continue;
        }
        //        broken++;
        std::shared_ptr<invariantNode> best = breakTie(cycle);
        //        Broken.push_back(best);
        //        brokenInvariants.at(best->id) = true;
        best->invar->setBroken(true);
        for (int cyc : invariantsCycles.at(best->id)) {
            brokenCycles.at(cyc) = true;
            //            std::cout << cyc << "  " << cycle << std::endl;
        }

        undefineVariable(best);
    }
    //    for(std::shared_ptr<invariantNode> in : Broken ){
    //        in->invar->getVariable()->undefine();
    //    }
    //    std::cout << broken << std::endl;



}
예제 #2
0
파일: BBCompare.cpp 프로젝트: hhexiy/ilp-bb
// Best lower bound first search
bool BBCompare::backupCompare(BBNode *x, BBNode *y) {
  int lbx = x->lpObjVal();
  int lby = y->lpObjVal();

  if (lbx != lby) {
    return lbx > lby;
  } else {
    return breakTie(x, y);
  }
}
예제 #3
0
파일: BBCompare.cpp 프로젝트: hhexiy/ilp-bb
// Return true if x is less than y (y is better)
bool BBCompare::compare(BBNode *x, BBNode *y) {
  // for debug
  bool optx = x->isInclOptSol();
  bool opty = y->isInclOptSol();
  if ((optx || opty) && (optx != (x->score()-y->score() > 0))) {
    log_info("wrong decision");
  }

  double diff = x->score() - y->score();
  if (diff == 0) {
    return breakTie(x, y);
    //return backupCompare(x, y);
  } else {
    return diff > 0 ? false : true;
  }
}