feat: Добавлена поддержка генерации всех представлений всех функций

This commit is contained in:
2021-05-07 00:42:49 +03:00
parent 1e4a37756f
commit e9840a1bbb

View File

@@ -18,9 +18,15 @@ const size_t ARGS_COUNT = 4;
const size_t FUNCTION_LEN = 1ll << ARGS_COUNT;
const size_t FUNCTIONS_COUNT = 1ll << FUNCTION_LEN;
const bool ONLY_CREATE_CLASSES = false;
const bool GENERATE_ALL_REPRESENTATIONS = true;
typedef Function<Storage, FUNCTION_LEN> MyFunction;
typedef BoolSquareMatrix<Storage, ARGS_COUNT> MyMatrix;
static_assert(
GENERATE_ALL_REPRESENTATIONS || !ONLY_CREATE_CLASSES,
"representations required NOT ONLY_CREATE_CLASSES"
);
map<Storage, string> function_formulas;
void test_function() {
@@ -131,6 +137,11 @@ vector< MyMatrix > get_good_matrices() {
vector<MyFunction> get_function_class(MyFunction f, const vector< MyMatrix >& tranformations, ostream& out) {
set<MyFunction> cur_res;
if constexpr ( GENERATE_ALL_REPRESENTATIONS ) {
// Тут достаточно использовать функциональный класс из одной функции.
// Хорошо работает для k=4 и меньше
return vector<MyFunction>{f};
}
for (Storage i = 0; i < FUNCTION_LEN; ++i) {
MyFunction cur_f = f;
for (Storage arg_ind = 0; arg_ind < ARGS_COUNT; ++arg_ind)
@@ -335,7 +346,12 @@ void fill_ranks(vector<MyFunction> monomials) {
--functions_remains;
used_map.at(el.value()) = 1;
}
size_t total_ranks = recover_ranks(ranks, used_map, functions_remains);
size_t total_ranks = 2;
if constexpr ( ONLY_CREATE_CLASSES ) {
total_ranks = recover_ranks(ranks, used_map, functions_remains);
}
clean_trash_ranks(ranks);
cout << "recovered to " << total_ranks << endl;
cout << "current ranks: " << endl;
@@ -405,7 +421,7 @@ void fill_ranks(vector<MyFunction> monomials) {
<< "\\hline" << endl
<< "\\endlastfoot" << endl
<< "\\hline" << endl
<< "Номер класса & Длина & Размер класса & Полином\\\\" << endl
<< "Номер класса & Длина & Размер класса & ПСПФ\\\\" << endl
<< "\\hline" << endl;
ranks.clear();
@@ -423,7 +439,7 @@ void fill_ranks(vector<MyFunction> monomials) {
vector<MyFunction> function_class = get_function_class(
current_fn, possible_tranformations, cout
);
cout << "size of function class " << current_fn.string() << " is " << function_class.size() << endl;
// cout << "size of function class " << current_fn.string() << " is " << function_class.size() << endl;
class_sizes[current_fn] = function_class.size();
for (auto marked_function: function_class) {
if ( used_map[marked_function.value()] == 0 )
@@ -477,5 +493,12 @@ int main() {
cout << "Monomials: " << monomials.size() << endl;
fill_ranks(monomials);
if constexpr ( GENERATE_ALL_REPRESENTATIONS ) {
ofstream f_out(("functions_strings_" + to_string(ARGS_COUNT) + ".txt").c_str());
for (size_t i = 0; i < FUNCTIONS_COUNT; ++i) {
f_out << function_formulas[i] << "\n";
}
}
return 0;
}