13namespace layer1_foundations {
14namespace combinatorics {
37 int verbose_level = 0;
38 int f_v = (verbose_level >= 1);
41 cout <<
"tdo_data::free" << endl;
64 cout <<
"tdo_data::free before D1" << endl;
71 cout <<
"tdo_data::free before D2" << endl;
78 cout <<
"tdo_data::free done" << endl;
94 int *&line_types,
int &nb_line_types,
int &line_types_allocated)
96 int f_v = (verbose_level >= 1);
97 int f_vv = (verbose_level >= 2);
98 int f_vvv = (verbose_level >= 3);
99 int i, nb_sol, nb_vars;
102 cout <<
"tdo_data::solve_first_system D1->n=" <<
D1->
n << endl;
109 if (nb_line_types >= line_types_allocated) {
110 int new_nb_line_types = line_types_allocated + 100;
112 cout <<
"tdo_data::solve_first_system reallocating to " << new_nb_line_types << endl;
114 int *new_line_types =
NEW_int(new_nb_line_types * nb_vars);
115 for (i = 0; i < nb_line_types * nb_vars; i++) {
116 new_line_types[i] = line_types[i];
119 line_types = new_line_types;
120 line_types_allocated = new_nb_line_types;
124 cout << nb_sol <<
" : ";
125 for (i = 0; i < nb_vars; i++) {
126 cout <<
" " <<
D1->
x[i];
130 for (i = 0; i < nb_vars; i++) {
131 line_types[nb_line_types * nb_vars + i] =
D1->
x[i];
141 cout <<
"tdo_data::solve_first_system: found " << nb_sol
142 <<
" refined types" << endl;
145 cout <<
"tdo_data::solve_first_system done" << endl;
152 int *&line_types,
int &nb_line_types,
153 int *&distributions,
int &nb_distributions,
156 int f_v = (verbose_level >= 1);
157 int f_vv = (verbose_level >= 2);
161 cout <<
"tdo_data::solve_second_system_omit omit=" << omit << endl;
163 int s, i, r = 0, f, l, h, j, u, first, len, N, a, ii, f_bad;
174 int nb_eqns_replaced;
179 cout << r <<
" : " << setw(3) << classes_len[r] <<
" : "
180 << setw(3) << f <<
" : " << setw(3) << l << endl;
182 cout <<
"omit=" << omit << endl;
183 cout <<
"calling D2->project f=" << f <<
" l=" << l << endl;
185 D2->
project(&D, f, l, eqn_number, nb_eqns_replaced,
186 eqns_replaced, verbose_level - 1);
190 cout <<
"after projection:" << endl;
199 cout <<
"number of solutions = " << nb_sol <<
" in "
202 nb_distributions = 0;
203 distributions =
NEW_int(nb_sol * nb_line_types);
206 for (N = 0; N < nb_sol; N++) {
209 cout <<
"tdo_data::solve_second_system_omit "
210 "N=" << N <<
" / " << nb_sol << endl;
213 for (j = 0; j < nb_line_types; j++) {
214 distributions[nb_distributions * nb_line_types + j] = 0;
216 for (j = 0; j < D.
n; j++) {
220 cout <<
"solution " << N <<
":" << endl;
221 for (j = 0; j < D.
n; j++) {
222 cout << setw(3) << D.
x[j] <<
" ";
228 for (i = 0; i <
D2->
m; i++) {
231 for (i = 0; i < D.
m; i++) {
237 cout <<
"RHS1" << endl;
238 for (i = 0; i < D.
m; i++) {
242 cout <<
" : " << D.
RHS1[i] << endl;
247 int nb_eqns_replaced2;
261 cout <<
"tdo_data::solve_second_system_omit "
262 "N=" << N <<
" / " << nb_sol << endl;
263 cout <<
"calling D2->project F=" << F <<
" L=" << L << endl;
266 nb_eqns_replaced2, eqns_replaced2,
270 for (i = 0; i < DD.
m; i++) {
280 cout <<
"after projection:" << endl;
284 cout <<
"solutions does not extend (bad RHS in eqn "
285 << i <<
"), skipping" << endl;
295 long int nb_backtrack;
298 cout <<
"N=" << N <<
" / " << nb_sol
299 <<
" number of solutions = " << nb_sol2 << endl;
302 cout <<
"solutions does not extend "
303 "(no solution), skipping" << endl;
315 distributions[nb_distributions * nb_line_types + u] =
325 for (j = 0; j < len; j++) {
327 distributions[nb_distributions *
328 nb_line_types + first + j] = a;
334 if (nb_distributions == 0) {
335 cout <<
"tdo_data::solve_second_system_omit "
336 "system has no solution" << endl;
339 cout <<
"tdo_data::solve_second_system_omit "
340 "system has " << nb_distributions
341 <<
" solutions" << endl;
351 int nb_eqns_replaced;
358 cout << r <<
" : " << setw(3) << classes_len[r]
359 <<
" : " << setw(3) << f <<
" : "
360 << setw(3) << l << endl;
363 eqns_replaced, verbose_level);
365 D.sum = classes_len[r];
367 D.solve_first(verbose_level);
374 int f_use_mckay_solver,
int f_once,
375 int *classes_len,
int f_scale,
int scaling,
376 int *&line_types,
int &nb_line_types,
377 int *&distributions,
int &nb_distributions,
384 if (cnt_second_system == Sol->
system_no[i]) {
385 cout <<
"reading solutions from file "
388 verbose_level, classes_len,
389 f_scale, scaling, line_types, nb_line_types,
390 distributions, nb_distributions,
397 f_use_mckay_solver, f_once, classes_len,
398 f_scale, scaling, line_types, nb_line_types,
399 distributions, nb_distributions);
403 int *classes_len,
int f_scale,
int scaling,
404 int *&line_types,
int &nb_line_types,
405 int *&distributions,
int &nb_distributions,
406 std::string &solution_file_name)
408 int f_v = (verbose_level >= 1);
409 int cnt, i, j, a, nb_sol, *the_solution;
410 int h, r, u, f, l, first, distributions_allocated;
415 the_solution =
NEW_int(Nb_vars);
417 ifstream ff(solution_file_name);
419 for (i = 0;
TRUE; i++) {
427 for (j = 1; j < Nb_vars; j++) {
435 cout <<
"the solution file " << solution_file_name
436 <<
" contains " << nb_sol <<
" solutions" << endl;
438 distributions_allocated = nb_sol;
439 nb_distributions = 0;
440 distributions =
NEW_int(distributions_allocated * nb_line_types);
442 ifstream ff(solution_file_name);
443 for (cnt = 0; cnt < nb_sol; cnt++) {
444 for (j = 0; j < Nb_vars; j++) {
445 ff >> the_solution[j];
452 distributions[nb_distributions * nb_line_types + u] =
462 for (j = 0; j < l; j++) {
463 a = the_solution[f + j];
467 distributions[nb_distributions * nb_line_types
478 cout <<
"solve_second_system_from_file: found "
479 << nb_distributions <<
" distributions." << endl;
484 int f_use_mckay_solver,
int f_once,
486 int f_scale,
int scaling,
487 int *&line_types,
int &nb_line_types,
488 int *&distributions,
int &nb_distributions)
490 int f_v = (verbose_level >= 1);
491 int f_vv = (verbose_level >= 2);
492 int f_vvv = (verbose_level >= 3);
493 int distributions_allocated, nb_sol, a;
494 int h, r, u, i, f, l, j, first, ret;
495 int Nb_vars, nb_steps = 0;
498 cout <<
"tdo_data::solve_second_system" << endl;
499 cout <<
"f_use_mckay_solver=" << f_use_mckay_solver << endl;
500 cout <<
"f_once=" << f_once << endl;
505 distributions_allocated = 100;
506 nb_distributions = 0;
507 distributions =
NEW_int(distributions_allocated * nb_line_types);
512 if (f_use_mckay_solver) {
523 if (nb_distributions && (nb_distributions % 1000) == 0) {
524 cout <<
"solve_second_system: " << nb_distributions
525 <<
" distributions" << endl;
527 if (nb_distributions >= distributions_allocated) {
528 int new_nb_distributions = distributions_allocated + 100;
530 cout <<
"reallocating to " << new_nb_distributions << endl;
533 int *new_distributions =
NEW_int(
534 new_nb_distributions * nb_line_types);
535 for (i = 0; i < nb_distributions * nb_line_types; i++) {
536 new_distributions[i] = distributions[i];
539 distributions = new_distributions;
540 distributions_allocated = new_nb_distributions;
543 cout << nb_sol <<
" : ";
544 for (i = 0; i < Nb_vars; i++) {
545 cout <<
" " << setw(2) <<
D2->
x[i];
555 distributions[nb_distributions * nb_line_types + u] =
565 for (j = 0; j < l; j++) {
570 distributions[nb_distributions * nb_line_types
581 if (f_use_mckay_solver) {
597 cout <<
"solve_second_system: found " << nb_distributions
598 <<
" distributions in " << nb_steps <<
" steps" << endl;
void solve_second_system_with_help(int verbose_level, int f_use_mckay_solver, int f_once, int *classes_len, int f_scale, int scaling, int *&line_types, int &nb_line_types, int *&distributions, int &nb_distributions, int cnt_second_system, solution_file_data *Sol)
void solve_second_system(int verbose_level, int f_use_mckay_solver, int f_once, int *classes_len, int f_scale, int scaling, int *&line_types, int &nb_line_types, int *&distributions, int &nb_distributions)
int solve_first_system(int verbose_level, int *&line_types, int &nb_line_types, int &line_types_allocated)
void solve_second_system_from_file(int verbose_level, int *classes_len, int f_scale, int scaling, int *&line_types, int &nb_line_types, int *&distributions, int &nb_distributions, std::string &solution_file_name)
void solve_second_system_omit(int verbose_level, int *classes_len, int *&line_types, int &nb_line_types, int *&distributions, int &nb_distributions, int omit)
diophantine systems of equations (i.e., linear systems over the integers)
int solve_next_mckay(int verbose_level)
int solve_next_betten(int verbose_level)
void multiply_A_x_to_RHS1()
int solve_all_mckay(long int &nb_backtrack_nodes, int maxresults, int verbose_level)
int solve_first_mckay_once_option(int f_once, int verbose_level)
void project(diophant *D, int first, int len, int *&eqn_number, int &nb_eqns_replaced, int *&eqns_replaced, int verbose_level)
void write_xml(std::ostream &ost, const char *label)
int solve_all_betten(int verbose_level)
int solve_first_betten(int verbose_level)
std::deque< std::vector< int > > _results
int solve_first(int verbose_level)
the orbiter library for the classification of combinatorial objects
internal class related to tdo_data
std::vector< int > system_no
std::vector< std::string > solution_file