Beispiel #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)
}
Beispiel #2
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)
        }