예제 #1
0
void tilingInterpolation::integer_pruning(box const & old_box, box const & new_box, int i) {
    Enode * it;
    //TODO what about shared ? should we rather take the projections
    if (is_a_var(i)) {
        it = make_false();
    } else {
        assert(is_b_var(i));
        it = make_true();
    }
    if (new_box.get_values()[i].is_empty()) {
        //if the new box is empty then we have a leaf
        push_partial_interpolant(it);
        proof_size += 1;
    } else {
        //we need to figure out what parts are pruned
        auto const fst_value = old_box.get_value(i);
        auto const snd_value = new_box.get_value(i);
        //pruning on the lower end
        if (fst_value.lb() < snd_value.lb()) {
            std::tuple<bool,int,double,bool> pivot(false, i, snd_value.lb(), false);
            split_stack.push(pivot);
            push_partial_interpolant(it);
            proof_size += 1;
        }
        //pruning on the upper end
        if (fst_value.ub() > snd_value.ub()) {
            std::tuple<bool,int,double,bool> pivot(true, i, snd_value.ub(), false);
            split_stack.push(pivot);
            push_partial_interpolant(it);
            proof_size += 1;
        }
    }
}
예제 #2
0
box contractor_int::prune(box b, SMTConfig & config) const {
    // ======= Proof =======
    thread_local static box old_box(b);
    if (config.nra_proof) { old_box = b; }

    m_input  = ibex::BitSet::empty(b.size());
    m_output = ibex::BitSet::empty(b.size());
    unsigned i = 0;
    ibex::IntervalVector & iv = b.get_values();
    for (Enode * e : b.get_vars()) {
        if (e->hasSortInt()) {
            auto old_iv = iv[i];
            iv[i] = ibex::integer(iv[i]);
            if (old_iv != iv[i]) {
                m_input.add(i);
                m_output.add(i);
            }
            if (iv[i].is_empty()) {
                b.set_empty();
                break;
            }
        }
        i++;
    }

    // ======= Proof =======
    if (config.nra_proof) {
        output_pruning_step(config.nra_proof_out, old_box, b, config.nra_readable_proof, "integer pruning");
    }
    return b;
}
예제 #3
0
파일: box.cpp 프로젝트: kquine/dreal3
box sample_point(box b) {
    static thread_local std::mt19937_64 rg(std::chrono::system_clock::now().time_since_epoch().count());
    unsigned const n = b.size();
    ibex::IntervalVector & values = b.get_values();
    for (unsigned i = 0; i < n; i++) {
        ibex::Interval & iv = values[i];
        double const lb = iv.lb();
        double const ub = iv.ub();
        if (lb != ub) {
            std::uniform_real_distribution<double> m_dist(lb, ub);
            iv = ibex::Interval(m_dist(rg));
        }
    }
    return b;
}