예제 #1
0
 void context::display_subexprs_info(std::ostream & out, expr * n) const {
     ptr_buffer<expr> todo;
     todo.push_back(n);
     while (!todo.empty()) {
         expr * n = todo.back();
         todo.pop_back();
         out << "#";
         out.width(6);
         out << std::left << n->get_id();
         out << ", relevant: " << is_relevant(n);
         if (m_manager.is_bool(n)) {
             out << ", val: ";
             out.width(7);
             out << std::right;
             if (lit_internalized(n))
                 out << get_assignment(n);
             else
                 out << "l_undef";
         }
         if (e_internalized(n)) {
             enode * e = get_enode(n);
             out << ", root: #" << e->get_root()->get_owner_id();
         }
         out << "\n";
         if (is_app(n)) {
             for (unsigned i = 0; i < to_app(n)->get_num_args(); i++)
                 todo.push_back(to_app(n)->get_arg(i));
         }
     }
 }
예제 #2
0
파일: metavar.cpp 프로젝트: silky/lean
std::pair<level, justification> substitution::instantiate_metavars(level const & l, bool use_jst) {
    if (!has_meta(l))
        return mk_pair(l, justification());
    justification j;
    auto save_jst = [&](justification const & j2) { j = mk_composite1(j, j2); };
    level r = replace(l, [&](level const & l) {
            if (!has_meta(l)) {
                return some_level(l);
            } else if (is_meta(l)) {
                auto p1 = get_assignment(l);
                if (p1) {
                    auto p2 = instantiate_metavars(p1->first, use_jst);
                    if (use_jst) {
                        justification new_jst = mk_composite1(p1->second, p2.second);
                        assign(meta_id(l), p2.first, new_jst);
                        save_jst(new_jst);
                    } else {
                        assign(meta_id(l), p2.first);
                    }
                    return some_level(p2.first);
                }
            }
            return none_level();
        });
    return mk_pair(r, j);
}
예제 #3
0
 void context::display_literal_info(std::ostream & out, literal l) const {
     l.display_compact(out, m_bool_var2expr.c_ptr());
     if (l.sign())
         out << "  (not " << mk_bounded_pp(bool_var2expr(l.var()), m_manager, 10) << ") ";
     else
         out << "  " << mk_bounded_pp(bool_var2expr(l.var()), m_manager, 10) << " ";
     out << "relevant: " << is_relevant(bool_var2expr(l.var())) << ", val: " << get_assignment(l) << "\n";
 }
예제 #4
0
파일: maxsmt.cpp 프로젝트: 0Chuzz/z3
 void maxsmt_solver_base::commit_assignment() {
     expr_ref tmp(m);
     rational k(0);
     for (unsigned i = 0; i < m_soft.size(); ++i) {
         if (get_assignment(i)) {
             k += m_weights[i];
         }
     }       
     pb_util pb(m);
     tmp = pb.mk_ge(m_weights.size(), m_weights.c_ptr(), m_soft.c_ptr(), k);
     TRACE("opt", tout << tmp << "\n";);
예제 #5
0
 void context::display_clause_detail(std::ostream & out, clause const * cls) const {
     out << "lemma: " << cls->is_lemma() << "\n";
     unsigned num_lits = cls->get_num_literals();
     for (unsigned i = 0; i < num_lits; i++) {
         literal l = cls->get_literal(i);
         display_literal(out, l);
         out << ", val: " << get_assignment(l) << ", lvl: " << get_assign_level(l)
             << ", ilvl: " << get_intern_level(l.var()) << ", var: " << l.var() << "\n"
             << mk_pp(bool_var2expr(l.var()), m_manager) << "\n\n";
     }
 }
예제 #6
0
 void context::display_eq_detail(std::ostream & out, enode * n) const {
     SASSERT(n->is_eq());
     out << "#" << n->get_owner_id()
         << ", root: #" << n->get_root()->get_owner_id()
         << ", cg: #" << n->m_cg->get_owner_id()
         << ", val: " << get_assignment(enode2bool_var(n))
         << ", lhs: #" << n->get_arg(0)->get_owner_id()
         << ", rhs: #" << n->get_arg(1)->get_owner_id()
         << ", lhs->root: #" << n->get_arg(0)->get_root()->get_owner_id()
         << ", rhs->root: #" << n->get_arg(1)->get_root()->get_owner_id()
         << ", is_marked: " << n->is_marked()
         << ", is_relevant: " << is_relevant(n)
         << ", iscope_lvl: " << n->get_iscope_lvl() << "\n";
 }
예제 #7
0
int main_0056_balanced_group_mt (int argc, char **argv) {
        const char *topic = test_mk_topic_name(__FUNCTION__, 1);
        rd_kafka_t *rk_p, *rk_c;
        rd_kafka_topic_t *rkt_p;
        int msg_cnt = 1000;
        int msg_base = 0;
        int partition_cnt = 2;
        int partition;
        uint64_t testid;
        rd_kafka_topic_conf_t *default_topic_conf;
        rd_kafka_topic_partition_list_t *sub, *topics;
        rd_kafka_resp_err_t err;
        test_timing_t t_assign, t_close, t_consume;
        int i;

        exp_msg_cnt = msg_cnt * partition_cnt;

        testid = test_id_generate();

        /* Produce messages */
        rk_p = test_create_producer();
        rkt_p = test_create_producer_topic(rk_p, topic, NULL);

        for (partition = 0; partition < partition_cnt; partition++) {
                test_produce_msgs(rk_p, rkt_p, testid, partition,
                                  msg_base + (partition * msg_cnt), msg_cnt,
                                  NULL, 0);
        }

        rd_kafka_topic_destroy(rkt_p);
        rd_kafka_destroy(rk_p);

        if (mtx_init(&lock, mtx_plain) != thrd_success)
                TEST_FAIL("Cannot create mutex.");

        test_conf_init(NULL, &default_topic_conf,
                       (test_session_timeout_ms * 3) / 1000);

        test_topic_conf_set(default_topic_conf, "auto.offset.reset",
                            "smallest");

        /* Fill in topic subscription set */
        topics = rd_kafka_topic_partition_list_new(1);
        rd_kafka_topic_partition_list_add(topics, topic, RD_KAFKA_PARTITION_UA);

        /* Create consumers and start subscription */
        rk_c = test_create_consumer(
                topic /*group_id*/, rebalance_cb, NULL,
                default_topic_conf);

        test_consumer_subscribe(rk_c, topic);

        rd_kafka_topic_partition_list_destroy(topics);

        /* Wait for both consumers to get an assignment */
        TIMING_START(&t_assign, "WAIT.ASSIGN");
        get_assignment(rk_c);
        TIMING_STOP(&t_assign);

        TIMING_START(&t_consume, "CONSUME.WAIT");
        for (i = 0; i < MAX_THRD_CNT; ++i) {
                if (tids[i] != 0)
                        thrd_join(tids[i], NULL);
        }
        TIMING_STOP(&t_consume);

        TEST_SAY("Closing remaining consumers\n");
        /* Query subscription */
        err = rd_kafka_subscription(rk_c, &sub);
        TEST_ASSERT(!err, "%s: subscription () failed: %s", rd_kafka_name(rk_c),
                    rd_kafka_err2str(err));
        TEST_SAY("%s: subscription (%d):\n", rd_kafka_name(rk_c), sub->cnt);
        for (i = 0; i < sub->cnt; ++i)
                TEST_SAY(" %s\n", sub->elems[i].topic);
        rd_kafka_topic_partition_list_destroy(sub);

        /* Run an explicit unsubscribe () (async) prior to close ()
         * to trigger race condition issues on termination. */
        TEST_SAY("Unsubscribing instance %s\n", rd_kafka_name(rk_c));
        err = rd_kafka_unsubscribe(rk_c);
        TEST_ASSERT(!err, "%s: unsubscribe failed: %s", rd_kafka_name(rk_c),
                    rd_kafka_err2str(err));

        TEST_SAY("Closing %s\n", rd_kafka_name(rk_c));
        TIMING_START(&t_close, "CONSUMER.CLOSE");
        err = rd_kafka_consumer_close(rk_c);
        TIMING_STOP(&t_close);
        TEST_ASSERT(!err, "consumer_close failed: %s", rd_kafka_err2str(err));

        rd_kafka_destroy(rk_c);
        rk_c = NULL;

        TEST_SAY("%d/%d messages consumed\n", consumed_msg_cnt, exp_msg_cnt);
        TEST_ASSERT(consumed_msg_cnt >= exp_msg_cnt,
                    "Only %d/%d messages were consumed", consumed_msg_cnt,
                    exp_msg_cnt);

        if (consumed_msg_cnt > exp_msg_cnt)
                TEST_SAY("At least %d/%d messages were consumed "
                         "multiple times\n",
                         consumed_msg_cnt - exp_msg_cnt, exp_msg_cnt);

        mtx_destroy(&lock);

        return 0;
}