示例#1
0
box icp_loop_with_nc_bt(box b, contractor const & ctc, SMTConfig & config) {
    static unsigned prune_count = 0;
    stack<box> box_stack;
    stack<int> bisect_var_stack;
    box_stack.push(b);
    bisect_var_stack.push(-1);  // Dummy var
    do {
        // Loop Invariant
        assert(box_stack.size() == bisect_var_stack.size());
        DREAL_LOG_INFO << "new_icp_loop()"
                       << "\t" << "box stack Size = " << box_stack.size();
        b = box_stack.top();
        try {
            b = ctc.prune(b, config);
        } catch (contractor_exception & e) {
            // Do nothing
        }
        prune_count++;
        box_stack.pop();
        bisect_var_stack.pop();
        if (!b.is_empty()) {
            // SAT
            if (b.max_diam() > config.nra_precision) {
                tuple<int, box, box> splits = b.bisect();
                unsigned const index = get<0>(splits);
                box const & first    = get<1>(splits);
                box const & second   = get<2>(splits);
                if (second.is_bisectable()) {
                    box_stack.push(second);
                    box_stack.push(first);
                } else {
                    box_stack.push(first);
                    box_stack.push(second);
                }
                bisect_var_stack.push(index);
                bisect_var_stack.push(index);
            } else {
                break;
            }
        } else {
            // UNSAT
            while (box_stack.size() > 0) {
                assert(box_stack.size() == bisect_var_stack.size());
                int bisect_var = bisect_var_stack.top();
                ibex::BitSet const & input = ctc.input();
                DREAL_LOG_DEBUG << ctc;
                if (!input[bisect_var]) {
                    box_stack.pop();
                    bisect_var_stack.pop();
                } else {
                    break;
                }
            }
        }
    } while (box_stack.size() > 0);
    DREAL_LOG_DEBUG << "prune count = " << prune_count;
    return b;
}
示例#2
0
    integral_constraint ic(static_cast<Enode*>(assert5), 1,
                           static_cast<Enode*>(zero),
                           static_cast<Enode*>(time_0),
                           {static_cast<Enode*>(x_0), static_cast<Enode*>(p_0)}, {},
                           {static_cast<Enode*>(x_t), static_cast<Enode*>(p_t)}, {},
                           {},
                           {make_pair(static_cast<Enode*>(vars[0]), static_cast<Enode*>(rhs_x)),
                            make_pair(static_cast<Enode*>(vars[1]), static_cast<Enode*>(rhs_p))});
    auto oc = make_shared<ode_constraint>(ic);

    contractor c = mk_contractor_capd_full(b, oc, ode_direction::FWD);

    cerr << *oc << endl;
    cerr << b << endl;
    auto input_before = c.input();
    auto output_before = c.output();
    cerr << "Input  (BEFORE) : ";  input_before.display(cerr) << endl;
    cerr << "Output (BEFORE) : "; output_before.display(cerr) << endl;
    c.prune(b, opensmt_ctx->getConfig());
    cerr << b << endl;
    auto input_after = c.input();
    auto output_after = c.output();
    cerr << "Input  (AFTER)  : ";  input_after.display(cerr) << endl;
    cerr << "Output (AFTER)  : "; output_after.display(cerr) << endl;
    for (auto ctc : c.used_constraints()) {
        cerr << "Used constraint : " << *ctc << endl;
    }

    REQUIRE(!input_after[0]);
    REQUIRE(input_after[1]);
示例#3
0
box ncbt_icp::solve(box b, contractor const & ctc, SMTConfig & config) {
    static unsigned prune_count = 0;
    vector<box> box_stack;
    vector<int> bisect_var_stack;
    box_stack.push_back(b);
    bisect_var_stack.push_back(-1);  // Dummy var
    do {
        // Loop Invariant
        assert(box_stack.size() == bisect_var_stack.size());
        DREAL_LOG_INFO << "new_icp_loop()"
                       << "\t" << "box stack Size = " << box_stack.size();
        b = box_stack.back();
        try {
            b = ctc.prune(b, config);
            if (config.nra_use_stat) { config.nra_stat.increase_prune(); }
        } catch (contractor_exception & e) {
            // Do nothing
        }
        prune_count++;
        box_stack.pop_back();
        bisect_var_stack.pop_back();
        if (!b.is_empty()) {
            // SAT
            tuple<int, box, box> splits = b.bisect(config.nra_precision);
            if (config.nra_use_stat) { config.nra_stat.increase_branch(); }
            int const index = get<0>(splits);
            if (index >= 0) {
                box const & first    = get<1>(splits);
                box const & second   = get<2>(splits);
                if (second.is_bisectable()) {
                    box_stack.push_back(second);
                    box_stack.push_back(first);
                } else {
                    box_stack.push_back(first);
                    box_stack.push_back(second);
                }
                bisect_var_stack.push_back(index);
                bisect_var_stack.push_back(index);
            } else {
                break;
            }
        } else {
            // UNSAT
            while (box_stack.size() > 0) {
                assert(box_stack.size() == bisect_var_stack.size());
                int bisect_var = bisect_var_stack.back();
                ibex::BitSet const & input = ctc.input();
                DREAL_LOG_DEBUG << ctc;
                if (!input[bisect_var]) {
                    box_stack.pop_back();
                    bisect_var_stack.pop_back();
                } else {
                    break;
                }
            }
        }
    } while (box_stack.size() > 0);
    DREAL_LOG_DEBUG << "prune count = " << prune_count;
    b.adjust_bound(box_stack);
    return b;
}