Esempio n. 1
0
void update_box_using_bitset(box & b, vector<ibex::Interval> const & v, ibex::BitSet const & s) {
    if (s.empty()) { return; }
    unsigned v_idx = 0;
    for (int i = s.min(); i <= s.max(); ++i) {
        if (s.contain(i)) {
            b[i] = v[v_idx++];
        }
    }
}
Esempio n. 2
0
vector<ibex::Interval> extract_from_box_using_bitset(box const & b, ibex::BitSet const & s) {
    vector<ibex::Interval> v;
    if (s.empty()) { return v; }
    for (int i = s.min(); i <= s.max(); ++i) {
        if (s.contain(i)) {
            v.push_back(b[i]);
        }
    }
    return v;
}
Esempio n. 3
0
File: box.cpp Progetto: pysmt/dreal3
vector<int> box::bisectable_dims(double const precision, ibex::BitSet const & input) const {
    thread_local static vector<int> dims;
    dims.clear();
    for (int i = 0; i < m_values.size(); i++) {
        if (input.contain(i) && is_bisectable_at(i, precision)) {
            dims.push_back(i);
        }
    }
    return dims;
}
Esempio n. 4
0
void contractor_fixpoint::worklist_fixpoint_alg(contractor_status & cs) {
    thread_local static queue<unsigned> q;
    q = queue<unsigned>();  // empty queue
    thread_local static ibex::BitSet ctc_bitset = ibex::BitSet::empty(m_clist.size());
    ctc_bitset.clear();

    // Add all contractors to the queue.
    for (int i = m_clist.size() - 1; i >= 0; --i) {
        contractor & c_i = m_clist[i];
        contractor_status_guard csg(cs);
        c_i.prune(cs);
        if (cs.m_box.is_empty()) { return; }
        ibex::BitSet const & output_i = cs.m_output;
        if (output_i.empty()) {
            continue;
        }
        q.push(i);
        ctc_bitset.add(i);
    }

    if (q.size() == 0) { return; }
    // Fixed Point Loop
    thread_local static box old_box(cs.m_box);
    do {
        interruption_point();
        old_box = cs.m_box;
        unsigned const idx = q.front();
        q.pop();
        ctc_bitset.remove(idx);
        assert(idx < m_clist.size());
        contractor & c = m_clist[idx];
        contractor_status_guard csg(cs);
        c.prune(cs);
        if (cs.m_box.is_empty()) {
            return;
        }
        auto const & c_output = cs.m_output;
        if (!c_output.empty()) {
            // j-th dimension is changed as a result of pruning
            // need to add a contractor which takes j-th dim as an input
            for (int j = c_output.min(); j <= c_output.max(); ++j) {
                if (!c_output.contain(j)) {
                    continue;
                }
                for (unsigned k = 0; k < m_clist.size(); ++k) {
                    // Only add if it's not in the current queue
                    if (!ctc_bitset.contain(k)) {
                        contractor const & c_k = m_clist[k];
                        if (c_k.get_input().contain(j)) {
                            q.push(k);
                            ctc_bitset.add(k);
                        }
                    }
                }
            }
        }
    } while (q.size() > 0 && cs.m_box.max_diam() >= cs.m_config.nra_precision && !m_term_cond(old_box, cs.m_box));
    return;
}