seqbuild 0.0.28__tar.gz → 0.0.30__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. {seqbuild-0.0.28 → seqbuild-0.0.30}/LICENSE.txt +1 -1
  2. {seqbuild-0.0.28 → seqbuild-0.0.30}/PKG-INFO +1 -3
  3. {seqbuild-0.0.28 → seqbuild-0.0.30}/README.md +0 -2
  4. {seqbuild-0.0.28 → seqbuild-0.0.30}/pyproject.toml +1 -1
  5. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/comm_lang.py +1 -2
  6. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/seqgen/ssi_load.py +94 -22
  7. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/seqgen/ssi_netop.py +163 -24
  8. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild.egg-info/PKG-INFO +1 -3
  9. {seqbuild-0.0.28 → seqbuild-0.0.30}/setup.py +1 -1
  10. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/__init__.py +0 -0
  11. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/desi/__init__.py +0 -0
  12. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/desi/approximators.py +0 -0
  13. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/desi/differentials.py +0 -0
  14. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/desi/fraction.py +0 -0
  15. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/desi/multi_metric.py +0 -0
  16. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/desi/not_equals.py +0 -0
  17. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/desi/nvec_gen.py +0 -0
  18. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/desi/seqcov_perm.py +0 -0
  19. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/__init__.py +0 -0
  20. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/cl_guide_parser.py +0 -0
  21. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/cmd_proc.py +0 -0
  22. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/make_cmd.py +0 -0
  23. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/commlang_guide.md +0 -0
  24. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/commond_11.txt +0 -0
  25. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/commond_12error.txt +0 -0
  26. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/commond_13.txt +0 -0
  27. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/commond_14.txt +0 -0
  28. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/commond_15.txt +0 -0
  29. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/commond_16.txt +0 -0
  30. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/commond_17.txt +0 -0
  31. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/commond_18.txt +0 -0
  32. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/commond_19.txt +0 -0
  33. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/commond_20.txt +0 -0
  34. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/commond_21.txt +0 -0
  35. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/commond_22.txt +0 -0
  36. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/commond_23.txt +0 -0
  37. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/commond_24.txt +0 -0
  38. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/commond_25.txt +0 -0
  39. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/commond_26.txt +0 -0
  40. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/commond_27.txt +0 -0
  41. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/commond_28.txt +0 -0
  42. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/commond_29.txt +0 -0
  43. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/commond_30.txt +0 -0
  44. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/commond_31.txt +0 -0
  45. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/commond_32.txt +0 -0
  46. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/commond_33.txt +0 -0
  47. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/commond_eight.txt +0 -0
  48. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/commond_five.txt +0 -0
  49. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/commond_four.txt +0 -0
  50. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/commond_lcg_cmp.txt +0 -0
  51. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/commond_lcg_cmp2.txt +0 -0
  52. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/commond_nine.txt +0 -0
  53. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/commond_one.txt +0 -0
  54. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/commond_seven.txt +0 -0
  55. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/commond_six.txt +0 -0
  56. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/commond_ten.txt +0 -0
  57. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/commond_three.txt +0 -0
  58. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/commond_two.txt +0 -0
  59. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/commondeth.txt +0 -0
  60. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/dummy_obj.txt +0 -0
  61. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/example_command.md +0 -0
  62. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/seqbuild_base_screen.png +0 -0
  63. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/seqbuild_help_cmd.png +0 -0
  64. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/seqbuild_help_make.png +0 -0
  65. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/seqbuild_help_screen.png +0 -0
  66. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/seqbuild_load_c9.png +0 -0
  67. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/seqbuild_realtime_command.png +0 -0
  68. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sample_script/seqbuild_show_numbers.png +0 -0
  69. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/face/sb_ui.py +0 -0
  70. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/intigers/__init__.py +0 -0
  71. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/intigers/extraneous.py +0 -0
  72. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/intigers/idectree.py +0 -0
  73. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/intigers/idt_proc.py +0 -0
  74. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/intigers/intfactor.py +0 -0
  75. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/intigers/lcg_v2.py +0 -0
  76. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/intigers/lcg_v3.py +0 -0
  77. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/intigers/mdr_v2.py +0 -0
  78. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/intigers/mod_prng.py +0 -0
  79. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/intigers/n2mvf_autogen.py +0 -0
  80. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/intigers/pof_autogen.py +0 -0
  81. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/intigers/poly_output_fitter_.py +0 -0
  82. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/intigers/prng_pw_op.py +0 -0
  83. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/intigers/process_seq.py +0 -0
  84. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/intigers/seq_struct.py +0 -0
  85. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/intigers/tvec.py +0 -0
  86. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/mini_dm/__init__.py +0 -0
  87. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/mini_dm/ag_ext.py +0 -0
  88. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/mini_dm/csrch.py +0 -0
  89. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/mini_dm/iseq.py +0 -0
  90. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/mini_dm/matfactor_eval.py +0 -0
  91. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/mini_dm/minmax_freq.py +0 -0
  92. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/mini_dm/n2m.py +0 -0
  93. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/mini_dm/n2m_function.py +0 -0
  94. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/mini_dm/n2m_index.py +0 -0
  95. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/mini_dm/ngram.py +0 -0
  96. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/mini_dm/nsfr.py +0 -0
  97. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/mini_dm/puc.py +0 -0
  98. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/mini_dm/sp_op.py +0 -0
  99. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/mini_dm/vs_fit.py +0 -0
  100. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/mini_dm/vs_fit_mem.py +0 -0
  101. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/mini_dm/vs_fit_op.py +0 -0
  102. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/mini_dm/vs_srch.py +0 -0
  103. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/seqgen/__init__.py +0 -0
  104. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/seqgen/gg_gen.py +0 -0
  105. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/seqgen/idt_gen.py +0 -0
  106. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/seqgen/mdr_gen.py +0 -0
  107. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/seqgen/optri_gen.py +0 -0
  108. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/seqgen/rch_gen.py +0 -0
  109. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/seqgen/sb_crypt.py +0 -0
  110. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild/seqgen/shadow_gen.py +0 -0
  111. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild.egg-info/SOURCES.txt +0 -0
  112. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild.egg-info/dependency_links.txt +0 -0
  113. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild.egg-info/requires.txt +0 -0
  114. {seqbuild-0.0.28 → seqbuild-0.0.30}/seqbuild.egg-info/top_level.txt +0 -0
  115. {seqbuild-0.0.28 → seqbuild-0.0.30}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 Richard Pham
3
+ Copyright (c) 2025-2026 Richard Pham
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: seqbuild
3
- Version: 0.0.28
3
+ Version: 0.0.30
4
4
  Summary: A collection of algorithms for pseudo-random number generation.
5
5
  Home-page: https://github.com/Changissnz/seqbuild
6
6
  Author: Richard Pham
@@ -48,8 +48,6 @@ for more details.
48
48
 
49
49
  # Third-Party Python Libraries
50
50
 
51
- PIL>=9.0.0
52
- bs4>=4.10.0
53
51
  numpy>=1.22.1
54
52
  matplotlib>=3.5.3
55
53
  scipy>=1.14.1
@@ -24,8 +24,6 @@ for more details.
24
24
 
25
25
  # Third-Party Python Libraries
26
26
 
27
- PIL>=9.0.0
28
- bs4>=4.10.0
29
27
  numpy>=1.22.1
30
28
  matplotlib>=3.5.3
31
29
  scipy>=1.14.1
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "seqbuild"
3
- version = "0.0.28"
3
+ version = "0.0.30"
4
4
  dependencies = [
5
5
  "numpy>=1.22.1",
6
6
  "matplotlib>=3.5.3",
@@ -73,6 +73,7 @@ class CommLangParser:
73
73
 
74
74
  def reload_file(self,filepath:str):
75
75
  self.fp = filepath
76
+ self.finstat = False
76
77
  self.preproc_file()
77
78
 
78
79
  def close(self):
@@ -100,7 +101,6 @@ class CommLangParser:
100
101
  def load_next_command(self):
101
102
  comm = ""
102
103
  stat = True
103
-
104
104
  while stat:
105
105
  if self.file_obj.tell() != self.file_end:
106
106
  line = self.file_obj.readline()
@@ -108,7 +108,6 @@ class CommLangParser:
108
108
  else:
109
109
  stat = False
110
110
  continue
111
-
112
111
  line = line.strip()
113
112
  if len(line) == 0:
114
113
  continue
@@ -1,9 +1,9 @@
1
1
  from morebs2.search_space_iterator import *
2
2
  from morebs2.matrix_methods import is_2dmatrix
3
3
 
4
- from ..intigers.lcg_v3 import *
5
- from ..intigers.prng_pw_op import *
6
- from ..intigers.extraneous import *
4
+ from intigers.lcg_v3 import *
5
+ from intigers.prng_pw_op import *
6
+ from intigers.extraneous import *
7
7
 
8
8
  SSIBL_STRUCTURES = ["lcg","mdr","mdrv2","optri"]
9
9
 
@@ -64,6 +64,35 @@ class OpTriGenLite:
64
64
  self.i = (self.i + 1) % (self.m.shape[0] * self.m.shape[1])
65
65
  return self.m[qi[0],qi[1]]
66
66
 
67
+ """
68
+ (S)earch (S)pace (I)terator Net Node, Type (L)inear (C)ongruential (G)enerator Net
69
+
70
+ A unit node for the PRNG found in file<seqgen.ssi_netop>, which is itself a PRNG. It
71
+ uses one of four possible structure types:
72
+ (1) "lcg": linear congruential generator
73
+ (2) "mdr": modulo decomposition representation
74
+ (3) "mdrv2": modulo decomposition representation version 2
75
+ (4) "optri": operation triangle
76
+ ---------------------------------------------------------------------------------------
77
+
78
+ (1) simply directly outputs the LCG output.
79
+
80
+ /-/-/-/-/
81
+
82
+ (2),(3), and (4) are activation-based, meaning that on a PRNG-scheduled basis, their
83
+ data structure `struct` is updated.
84
+ NOTE:
85
+ In SeqBuild functionalities, this updating process is programmatically done by
86
+ the class<SSINetOp> PRNG.
87
+
88
+ The order of class methods to called when `sidn` is one of (2),(3), or (4) is:
89
+ - method<SSINetNode__TypeLCGNet.set_actsize>
90
+ - method<SSINetNode__TypeLCGNet.activate_base>
91
+
92
+ Additionally, if `sidn` is of `mdr`|`mdrv2`, then an additional call to
93
+ method<SSINetNode__TypeLCGNet.load_first>, in order to calculate the next
94
+ number sequence from `struct`.
95
+ """
67
96
  class SSINetNode__TypeLCGNet:
68
97
 
69
98
  def __init__(self,structure_idn,prg,op_pair=None,exclude_neg=None,\
@@ -80,26 +109,28 @@ class SSINetNode__TypeLCGNet:
80
109
  assert len(op_pair) == 2
81
110
  assert tmpcache_ratio >= 1.0
82
111
 
112
+ # used for `optri`, `mdr`
113
+ self.base_queue = []
114
+ self.base_activated = False
115
+ self.tmp_queue = []
116
+ self.activation_size = None
117
+ self.termination_length = None
118
+
83
119
  # used for `mdr`
84
120
  self.exclude_neg = exclude_neg
85
121
  self.tmpcache_ratio = tmpcache_ratio
122
+ self.rvalues = []
86
123
 
87
124
  # used for `optri`
88
125
  self.op_pair = op_pair
89
126
 
90
- # used for `optri`, `mdr`
91
- self.base_queue = []
92
- self.base_activated = False
93
- self.tmp_queue = []
94
-
95
127
  self.struct = None
96
- # use for `mdr` `
97
- self.rvalues = []
98
-
99
- self.activation_size = None
100
- self.termination_length = None
101
128
 
129
+ # output counter, used in conjunction w/ `termination_length`.
102
130
  self.c = 0
131
+
132
+ # struct update counter
133
+ self.uc = 0
103
134
  return
104
135
 
105
136
  def __next__(self):
@@ -117,12 +148,12 @@ class SSINetNode__TypeLCGNet:
117
148
  q = self.rvalues.pop(0)
118
149
  else:
119
150
  q = next(self.struct)
120
-
151
+
121
152
  self.c += 1
122
153
  return q
123
154
 
124
155
  """
125
-
156
+ sets the `activation_size` class variable, which allows
126
157
  """
127
158
  def set_actsize(self, activation_size):
128
159
  assert "mdr" in self.sidn or "optri" in self.sidn
@@ -132,11 +163,16 @@ class SSINetNode__TypeLCGNet:
132
163
  self.activation_size = activation_size
133
164
  return
134
165
 
166
+ """
167
+ Updates the queues `tmp_queue` and `base_queue`.
168
+ """
135
169
  def activate_base(self,aux_prg,verbose=0):
136
170
  assert type(aux_prg) in {MethodType,FunctionType}
137
-
171
+
138
172
  self.base_activated = True
139
173
  x = self.tmp_queue[:self.activation_size]
174
+ #print("base {}, activation {}, tmp {}".format(len(self.base_queue),len(x),len(self.tmp_queue)))
175
+ #print("TQ: ",self.tmp_queue)
140
176
  self.base_queue = x
141
177
  self.tmp_queue = self.tmp_queue[self.activation_size:]
142
178
 
@@ -144,8 +180,14 @@ class SSINetNode__TypeLCGNet:
144
180
  if q == False:
145
181
  q = self.activate_optri(aux_prg,verbose)
146
182
  self.struct = q
183
+
184
+ self.uc += 1
147
185
  return
148
186
 
187
+ """
188
+ instantiates a new <ModuloDecomp> or <ModuloDecompV2> instance,
189
+ using a modulated version of the number sequence `base_queue`.
190
+ """
149
191
  def activate_mdr(self,aux_prg,verbose):
150
192
  if "mdr" not in self.sidn:
151
193
  return False
@@ -154,15 +196,16 @@ class SSINetNode__TypeLCGNet:
154
196
 
155
197
  mdr = None
156
198
  if verbose:
157
- print("= activating {} w/ \n{}".format(self.sidn,BQ))
199
+ print("= activating {},act={},term={} w/ \n{}".format(self.sidn,self.activation_size,self.termination_length,BQ))
158
200
 
159
201
  if self.sidn == "mdr":
160
- m = ModuloDecomp(IntSeq(BQ))
202
+ m = ModuloDecomp(IntSeq(BQ),max_absmult=112)
161
203
  m.merge(bool(self.exclude_neg))
162
204
  mdr = ModuloDecompRepr(m,1)
163
205
  else:
164
- m = ModuloDecomp(IntSeq(BQ),\
165
- self.exclude_neg)
206
+ m = ModuloDecompV2(IntSeq(BQ),\
207
+ bool(self.exclude_neg),max_absmult=112)
208
+
166
209
  mdr = ModuloDecompRepr(m,2)
167
210
 
168
211
  L = len(self.base_queue)
@@ -181,7 +224,8 @@ class SSINetNode__TypeLCGNet:
181
224
  self.termination_length = L_
182
225
 
183
226
  if verbose:
184
- print("= activating {} w/ \n{}".format(self.sidn,self.base_queue))
227
+ print("= activating {},act={},term={} w/ \n{}".format(self.sidn,self.activation_size,self.termination_length,\
228
+ self.base_queue))
185
229
 
186
230
  B = [npint32__mod__Q(b) for b in self.base_queue]
187
231
  iseq = IntSeq(B)
@@ -206,10 +250,27 @@ class SSINetNode__TypeLCGNet:
206
250
  self.rvalues = self.struct.reconstruct()
207
251
  return
208
252
 
253
+ """
254
+ Outputs a maximum of `max_batch_size` <SSINetNode__TypeLCGNet> instances, each of the
255
+ same structure type `structure_idn`. See variable<SSIBL_STRUCTURES> for a full view of
256
+ those structures.
257
+
258
+ This is a preliminary <SSINetNode__TypeLCGNet> generator, used by the generator
259
+ class<SSINetOp>.
260
+
261
+ The generation of <SSINetNode__TypeLCGNet> instances that are of structure type `lcg`
262
+ is via the output from a standard pass of a <SearchSpaceIterator> instance (a 4-dimensional
263
+ space represented by `param_bounds`), the four dimensions accounting for the four
264
+ parameter values that form an LCG (initial value, multiple, additive, modulo).
265
+
266
+ NOTE:
267
+ The PRNG <SSINetOp> gets its name from this generation scheme concerning LCGs.
268
+ """
209
269
  class SSIBatchLoader__TypeLCGNet:
210
270
 
211
271
  """
212
272
  param_bounds := bounds vector (if structure is lcg) | ordered binary range (i.e. 00,01,10,11)
273
+ max_batch_size := int | inf
213
274
  """
214
275
  def __init__(self,structure_idn,param_bounds,max_batch_size,aux_prg,ssi_hr=DEFAULT_SSINET_HOP_RANGE):
215
276
  assert structure_idn in SSIBL_STRUCTURES
@@ -239,6 +300,7 @@ class SSIBatchLoader__TypeLCGNet:
239
300
  stat0 = is_bounds_vector(param_bounds)
240
301
  assert stat0
241
302
  assert np.all(param_bounds[:,1] >= param_bounds[:,0])
303
+ assert len(param_bounds) == 4
242
304
  self.param_bounds = param_bounds
243
305
 
244
306
  elif "mdr" in self.sidn:
@@ -303,17 +365,27 @@ class SSIBatchLoader__TypeLCGNet:
303
365
 
304
366
  return q,q1
305
367
 
368
+ """
369
+ A graph relation generator, used by class<SSINetOp> in its auto-generation method.
370
+ The relations are between elements of `structure_instances`, each a <SSINetNode__TypeLCGNet>.
306
371
 
372
+ Outputs relations into the map `h2tree_map`, a head-to-tree map.
373
+ """
307
374
  class SSIBatch2Net:
308
375
 
309
376
  def __init__(self,structure_instances,num_trees,prg):
310
377
  assert len(structure_instances) > 0
311
- assert type(num_trees) == int
378
+ assert type(num_trees) == int and num_trees > 0
312
379
  assert num_trees <= len(structure_instances)
313
380
  assert type(prg) in {MethodType,FunctionType}
314
381
 
382
+ # each element is <SSINetNode__TypeLCGNet>
315
383
  self.si = structure_instances
316
384
  self.num_trees = num_trees
385
+
386
+ # `si` index -> Directed Tree
387
+ # Directed Tree: source node -> {target nodeset}
388
+ # `struct_list` index -> {`struct_list` indices}
317
389
  self.prg = prg
318
390
  self.h2tree_map = dict()
319
391
  return
@@ -2,11 +2,74 @@ from .ssi_load import *
2
2
  from morebs2.numerical_generator import prg_partition_for_sz__n_rounds
3
3
  from morebs2.g2tdecomp import *
4
4
 
5
- class SSINetOp:
5
+ """
6
+ (S)earch (S)pace (I)terator Net Operator.
7
+
8
+ A pseudo-random number generator that relies in part on structure provided by
9
+ a search space iterator.
10
+
11
+ *Instantiation Variables*
12
+ Set `io_prg` to a PRNG to add noise to pre-output values that are responsible
13
+ for the output values from <SSINetOp>.
14
+
15
+ Set `shuffle_dist` to 1 (active) for the <SSINetOp> to shuffle the numbers in
16
+ its reference queue Q, every time before using the shuffled numbers to update
17
+ the pertinent <SSINetNode__TypeLCGNet>s.
18
+
19
+ The reference queue Q is `tmp_queue` (contains numbers from all structure types
20
+ `lcg`,`mdr*`,`optri`) if `lcg_input_only` is set to 0. Otherwise, Q is `lcg_queue`.
21
+
22
+ *Qualities*
23
+
24
+ In a typical instantiation via method<SSINetOp.one_instance>, <SSIBatchLoader__TypeLCGNet>
25
+ is used to generate at least five <SSINetNode__TypeLCGNet> instances. These instances contain
26
+ at least one of each of the following structure types: "lcg","mdr", and "optri".
27
+
28
+ Despite this PRNG getting its name from the <SearchSpaceIterator> used to generate LCGs, LCGs
29
+ are not required for this PRNG to output values. However, not using a significantly stochastic
30
+ quantity of LCGs, produced from the <SearchSpaceIterator> pass, would mean the <SSINetOp>
31
+ relies much more on its PRNG parameter `prg` to produce reference values for `mdr` and `optri`
32
+ <SSINetNode__TypeLCGNet> types. This basically translates to greater predictability of the
33
+ <SSINetOp> PRNG output, with knowledge of the `prg` output.
34
+
35
+ There are two classes of relations connecting the sequence `struct_list` of <SSINetNode__TypeLCGNet>s
36
+ together:
37
+ - head node (tree identifier) -> directed node tree [`h2tree_map`]
38
+ - tree identifier -> {tree identifiers}.
39
+
40
+ These relations determine which <SSINetNode__TypeLCGNet>s get updated, through the course of source
41
+ trees being selected by <SSINetOp> to output values.
42
+
43
+ *Basic Rundown*
44
+ <SSINetOp> starts by setting activation and termination sizes for every non-LCG node.
45
+
46
+ Every time <SSINetOp.__next__> is called, PRNG outputs the 0'th value from its primary queue,
47
+ `mainstream_queue`.
48
+
49
+ If `mainstream_queue` is empty, <SSINetOp> adds more numbers to queue by this procedure:
50
+ - <SSINetOp> clears its `tmp_queue`.
51
+ - It chooses one of its trees T.
52
+ - It iterates through each node n of T, and adds n's output to `tmp_queue`.
53
+ - For each of the neighboring trees T' connected to T, <SSINetOp> updates the `tmp_queue`
54
+ of every node of `T'. See the section `*Instantiation Variables*` for the class
55
+ variables involved in this update process. Also see method<<SSINetOp.distribute_to_connected_trees>
56
+ and method<SSINetOp.distribute_seq_to_tree>.
57
+ - Additionally, each of these nodes may update their base `struct` by first passing values from their
58
+ `tmp_queue`s to `base_queue`s, depending on if their counters pass their `activation_size` and
59
+ `termination_length` parameters.
60
+
61
+ NOTE: there are two primary types for updating: `rapid` and `slow`. See
62
+ method<SSINetOp.update_node__type_*> for details on this update.
63
+ This is specified by the class instantiation variable<rapid_update>.
64
+
65
+ The `rapid` update type results in slower number generation.
66
+
67
+ """
68
+ class SSINetOp:
6
69
 
7
70
  def __init__(self,struct_list,h2tree_map,prg,\
8
71
  lcg_input_only=0,uniform_io_dist=1,shuffle_dist=0,\
9
- io_prg=None,verbose:bool=False):
72
+ io_prg=None,rapid_update=False,verbose:bool=False):
10
73
 
11
74
  assert len(struct_list) > 3
12
75
  assert len(h2tree_map) > 0
@@ -15,20 +78,27 @@ class SSINetOp:
15
78
  assert uniform_io_dist in {0,1}
16
79
  assert shuffle_dist in {0,1}
17
80
  assert type(io_prg) in {MethodType,FunctionType,type(None)}
81
+ assert type(rapid_update) == bool
18
82
 
83
+ # each element is <SSINetNode__TypeLCGNet>
19
84
  self.struct_list = struct_list
85
+ # `struct_list` index -> Directed Tree
86
+ # Directed Tree: source node -> {target nodeset}
87
+ # `struct_list` index -> {`struct_list` indices}
20
88
  self.h2tree_map = h2tree_map
89
+ # key of `h2tree_map` -> {other keys of `h2tree_map`}
21
90
  self.edges = dict()
22
91
  self.prg = prg
23
92
  self.lcg_input_only = lcg_input_only
24
93
  self.uniform_io_dist = uniform_io_dist
25
94
  self.shuffle_dist = shuffle_dist
26
95
  self.io_prg = io_prg
27
-
96
+ self.rapid_update = rapid_update
28
97
  self.verbose = verbose
29
98
 
30
- # storage of values from some source; values can be used for
31
- # the structures `mdr`,`mdrv2`,`optri`.
99
+ # storage of values from some source <SSINetNode__TypeLCGNet>;
100
+ # values can be used for the structures
101
+ # `mdr`,`mdrv2`,`optri`.
32
102
  self.mainstream_queue = []
33
103
  self.prev_output = None
34
104
 
@@ -42,6 +112,7 @@ class SSINetOp:
42
112
  self.prev = None
43
113
 
44
114
  self.preprocess()
115
+ self.retry_counter = 3
45
116
  return
46
117
 
47
118
  ##-------------------------------------------------------------------
@@ -55,6 +126,9 @@ class SSINetOp:
55
126
  cx = combinations(ks,2)
56
127
  q = prg__single_to_int(self.prg)
57
128
 
129
+ for k in ks:
130
+ self.edges[k] = set()
131
+
58
132
  for c in cx:
59
133
  d = int(round(q())) % 2
60
134
  if d:
@@ -67,6 +141,10 @@ class SSINetOp:
67
141
  self.edges[c[0]]|= {c[1]}
68
142
  self.edges[c[1]]|= {c[0]}
69
143
 
144
+ """
145
+ sets activation and termination sizes for every <SSINetNode__TypeLCGNet> that
146
+ is not of structure type `lcg`.
147
+ """
70
148
  def set_actterm_sizes(self):
71
149
  for q in self.struct_list:
72
150
  if q.sidn == "lcg":
@@ -79,7 +157,7 @@ class SSINetOp:
79
157
  r = modulo_in_range(self.prg(),\
80
158
  DEFAULT_SSINETNODE__TYPE_FITTER_NUM_ITER)
81
159
  q.termination_length = int(ceil(q.activation_size * r))
82
- q.activate_base(self.prg)
160
+ q.activate_base(self.prg,True)
83
161
 
84
162
  return
85
163
 
@@ -87,6 +165,9 @@ class SSINetOp:
87
165
 
88
166
  def __next__(self):
89
167
 
168
+ if self.retry_counter == 0:
169
+ return 0
170
+
90
171
  if len(self.mainstream_queue) > 0:
91
172
  q = self.mainstream_queue.pop(0)
92
173
  self.prev_output = q
@@ -98,16 +179,26 @@ class SSINetOp:
98
179
  while len(self.mainstream_queue) == 0:
99
180
  H = self.choose_tree(exclude_trees)
100
181
  if self.verbose: print("- tree {}".format(H))
101
- assert type(H) != type(None)
102
-
182
+
183
+ # case: no trees produced any values, recursively
184
+ # call __next__
185
+ if type(H) == type(None):
186
+ self.retry_counter -= 1
187
+ return self.__next__()
188
+
103
189
  self.process_tree(H)
104
190
  exclude_trees |= {H}
105
191
 
106
192
  q = self.mainstream_queue.pop(0)
107
193
  q = self.apply_noise(q)
108
194
  self.prev_output = q
195
+ self.retry_counter = 3
109
196
  return q
110
197
 
198
+ """
199
+ 50/50 probability of modifying float `q` if `io_prg` is not
200
+ null.
201
+ """
111
202
  def apply_noise(self,q):
112
203
  if type(self.io_prg) == type(None):
113
204
  return q
@@ -133,8 +224,14 @@ class SSINetOp:
133
224
  # process value for each node
134
225
  for k in K:
135
226
  q = self.process_node(k)
136
- if type(q) != type(None):
137
- self.tmp_queue.append(q)
227
+ if type(q) == type(None):
228
+ continue
229
+
230
+ if np.isnan(q) or np.isinf(q):
231
+ continue
232
+
233
+ self.tmp_queue.append(q)
234
+
138
235
  if self.verbose:
139
236
  print("\t+ procvec")
140
237
  print("\t{}".format(self.lcg_queue))
@@ -161,16 +258,33 @@ class SSINetOp:
161
258
  if type(self.prev_output) != type(None):
162
259
  q.load_first(self.prev_output)
163
260
  x = next(q)
164
- if self.verbose: print("{} next: {}".format(q.sidn,x))
165
261
  else:
166
262
  x = next(q)
167
- if self.verbose: print("{} next: {}".format(q.sidn,x))
263
+
264
+ if self.verbose and q.sidn != "lcg": print("{} next: {}, term={},c={},tmp_q={},base_q={}".\
265
+ format(q.sidn,x,q.termination_length,q.c,len(q.tmp_queue),len(q.base_queue)))
168
266
 
169
267
  # case: set new activation and termination length
268
+ if self.rapid_update:
269
+ F = self.update_node__type_rapid
270
+ else:
271
+ F = self.update_node__type_slow
272
+
273
+ F(index)
274
+
275
+ if type(x) != type(None):
276
+ self.mo_queue.append(x)
277
+
278
+ return x
279
+
280
+ def update_node__type_slow(self,index):
281
+ q = self.struct_list[index]
282
+
170
283
  if q.c >= q.termination_length:
171
- if self.verbose: print("** updating {} @ index={}".format(q.sidn,index))
172
284
 
173
285
  q.activation_size = modulo_in_range(int(round(self.prg())),DEFAULT_BASE_QUEUE_ACTIVATION_RANGE)
286
+ if self.verbose: print("** updating {} @ index={},act={}".format(q.sidn,index,q.activation_size))
287
+
174
288
  q.c = 0
175
289
 
176
290
  #q.struct = None
@@ -181,14 +295,34 @@ class SSINetOp:
181
295
  if self.verbose: print("\tbase update")
182
296
  q.activate_base(self.prg,self.verbose)
183
297
 
184
- if type(x) != type(None):
185
- self.mo_queue.append(x)
298
+ def update_node__type_rapid(self,index):
299
+ q = self.struct_list[index]
186
300
 
187
- return x
301
+ L = len(q.tmp_queue)
302
+ if L >= q.activation_size:
303
+ if self.verbose: print("\tbase update")
304
+ q.activate_base(self.prg,self.verbose)
305
+
306
+ if q.c >= q.termination_length:
307
+
308
+ q.activation_size = modulo_in_range(int(round(self.prg())),DEFAULT_BASE_QUEUE_ACTIVATION_RANGE)
309
+ if self.verbose: print("** updating {} @ index={},act={}".format(q.sidn,index,q.activation_size))
310
+
311
+ q.c = 0
312
+
313
+ #q.struct = None
314
+ q.base_queue.clear()
315
+ q.base_activated = False
188
316
 
189
317
 
190
318
  #--------- network distribution of output values -----------------------------------
191
319
 
320
+ """
321
+ distributes reference vectors to every neighboring tree connected
322
+ to `head`. Reference vectors are drawn from either the `lcg_queue`
323
+ or `tmp_queue`. Each reference vector is appended to its associated
324
+ node's `tmp_queue`.
325
+ """
192
326
  def distribute_to_connected_trees(self,head):
193
327
  neighbors = self.edges[head]
194
328
 
@@ -208,16 +342,18 @@ class SSINetOp:
208
342
 
209
343
  def D(node):
210
344
  L_ = [self.apply_noise(l) for l in L]
345
+
346
+ # case: uniform i/o, send entire sequence to node's tmp queue
211
347
  if self.uniform_io_dist:
212
348
  node.update_tmp_queue(deepcopy(L_))
213
349
  return
214
350
 
215
- L_ = []
351
+ L2 = []
216
352
  prg_ = prg__single_to_int(self.prg)
217
- for l in L:
353
+ for l in L_:
218
354
  d = prg_() % 2
219
- if d: L_.append(l)
220
- node.update_tmp_queue(deepcopy(L_))
355
+ if d: L2.append(l)
356
+ node.update_tmp_queue(deepcopy(L2))
221
357
 
222
358
  assert head in self.h2tree_map
223
359
  T = self.h2tree_map[head]
@@ -256,9 +392,12 @@ class SSINetOp:
256
392
 
257
393
  #-------------- instantiation ------------------------------------------------
258
394
 
395
+ def node_to_activation_count_map(self):
396
+ return {i:n.uc for (i,n) in enumerate(self.struct_list)}
397
+
259
398
  @staticmethod
260
399
  def one_instance(num_nodes,prg,prg2,lcg_input_only=0,uniform_io_dist=1,shuffle_dist=0,\
261
- prg_io_noise=0):
400
+ prg_io_noise=0,rapid_update=True):
262
401
  assert num_nodes >= 5
263
402
  num_sets = 3
264
403
  var = 0.25
@@ -284,15 +423,15 @@ class SSINetOp:
284
423
  q2 = ssb2n.h2tree_map
285
424
  io_prg = prg if prg_io_noise else None
286
425
  return SSINetOp(q1,q2,prg2,lcg_input_only=lcg_input_only,\
287
- uniform_io_dist=uniform_io_dist,shuffle_dist=shuffle_dist,io_prg=io_prg)
426
+ uniform_io_dist=uniform_io_dist,shuffle_dist=shuffle_dist,\
427
+ io_prg=io_prg,rapid_update=rapid_update)
288
428
 
289
429
  @staticmethod
290
430
  def one_instance__slist(sidn,batch_size,prg):
291
431
  # make an LCG from `prg` output
292
432
  ix = [prg() for _ in range(4)]
293
433
  ix = [modulo_in_range(ix_,[1.,101.]) for ix_ in ix]
294
- prg2 = prg__LCG(ix[0],ix[1],ix[2],ix[3])
295
-
434
+ prg2 = prg__LCG(ix[0],ix[1],ix[2],ix[3])
296
435
  if sidn == "lcg":
297
436
  prg3 = prg__single_to_bounds_outputter(prg,4)
298
437
  param_bounds = prg3()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: seqbuild
3
- Version: 0.0.28
3
+ Version: 0.0.30
4
4
  Summary: A collection of algorithms for pseudo-random number generation.
5
5
  Home-page: https://github.com/Changissnz/seqbuild
6
6
  Author: Richard Pham
@@ -48,8 +48,6 @@ for more details.
48
48
 
49
49
  # Third-Party Python Libraries
50
50
 
51
- PIL>=9.0.0
52
- bs4>=4.10.0
53
51
  numpy>=1.22.1
54
52
  matplotlib>=3.5.3
55
53
  scipy>=1.14.1
@@ -5,7 +5,7 @@ with open('README.md') as f:
5
5
 
6
6
  setup(
7
7
  name='seqbuild',
8
- version='0.0.28',
8
+ version='0.0.30',
9
9
  description='A collection of algorithms for pseudo-random number generation.',
10
10
  long_description=readme,
11
11
  author='Richard Pham',
File without changes