18namespace layer4_classification {
60 int target_size,
int starter_size,
61 std::string &input_prefix, std::string &output_prefix,
62 std::string &solution_prefix, std::string &base_fname,
66 int f_v = (verbose_level >= 1);
67 int f_vv = (verbose_level >= 3);
71 cout <<
"exact_cover::init_basic" << endl;
75 cout <<
"exact_cover::init_basic input_prefix=" <<
input_prefix << endl;
76 cout <<
"exact_cover::init_basic output_prefix=" <<
output_prefix << endl;
77 cout <<
"exact_cover::init_basic solution_prefix=" <<
solution_prefix << endl;
78 cout <<
"exact_cover::init_basic base_fname=" <<
base_fname << endl;
79 cout <<
"exact_cover::init_basic target_size=" <<
target_size << endl;
80 cout <<
"exact_cover::init_basic starter_size=" <<
starter_size << endl;
81 cout <<
"exact_cover::init_basic f_lex=" <<
f_lex << endl;
105 cout <<
"exact_cover::init_basic counting number "
106 "of orbits from file " << fname << endl;
109 cout <<
"exact_cover::init_basic the file " << fname
110 <<
" does not exist" << endl;
116 cout <<
"exact_cover::init_basic starter_nb_cases = "
132 cout <<
"exact_cover::init_basic fname_solutions = "
134 cout <<
"exact_cover::init_basic fname_statistics = "
140 cout <<
"exact_cover::init_basic done" << endl;
145 void (*early_test_func)(
long int *S,
int len,
146 long int *candidates,
int nb_candidates,
147 long int *good_candidates,
int &nb_good_candidates,
148 void *data,
int verbose_level),
149 void *early_test_func_data,
152 int f_v = (verbose_level >= 1);
155 cout <<
"exact_cover::init_early_test_func" << endl;
162 void (*prepare_function_new)(
exact_cover *E,
int starter_case,
169 int f_v = (verbose_level >= 1);
172 cout <<
"exact_cover::init_prepare_function_new" << endl;
179 int f_v = (verbose_level >= 1);
203 cout <<
"exact_cover::set_split fname_solutions = "
205 cout <<
"exact_cover::set_split fname_statistics = "
212 int f_v = (verbose_level >= 1);
234 cout <<
"exact_cover::set_single_case fname_solutions = "
236 cout <<
"exact_cover::set_single_case fname_statistics = "
244 int f_v = (verbose_level >= 1);
248 cout <<
"exact_cover::randomize" << endl;
257 cout <<
"exact_cover::randomize after int_matrix_read_csv "
262 cout <<
"exact_cover::randomize int_matrix_read_csv "
263 "m != starter_nb_cases" << endl;
267 cout <<
"exact_cover::randomize read the random permutation "
268 "of degree " << m <<
" from file "
275 long int *S,
int len,
void *data,
int verbose_level),
276 void *solution_test_func_data,
279 int f_v = (verbose_level >= 1);
282 cout <<
"exact_cover::add_solution_test_function" << endl;
291 int starter_case,
int verbose_level)
301 int f_save,
int f_read_instead,
302 int f_draw_system, std::string &fname_system,
303 int f_write_tree, std::string &fname_tree,
int verbose_level)
305 int f_v = (verbose_level >= 1);
307 int f_v3 = (verbose_level >= 3);
317 int nb_deleted_solutions = 0;
319 int the_starter_case;
326 cout <<
"exact_cover::compute_liftings_new" << endl;
328 cout <<
"f_lex=" <<
f_lex << endl;
329 cout <<
"f_solve=" << f_solve << endl;
330 cout <<
"f_save=" << f_save << endl;
331 cout <<
"f_read_instead=" << f_read_instead << endl;
333 cout <<
"verbose_level=" << verbose_level << endl;
349 int nb_col, nb_sol, nb_sol_deleted, nb_backtrack, dt, sol_length = 0;
374 the_starter_case = starter_case;
377 cout <<
"exact_cover::compute_liftings_new "
378 "starter_case " << starter_case <<
" / "
380 << the_starter_case << endl;
385 long int *Solutions = NULL;
393 string fname_system2;
398 sprintf(str,
"_%d", the_starter_case);
399 fname_system2.assign(fname_system);
400 fname_system2.append(str);
403 sprintf(str,
"_%d", the_starter_case);
404 fname_tree2.assign(fname_tree);
405 fname_tree2.append(str);
409 f_solve, f_save, f_read_instead,
411 Solutions, sol_length, nb_sol, nb_backtrack, dt,
412 f_draw_system, fname_system2,
413 f_write_tree, fname_tree2,
419 int tps, ts, tm, th, td;
423 cout <<
"exact_cover::compute_liftings_new "
424 "starter_case " << starter_case <<
" / "
426 << the_starter_case <<
" found " << nb_sol
427 <<
" solutions with " << nb_backtrack
428 <<
" backtrack nodes in ";
438 cout <<
"exact_cover::compute_liftings_new "
439 "nb_sol && !Solutions" << endl;
444 cout <<
"exact_cover::compute_liftings_new "
445 "There are " << nb_sol <<
" solutions" << endl;
451 cout <<
"exact_cover::compute_liftings_new "
452 "final processing of solutions" << endl;
455 long int *the_solution;
460 for (i = 0; i < nb_sol; i++) {
462 cout <<
"exact_cover::compute_liftings_new "
463 "solution " << i <<
" / " << nb_sol << endl;
467 for (j = 0; j < sol_length; j++) {
469 Solutions[i * sol_length + j];
474 cout <<
"exact_cover::compute_liftings_new "
475 "calling solution_test_func" << endl;
477 f_do_it = (*solution_test_func)(
this,
488 cout <<
"solution " << i <<
" survives the "
489 "test and has been written to file" << endl;
491 fp << the_starter_case;
493 fp <<
" " << the_solution[j];
499 cout <<
"solution " << i <<
" is not a real "
500 "solution, skip" << endl;
503 nb_deleted_solutions++;
511 (*late_cleanup_function)(
this, the_starter_case, verbose_level);
515 nb_sol -= nb_sol_deleted;
517 cout <<
"exact_cover::compute_liftings_new starter_case "
519 <<
" which is case " << the_starter_case
520 <<
" with " << nb_sol <<
" solutions in "
522 "(nb_sol_deleted=" << nb_sol_deleted <<
")" << endl;
524 total_solutions += nb_sol;
525 Case_nb[nb_cases] = the_starter_case;
526 Nb_col[nb_cases] = nb_col;
527 Nb_sol[nb_cases] = nb_sol;
528 Nb_backtrack[nb_cases] = nb_backtrack;
532 Nb_sol_total += nb_sol;
534 fp << -1 <<
" " << Nb_sol_total << endl;
538 cout <<
"total_solutions = " << Nb_sol_total << endl;
539 cout <<
"nb_deleted_solutions=" << nb_deleted_solutions << endl;
542 const char *column_labels[6] = {
"Case_nb",
"Nb_sol",
"Nb_backtrack",
543 "Nb_col",
"Dt",
"Dt_in_sec" };
546 Vec[2] = Nb_backtrack;
567 cout <<
"exact_cover::compute_liftings_new done" << endl;
573 int f_solve,
int f_save,
int f_read_instead,
575 long int *&Solutions,
int &sol_length,
int &nb_sol,
int &nb_backtrack,
int &dt,
576 int f_draw_system, std::string &fname_system,
577 int f_write_tree, std::string &fname_tree,
580 int f_v = (verbose_level >= 1);
581 int f_vv = (verbose_level >= 2);
582 int f_v4 = (verbose_level >= 4);
589 cout <<
"exact_cover::compute_liftings_single_case_new "
591 <<
" verbose_level=" << verbose_level << endl;
596 cout <<
"exact_cover::compute_liftings_single_case_new "
597 "prepare_function_new == NULL" << endl;
607 cout <<
"exact_cover::compute_liftings_single_case_new "
609 <<
" before R->init_from_file" << endl;
622 cout <<
"exact_cover::compute_liftings_single_case_new "
624 <<
" before R->init_from_file prefix=" << prefix << endl;
635 void orbit_rep::init_from_file(
636 action *A,
char *prefix,
637 int level,
int orbit_at_level,
int level_of_candidates_file,
638 void (*early_test_func_callback)(
long int *S,
int len,
639 long int *candidates,
int nb_candidates,
640 long int *good_candidates,
int &nb_good_candidates,
641 void *data,
int verbose_level),
642 void *early_test_func_callback_data,
647 cout <<
"exact_cover::compute_liftings_single_case_new "
649 <<
" after R->init_from_file prefix=" << prefix << endl;
657 cout <<
"exact_cover::compute_liftings_single_case "
659 <<
" stab_go = " << *R->
stab_go <<
" starter = ";
665 cout <<
"exact_cover::compute_liftings_single_case_new "
667 <<
" calling prepare function" << endl;
671 long int *col_labels;
672 int f_ruled_out =
FALSE;
674 (*prepare_function_new)(
this, starter_case,
681 cout <<
"exact_cover::compute_liftings_single_case_new "
682 "after prepare function" << endl;
687 cout <<
"Case is ruled out" << endl;
696 cout <<
"The system is " << Dio->
m <<
" x " << Dio->
n << endl;
707 int xmax_in = 1000000;
708 int ymax_in = 1000000;
709 int xmax_out = 1000000;
710 int ymax_out = 1000000;
714 cout <<
"exact_cover::compute_liftings_single_case_new "
715 "drawing the system" << endl;
721 cout <<
"exact_cover::compute_liftings_single_case_new "
722 "drawing the system done" << endl;
732 sprintf(str,
"system_%d.txt", starter_case);
739 sprintf(str,
"system_%d_Levi_graph.bin", starter_case);
740 fname_Levi.assign(str);
748 sprintf(str,
"system_%d.sol", starter_case);
749 fname_sol.assign(str);
758 cout <<
"exact_cover::compute_liftings_single_case_new " << endl;
766 cout <<
"exact_cover::compute_liftings_single_case_new "
767 "before save_in_general_format, fname=" << fname << endl;
771 cout <<
"exact_cover::compute_liftings_single_case_new "
772 "after save_in_general_format" << endl;
775 if (f_solve || f_read_instead) {
782 long int nb_backtrack_nodes;
785 cout <<
"exact_cover::compute_liftings_single_case_new "
786 "before solve_all_mckay" << endl;
790 cout <<
"exact_cover::compute_liftings_single_case_new "
791 "after solve_all_mckay" << endl;
795 cout <<
"exact_cover::compute_liftings_single_case_new "
796 "before solve_all_DLX_with_RHS" << endl;
799 fname_tree, verbose_level - 5);
801 cout <<
"exact_cover::compute_liftings_single_case_new "
802 "after solve_all_DLX_with_RHS" << endl;
807 cout <<
"exact_cover::compute_liftings_single_case_new "
809 << nb_backtrack_nodes <<
" nb_sol = "
813 else if (f_read_instead) {
818 sprintf(str,
"system_%d.solutions", starter_case);
820 fname_sol.append(str);
823 cout <<
"exact_cover::compute_liftings_single_case_new "
824 "trying to read solution file " << fname_sol
825 <<
" of size " << Fio.
file_size(fname_sol) << endl;
832 cout <<
"exact_cover::compute_liftings_single_case_new "
834 <<
" solutions from file " << fname_sol << endl;
841 sol_length = Dio->
sum;
850 cout <<
"exact_cover::compute_liftings_single_case_new "
851 "nb_sol=" << nb_sol << endl;
859 Solutions, nb_sol, sol_length);
861 for (i = 0; i < nb_sol; i++) {
862 for (j = 0; j < sol_length; j++) {
863 a = Solutions[i * sol_length + j];
865 Solutions[i * sol_length + j] = b;
869 cout <<
"exact_cover::compute_liftings_single_case_new "
870 "nb_sol=" << nb_sol << endl;
901 cout <<
"exact_cover::compute_liftings_single_case_new "
903 <<
" done with " << nb_sol <<
" solutions" << endl;
909 int &nb_live_blocks2,
913 int f_v = (verbose_level >= 1);
916 cout <<
"exact_cover::lexorder_test" << endl;
918 int nb_accepted, max_starter;
924 cout <<
"exact_cover::lexorder_test "
925 "Before lexorder_test, "
926 "nb_live_blocks2=" << nb_live_blocks2 << endl;
929 stab_gens , max_starter, verbose_level);
932 cout <<
"exact_cover::lexorder_test "
933 "After lexorder_test, nb_live_blocks2=" << nb_accepted
934 <<
" we reject " << nb_live_blocks2 - nb_accepted
935 <<
" blocks" << endl;
937 nb_live_blocks2 = nb_accepted;
940 cout <<
"exact_cover::lexorder_test done" << endl;
a collection of functions related to file io
void int_vec_array_write_csv(int nb_vecs, int **Vec, int len, std::string &fname, const char **column_label)
int count_number_of_orbits_in_file(std::string &fname, int verbose_level)
void int_matrix_read_csv(std::string &fname, int *&M, int &m, int &n, int verbose_level)
long int file_size(std::string &fname)
void lint_matrix_write_text(std::string &fname, long int *M, int m, int n)
interface to system functions
int os_ticks_per_second()
void print_elapsed_time(std::ostream &ost, int d, int h, int m, int s)
void os_ticks_to_dhms(int ticks, int tps, int &d, int &h, int &m, int &s)
diophantine systems of equations (i.e., linear systems over the integers)
void get_solutions(long int *&Sol, int &nb_sol, int verbose_level)
void trivial_row_reductions(int &f_no_solution, int verbose_level)
void read_solutions_from_file(std::string &fname_sol, int verbose_level)
int solve_all_mckay(long int &nb_backtrack_nodes, int maxresults, int verbose_level)
int solve_all_DLX_with_RHS(int f_write_tree, const char *fname_tree, int verbose_level)
void write_solutions(std::string &fname, int verbose_level)
void draw_it(std::string &fname_base, graphics::layered_graph_draw_options *Draw_options, int verbose_level)
void save_in_general_format(std::string &fname, int verbose_level)
a permutation group in a fixed action.
void lexorder_test(long int *set, int set_sz, int &set_sz_after_test, data_structures_groups::vector_ge *gens, int max_starter, int verbose_level)
to hold one orbit after reading files from Orbiters poset classification
void init_from_file(actions::action *A, std::string &prefix, int level, int orbit_at_level, int level_of_candidates_file, void(*early_test_func_callback)(long int *S, int len, long int *candidates, int nb_candidates, long int *good_candidates, int &nb_good_candidates, void *data, int verbose_level), void *early_test_func_callback_data, int verbose_level)
ring_theory::longinteger_object * stab_go
groups::strong_generators * Strong_gens
to hold a vector of group elements
a strong generating set for a permutation group with respect to a fixed action
exact cover problems arising with the lifting of combinatorial objects
void set_single_case(int single_case, int verbose_level)
std::string solution_prefix
void set_split(int split_r, int split_m, int verbose_level)
std::string output_prefix
void(* prepare_function_new)(exact_cover *E, int starter_case, long int *candidates, int nb_candidates, groups::strong_generators *Strong_gens, solvers::diophant *&Dio, long int *&col_label, int &f_ruled_out, int verbose_level)
void add_solution_test_function(int(*solution_test_func)(exact_cover *EC, long int *S, int len, void *data, int verbose_level), void *solution_test_func_data, int verbose_level)
std::string fname_solutions
int(* solution_test_func)(exact_cover *EC, long int *S, int len, void *data, int verbose_level)
void init_basic(void *user_data, actions::action *A_base, actions::action *A_on_blocks, int target_size, int starter_size, std::string &input_prefix, std::string &output_prefix, std::string &solution_prefix, std::string &base_fname, int f_lex, int verbose_level)
void add_late_cleanup_function(void(*late_cleanup_function)(exact_cover *E, int starter_case, int verbose_level))
actions::action * A_on_blocks
void compute_liftings_new(int f_solve, int f_save, int f_read_instead, int f_draw_system, std::string &fname_system, int f_write_tree, std::string &fname_tree, int verbose_level)
void init_early_test_func(void(*early_test_func)(long int *S, int len, long int *candidates, int nb_candidates, long int *good_candidates, int &nb_good_candidates, void *data, int verbose_level), void *early_test_func_data, int verbose_level)
void * solution_test_func_data
void * early_test_func_data
void init_prepare_function_new(void(*prepare_function_new)(exact_cover *E, int starter_case, long int *candidates, int nb_candidates, groups::strong_generators *Strong_gens, solvers::diophant *&Dio, long int *&col_label, int &f_ruled_out, int verbose_level), int verbose_level)
void(* early_test_func)(long int *S, int len, long int *candidates, int nb_candidates, long int *good_candidates, int &nb_good_candidates, void *data, int verbose_level)
void(* late_cleanup_function)(exact_cover *E, int starter_case, int verbose_level)
int f_has_solution_test_func
std::string fname_statistics
void randomize(std::string &random_permutation_fname, int verbose_level)
int f_has_late_cleanup_function
void compute_liftings_single_case_new(int starter_case, int f_solve, int f_save, int f_read_instead, int &nb_col, long int *&Solutions, int &sol_length, int &nb_sol, int &nb_backtrack, int &dt, int f_draw_system, std::string &fname_system, int f_write_tree, std::string &fname_tree, int verbose_level)
std::string random_permutation_fname
void lexorder_test(long int *live_blocks2, int &nb_live_blocks2, data_structures_groups::vector_ge *stab_gens, int verbose_level)
#define Lint_vec_copy(A, B, C)
#define Lint_vec_print(A, B, C)
orbiter_kernel_system::orbiter_session * Orbiter
global Orbiter session
the orbiter library for the classification of combinatorial objects