Orbiter 2022
Combinatorial Objects
orbiter_session.cpp
Go to the documentation of this file.
1/*
2 * orbiter_session.cpp
3 *
4 * Created on: May 26, 2020
5 * Author: betten
6 */
7
8
9
10
11
12
13#include "foundations.h"
14
15
16using namespace std;
18
19namespace orbiter {
20namespace layer1_foundations {
21namespace orbiter_kernel_system {
22
24
26
27
29{
30
31 cout << "orbiter_session::orbiter_session" << endl;
32
33 if (Orbiter) {
34 cout << "orbiter_session::orbiter_session The_Orbiter_session is non NULL" << endl;
35 exit(1);
36 }
37 Orbiter = this;
38
39
40 // this needs to come first, because NEW_OBJECT requires it:
41
43
44
45
46 verbose_level = 0;
47
48 t0 = 0;
49
52
55
57
58 f_seed = FALSE;
59 the_seed = TRUE;
60
63
65 //override_polynomial = NULL;
66
68 //orbiter_path;
69
71 //magma_path
72
73 f_fork = FALSE;
75 // fork_variable
76 // fork_logfile_mask
77 fork_from = 0;
78 fork_to = 0;
79 fork_step = 0;
80
82
87
88
91
92
95
96 cout << "orbiter_session::orbiter_session done" << endl;
97
98}
99
100
102{
103 int verbose_level = 1;
104
105 int f_v = (verbose_level >= 1);
106
107 if (f_v) {
108 cout << "orbiter_session::~orbiter_session" << endl;
109 }
110
111
112 cout << "nb_times_finite_field_created=" << nb_times_finite_field_created << endl;
113 cout << "nb_times_projective_space_created=" << nb_times_projective_space_created << endl;
114 cout << "nb_times_action_created=" << nb_times_action_created << endl;
115 cout << "nb_calls_to_densenauty=" << nb_calls_to_densenauty << endl;
116
119 }
120
121 Orbiter = NULL;
122
123 if (f_v) {
124 cout << "orbiter_session::~orbiter_session done" << endl;
125 }
126}
127
128
130 std::string *argv, int i, int verbose_level)
131{
132 string_tools ST;
133
134 if (ST.stringcmp(argv[i], "-v") == 0) {
135 cout << "-v <int : verbosity>" << endl;
136 }
137 else if (ST.stringcmp(argv[i], "-draw_options") == 0) {
138 cout << "-draw_options ... -end" << endl;
139 }
140 else if (ST.stringcmp(argv[i], "-draw_incidence_structure_description") == 0) {
141 cout << "-draw_incidence_structure_description ... -end" << endl;
142 }
143 else if (ST.stringcmp(argv[i], "-list_arguments") == 0) {
144 cout << "-list_arguments" << endl;
145 }
146 else if (ST.stringcmp(argv[i], "-seed") == 0) {
147 cout << "-seed <int : seed>" << endl;
148 }
149 else if (ST.stringcmp(argv[i], "-memory_debug") == 0) {
150 cout << "-memory_debug <int : memory_debug_verbose_level>" << endl;
151 }
152 else if (ST.stringcmp(argv[i], "-override_polynomial") == 0) {
153 cout << "-override_polynomial <string : polynomial in decimal>" << endl;
154 }
155 else if (ST.stringcmp(argv[i], "-orbiter_path") == 0) {
156 cout << "-orbiter_path <string : path>" << endl;
157 }
158 else if (ST.stringcmp(argv[i], "-magma_path") == 0) {
159 cout << "-magma_path <string : path>" << endl;
160 }
161 else if (ST.stringcmp(argv[i], "-fork") == 0) {
162 cout << "-fork <string : variable> <string : logfile_mask> <int : from> <int : to> <int : step>" << endl;
163 }
164}
165
167 std::string *argv, int i, int verbose_level)
168{
169 string_tools ST;
170
171 if (ST.stringcmp(argv[i], "-v") == 0) {
172 return true;
173 }
174 else if (ST.stringcmp(argv[i], "-draw_options") == 0) {
175 return true;
176 }
177 else if (ST.stringcmp(argv[i], "-draw_incidence_structure_description") == 0) {
178 return true;
179 }
180 else if (ST.stringcmp(argv[i], "-list_arguments") == 0) {
181 return true;
182 }
183 else if (ST.stringcmp(argv[i], "-seed") == 0) {
184 return true;
185 }
186 else if (ST.stringcmp(argv[i], "-memory_debug") == 0) {
187 return true;
188 }
189 else if (ST.stringcmp(argv[i], "-override_polynomial") == 0) {
190 return true;
191 }
192 else if (ST.stringcmp(argv[i], "-orbiter_path") == 0) {
193 return true;
194 }
195 else if (ST.stringcmp(argv[i], "-magma_path") == 0) {
196 return true;
197 }
198 else if (ST.stringcmp(argv[i], "-fork") == 0) {
199 return true;
200 }
201 return false;
202}
203
205 std::string *argv, int i0)
206{
207 int i;
208 int f_v = FALSE;
209 string_tools ST;
210
211 cout << "orbiter_session::read_arguments" << endl;
212
213 os_interface Os;
214
215 t0 = Os.os_ticks();
216
218
219 for (i = i0; i < argc; i++) {
220 if (ST.stringcmp(argv[i], "-v") == 0) {
221 verbose_level = ST.strtoi(argv[++i]);
222 f_v = (verbose_level >= 1);
223 //cout << "-v " << verbose_level << endl;
224 }
225 else if (ST.stringcmp(argv[i], "-draw_options") == 0) {
227
229 //cout << "-draw_options " << endl;
230 i += draw_options->read_arguments(argc - (i + 1),
231 argv + i + 1, 0 /*verbose_level*/);
232
233 if (f_v) {
234 cout << "done reading -draw_options " << endl;
235 cout << "i = " << i << endl;
236 cout << "argc = " << argc << endl;
237 if (i < argc) {
238 cout << "next argument is " << argv[i] << endl;
239 }
240 cout << "-f_draw_options " << endl;
242 }
243 }
244 else if (ST.stringcmp(argv[i], "-draw_incidence_structure_description") == 0) {
246
248 //cout << "-draw_incidence_structure_description " << endl;
250 argv + i + 1, 0 /*verbose_level*/);
251
252 if (f_v) {
253 cout << "done reading -draw_incidence_structure_description " << endl;
254 cout << "i = " << i << endl;
255 cout << "argc = " << argc << endl;
256 if (i < argc) {
257 cout << "next argument is " << argv[i] << endl;
258 }
259 cout << "-draw_incidence_structure_description " << endl;
260 }
261 }
262
263
264 else if (ST.stringcmp(argv[i], "-list_arguments") == 0) {
266 if (f_v) {
267 cout << "-list_arguments " << endl;
268 }
269 }
270 else if (ST.stringcmp(argv[i], "-seed") == 0) {
271 f_seed = TRUE;
272 the_seed = ST.strtoi(argv[++i]);
273 if (f_v) {
274 cout << "-seed " << the_seed << endl;
275 }
276 }
277 else if (ST.stringcmp(argv[i], "-memory_debug") == 0) {
279 memory_debug_verbose_level = ST.strtoi(argv[++i]);
280 if (f_v) {
281 cout << "-memory_debug " << memory_debug_verbose_level << endl;
282 }
283 }
284 else if (ST.stringcmp(argv[i], "-override_polynomial") == 0) {
286 override_polynomial.assign(argv[++i]);
287 if (f_v) {
288 cout << "-override_polynomial " << override_polynomial << endl;
289 }
290 }
291 else if (ST.stringcmp(argv[i], "-orbiter_path") == 0) {
293 orbiter_path.assign(argv[++i]);
294 if (f_v) {
295 cout << "-orbiter_path " << orbiter_path << endl;
296 }
297 }
298 else if (ST.stringcmp(argv[i], "-magma_path") == 0) {
300 magma_path.assign(argv[++i]);
301 if (f_v) {
302 cout << "-magma_path " << magma_path << endl;
303 }
304 }
305 else if (ST.stringcmp(argv[i], "-fork") == 0) {
306 f_fork = TRUE;
308 fork_variable.assign(argv[++i]);
309 fork_logfile_mask.assign(argv[++i]);
310 fork_from = ST.strtoi(argv[++i]);
311 fork_to = ST.strtoi(argv[++i]);
312 fork_step = ST.strtoi(argv[++i]);
313 if (f_v) {
314 cout << "-fork " << fork_variable
315 << " " << fork_logfile_mask
316 << " " << fork_from
317 << " " << fork_to
318 << " " << fork_step
319 << endl;
320 }
321 }
322 else {
323 break;
324 }
325 }
326
327 if (f_v) {
328 cout << "orbiter_session::read_arguments done" << endl;
329 }
330 return i;
331}
332
333void orbiter_session::fork(int argc, std::string *argv, int verbose_level)
334{
335 int f_v = (verbose_level >= 1);
336 string_tools ST;
337
338 if (f_v) {
339 cout << "orbiter_session::fork" << endl;
340 }
341
342 cout << "forking with respect to " << fork_variable << endl;
343 int j, h, case_number;
344 vector<int> places;
345
346 for (j = 1; j < argc; j++) {
347 if (ST.stringcmp(argv[j], fork_variable.c_str()) == 0) {
348 if (j != fork_argument_idx + 1) {
349 places.push_back(j);
350 }
351 }
352 }
353 cout << "the variable appears in " << places.size() << " many places:" << endl;
354 for (j = 0; j < places.size(); j++) {
355 cout << "argument " << places[j] << " is " << argv[places[j]] << endl;
356 }
357
358
359 for (case_number = fork_from; case_number < fork_to; case_number += fork_step) {
360
361 cout << "forking case " << case_number << endl;
362
363 string cmd;
364
365 cmd.assign(orbiter_path);
366 cmd.append("orbiter.out");
367 for (j = fork_argument_idx + 6; j < argc; j++) {
368 cmd.append(" \"");
369 for (h = 0; h < places.size(); h++) {
370 if (places[h] == j) {
371 break;
372 }
373 }
374 if (h < places.size()) {
375 char str[1000];
376
377 sprintf(str, "%d", case_number);
378 cmd.append(str);
379 }
380 else {
381 cmd.append(argv[j]);
382 }
383 cmd.append("\" ");
384 }
385 char str[1000];
386
387 sprintf(str, fork_logfile_mask.c_str(), case_number);
388 cmd.append(" >");
389 cmd.append(str);
390 cmd.append(" &");
391 cout << "system: " << cmd << endl;
392 system(cmd.c_str());
393 }
394 if (f_v) {
395 cout << "orbiter_session::fork done" << endl;
396 }
397
398}
399
400
402{
403 return Orbiter_symbol_table->get_object(idx);
404}
405
407{
409}
410
411int orbiter_session::find_symbol(std::string &label)
412{
413 return Orbiter_symbol_table->find_symbol(label);
414}
415
417 int *&v, int &sz, int verbose_level)
418{
419 int f_v = (verbose_level >= 1);
420
421 if (f_v) {
422 cout << "orbiter_session::get_vector_from_label" << endl;
423 }
424 if (isalpha(label[0])) {
425 if (f_v) {
426 cout << "orbiter_session::get_vector_from_label "
427 "searching label " << label << endl;
428 }
429 int idx;
430
431 idx = Orbiter->find_symbol(label);
432
433 if (Orbiter->get_object_type(idx) == t_vector) {
434
435 vector_builder *VB;
436
437 VB = (vector_builder *) Orbiter->get_object(idx);
438
439 sz = VB->len;
440 v = NEW_int(sz);
441 Int_vec_copy(VB->v, v, sz);
442 }
443 else if (Orbiter->get_object_type(idx) == t_set) {
444
445 set_builder *SB;
446
447 SB = (set_builder *) Orbiter->get_object(idx);
448
449 sz = SB->sz;
450 v = NEW_int(sz);
451 Lint_vec_copy_to_int(SB->set, v, sz);
452 }
453 }
454 else {
455
456 Int_vec_scan(label, v, sz);
457 }
458
459 if (f_v) {
460 cout << "orbiter_session::get_vector_from_label done" << endl;
461 }
462}
463
465 int *&v, int &sz, int verbose_level)
466{
467 int f_v = (verbose_level >= 1);
468
469 if (f_v) {
470 cout << "orbiter_session::get_int_vector_from_label" << endl;
471 }
472 if (isalpha(label[0])) {
473 if (f_v) {
474 cout << "orbiter_session::get_int_vector_from_label "
475 "searching label " << label << endl;
476 }
477 int idx;
478
479 idx = Orbiter->find_symbol(label);
480
481 if (Orbiter->get_object_type(idx) == t_vector) {
482
483 vector_builder *VB;
484
485 VB = (vector_builder *) Orbiter->get_object(idx);
486
487 sz = VB->len;
488 v = NEW_int(sz);
489 Int_vec_copy(VB->v, v, sz);
490 }
491 else if (Orbiter->get_object_type(idx) == t_set) {
492
493 set_builder *SB;
494
495 SB = (set_builder *) Orbiter->get_object(idx);
496
497 sz = SB->sz;
498 v = NEW_int(sz);
499 Lint_vec_copy_to_int(SB->set, v, sz);
500 }
501 }
502 else {
503
504 Int_vec_scan(label, v, sz);
505 }
506
507 if (f_v) {
508 cout << "orbiter_session::get_int_vector_from_label done" << endl;
509 }
510}
511
512
514 long int *&v, int &sz, int verbose_level)
515{
516 int f_v = (verbose_level >= 1);
517
518 if (f_v) {
519 cout << "orbiter_session::get_lint_vector_from_label" << endl;
520 }
521 if (isalpha(label[0])) {
522 if (f_v) {
523 cout << "orbiter_session::get_lint_vector_from_label "
524 "searching label " << label << endl;
525 }
526 int idx;
527
528 idx = Orbiter->find_symbol(label);
529
530 if (Orbiter->get_object_type(idx) == t_vector) {
531
532 vector_builder *VB;
533
534 VB = (vector_builder *) Orbiter->get_object(idx);
535
536 sz = VB->len;
537 v = NEW_lint(sz);
538 Int_vec_copy_to_lint(VB->v, v, sz);
539 }
540 else if (Orbiter->get_object_type(idx) == t_set) {
541
542 set_builder *SB;
543
544 SB = (set_builder *) Orbiter->get_object(idx);
545
546 sz = SB->sz;
547 v = NEW_lint(sz);
548 Lint_vec_copy(SB->set, v, sz);
549 }
550 }
551 else {
552
553 Lint_vec_scan(label, v, sz);
554 }
555
556 if (f_v) {
557 cout << "orbiter_session::get_lint_vector_from_label done" << endl;
558 }
559}
560
562 int *&v, int &m, int &n)
563{
564 int verbose_level = 0;
565 int f_v = (verbose_level >= 1);
566
567 if (f_v) {
568 cout << "orbiter_session::get_matrix_from_label" << endl;
569 }
570 if (isalpha(label[0])) {
571 if (f_v) {
572 cout << "orbiter_session::get_matrix_from_label "
573 "searching label " << label << endl;
574 }
575 int idx;
576
577 idx = Orbiter->find_symbol(label);
578
579 if (Orbiter->get_object_type(idx) == t_vector) {
580
581 vector_builder *VB;
582
583 VB = (vector_builder *) Orbiter->get_object(idx);
584
585 int sz;
586
587 sz = VB->len;
588 v = NEW_int(sz);
589 Int_vec_copy(VB->v, v, sz);
590
591 if (!VB->f_has_k) {
592 cout << "orbiter_session::get_matrix_from_label "
593 "the vector does not have matrix formatting information" << endl;
594 exit(1);
595 }
596 m = VB->k;
597 n = (VB->len + m - 1) / m;
598 }
599 else if (Orbiter->get_object_type(idx) == t_set) {
600 cout << "orbiter_session::get_matrix_from_label "
601 "the object must be of type vector" << endl;
602 exit(1);
603 }
604 }
605 else {
606
607 cout << "orbiter_session::get_matrix_from_label "
608 "an object label must be given, starting with a letter" << endl;
609 exit(1);
610 }
611
612 if (f_v) {
613 cout << "orbiter_session::get_matrix_from_label done" << endl;
614 }
615}
616
617
618void orbiter_session::find_symbols(std::vector<std::string> &Labels, int *&Idx)
619{
620 int i, idx;
621
622 Idx = NEW_int(Labels.size());
623
624 for (i = 0; i < Labels.size(); i++) {
625 idx = find_symbol(Labels[i]);
626 if (idx == -1) {
627 cout << "cannot find symbol " << Labels[i] << endl;
628 exit(1);
629 }
630 Idx[i] = idx;
631 }
632}
633
635{
637}
638
640 orbiter_symbol_table_entry *Symb, int verbose_level)
641{
643}
644
645void orbiter_session::get_lint_vec(std::string &label,
646 long int *&the_set, int &set_size, int verbose_level)
647{
648 int f_v = (verbose_level >= 1);
649
650 if (f_v) {
651 cout << "orbiter_session::get_lint_vec" << endl;
652 }
653 if (isalpha(label.c_str()[0])) {
654 int idx;
655
656 if (f_v) {
657 cout << "orbiter_session::get_lint_vec" << endl;
658 cout << "object label " << label << endl;
659 }
660
661
663 if (f_v) {
664 cout << "orbiter_session::get_lint_vec" << endl;
665 cout << "idx = " << idx << endl;
666 }
667 if (idx == -1) {
668 cout << "orbiter_session::get_lint_vec cannot find symbol " << label << endl;
669 exit(1);
670 }
672 cout << "orbiter_session::get_lint_vec object not of type set" << endl;
673 exit(1);
674 }
675 set_builder *SB;
676
678
679 set_size = SB->sz;
680 the_set = NEW_lint(SB->sz);
681 Lint_vec_copy(SB->set, the_set, set_size);
682
683 if (f_v) {
684 cout << "orbiter_session::get_lint_vec" << endl;
685 cout << "set : ";
686 Lint_vec_print(cout, the_set, set_size);
687 cout << endl;
688 }
689
690 }
691 else {
692 Lint_vec_scan(label.c_str(), the_set, set_size);
693 }
694 if (f_v) {
695 cout << "orbiter_session::get_lint_vec done" << endl;
696 }
697
698}
699
701{
703}
704
706{
707 int idx;
708
709 idx = Orbiter_symbol_table->find_symbol(label);
710 if (idx == -1) {
711 cout << "orbiter_session::get_object_of_type_vector cannot find symbol " << label << endl;
712 exit(1);
713 }
714 if (get_object_type(idx) != t_vector) {
715 cout << "orbiter_session::get_object_of_type_vector object type != t_vector" << endl;
716 exit(1);
717 }
718 return (vector_builder *) get_object(idx);
719
720
721}
722
724{
726 cout << "memory debugging started" << endl;
727}
728
730{
732 cout << "memory debugging stopped" << endl;
733}
734
735
736}}}
737
738
to create a set of integers from class set_builder_description
functions related to strings and character arrays
to create a vector of field elements from class vector_builder_description
options for drawing an object of type layered_graph
Definition: graphics.h:457
int read_arguments(int argc, std::string *argv, int verbose_level)
The orbiter session is responsible for the command line interface and the program execution.
void fork(int argc, std::string *argv, int verbose_level)
orbiter_kernel_system::orbiter_symbol_table * Orbiter_symbol_table
void get_vector_from_label(std::string &label, int *&v, int &sz, int verbose_level)
data_structures::vector_builder * get_object_of_type_vector(std::string &label)
void find_symbols(std::vector< std::string > &Labels, int *&Idx)
void get_int_vector_from_label(std::string &label, int *&v, int &sz, int verbose_level)
void get_lint_vec(std::string &label, long int *&the_set, int &set_size, int verbose_level)
void get_lint_vector_from_label(std::string &label, long int *&v, int &sz, int verbose_level)
int recognize_keyword(int argc, std::string *argv, int i, int verbose_level)
void print_help(int argc, std::string *argv, int i, int verbose_level)
void add_symbol_table_entry(std::string &label, orbiter_symbol_table_entry *Symb, int verbose_level)
graphics::draw_incidence_structure_description * Draw_incidence_structure_description
orbiter_kernel_system::mem_object_registry * global_mem_object_registry
void get_matrix_from_label(std::string &label, int *&v, int &m, int &n)
symbol table to store data entries for the orbiter run-time system
symbol table to store data entries for the orbiter run-time system
void add_symbol_table_entry(std::string &str, orbiter_symbol_table_entry *Symb, int verbose_level)
#define Lint_vec_copy(A, B, C)
Definition: foundations.h:694
#define Int_vec_scan(A, B, C)
Definition: foundations.h:716
#define Lint_vec_scan(A, B, C)
Definition: foundations.h:717
#define NEW_OBJECT(type)
Definition: foundations.h:638
#define Lint_vec_print(A, B, C)
Definition: foundations.h:686
#define FREE_OBJECT(p)
Definition: foundations.h:651
#define NEW_int(n)
Definition: foundations.h:625
#define TRUE
Definition: foundations.h:231
#define FALSE
Definition: foundations.h:234
#define Lint_vec_copy_to_int(A, B, C)
Definition: foundations.h:723
#define Int_vec_copy(A, B, C)
Definition: foundations.h:693
#define Int_vec_copy_to_lint(A, B, C)
Definition: foundations.h:722
#define NEW_lint(n)
Definition: foundations.h:628
Basic data structures used throughout the project.
Definition: algorithms.cpp:23
orbiter_kernel_system::orbiter_session * Orbiter
global Orbiter session
the orbiter library for the classification of combinatorial objects