forked from libsemigroups/libsemigroups_pybind11
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtodd-coxeter-impl.cpp
More file actions
1622 lines (1308 loc) · 55.9 KB
/
todd-coxeter-impl.cpp
File metadata and controls
1622 lines (1308 loc) · 55.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//
// libsemigroups_pybind11
// Copyright (C) 2024 James Mitchell
//
// This program is free software:you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// TODO(0.5): remove the doc that isn't actually used
// libsemigroups headers
#include <chrono>
#include <libsemigroups/todd-coxeter.hpp>
#include <libsemigroups/detail/cong-common-class.hpp>
// pybind11....
#include <pybind11/chrono.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
// libsemigroups_pybind11....
#include "cong-common.hpp" // for contains
#include "main.hpp" // for init_detail_todd_coxeter_impl
namespace libsemigroups {
namespace py = pybind11;
using std::literals::operator""sv;
void init_detail_todd_coxeter_impl(py::module& m) {
using ToddCoxeterImpl_ = detail::ToddCoxeterImpl;
py::class_<ToddCoxeterImpl_, detail::CongruenceCommon> thing(
m, "ToddCoxeterImpl");
py::class_<ToddCoxeterImpl_::options> options(thing,
"options",
R"pbdoc(
This class containing various options that can be used to control the
behaviour of Todd-Coxeter.)pbdoc");
py::options enum_settings;
enum_settings.disable_enum_members_docstring();
py::enum_<ToddCoxeterImpl_::options::strategy> strategy(options,
"strategy",
R"pbdoc(
:sig=(self: ToddCoxeter.options.strategy, value: int):
Values for defining the strategy.
The values in this enum can be used as the argument for the method
:py:meth:`ToddCoxeter.strategy` to specify which strategy should be
used when performing a coset enumeration.
The valid values are :
.. py:attribute:: strategy.hlt
:value: <strategy.hlt: 0>
This value indicates that the HLT (Hazelgrove-Leech-Trotter) strategy should be used. This is analogous to ACE's R-style.
.. py:attribute:: strategy.felsch
:value: <strategy.felsch: 1>
This value indicates that the Felsch strategy should be used. This is analogous to ACE's C-style.
.. py:attribute:: strategy.CR
:value: <strategy.CR: 2>
This strategy is meant to mimic the ACE strategy of the same name. The Felsch is run until at least :any:`f_defs` nodes are defined, then the HLT strategy is run until at least :any:`hlt_defs` divided by :math:`N` nodes have been defined, where :math:`N` is the sum of the lengths of the words in the presentation and generating pairs. These steps are repeated until the enumeration terminates.
.. py:attribute:: strategy.R_over_C
:value: <strategy.R_over_C: 3>
This strategy is meant to mimic the ACE strategy R/C. The HLT strategy is run until the first lookahead is triggered (when :the number of nodes active is at least :any:`lookahead_next`). A full lookahead is then performed, and then the CR strategy is used.
.. py:attribute:: strategy.Cr
:value: <strategy.Cr: 4>
This strategy is meant to mimic the ACE strategy Cr. The Felsch strategy is run until at least :any:`f_defs` new nodes have been defined, then the HLT strategy is run until at least :any:`hlt_defs` divided by :math:`N` nodes have been defined, where :math:`N` is the sum of the lengths of the words in the presentation and generating pairs. Then the Felsch strategy is run.
.. py:attribute:: strategy.Rc
:value: <strategy.Rc: 5>
This strategy is meant to mimic the ACE strategy Rc. The HLT strategy is run until at least :any:`hlt_defs` divided by :math:`N` new nodes have been defined (where :math:`N` is the sum of the lengths of the words in the presentation and generating pairs) the Felsch strategy is then run until at least :any:`f_defs` new nodes are defined, and then the HLT strategy is run.
)pbdoc");
strategy.value("hlt", ToddCoxeterImpl_::options::strategy::hlt)
.value("felsch", ToddCoxeterImpl_::options::strategy::felsch)
.value("CR", ToddCoxeterImpl_::options::strategy::CR)
.value("R_over_C", ToddCoxeterImpl_::options::strategy::R_over_C)
.value("Cr", ToddCoxeterImpl_::options::strategy::Cr)
.value("Rc", ToddCoxeterImpl_::options::strategy::Rc)
.export_values();
py::enum_<ToddCoxeterImpl_::options::lookahead_extent>(options,
"lookahead_extent",
R"pbdoc(
:sig=(self: ToddCoxeter.options.lookahead_extent, value: int):
Enum for specifying the extent of any lookahead performed.
The values in this enum can be used as the argument for
:any:`ToddCoxeter.lookahead_extent` to specify the extent of any lookahead that
should be performed.
The valid values are :
.. py:attribute:: lookahead_extent.full
:value: <lookahead_extent.full: 0>
Perform a full lookahead from every node in the word graph. Full lookaheads are therefore sometimes slower but may detect more coincidences than a partial lookahead.
.. py:attribute:: lookahead_extent.partial
:value: <lookahead_extent.partial: 1>
Perform a partial lookahead starting from the current node in the word graph. Partial lookaheads are sometimes faster but may not detect as many coincidences as a full lookahead.
)pbdoc")
.value("full", ToddCoxeterImpl_::options::lookahead_extent::full)
.value("partial", ToddCoxeterImpl_::options::lookahead_extent::partial)
.export_values();
py::enum_<ToddCoxeterImpl_::options::lookahead_style>(options,
"lookahead_style",
R"pbdoc(
:sig=(self: ToddCoxeter.options.lookahead_style, value: int):
Enum class for specifying the style of any lookahead performed.
The values in this enum can be used as the argument for
:any:`ToddCoxeter.lookahead_style` to specify the style of any lookahead that
should be performed.
The valid values are :
.. py:attribute:: lookahead_style.hlt
:value: <lookahead_style.hlt: 0>
The lookahead will be done in HLT style by following the paths labelled by every relation from every node in the range specified by :any:`lookahead_extent.full` or :any:`lookahead_extent.partial`.
.. py:attribute:: lookahead_style.felsch
:value: <lookahead_style.hlt: 0>
The lookahead will be done in Felsch style where every edge is considered in every path labelled by a relation in which it occurs.
)pbdoc")
.value("hlt", ToddCoxeterImpl_::options::lookahead_style::hlt)
.value("felsch", ToddCoxeterImpl_::options::lookahead_style::felsch)
.export_values();
py::enum_<ToddCoxeterImpl_::options::def_policy>(options,
"def_policy",
R"pbdoc(
:sig=(self: ToddCoxeter.options.def_policy, value: int):
Enum class containing values for specifying how to handle edge
definitions.
The values in this enum can be used as the argument for
:any:`ToddCoxeter.def_policy`.
For our purposes, a *definition* is a recently defined edge in the
word graph that we are attempting to construct in an instance of
:any:`ToddCoxeter`. The values in this enum influence how these
definitions are stored and processed.
For every definition held in the definition stack, a depth first
search through the Felsch tree of the generating pairs is
performed. The aim is to only follow paths from nodes in the word
graph labelled by generating pairs that actually pass through the
edge described by a definition.
The values in this enum represent what to do if the number of
definitions in the stack exceeds the value :any:`ToddCoxeter.def_max`.
The valid values are:
.. py:attribute:: def_policy.no_stack_if_no_space
:value: <def_policy.no_stack_if_no_space: 0>
Do not put newly generated definitions in the stack if the stack already has size :any:`def_max`.
.. py:attribute:: def_policy.purge_from_top
:value: <def_policy.purge_from_top: 1>
If the definition stack has size :any:`def_max` and a new definition is generated, then definitions with dead source node are are popped from the top of the stack (if any).
.. py:attribute:: def_policy.purge_all
:value: <def_policy.purge_all: 2>
If the definition stack has size :any:`def_max` and a new definition is generated, then definitions with dead source node are are popped from the entire of the stack (if any).
.. py:attribute:: def_policy.discard_all_if_no_space
:value: <def_policy.discard_all_if_no_space: 3>
If the definition stack has size :any:`def_max` and a new definition is generated, then all definitions in the stack are discarded.
.. py:attribute:: def_policy.unlimited
:value: <def_policy.unlimited: 4>
There is no limit to the number of definitions that can be put in the stack.
)pbdoc")
.value("no_stack_if_no_space",
ToddCoxeterImpl_::options::def_policy::no_stack_if_no_space)
.value("purge_from_top",
ToddCoxeterImpl_::options::def_policy::purge_from_top)
.value("purge_all", ToddCoxeterImpl_::options::def_policy::purge_all)
.value("discard_all_if_no_space",
ToddCoxeterImpl_::options::def_policy::discard_all_if_no_space)
.value("unlimited", ToddCoxeterImpl_::options::def_policy::unlimited)
.export_values();
py::enum_<ToddCoxeterImpl_::word_graph_type::options::def_version>(
options,
"def_version",
R"pbdoc(
:sig=(self: ToddCoxeter.options.def_version, value: int):
Values for specifying how to handle definitions.
The valid values are:
.. py:attribute:: def_version.one
:value: <def_version.one: 0>
Version 1 definition processing.
.. py:attribute:: def_version.two
:value: <def_version.two: 1>
Version 2 definition processing.
)pbdoc")
.value("one",
ToddCoxeterImpl_::word_graph_type::options::def_version::one)
.value("two",
ToddCoxeterImpl_::word_graph_type::options::def_version::two)
.export_values();
//////////////////////////////////////////////////////////////////////////
// Things from cong-common.hpp . . .
//////////////////////////////////////////////////////////////////////////
def_construct_default(thing, "ToddCoxeterImpl_");
def_init_default(thing, "ToddCoxeterImpl_");
def_construct_kind_presentation(thing, "ToddCoxeterImpl_");
def_init_kind_presentation(thing, "ToddCoxeterImpl_");
def_number_of_classes(thing, "ToddCoxeter");
def_copy(thing, "ToddCoxeterImpl_");
def_add_generating_pair(thing, "ToddCoxeterImpl_");
def_currently_contains(thing, "ToddCoxeterImpl_");
def_contains(thing, "ToddCoxeterImpl_");
def_reduce_no_run(thing, "ToddCoxeterImpl_", doc{.detail = R"pbdoc(
If the :any:`ToddCoxeter` instance is not :any:`Runner.finished`,
then it might be that equivalent input words produce different output
words. This function triggers no congruence enumeration.)pbdoc"sv});
def_reduce(thing, "ToddCoxeterImpl_");
// There's no generating_pairs for ToddCoxeterImpl_ only
// internal_generating_pairs
////////////////////////////////////////////////////////////////////////
// Constructors + Initializers
////////////////////////////////////////////////////////////////////////
thing.def(py::init<congruence_kind, ToddCoxeterImpl_&>(),
py::arg("knd"),
py::arg("tc"),
R"pbdoc(
:sig=(self: ToddCoxeter, knd: congruence_kind, tc: ToddCoxeter) -> None:
:only-document-once:
Construct from :any:`congruence_kind` and :any:`ToddCoxeter`.
This function constructs a :any:`ToddCoxeter` instance representing a
congruence of kind *knd* over the :any:`ToddCoxeter` instance *tc*. The
:any:`ToddCoxeter` instance constructed in this way represents a quotient of
the word graph represented by *tc*.
:param knd: the kind (onesided, or twosided) of the congruence.
:type knd: congruence_kind
:param tc: the :any:`ToddCoxeter` instance.
:type tc: :any:`ToddCoxeter`
:raises LibsemigroupsError:
if the arguments *knd* and *tc* are not compatible. If the first item is
``tc.kind()`` and the second is the parameter *knd*, then compatible
arguments are (one-sided, one-sided), (two-sided, one-sided), and (two-sided,
two-sided).)pbdoc");
thing.def(py::init<congruence_kind, WordGraph<uint32_t> const&>(),
py::arg("knd"),
py::arg("wg"),
R"pbdoc(
:sig=(self: ToddCoxeter, knd: congruence_kind, wg: WordGraph) -> None:
:only-document-once:
Construct from :any:`congruence_kind` and :any:`WordGraph`.
This function constructs a :any:`ToddCoxeter` instance representing a
congruence of kind *knd* over the :any:`WordGraph` *wg*. The
:any:`ToddCoxeter` instance constructed in this way represents a
quotient of the word graph *wg*. If *wg* happens to be the left
or right Cayley graph of a semigroup or monoid, then the
:any:`ToddCoxeter` instance will represent a quotient of that
semigroup.
:param knd: the kind (onesided or twosided) of the congruence.
:type knd: congruence_kind
:param wg: the word graph.
:type wg: WordGraph
)pbdoc");
thing.def(
"init",
[](ToddCoxeterImpl_& self,
congruence_kind knd,
ToddCoxeterImpl_ const& tc) -> ToddCoxeterImpl_& {
return self.init(knd, tc);
},
py::arg("knd"),
py::arg("tc"),
R"pbdoc(
:sig=(self: ToddCoxeter, knd: congruence_kind, tc: ToddCoxeter) -> ToddCoxeter:
:only-document-once:
Re-initialize a :any:`ToddCoxeter` instance.
This function puts a :any:`ToddCoxeter` instance back into the state
that it would have been in if it had just been newly constructed from
*knd* and *tc*.
:param knd: the kind (onesided, or twosided) of the congruence.
:type knd: congruence_kind
:param tc: the :any:`ToddCoxeter` instance.
:type tc: ToddCoxeter
:returns: *self*.
:rtype: ToddCoxeter
:raises LibsemigroupsError:
if the arguments *knd* and *tc* are not compatible. If the first item is
``tc.kind()`` and the second is the parameter *knd*, then compatible
arguments are (one-sided, one-sided), (two-sided, one-sided), and (two-sided,
two-sided).
)pbdoc");
thing.def(
"init",
[](ToddCoxeterImpl_& self,
congruence_kind knd,
WordGraph<uint32_t> const& wg) -> ToddCoxeterImpl_& {
return self.init(knd, wg);
},
py::arg("knd"),
py::arg("wg"),
R"pbdoc(
:sig=(self: ToddCoxeter, knd: congruence_kind, wg: WordGraph) -> ToddCoxeter:
:only-document-once:
Re-initialize a :any:`ToddCoxeter` instance.
This function puts a :any:`ToddCoxeter` instance back into the state
that it would have been in if it had just been newly constructed from
*knd* and *wg*.
:param knd: the kind (onesided or twosided) of the congruence.
:type knd: congruence_kind
:param wg: the word graph.
:type wg: WordGraph
:returns: *self*.
:rtype: ToddCoxeter
)pbdoc");
////////////////////////////////////////////////////////////////////////
// Settings
////////////////////////////////////////////////////////////////////////
thing.def(
"def_max",
[](ToddCoxeterImpl_ const& self) { return self.def_max(); },
R"pbdoc(
:sig=(self: ToddCoxeter) -> int:
Get the current value of the setting for the maximum number of
definitions.
:returns:
The current value of the setting.
:rtype:
int
)pbdoc");
thing.def(
"def_max",
[](ToddCoxeterImpl_& self, size_t val) -> ToddCoxeterImpl_& {
return self.def_max(val);
},
py::arg("val"),
R"pbdoc(
:sig=(self: ToddCoxeter, val: int) -> ToddCoxeter:
Set the maximum number of definitions in the stack.
This setting specifies the maximum number of definitions that can be in the
stack at any given time. What happens if there are the maximum number of
definitions in the stack and a new definition is generated is governed by
:any:`ToddCoxeter.def_policy`.
The default value of this setting is ``2000``.
:param val: the maximum size of the definition stack.
:type val: int
:returns: *self*.
:rtype: ToddCoxeter
)pbdoc");
thing.def(
"def_policy",
[](ToddCoxeterImpl_ const& self) { return self.def_policy(); },
R"pbdoc(
:sig=(self: ToddCoxeter) -> ToddCoxeter.options.def_policy:
Get the current value of the definition policy. This function returns
the current value of the definition policy which specifies how to handle
definitions. For details see :any:`options.def_policy`.
:returns:
The current value of the setting, a value of type
:any:`options.def_policy`.
:rtype:
ToddCoxeter.options.def_policy
)pbdoc");
thing.def(
"def_policy",
[](ToddCoxeterImpl_& self, ToddCoxeterImpl_::options::def_policy val)
-> ToddCoxeterImpl_& { return self.def_policy(val); },
py::arg("val"),
R"pbdoc(
:sig=(self: ToddCoxeter, val: ToddCoxeter.options.def_policy) -> ToddCoxeter:
Set the definition policy.
This function can be used to specify how to handle definitions. For details see
:any:`options.def_policy`. The default value of this setting is
:any:`def_policy.no_stack_if_no_space`.
:param val: the policy to use.
:type val: ToddCoxeter.options.def_policy
:returns: *self*.
:rtype: ToddCoxeter
)pbdoc");
thing.def(
"def_version",
[](ToddCoxeterImpl_& self) { return self.def_version(); },
R"pbdoc(
:sig=(self: ToddCoxeter) -> ToddCoxeter.options.def_version:
The current value of the definition policy setting.
:returns:
The current value of the setting.
:rtype:
ToddCoxeter.options.def_version
)pbdoc");
thing.def(
"def_version",
[](ToddCoxeterImpl_& self, ToddCoxeterImpl_::options::def_version val)
-> ToddCoxeterImpl_& { return self.def_version(val); },
py::arg("val"),
R"pbdoc(
:sig=(self: ToddCoxeter, val: ToddCoxeter.options.def_version) -> ToddCoxeter:
This function can be used to specify how which version of definition handling
to use. For details see :any:`options.def_version`.
The default value of this setting is :any:`def_version.two`.
:param val: the version to use.
:type val: ToddCoxeter.options.def_version
:returns: *self*.
:rtype: ToddCoxeter
)pbdoc");
thing.def(
"f_defs",
[](ToddCoxeterImpl_ const& self) { return self.f_defs(); },
R"pbdoc(
:sig=(self: ToddCoxeter) -> int:
Get the number of Felsch style definitions in ACE strategies. This
function returns the approx number of Felsch style definitions in each
phase of the `ACE <https://staff.itee.uq.edu.au/havas/>`_ style
strategies:
- :any:`strategy.CR`;
- :any:`strategy.R_over_C`;
- :any:`strategy.R_over_C`;
- :any:`strategy.Cr`; and
- :any:`strategy.Rc`.
If the strategy is not one of those listed above, then this setting is
ignored.
The default value of this setting is ``10 ** 5``.
:returns:
The current value of the setting.
:rtype:
int
)pbdoc");
thing.def(
"f_defs",
[](ToddCoxeterImpl_& self, size_t val) -> ToddCoxeterImpl_& {
return self.f_defs(val);
},
py::arg("val"),
R"pbdoc(
:sig=(self: ToddCoxeter, val: int) -> ToddCoxeter:
Set the number of Felsch style definitions in ACE strategies.
This function can be used to set the approx number of Felsch style definitions
in each phase of the `ACE <https://staff.itee.uq.edu.au/havas/>`_
style strategies:
* :any:`strategy.CR`;
* :any:`strategy.R_over_C`;
* :any:`strategy.R_over_C`;
* :any:`strategy.Cr`; and
* :any:`strategy.Rc`.
If the strategy is not one of those listed above, then this setting is
ignored.
The default value of this setting is ``10 ** 5``.
:param val: the value to use.
:type val: int
:returns: *self*.
:rtype: ToddCoxeter
:raises LibsemigroupsError: if *val* is ``0``.
)pbdoc");
thing.def(
"hlt_defs",
[](ToddCoxeterImpl_ const& self) { return self.hlt_defs(); },
R"pbdoc(
:sig=(self: ToddCoxeter) -> int:
Get the number of HLT style definitions in ACE strategies. This function
returns the approx number of HLT style definitions in each phase of
the `ACE <https://staff.itee.uq.edu.au/havas/>`_ style strategies:
- :any:`strategy.CR`;
- :any:`strategy.R_over_C`;
- :any:`strategy.R_over_C`;
- :any:`strategy.Cr`; and
- :any:`strategy.Rc`.
If the strategy is not one of those listed above, then this setting is
ignored.
The default value of this setting is ``10 ** 5``.
:returns:
The current value of the setting.
:rtype:
int
)pbdoc");
thing.def(
"hlt_defs",
[](ToddCoxeterImpl_& self, size_t val) -> ToddCoxeterImpl_& {
return self.hlt_defs(val);
},
py::arg("val"),
R"pbdoc(
:sig=(self: ToddCoxeter, val: int) -> ToddCoxeter:
Set the number of HLT style definitions in ACE strategies.
This function can be used to set the approx number of HLT style definitions in
each phase of the `ACE <https://staff.itee.uq.edu.au/havas/>`_
style strategies:
* :any:`strategy.CR`;
* :any:`strategy.R_over_C`;
* :any:`strategy.R_over_C`;
* :any:`strategy.Cr`; and
* :any:`strategy.Rc`.
If the strategy is not one of those listed above, then this setting is ignored.
The default value of this setting is ``2 * 10 ** 5``.
:param val: the value to use.
:type val: int
:returns: *self*.
:rtype: ToddCoxeter
:raises LibsemigroupsError: if *val* is ``0``.
)pbdoc");
thing.def(
"large_collapse",
[](ToddCoxeterImpl_ const& self) { return self.large_collapse(); },
R"pbdoc(
:sig=(self: ToddCoxeter) -> int:
Get the current size of a large collapse. This function can be used to
get what is currently considered a "large" collapse. See
:any:`large_collapse` for the meaning of this setting.
The default value of this setting is ``10 ** 5``.
:returns:
The current value of the setting.
:rtype:
int
)pbdoc");
thing.def(
"large_collapse",
[](ToddCoxeterImpl_& self, size_t val) -> ToddCoxeterImpl_& {
return self.large_collapse(val);
},
py::arg("val"),
R"pbdoc(
:sig=(self: ToddCoxeter, val: int) -> ToddCoxeter:
Set the size of a large collapse.
This function can be used to set what should be considered a "large"
collapse.By default when processing coincidences nodes are merged in the word
graph one pair at a time, and the in-neighbours of the surviving node are
updated at the same time. If the number of coincidences is large, then it might
be that a pair of nodes are merged at one step, then the surviving node is
merged with another node at a future step, and this may happen many many times.
This results in the in-neighbours of the surviving nodes being repeatedly
traversed, which can result in a significant performance penalty. It can be
beneficial to stop updating the in-neighbours as nodes are merged, and to just
rebuild the entire in-neighbours data structure by traversing the entire word
graph after all coincidences have been processed. This is beneficial if the
number of surviving nodes is relatively small in comparison to the number of
nodes merged. The purpose of this setting is to specify what should be
considered a "large" collapse, or more precisely, what number of coincidences
in the stack will trigger a change from updating the in-neighbours one-by-one
to traversing the entire graph once after all coincidences have been
processed.
The default value of this setting is ``100000``.
:param val: the value to use.
:type val: int
:returns: *self*.
:rtype: ToddCoxeter
)pbdoc");
thing.def(
"lookahead_extent",
[](ToddCoxeterImpl_ const& self) { return self.lookahead_extent(); },
R"pbdoc(
:sig=(self: ToddCoxeter) -> ToddCoxeter.options.lookahead_extent:
Get the current value of the lookahead extent. This function returns the
current value of the lookahead extent setting. The default value of this
setting is :any:`lookahead_extent.partial`.
:returns:
The current lookahead extent.
:rtype:
ToddCoxeter.options.lookahead_extent
)pbdoc");
thing.def(
"lookahead_extent",
[](ToddCoxeterImpl_& self,
ToddCoxeterImpl_::options::lookahead_extent val)
-> ToddCoxeterImpl_& { return self.lookahead_extent(val); },
py::arg("val"),
R"pbdoc(
:sig=(self: ToddCoxeter, val: ToddCoxeter.options.lookahead_extent) -> ToddCoxeter:
Set the lookahead extent.
This function can be used to specify the extent of any lookaheads that might
take place in a congruence enumeration. The possible values are
:any:`lookahead_extent.partial` or :any:`lookahead_extent.full`. The
default value of this setting is :any:`lookahead_extent.partial`.
:param val: the extent.
:type val: ToddCoxeter.options.lookahead_extent
:returns: *self*.
:rtype: ToddCoxeter
)pbdoc");
thing.def(
"lookahead_growth_factor",
[](ToddCoxeterImpl_ const& self) {
return self.lookahead_growth_factor();
},
R"pbdoc(
:sig=(self: ToddCoxeter) -> float:
Get the current value of the lookahead growth factor. This function
returns the current value of the lookahead growth factor. See
:any:`lookahead_growth_factor` for a full explanation of this
setting.
:returns:
The lookahead growth factor.
:rtype:
float
)pbdoc");
thing.def(
"lookahead_growth_factor",
[](ToddCoxeterImpl_& self, float val) -> ToddCoxeterImpl_& {
return self.lookahead_growth_factor(val);
},
py::arg("val"),
R"pbdoc(
:sig=(self: ToddCoxeter, val: float) -> ToddCoxeter:
Set the lookahead growth factor.
This setting determines by what factor the number of nodes required to trigger
a lookahead grows. More specifically, at the end of any lookahead if the number
of active nodes already exceeds the value of :any:`lookahead_next` or the
number of nodes killed during the lookahead is less than the number of active
nodes divided by :any:`lookahead_growth_threshold`, then the value of
:any:`lookahead_next` is increased by a multiple of *val*. The default value
is of this setting is ``2.0``.
:param val: the value indicating the lookahead growth factor.
:type val: float
:returns: *self*.
:rtype: ToddCoxeter
:raises LibsemigroupsError: if *val* is less than ``1.0``.
)pbdoc");
thing.def(
"lookahead_growth_threshold",
[](ToddCoxeterImpl_ const& self) {
return self.lookahead_growth_threshold();
},
R"pbdoc(
:sig=(self: ToddCoxeter) -> int:
Get the current value of the lookahead growth threshold. This function returns
the current value of the lookahead growth threshold. See
:any:`lookahead_growth_threshold` for a full description of this setting.
:returns:
The current value of the lookahead growth threshold.
:rtype:
int
)pbdoc");
thing.def(
"lookahead_growth_threshold",
[](ToddCoxeterImpl_& self, size_t val) -> ToddCoxeterImpl_& {
return self.lookahead_growth_threshold(val);
},
py::arg("val"),
R"pbdoc(
:sig=(self: ToddCoxeter, val: int) -> ToddCoxeter:
Set the lookahead growth threshold.
This setting determines the threshold for the number of nodes required to
trigger a lookahead. More specifically, at the end of any lookahead if the
number of active nodes already exceeds the value of :any:`lookahead_next` or
the number of nodes killed during the lookahead is less than the number of
active nodes divided by :any:`lookahead_growth_threshold`, then the value of
:any:`lookahead_next` is increased. The default value is ``4``.
:param val: the value indicating the lookahead growth threshold.
:type val: int
:returns: *self*.
:rtype: ToddCoxeter
)pbdoc");
thing.def(
"lookahead_min",
[](ToddCoxeterImpl_ const& self) { return self.lookahead_min(); },
R"pbdoc(
:sig=(self: ToddCoxeter) -> int:
Get the current value of the minimum lookahead setting. This function
returns the current value of the minimum lookahead. See
:any:`lookahead_min` for a full description of this setting. The
default value is ``10 ** 4``.
:returns:
The current value of the minimum lookahead.
:rtype:
int
)pbdoc");
thing.def(
"lookahead_min",
[](ToddCoxeterImpl_& self, size_t val) -> ToddCoxeterImpl_& {
return self.lookahead_min(val);
},
py::arg("val"),
R"pbdoc(
:sig=(self: ToddCoxeter, val: int) -> ToddCoxeter:
Set the minimum value of lookahead_next.
After a lookahead is performed the value of :any:`lookahead_next` is modified
depending on the outcome of the current lookahead. If the return value of
:any:`lookahead_next` is too small or too large, then the value is adjusted
according to :any:`lookahead_growth_factor` and
:any:`lookahead_growth_threshold`. This setting specified the minimum possible
value for :any:`lookahead_next()`. The default value is ``10 ** 4``.
:param val: value indicating the minimum value of lookahead_next.
:type val: int
:returns: *self*.
:rtype: ToddCoxeter
)pbdoc");
thing.def(
"lookahead_next",
[](ToddCoxeterImpl_ const& self) { return self.lookahead_next(); },
R"pbdoc(
:sig=(self: ToddCoxeter) -> int:
Get the current value of the lookahead next setting. This function returns the
current value of the lookahead next setting. See the other overload of this
function for a full description of this setting.
:returns:
The number of active nodes that will trigger the next lookahead.
:rtype:
int
)pbdoc");
thing.def(
"lookahead_next",
[](ToddCoxeterImpl_& self, size_t val) -> ToddCoxeterImpl_& {
return self.lookahead_next(val);
},
py::arg("val"),
R"pbdoc(
:sig=(self: ToddCoxeter, val: int) -> ToddCoxeter:
Set the threshold that will trigger a lookahead.
If the number of active nodes exceeds the value set by this function, then a
lookahead of style :any:`ToddCoxeter.lookahead_style` and extent
:any:`ToddCoxeter.lookahead_extent` will be triggered. The default value is
``5 * 10 ** 6``.
:param val: value indicating the initial threshold.
:type val: int
:returns: *self*.
:rtype: ToddCoxeter
)pbdoc");
thing.def(
"lookahead_stop_early_interval",
[](ToddCoxeterImpl_ const& self) {
return self.lookahead_stop_early_interval();
},
R"pbdoc(
:sig=(self: ToddCoxeter) -> datetime.timedelta:
Get the current value of the lookahead stop early interval. This
function returns the current value of the lookahead stop early interval.
See :any:`lookahead_stop_early_interval` for a
full description of this setting.
:returns:
The length of the interval.
:rtype:
datetime.timedelta
)pbdoc");
thing.def(
"lookahead_stop_early_interval",
[](ToddCoxeterImpl_& self,
std::chrono::nanoseconds val) -> ToddCoxeterImpl_& {
return self.lookahead_stop_early_interval(val);
},
py::arg("val"),
R"pbdoc(
:sig=(self: ToddCoxeter, val: datetime.timedelta) -> ToddCoxeter:
Set the lookahead stop early interval.
During any lookaheads that are performed, it is periodically checked what
proportion of the active nodes have been killed since the previous such check.
This function can be used to set the interval between these checks. The purpose
of this setting is to allow lookaheads to be stopped early if the number of
nodes being killed is too small (for example, if :math:`<1%` of nodes were
killed in the previous second, then we might want to stop the lookahead early,
since lookaheads take some time but may not result in many nodes being
killed).
The default value is 1 second.
:param val: the new value for the interval.
:type val: datetime.timedelta
:returns: *self*.
:rtype: ToddCoxeter
)pbdoc");
thing.def(
"lookahead_stop_early_ratio",
[](ToddCoxeterImpl_ const& self) {
return self.lookahead_stop_early_ratio();
},
R"pbdoc(
:sig=(self: ToddCoxeter) -> float:
Get the current value of the lookahead stop early ratio. This function
returns the current value of the lookahead stop early ratio. See
:any:`lookahead_stop_early_ratio` for a full description of this
setting.
:returns:
The ratio.
:rtype:
float
)pbdoc");
thing.def(
"lookahead_stop_early_ratio",
[](ToddCoxeterImpl_& self, float val) -> ToddCoxeterImpl_& {
return self.lookahead_stop_early_ratio(val);
},
py::arg("val"),
R"pbdoc(
:sig=(self: ToddCoxeter, val: float) -> ToddCoxeter:
Set the lookahead stop early ratio.
During any lookaheads that are performed, it is periodically checked what
proportion of the active nodes have been killed since the previous such check.
This function can be used to set the minimum proportion of the active nodes
that must be killed every :any:`lookahead_stop_early_interval` to avoid the
lookahead being stopped early. The purpose of this setting is to allow
lookaheads to be stopped early if the number of nodes being killed is too small
(for example, if no nodes were killed in the previous second, then we might
want to stop the lookahead early, since lookaheads take some time but may not
result in many nodes being killed).
The default value is `0.01`
:param val: the proportion of active nodes.
:type val: float
:returns: *self*.
:rtype: ToddCoxeter
:raises LibsemigroupsError:
if *val* is not in the interval :math:`[0, 1)`.
)pbdoc");
thing.def(
"lookahead_style",
[](ToddCoxeterImpl_ const& self) { return self.lookahead_style(); },
R"pbdoc(
:sig=(self: ToddCoxeter) -> ToddCoxeter.options.lookahead_style:
Get the current value of the lookahead style. This function returns the current
value of the lookahead style. See :any:`ToddCoxeter.lookahead_style`
for a full description of this setting.
:returns:
The current lookahead style.
:rtype:
ToddCoxeter.options.lookahead_style
)pbdoc");
thing.def(
"lookahead_style",
[](ToddCoxeterImpl_& self,