Orbiter 2022
Combinatorial Objects
exact_cover.cpp
Go to the documentation of this file.
1// exact_cover.cpp
2//
3// Anton Betten
4//
5// started: April 30 2013
6//
7//
8//
9
11#include "discreta/discreta.h"
14
15using namespace std;
16
17namespace orbiter {
18namespace layer4_classification {
19
20
22{
23 null();
24}
25
27{
28 freeself();
29}
30
32{
33 starter = NULL;
37
39 early_test_func = NULL;
41
43 //random_permutation_fname = NULL;
44 random_permutation = NULL;
45}
46
48{
49 if (starter) {
51 }
54 }
55 null();
56}
57
58void exact_cover::init_basic(void *user_data,
59 actions::action *A_base, actions::action *A_on_blocks,
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,
63 int f_lex,
64 int verbose_level)
65{
66 int f_v = (verbose_level >= 1);
67 int f_vv = (verbose_level >= 3);
69
70 if (f_v) {
71 cout << "exact_cover::init_basic" << endl;
72 }
73
74 if (f_vv) {
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;
82 }
89 f_split = FALSE;
95
96 string fname;
97 char str[1000];
98
99 fname.assign(input_prefix);
100 fname.append(base_fname);
101 sprintf(str, "_lvl_%d", starter_size);
102 fname.append(str);
103
104 if (f_v) {
105 cout << "exact_cover::init_basic counting number "
106 "of orbits from file " << fname << endl;
107 }
108 if (Fio.file_size(fname) <= 0) {
109 cout << "exact_cover::init_basic the file " << fname
110 << " does not exist" << endl;
111 exit(1);
112 }
114 verbose_level + 2);
115 if (f_v) {
116 cout << "exact_cover::init_basic starter_nb_cases = "
117 << starter_nb_cases << endl;
118 }
119
122
123 sprintf(str, "_depth_%d_solutions.txt", starter_size);
124 fname_solutions.append(str);
125
128 sprintf(str, "_depth_%d_statistics.csv", starter_size);
129 fname_statistics.append(str);
130
131 if (f_vv) {
132 cout << "exact_cover::init_basic fname_solutions = "
133 << fname_solutions << endl;
134 cout << "exact_cover::init_basic fname_statistics = "
135 << fname_statistics << endl;
136 }
138
139 if (f_v) {
140 cout << "exact_cover::init_basic done" << endl;
141 }
142}
143
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,
150 int verbose_level)
151{
152 int f_v = (verbose_level >= 1);
153
154 if (f_v) {
155 cout << "exact_cover::init_early_test_func" << endl;
156 }
159}
160
162 void (*prepare_function_new)(exact_cover *E, int starter_case,
163 long int *candidates, int nb_candidates, groups::strong_generators *Strong_gens,
164 solvers::diophant *&Dio, long int *&col_label,
165 int &f_ruled_out,
166 int verbose_level),
167 int verbose_level)
168{
169 int f_v = (verbose_level >= 1);
170
171 if (f_v) {
172 cout << "exact_cover::init_prepare_function_new" << endl;
173 }
175}
176
177void exact_cover::set_split(int split_r, int split_m, int verbose_level)
178{
179 int f_v = (verbose_level >= 1);
180
184
185 char str[1000];
186
187
190
191
192 sprintf(str, "_depth_%d_split_%d_%d_solutions.txt", starter_size, split_r, split_m);
193 fname_solutions.append(str);
194
195
198
199 sprintf(str, "_depth_%d_split_%d_%d_statistics.csv", starter_size, split_r, split_m);
200 fname_statistics.append(str);
201
202 if (f_v) {
203 cout << "exact_cover::set_split fname_solutions = "
204 << fname_solutions << endl;
205 cout << "exact_cover::set_split fname_statistics = "
206 << fname_statistics << endl;
207 }
208}
209
210void exact_cover::set_single_case(int single_case, int verbose_level)
211{
212 int f_v = (verbose_level >= 1);
213
216
217 char str[1000];
218
221
222
223 sprintf(str, "_depth_%d_case_%d_solutions.txt", starter_size, single_case);
224 fname_solutions.append(str);
225
226
229
230 sprintf(str, "_depth_%d_case_%d_statistics.csv", starter_size, single_case);
231 fname_statistics.append(str);
232
233 if (f_v) {
234 cout << "exact_cover::set_single_case fname_solutions = "
235 << fname_solutions << endl;
236 cout << "exact_cover::set_single_case fname_statistics = "
237 << fname_statistics << endl;
238 }
239}
240
241void exact_cover::randomize(std::string &random_permutation_fname,
242 int verbose_level)
243{
244 int f_v = (verbose_level >= 1);
246
247 if (f_v) {
248 cout << "exact_cover::randomize" << endl;
249 }
250 int m, n;
251
255 random_permutation, m, n, verbose_level);
256 if (n != 1) {
257 cout << "exact_cover::randomize after int_matrix_read_csv "
258 "n != n" << endl;
259 exit(1);
260 }
261 if (m != starter_nb_cases) {
262 cout << "exact_cover::randomize int_matrix_read_csv "
263 "m != starter_nb_cases" << endl;
264 exit(1);
265 }
266 if (f_v) {
267 cout << "exact_cover::randomize read the random permutation "
268 "of degree " << m << " from file "
269 << random_permutation_fname << endl;
270 }
271}
272
274 int (*solution_test_func)(exact_cover *EC,
275 long int *S, int len, void *data, int verbose_level),
276 void *solution_test_func_data,
277 int verbose_level)
278{
279 int f_v = (verbose_level >= 1);
280
281 if (f_v) {
282 cout << "exact_cover::add_solution_test_function" << endl;
283 }
287}
288
290 void (*late_cleanup_function)(exact_cover *E,
291 int starter_case, int verbose_level)
292 )
293{
296}
297
298
299
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)
304{
305 int f_v = (verbose_level >= 1);
306 //int f_vv = (verbose_level >= 2);
307 int f_v3 = (verbose_level >= 3);
308 int Nb_sol_total;
309 int *Case_nb;
310 int *Nb_col;
311 int *Nb_sol;
312 int *Nb_backtrack;
313 int *Dt;
314 int *Dt_in_sec;
315 int nb_cases;
316 int total_solutions;
317 int nb_deleted_solutions = 0;
318 int starter_case;
319 int the_starter_case;
322
323
324
325 if (f_v) {
326 cout << "exact_cover::compute_liftings_new" << endl;
327 cout << "starter_size=" << starter_size << 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;
332 cout << "starter_nb_cases=" << starter_nb_cases << endl;
333 cout << "verbose_level=" << verbose_level << endl;
334 }
335
336
337 Nb_sol_total = 0;
338 Nb_sol = 0;
339 nb_cases = 0;
340 Case_nb = NEW_int(starter_nb_cases);
341 Nb_col = NEW_int(starter_nb_cases);
342 Nb_sol = NEW_int(starter_nb_cases);
343 Nb_backtrack = NEW_int(starter_nb_cases);
345 Dt_in_sec = NEW_int(starter_nb_cases);
346 {
347 ofstream fp(fname_solutions);
348 int f_do_it;
349 int nb_col, nb_sol, nb_sol_deleted, nb_backtrack, dt, sol_length = 0;
350
351 total_solutions = 0;
352
353 for (starter_case = 0; starter_case < starter_nb_cases; starter_case++) {
354 f_do_it = FALSE;
355
356 if (f_split) {
357 if ((starter_case % split_m) == split_r) {
358 f_do_it = TRUE;
359 }
360 }
361 else {
362 f_do_it = TRUE;
363 }
364
365 if (!f_do_it) {
366 continue;
367 }
368
369
370 if (f_randomized) {
371 the_starter_case = random_permutation[starter_case];
372 }
373 else {
374 the_starter_case = starter_case;
375 }
376 if (f_v) {
377 cout << "exact_cover::compute_liftings_new "
378 "starter_case " << starter_case << " / "
379 << starter_nb_cases << " is case "
380 << the_starter_case << endl;
381 }
382 nb_col = 0;
383 nb_sol = 0;
384
385 long int *Solutions = NULL;
386 //char fname1[1000];
387
388
389 //if (f_write_tree) {
390 // sprintf(fname1, fname_tree, starter_case);
391 //}
392
393 string fname_system2;
394 string fname_tree2;
395 char str[1000];
396
397 if (f_draw_system) {
398 sprintf(str, "_%d", the_starter_case);
399 fname_system2.assign(fname_system);
400 fname_system2.append(str);
401 }
402 if (f_write_tree) {
403 sprintf(str, "_%d", the_starter_case);
404 fname_tree2.assign(fname_tree);
405 fname_tree2.append(str);
406 //sprintf(fname_tree2, "%s_%d", fname_tree, the_starter_case);
407 }
408 compute_liftings_single_case_new(the_starter_case,
409 f_solve, f_save, f_read_instead,
410 nb_col,
411 Solutions, sol_length, nb_sol, nb_backtrack, dt,
412 f_draw_system, fname_system2,
413 f_write_tree, fname_tree2,
414 verbose_level /* - 2 */);
415
416 // see below
417
418 if (f_v) {
419 int tps, ts, tm, th, td;
420
421 tps = Os.os_ticks_per_second();
422 Os.os_ticks_to_dhms(dt, tps, td, th, tm, ts);
423 cout << "exact_cover::compute_liftings_new "
424 "starter_case " << starter_case << " / "
425 << starter_nb_cases << " which is case "
426 << the_starter_case << " found " << nb_sol
427 << " solutions with " << nb_backtrack
428 << " backtrack nodes in ";
429 Os.print_elapsed_time(cout, td, th, tm, ts);
430 cout << endl;
431 }
432
433 nb_sol_deleted = 0;
434
435 if (nb_sol) {
436
437 if (!Solutions) {
438 cout << "exact_cover::compute_liftings_new "
439 "nb_sol && !Solutions" << endl;
440 exit(1);
441 }
442
443 if (f_v3) {
444 cout << "exact_cover::compute_liftings_new "
445 "There are " << nb_sol << " solutions" << endl;
446 //int_matrix_print(Solutions, nb_sol, sol_length);
447 }
448
449
450 if (f_v3) {
451 cout << "exact_cover::compute_liftings_new "
452 "final processing of solutions" << endl;
453 }
454
455 long int *the_solution;
456
457 the_solution = NEW_lint(starter_size + sol_length);
458 int i, j, f_do_it;
459
460 for (i = 0; i < nb_sol; i++) {
461 if (FALSE /* f_v3 */) {
462 cout << "exact_cover::compute_liftings_new "
463 "solution " << i << " / " << nb_sol << endl;
464 }
465
466 Lint_vec_copy(starter, the_solution, starter_size);
467 for (j = 0; j < sol_length; j++) {
468 the_solution[starter_size + j] =
469 Solutions[i * sol_length + j];
470 }
471
473 if (FALSE /* f_v3 */) {
474 cout << "exact_cover::compute_liftings_new "
475 "calling solution_test_func" << endl;
476 }
477 f_do_it = (*solution_test_func)(this,
478 the_solution, starter_size + sol_length,
479 solution_test_func_data, 0 /* verbose_level */);
480 }
481 else {
482 f_do_it = TRUE;
483 }
484
485
486 if (f_do_it) {
487 if (f_has_solution_test_func && f_v3) {
488 cout << "solution " << i << " survives the "
489 "test and has been written to file" << endl;
490 }
491 fp << the_starter_case;
492 for (j = 0; j < starter_size + sol_length; j++) {
493 fp << " " << the_solution[j];
494 }
495 fp << endl;
496 }
497 else {
498 if (f_v3) {
499 cout << "solution " << i << " is not a real "
500 "solution, skip" << endl;
501 }
502 nb_sol_deleted++;
503 nb_deleted_solutions++;
504 }
505 }
506 FREE_lint(the_solution);
507 FREE_lint(Solutions);
508 }
509
511 (*late_cleanup_function)(this, the_starter_case, verbose_level);
512 }
513
514
515 nb_sol -= nb_sol_deleted;
516 if (f_v) {
517 cout << "exact_cover::compute_liftings_new starter_case "
518 << starter_case << " / " << starter_nb_cases
519 << " which is case " << the_starter_case
520 << " with " << nb_sol << " solutions in "
521 << dt / Os.os_ticks_per_second() << " sec "
522 "(nb_sol_deleted=" << nb_sol_deleted << ")" << endl;
523 }
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;
529 Dt[nb_cases] = dt;
530 Dt_in_sec[nb_cases] = dt / Os.os_ticks_per_second();
531 nb_cases++;
532 Nb_sol_total += nb_sol;
533 }
534 fp << -1 << " " << Nb_sol_total << endl;
535 }
536 cout << "written file " << fname_solutions << " of size "
537 << Fio.file_size(fname_solutions) << endl;
538 cout << "total_solutions = " << Nb_sol_total << endl;
539 cout << "nb_deleted_solutions=" << nb_deleted_solutions << endl;
540
541 int *Vec[6];
542 const char *column_labels[6] = {"Case_nb", "Nb_sol", "Nb_backtrack",
543 "Nb_col", "Dt", "Dt_in_sec" };
544 Vec[0] = Case_nb;
545 Vec[1] = Nb_sol;
546 Vec[2] = Nb_backtrack;
547 Vec[3] = Nb_col;
548 Vec[4] = Dt;
549 Vec[5] = Dt_in_sec;
550
551 Fio.int_vec_array_write_csv(6, Vec, nb_cases,
552 fname_statistics, column_labels);
553 //int_vecs_write_csv(Nb_sol, Nb_col, nb_cases,
554 //fname_statistics, "Nb_sol", "Nb_col");
555 cout << "written file " << fname_statistics << " of size "
556 << Fio.file_size(fname_statistics) << endl;
557
558
559
560 FREE_int(Case_nb);
561 FREE_int(Nb_col);
562 FREE_int(Nb_sol);
563 FREE_int(Nb_backtrack);
564 FREE_int(Dt);
565 FREE_int(Dt_in_sec);
566 if (f_v) {
567 cout << "exact_cover::compute_liftings_new done" << endl;
568 }
569}
570
571
573 int f_solve, int f_save, int f_read_instead,
574 int &nb_col,
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,
578 int verbose_level)
579{
580 int f_v = (verbose_level >= 1);
581 int f_vv = (verbose_level >= 2);
582 int f_v4 = (verbose_level >= 4);
583 string prefix;
586
587
588 if (f_v) {
589 cout << "exact_cover::compute_liftings_single_case_new "
590 "case " << starter_case << " / " << starter_nb_cases
591 << " verbose_level=" << verbose_level << endl;
592 }
593
594
595 if (prepare_function_new == NULL) {
596 cout << "exact_cover::compute_liftings_single_case_new "
597 "prepare_function_new == NULL" << endl;
598 exit(1);
599 }
600
601 Solutions = NULL;
602 nb_sol = 0;
603 nb_col = 0;
604 nb_backtrack = 0;
605
606 if (f_vv) {
607 cout << "exact_cover::compute_liftings_single_case_new "
608 "case " << starter_case << " / " << starter_nb_cases
609 << " before R->init_from_file" << endl;
610 }
611
612
613 prefix.assign(input_prefix);
614 prefix.append(base_fname);
615 //snprintf(str, 2000, "%s%s", input_prefix, base_fname);
616
619
620
621 if (f_vv) {
622 cout << "exact_cover::compute_liftings_single_case_new "
623 "case " << starter_case << " / " << starter_nb_cases
624 << " before R->init_from_file prefix=" << prefix << endl;
625 }
626
627 R->init_from_file(A_base, prefix,
628 starter_size, starter_case, starter_size - 1,
631 verbose_level - 3
632 );
633
634#if 0
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,
643 int verbose_level)
644#endif
645
646 if (f_vv) {
647 cout << "exact_cover::compute_liftings_single_case_new "
648 "case " << starter_case << " / " << starter_nb_cases
649 << " after R->init_from_file prefix=" << prefix << endl;
650 }
651
652 // R has: int *candidates; int nb_candidates;
653
655
656 if (f_v) {
657 cout << "exact_cover::compute_liftings_single_case "
658 "case " << starter_case << " / " << starter_nb_cases
659 << " stab_go = " << *R->stab_go << " starter = ";
661 cout << endl;
662 }
663
664 if (f_vv) {
665 cout << "exact_cover::compute_liftings_single_case_new "
666 "case " << starter_case << " / " << starter_nb_cases
667 << " calling prepare function" << endl;
668 }
669
670 solvers::diophant *Dio = NULL;
671 long int *col_labels;
672 int f_ruled_out = FALSE;
673
674 (*prepare_function_new)(this, starter_case,
676 Dio, col_labels,
677 f_ruled_out,
678 verbose_level);
679
680 if (f_vv) {
681 cout << "exact_cover::compute_liftings_single_case_new "
682 "after prepare function" << endl;
683 }
684
685 if (f_ruled_out) {
686 if (f_vv) {
687 cout << "Case is ruled out" << endl;
688 }
689 nb_sol = 0;
690 nb_col = 0;
691 nb_backtrack = 0;
692 dt = 0;
693 }
694 else {
695 if (f_vv) {
696 cout << "The system is " << Dio->m << " x " << Dio->n << endl;
697 }
698 if (FALSE && f_v4) {
699 Dio->print();
700 }
701
702 Dio->trivial_row_reductions(f_ruled_out, verbose_level);
703
704
705 if (f_draw_system) {
706#if 0
707 int xmax_in = 1000000;
708 int ymax_in = 1000000;
709 int xmax_out = 1000000;
710 int ymax_out = 1000000;
711#endif
712
713 if (f_v) {
714 cout << "exact_cover::compute_liftings_single_case_new "
715 "drawing the system" << endl;
716 }
717 Dio->draw_it(fname_system,
718 orbiter_kernel_system::Orbiter->draw_options,
719 verbose_level - 1);
720 if (f_v) {
721 cout << "exact_cover::compute_liftings_single_case_new "
722 "drawing the system done" << endl;
723 }
724 }
725
726 char str[1000];
727 string fname;
728 string fname_Levi;
729 string fname_sol;
730
731 fname.assign(output_prefix);
732 sprintf(str, "system_%d.txt", starter_case);
733 fname.assign(str);
734
735 //sprintf(fname, "%ssystem_%d.txt", output_prefix, starter_case);
736
737
738 fname_Levi.assign(output_prefix);
739 sprintf(str, "system_%d_Levi_graph.bin", starter_case);
740 fname_Levi.assign(str);
741
742
743 //sprintf(fname_Levi, "%ssystem_%d_Levi_graph.bin",
744 // output_prefix, starter_case);
745
746
747 fname_sol.assign(output_prefix);
748 sprintf(str, "system_%d.sol", starter_case);
749 fname_sol.assign(str);
750
751 //sprintf(fname_sol, "%ssystem_%d.sol", output_prefix, starter_case);
752
753
754 if (f_save) {
755
756
757 if (f_v) {
758 cout << "exact_cover::compute_liftings_single_case_new " << endl;
759 //"before save_as_Levi_graph, fname=" << fname_Levi << endl;
760 }
761
762
763 //Dio->save_as_Levi_graph(fname_Levi, verbose_level - 1);
764
765 if (f_v) {
766 cout << "exact_cover::compute_liftings_single_case_new "
767 "before save_in_general_format, fname=" << fname << endl;
768 }
769 Dio->save_in_general_format(fname, verbose_level - 1);
770 if (f_v) {
771 cout << "exact_cover::compute_liftings_single_case_new "
772 "after save_in_general_format" << endl;
773 }
774 }
775 if (f_solve || f_read_instead) {
776 int t0 = 0, t1 = 0;
777 int i, j, a, b;
778
779 if (f_solve) {
780 t0 = Os.os_ticks();
781
782 long int nb_backtrack_nodes;
783
784 if (f_v) {
785 cout << "exact_cover::compute_liftings_single_case_new "
786 "before solve_all_mckay" << endl;
787 }
788 Dio->solve_all_mckay(nb_backtrack_nodes, INT_MAX, verbose_level - 3);
789 if (f_v) {
790 cout << "exact_cover::compute_liftings_single_case_new "
791 "after solve_all_mckay" << endl;
792 }
793#if 0
794 if (f_v) {
795 cout << "exact_cover::compute_liftings_single_case_new "
796 "before solve_all_DLX_with_RHS" << endl;
797 }
798 Dio->solve_all_DLX_with_RHS(f_write_tree,
799 fname_tree, verbose_level - 5);
800 if (f_v) {
801 cout << "exact_cover::compute_liftings_single_case_new "
802 "after solve_all_DLX_with_RHS" << endl;
803 }
804#endif
805 t1 = Os.os_ticks();
806 if (f_v) {
807 cout << "exact_cover::compute_liftings_single_case_new "
808 "nb_backtrack = "
809 << nb_backtrack_nodes << " nb_sol = "
810 << Dio->_resultanz << endl;
811 }
812 }
813 else if (f_read_instead) {
814 string fname_sol;
815 char str[1000];
816
817
818 sprintf(str, "system_%d.solutions", starter_case);
819 fname_sol.assign(solution_prefix);
820 fname_sol.append(str);
821
822 if (f_v) {
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;
826 }
827
828 Dio->read_solutions_from_file(fname_sol, 0 /*verbose_level - 2*/);
829 Dio->nb_steps_betten = 0;
830
831 if (f_v) {
832 cout << "exact_cover::compute_liftings_single_case_new "
833 "read " << Dio->_resultanz
834 << " solutions from file " << fname_sol << endl;
835 }
836
837 }
838 nb_col = Dio->n;
839 nb_sol = Dio->_resultanz;
840 nb_backtrack = Dio->nb_steps_betten;
841 sol_length = Dio->sum;
842 if (nb_sol) {
843#if 0
844 if (f_save) {
845 Dio->write_solutions(verbose_level);
846 }
847#endif
848 Dio->get_solutions(Solutions, nb_sol, 0/*verbose_level - 1*/);
849 if (f_v4) {
850 cout << "exact_cover::compute_liftings_single_case_new "
851 "nb_sol=" << nb_sol << endl;
852 //cout << "exact_cover::compute_liftings_single_case_new "
853 //"Solutions:" << endl;
854 //int_matrix_print(Solutions, nb_sol, sol_length);
855 }
856
857 if (f_save) {
858 Fio.lint_matrix_write_text(fname_sol,
859 Solutions, nb_sol, sol_length);
860 }
861 for (i = 0; i < nb_sol; i++) {
862 for (j = 0; j < sol_length; j++) {
863 a = Solutions[i * sol_length + j];
864 b = col_labels[a];
865 Solutions[i * sol_length + j] = b;
866 }
867 }
868 if (f_v4) {
869 cout << "exact_cover::compute_liftings_single_case_new "
870 "nb_sol=" << nb_sol << endl;
871 //cout << "exact_cover::compute_liftings_single_case_new "
872 //"Solutions in terms of col_labels[]:" << endl;
873 //int_matrix_print(Solutions, nb_sol, sol_length);
874 }
875 }
876 else {
877 Solutions = NULL;
878 }
879 dt = t1 - t0;
880 }
881 else {
882 nb_sol = 0;
883 nb_col = Dio->n;
884 nb_backtrack = 0;
885 dt = 0;
886 sol_length = 0;
887 }
888 } // else
889
890
891 if (Dio) {
892 delete Dio;
893 FREE_lint(col_labels);
894 // we don't use cleanup_function any more
895 }
896
897
898 delete R;
899
900 if (f_v) {
901 cout << "exact_cover::compute_liftings_single_case_new "
902 "case " << starter_case << " / " << starter_nb_cases
903 << " done with " << nb_sol << " solutions" << endl;
904 }
905
906}
907
908void exact_cover::lexorder_test(long int *live_blocks2,
909 int &nb_live_blocks2,
911 int verbose_level)
912{
913 int f_v = (verbose_level >= 1);
914
915 if (f_v) {
916 cout << "exact_cover::lexorder_test" << endl;
917 }
918 int nb_accepted, max_starter;
919
920 if (starter_size) {
921 max_starter = starter[starter_size - 1];
922
923 if (f_v) {
924 cout << "exact_cover::lexorder_test "
925 "Before lexorder_test, "
926 "nb_live_blocks2=" << nb_live_blocks2 << endl;
927 }
928 A_on_blocks->lexorder_test(live_blocks2, nb_live_blocks2, nb_accepted,
929 stab_gens /*starter_stabilizer_gens */, max_starter, verbose_level);
930
931 if (f_v) {
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;
936 }
937 nb_live_blocks2 = nb_accepted;
938 }
939 if (f_v) {
940 cout << "exact_cover::lexorder_test done" << endl;
941 }
942}
943
944}}
945
void int_vec_array_write_csv(int nb_vecs, int **Vec, int len, std::string &fname, const char **column_label)
Definition: file_io.cpp:1240
int count_number_of_orbits_in_file(std::string &fname, int verbose_level)
Definition: file_io.cpp:1918
void int_matrix_read_csv(std::string &fname, int *&M, int &m, int &n, int verbose_level)
Definition: file_io.cpp:1477
void lint_matrix_write_text(std::string &fname, long int *M, int m, int n)
Definition: file_io.cpp:1734
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)
Definition: solvers.h:209
void get_solutions(long int *&Sol, int &nb_sol, int verbose_level)
Definition: diophant.cpp:1062
void trivial_row_reductions(int &f_no_solution, int verbose_level)
Definition: diophant.cpp:2427
void read_solutions_from_file(std::string &fname_sol, int verbose_level)
Definition: diophant.cpp:1010
int solve_all_mckay(long int &nb_backtrack_nodes, int maxresults, int verbose_level)
Definition: diophant.cpp:1435
int solve_all_DLX_with_RHS(int f_write_tree, const char *fname_tree, int verbose_level)
Definition: diophant.cpp:1279
void write_solutions(std::string &fname, int verbose_level)
Definition: diophant.cpp:958
void draw_it(std::string &fname_base, graphics::layered_graph_draw_options *Draw_options, int verbose_level)
Definition: diophant.cpp:4043
void save_in_general_format(std::string &fname, int verbose_level)
Definition: diophant.cpp:2879
a permutation group in a fixed action.
Definition: actions.h:99
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)
Definition: action.cpp:2438
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)
Definition: orbit_rep.cpp:67
a strong generating set for a permutation group with respect to a fixed action
Definition: groups.h:1703
exact cover problems arising with the lifting of combinatorial objects
Definition: solver.h:27
void set_single_case(int single_case, int verbose_level)
void set_split(int split_r, int split_m, int verbose_level)
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)
Definition: solver.h:44
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)
int(* solution_test_func)(exact_cover *EC, long int *S, int len, void *data, int verbose_level)
Definition: solver.h:60
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)
Definition: exact_cover.cpp:58
void add_late_cleanup_function(void(*late_cleanup_function)(exact_cover *E, int starter_case, int verbose_level))
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 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)
Definition: solver.h:53
void(* late_cleanup_function)(exact_cover *E, int starter_case, int verbose_level)
Definition: solver.h:65
void randomize(std::string &random_permutation_fname, int verbose_level)
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)
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)
Definition: foundations.h:694
#define FREE_int(p)
Definition: foundations.h:640
#define NEW_OBJECT(type)
Definition: foundations.h:638
#define Lint_vec_print(A, B, C)
Definition: foundations.h:686
#define NEW_int(n)
Definition: foundations.h:625
#define TRUE
Definition: foundations.h:231
#define FALSE
Definition: foundations.h:234
#define FREE_lint(p)
Definition: foundations.h:642
#define NEW_lint(n)
Definition: foundations.h:628
orbiter_kernel_system::orbiter_session * Orbiter
global Orbiter session
the orbiter library for the classification of combinatorial objects