Пример #1
0
void Paver::evaluate(PrePaving &paving, Ints &certainties, Box &box) {
  //std::cout << "Box: " << box << std::endl;
  //std::cout << "DirVars: " << dirvars() << std::endl;
  cert_ = 1;
  for (nat f = 0; f < nrels(); ++f) {
    // if f-th formula is certainly true, don't check it again
    if (certainties[f] > 0) continue;
    if (!dirvars().empty() && rels_[f].ope().isFresh(dirvars().back().var) &&
        where(dirvars(), dirvars().back().var) != EXTERIOR) {
      // top variable doesn't appear in f-th formula, don't check it again
      cert_ = (cert_ > 0 ? certainties[f] : std::max(cert_, certainties[f]));
      continue;
    }
    evalDefs();
    certainties[f] = rels_[f].eval(box, defbox_, bps_[f], tolerance_);
    // if f-th formula is certainly not true, conjunction of formulas is certainly not true
    if (certainties[f] == 0) {
      cert_ = 0;
      if (search_ == FULL)
        paving.push_box(3, box); // Whole interval (certainly not)
      return;
    }
    if (certainties[f] < 0)
      cert_ = (cert_ > 0 ? certainties[f] : std::max(cert_, certainties[f]));
  }
  if (cert_ > 0) // Conjunction of formulas is certainly true
    paving.push_box(0, box); // Whole interval (certainly)
  else // Conjunction of formulas is possibly true
    paving.push_box(std::abs(cert_), box); // Whole interval (possibly)
}
Пример #2
0
void PrePaving::insert(const PrePaving &paving) {
  //assert(type_ == -1);
  if (ntypes() < paving.ntypes())
    boxes_.resize(paving.ntypes());
  for (nat i = 0; i < paving.ntypes(); i++) {
    for (nat k = 0; k < paving.size(i); ++k) {
      boxes_[i].push_back(paving.boxes(i)[k]);
    }
  }
}
Пример #3
0
void Paver::combine(PrePaving &paving, const DirVar &,
                    const PrePaving &paving1, const PrePaving &paving2) {
  // Paving type can only be POSSIBLE and contain only one box
  if (paving1.type() == paving2.type() &&
      paving1.type() >= 0)
    paving.move_box_to(paving1.type());
  else {
    paving.clear_boxes();
    if (!paving1.empty())
      paving.insert(paving1);
    if (!paving2.empty())
      paving.insert(paving2);
  }
}
Пример #4
0
        void evaluate(PrePaving &paving, Ints &certainties, Environment &box) override {
            currentBoxCertainty_ = 1;
            nat numberOfFormulas = 1;
            Box aBox = box.box;
            for (nat i = 0; i < numberOfFormulas; ++i) {
                bool isCurrentFormulaTrue = certainties[i] > 0;
                if (isCurrentFormulaTrue) continue;

//                bool isSelectionNonEmpty = not dirvars().empty();
//                if (isSelectionNonEmpty) {
//                    Real currentFormulaLHS = relationalFormulas_[i].ope();
//                    nat mostRecentSelectionVariable = dirvars().back().var;
//                    if (not currentFormulaLHS.hasVar(mostRecentSelectionVariable)
//                        /* TODO: Remove the following line and other users trivially true
//                         * that seems useless:
//                         * && where(dirvars(), dirvars().back().var) != EXTERIOR */
//                            ) {
//                        // top variable doesn't appear in i-th formula, don't check it again
//                        currentBoxCertainty_ = (currentBoxCertainty_ > 0 ? certainties[i] : std::max(currentBoxCertainty_, certainties[i]));
//                        continue;
//                    }
//                }
                evalGlobalDefinitions(); // TODO: Take out from the loop, since it should be constant or, if not, it would be asymmetric
                certainties[i] = CertaintyClass::certainty2Int(
                        this->booleanExpression_->eval(box, this->defaultEnclosureMethodTrueBernsteinFalseInterval_,
                                                       this->absoluteToleranceForStoppingBranchAndBound_));
                // if i-th formula is certainly not true, conjunction of formulas is certainly not true
                if (certainties[i] == 0) {
                    currentBoxCertainty_ = 0;
                    if (search_ == FULL)
                        paving.push_box(3, aBox); // Whole interval (certainly not)
                    return;
                }
                if (certainties[i] < 0)
                    currentBoxCertainty_ = (currentBoxCertainty_ > 0 ? certainties[i] : std::max(currentBoxCertainty_,
                                                                                                 certainties[i]));
            }
            if (currentBoxCertainty_ > 0) // Conjunction of formulas is certainly true
                paving.push_box(0, aBox); // Whole interval (certainly)
            else // Conjunction of formulas is possibly true
                paving.push_box(std::abs(currentBoxCertainty_), aBox); // Whole interval (possibly)
        }
Пример #5
0
void Paver::combine(PrePaving &paving, const DirVar &,
                    const PrePaving &paving1) {
  paving.clear_boxes();
  if (!paving1.empty())
    paving.insert(paving1);
}