コード例 #1
0
ファイル: count_spectra.cpp プロジェクト: ruimaranhao/MHS2
std::ostream & t_count_spectra::print (std::ostream & out,
                                       const t_spectra_filter * filter) const {
    if (filter) {
        assert(filter->get_last_component() <= get_component_count());
        assert(filter->get_last_transaction() <= get_transaction_count());
    }

    t_spectra_iterator it(get_component_count(),
                          get_transaction_count(),
                          filter);
    out << "Tr |";

    while (it.next_component())
        out << std::setw(3) << it.get_component() << "|";

    out << "|Err (q)\n";

    while (it.next_transaction()) {
        out << std::setw(3) << it.get_transaction() << "|";

        while (it.next_component())
            out << std::setw(3) << get_activations(it.get_component(), it.get_transaction()) << "|";

        out << "| " << is_error(it.get_transaction()) << "(" << get_error(it.get_transaction()) << ")\n";
    }

    return out;
}
コード例 #2
0
bool t_spectra::is_candidate (const t_candidate & candidate,
                              const t_spectra_filter * filter) const {
    t_spectra_iterator it(get_component_count(),
                          get_transaction_count(),
                          filter);


    while (it.transaction.next()) {
        bool hit = false;

        if (!is_error(it.transaction.get())) // TODO: Improve performance by maintaining a filter of all failing transactions

            continue;

        BOOST_FOREACH(t_component_id c, candidate) {
            if (get_activations(c, it.transaction.get())) {
                hit = true;
                break;
            }
        }

        if (!hit)
            return false;
    }

    return true;
}
コード例 #3
0
t_count t_spectra::get_suspicious_components_count (t_candidate & suspicious,
                                                    const t_spectra_filter * filter) const {
    t_spectra_filter tmp;


    if (filter)
        tmp = *filter;

    tmp.components.filter_all(suspicious);

    t_spectra_iterator it(get_component_count(),
                          get_transaction_count(),
                          &tmp);

    while (it.transaction.next()) {
        if (!is_error(it.transaction.get())) // TODO: Improve performance by maintaining a filter of all failing transactions

            continue;

        while (it.component.next()) {
            if (is_active(it.component.get(), it.transaction.get())) {
                tmp.components.filter(it.component.get());
                suspicious.insert(it.component.get());
            }
        }
    }

    return suspicious.size();
}
コード例 #4
0
ファイル: count_spectra.cpp プロジェクト: ruimaranhao/MHS2
void t_count_spectra::hit (t_component_id component,
                           t_transaction_id transaction,
                           t_count count,
                           bool ignore_unknown_components) {
    assert(component > 0);
    assert(transaction > 0);

    if (component > get_component_count() ||
        transaction > get_transaction_count()) {
        if (!ignore_unknown_components)
            set_count(std::max(component, get_component_count()),
                      std::max(transaction, get_transaction_count()));
        else
            return;
    }

    activity[(transaction - 1) * get_component_count() + (component - 1)] += count;
}
コード例 #5
0
ファイル: count_spectra.cpp プロジェクト: ruimaranhao/MHS2
std::ostream & t_count_spectra::write (std::ostream & out,
                                       const t_spectra_filter * filter) const {
    if (filter) {
        assert(filter->get_last_component() <= get_component_count());
        assert(filter->get_last_transaction() <= get_transaction_count());
    }

    t_spectra_iterator it(get_component_count(),
                          get_transaction_count(),
                          filter);
    out << get_component_count(filter) << " " << get_transaction_count(filter) << "\n";

    while (it.next_transaction()) {
        while (it.next_component())
            out << get_activations(it.get_component(), it.get_transaction()) << " ";

        out << " " << get_error(it.get_transaction()) << "\n";
    }

    return out;
}
コード例 #6
0
ファイル: count_spectra.cpp プロジェクト: ruimaranhao/MHS2
void t_count_spectra::set_count (t_count component_count,
                                 t_count transaction_count) {
    t_activity_ptr old_activity(activity);

    t_component_id max_component = std::min(component_count, get_component_count());
    t_component_id max_transaction = std::min(transaction_count, get_transaction_count());


    activity = t_activity_ptr(new t_count[component_count * transaction_count]);
    memset(activity.get(), 0, component_count * transaction_count * sizeof(t_count));

    for (t_component_id component = 0;
         component < max_component;
         component++)
        for (t_transaction_id transaction = 0;
             transaction < max_transaction;
             transaction++) {
            activity[transaction * component_count + component] =
                old_activity[transaction * get_component_count() + component];
        }

    t_basic_spectra::set_count(component_count,
                               transaction_count);
}
コード例 #7
0
ファイル: count_spectra.cpp プロジェクト: ruimaranhao/MHS2
t_transaction_id t_count_spectra::new_transaction () {
    set_count(get_component_count(), get_transaction_count() + 1);
    return get_transaction_count();
}