mapFolding 0.15.4__py3-none-any.whl → 0.16.0__py3-none-any.whl
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.
- mapFolding/__init__.py +7 -9
- mapFolding/_theSSOT.py +1 -0
- mapFolding/algorithms/daoOfMapFolding.py +1 -2
- mapFolding/algorithms/getBucketsTotal.py +137 -0
- mapFolding/algorithms/matrixMeanders.py +457 -286
- mapFolding/algorithms/oeisIDbyFormula.py +310 -76
- mapFolding/algorithms/zCuzDocStoopidoeisIDbyFormula.py +84 -0
- mapFolding/basecamp.py +99 -14
- mapFolding/dataBaskets.py +74 -0
- mapFolding/oeis.py +3 -2
- mapFolding/reference/A000682facts.py +662 -0
- mapFolding/reference/A005316facts.py +62 -0
- mapFolding/reference/matrixMeandersAnalysis/__init__.py +1 -0
- mapFolding/reference/matrixMeandersAnalysis/evenEven.py +144 -0
- mapFolding/reference/matrixMeandersAnalysis/oddEven.py +54 -0
- mapFolding/someAssemblyRequired/A007822/A007822rawMaterials.py +55 -0
- mapFolding/someAssemblyRequired/A007822/__init__.py +0 -0
- mapFolding/someAssemblyRequired/A007822/makeA007822AsynchronousModules.py +185 -0
- mapFolding/someAssemblyRequired/A007822/makeA007822Modules.py +71 -0
- mapFolding/someAssemblyRequired/RecipeJob.py +2 -2
- mapFolding/someAssemblyRequired/__init__.py +9 -2
- mapFolding/someAssemblyRequired/_toolIfThis.py +4 -3
- mapFolding/someAssemblyRequired/_toolkitContainers.py +8 -8
- mapFolding/someAssemblyRequired/infoBooth.py +27 -30
- mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py +1 -1
- mapFolding/someAssemblyRequired/makeJobTheorem2codon.py +5 -2
- mapFolding/someAssemblyRequired/makingModules_count.py +301 -0
- mapFolding/someAssemblyRequired/makingModules_doTheNeedful.py +120 -0
- mapFolding/someAssemblyRequired/mapFolding/__init__.py +0 -0
- mapFolding/someAssemblyRequired/mapFolding/makeMapFoldingModules.py +220 -0
- mapFolding/someAssemblyRequired/toolkitMakeModules.py +152 -0
- mapFolding/someAssemblyRequired/toolkitNumba.py +1 -1
- mapFolding/someAssemblyRequired/transformationTools.py +1 -0
- mapFolding/syntheticModules/A007822/__init__.py +1 -0
- mapFolding/syntheticModules/{algorithmA007822Numba.py → A007822/algorithmNumba.py} +2 -4
- mapFolding/syntheticModules/A007822/asynchronous.py +148 -0
- mapFolding/syntheticModules/A007822/asynchronousAnnex.py +68 -0
- mapFolding/syntheticModules/A007822/asynchronousTheorem2.py +53 -0
- mapFolding/syntheticModules/A007822/asynchronousTrimmed.py +47 -0
- mapFolding/syntheticModules/dataPackingA007822.py +1 -1
- mapFolding/tests/test_computations.py +2 -2
- mapFolding/trim_memory.py +62 -0
- mapFolding/zCuzDocStoopid/__init__.py +1 -0
- mapFolding/zCuzDocStoopid/makeDocstrings.py +63 -0
- {mapfolding-0.15.4.dist-info → mapfolding-0.16.0.dist-info}/METADATA +9 -2
- mapfolding-0.16.0.dist-info/RECORD +100 -0
- mapFolding/someAssemblyRequired/A007822rawMaterials.py +0 -46
- mapFolding/someAssemblyRequired/makeAllModules.py +0 -764
- mapfolding-0.15.4.dist-info/RECORD +0 -78
- /mapFolding/syntheticModules/{algorithmA007822.py → A007822/algorithm.py} +0 -0
- /mapFolding/syntheticModules/{initializeStateA007822.py → A007822/initializeState.py} +0 -0
- /mapFolding/syntheticModules/{theorem2A007822.py → A007822/theorem2.py} +0 -0
- /mapFolding/syntheticModules/{theorem2A007822Numba.py → A007822/theorem2Numba.py} +0 -0
- /mapFolding/syntheticModules/{theorem2A007822Trimmed.py → A007822/theorem2Trimmed.py} +0 -0
- {mapfolding-0.15.4.dist-info → mapfolding-0.16.0.dist-info}/WHEEL +0 -0
- {mapfolding-0.15.4.dist-info → mapfolding-0.16.0.dist-info}/entry_points.txt +0 -0
- {mapfolding-0.15.4.dist-info → mapfolding-0.16.0.dist-info}/licenses/LICENSE +0 -0
- {mapfolding-0.15.4.dist-info → mapfolding-0.16.0.dist-info}/top_level.txt +0 -0
mapFolding/__init__.py
CHANGED
|
@@ -57,8 +57,7 @@ from mapFolding._theTypes import (
|
|
|
57
57
|
NumPyElephino as NumPyElephino,
|
|
58
58
|
NumPyFoldsTotal as NumPyFoldsTotal,
|
|
59
59
|
NumPyIntegerType as NumPyIntegerType,
|
|
60
|
-
NumPyLeavesTotal as NumPyLeavesTotal
|
|
61
|
-
)
|
|
60
|
+
NumPyLeavesTotal as NumPyLeavesTotal)
|
|
62
61
|
|
|
63
62
|
from mapFolding._theSSOT import packageSettings as packageSettings
|
|
64
63
|
|
|
@@ -68,18 +67,18 @@ from mapFolding.beDRY import (
|
|
|
68
67
|
getTaskDivisions as getTaskDivisions,
|
|
69
68
|
makeDataContainer as makeDataContainer,
|
|
70
69
|
setProcessorLimit as setProcessorLimit,
|
|
71
|
-
validateListDimensions as validateListDimensions
|
|
72
|
-
)
|
|
70
|
+
validateListDimensions as validateListDimensions)
|
|
73
71
|
|
|
74
|
-
from mapFolding.dataBaskets import
|
|
72
|
+
from mapFolding.dataBaskets import (
|
|
73
|
+
MapFoldingState as MapFoldingState,
|
|
74
|
+
MatrixMeandersState as MatrixMeandersState)
|
|
75
75
|
|
|
76
76
|
from mapFolding.filesystemToolkit import (
|
|
77
77
|
getFilenameFoldsTotal as getFilenameFoldsTotal,
|
|
78
78
|
getPathFilenameFoldsTotal as getPathFilenameFoldsTotal,
|
|
79
79
|
getPathRootJobDEFAULT as getPathRootJobDEFAULT,
|
|
80
80
|
saveFoldsTotal as saveFoldsTotal,
|
|
81
|
-
saveFoldsTotalFAILearly as saveFoldsTotalFAILearly
|
|
82
|
-
)
|
|
81
|
+
saveFoldsTotalFAILearly as saveFoldsTotalFAILearly)
|
|
83
82
|
|
|
84
83
|
from mapFolding.basecamp import countFolds as countFolds
|
|
85
84
|
|
|
@@ -89,5 +88,4 @@ from mapFolding.oeis import (
|
|
|
89
88
|
getFoldsTotalKnown as getFoldsTotalKnown,
|
|
90
89
|
getOEISids as getOEISids,
|
|
91
90
|
OEIS_for_n as OEIS_for_n,
|
|
92
|
-
oeisIDfor_n as oeisIDfor_n
|
|
93
|
-
)
|
|
91
|
+
oeisIDfor_n as oeisIDfor_n)
|
mapFolding/_theSSOT.py
CHANGED
|
@@ -108,6 +108,7 @@ OEISidMeandersManuallySet: dict[str, MetadataOEISidMeandersManuallySet] = {
|
|
|
108
108
|
'A060206': {'valuesTestValidation': [*range(3, 9)]},
|
|
109
109
|
'A077460': {'valuesTestValidation': [*range(3, 8)]},
|
|
110
110
|
'A078591': {'valuesTestValidation': [*range(3, 10)]},
|
|
111
|
+
'A178961': {'valuesTestValidation': [*range(3, 11)]},
|
|
111
112
|
'A223094': {'valuesTestValidation': [*range(3, 11)]},
|
|
112
113
|
'A259702': {'valuesTestValidation': [*range(3, 13)]},
|
|
113
114
|
'A301620': {'valuesTestValidation': [*range(3, 11)]},
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# ruff: noqa: D100 D103
|
|
2
1
|
from mapFolding.dataBaskets import MapFoldingState
|
|
3
2
|
|
|
4
3
|
def activeLeafGreaterThan0(state: MapFoldingState) -> bool:
|
|
@@ -140,4 +139,4 @@ def count(state: MapFoldingState) -> MapFoldingState:
|
|
|
140
139
|
|
|
141
140
|
def doTheNeedful(state: MapFoldingState) -> MapFoldingState:
|
|
142
141
|
state = count(state)
|
|
143
|
-
return state
|
|
142
|
+
return state
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"""Buckets."""
|
|
2
|
+
from mapFolding import MatrixMeandersState
|
|
3
|
+
from mapFolding.reference.A005316facts import bucketsIf_k_EVEN_by_nLess_k, bucketsIf_k_ODD_by_nLess_k
|
|
4
|
+
from math import exp, log
|
|
5
|
+
from typing import NamedTuple
|
|
6
|
+
import math
|
|
7
|
+
|
|
8
|
+
class ImaKey(NamedTuple):
|
|
9
|
+
"""keys for dictionaries."""
|
|
10
|
+
|
|
11
|
+
oeisID: str
|
|
12
|
+
kIsOdd: bool
|
|
13
|
+
nLess_kIsOdd: bool
|
|
14
|
+
|
|
15
|
+
def getBucketsTotal(state: MatrixMeandersState, safetyMultiplicand: float = 1.2) -> int:
|
|
16
|
+
"""Estimate the total number of non-unique curveLocations that will be computed from the existing curveLocations.
|
|
17
|
+
|
|
18
|
+
Notes
|
|
19
|
+
-----
|
|
20
|
+
Subexponential bucketsTotal unified estimator parameters (derived in reference notebook).
|
|
21
|
+
|
|
22
|
+
The model is: log(buckets) = intercept + bN*log(n) + bK*log(k) + bD*log(n-k) + g_r*(k/n) + g_r2*(k/n)^2 + g_s*((n-k)/n) + offset(subseries)
|
|
23
|
+
Subseries key: f"{oeisID}_kOdd={int(kIsOdd)}_dOdd={int(nLess_kIsOdd)}" with a reference subseries offset of zero.
|
|
24
|
+
These coefficients intentionally remain in-source (SSOT) to avoid runtime JSON parsing overhead and to support reproducibility.
|
|
25
|
+
"""
|
|
26
|
+
dictionaryExponentialCoefficients: dict[ImaKey, float] = {
|
|
27
|
+
(ImaKey(oeisID='', kIsOdd=False, nLess_kIsOdd=True)): 0.834,
|
|
28
|
+
(ImaKey(oeisID='', kIsOdd=False, nLess_kIsOdd=False)): 1.5803,
|
|
29
|
+
(ImaKey(oeisID='', kIsOdd=True, nLess_kIsOdd=True)): 1.556,
|
|
30
|
+
(ImaKey(oeisID='', kIsOdd=True, nLess_kIsOdd=False)): 1.8047,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
logarithmicOffsets: dict[ImaKey, float] ={
|
|
34
|
+
(ImaKey('A000682', kIsOdd=False, nLess_kIsOdd=False)): 0.0,
|
|
35
|
+
(ImaKey('A000682', kIsOdd=False, nLess_kIsOdd=True)): -0.07302547148212568,
|
|
36
|
+
(ImaKey('A000682', kIsOdd=True, nLess_kIsOdd=False)): -0.00595307513938792,
|
|
37
|
+
(ImaKey('A000682', kIsOdd=True, nLess_kIsOdd=True)): -0.012201222865243722,
|
|
38
|
+
(ImaKey('A005316', kIsOdd=False, nLess_kIsOdd=False)): -0.6392728422078733,
|
|
39
|
+
(ImaKey('A005316', kIsOdd=False, nLess_kIsOdd=True)): -0.6904925299923548,
|
|
40
|
+
(ImaKey('A005316', kIsOdd=True, nLess_kIsOdd=False)): 0.0,
|
|
41
|
+
(ImaKey('A005316', kIsOdd=True, nLess_kIsOdd=True)): 0.0,
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
logarithmicParameters: dict[str, float] = {
|
|
45
|
+
'intercept': -166.1750299793178,
|
|
46
|
+
'log(n)': 1259.0051001675547,
|
|
47
|
+
'log(k)': -396.4306071056408,
|
|
48
|
+
'log(nLess_k)': -854.3309503739766,
|
|
49
|
+
'k/n': 716.530410654819,
|
|
50
|
+
'(k/n)^2': -2527.035113444166,
|
|
51
|
+
'normalized k': -882.7054406339189,
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
bucketsTotalMaximumBy_kOfMatrix: dict[int, int] = {1:3, 2:12, 3:40, 4:125, 5:392, 6:1254, 7:4087, 8:13623, 9:46181, 10:159137, 11:555469, 12:1961369, 13:6991893, 14:25134208}
|
|
55
|
+
|
|
56
|
+
xCommon = 1.57
|
|
57
|
+
|
|
58
|
+
nLess_k: int = state.n - state.kOfMatrix
|
|
59
|
+
kIsOdd: bool = bool(state.kOfMatrix & 1)
|
|
60
|
+
nLess_kIsOdd: bool = bool(nLess_k & 1)
|
|
61
|
+
kIsEven: bool = not kIsOdd
|
|
62
|
+
bucketsTotal: int = -8
|
|
63
|
+
|
|
64
|
+
"""NOTE temporary notes
|
|
65
|
+
I have a fault in my thinking. bucketsTotal increases as k decreases until ~0.4k, then bucketsTotal decreases rapidly to 1. I
|
|
66
|
+
have ignored the decreasing side. In the formulas for estimation, I didn't differentiate between increasing and decreasing.
|
|
67
|
+
So, I probably need to refine the formulas. I guess I need to add checks to the if/else monster, too.
|
|
68
|
+
|
|
69
|
+
While buckets is increasing:
|
|
70
|
+
3 types of estimates:
|
|
71
|
+
1. Exponential growth.
|
|
72
|
+
2. Logarithmic growth.
|
|
73
|
+
3. Hard ceiling.
|
|
74
|
+
While buckets is decreasing:
|
|
75
|
+
1. Hard ceiling, same as increasing side.
|
|
76
|
+
2. ???
|
|
77
|
+
3. buckets = 1.
|
|
78
|
+
|
|
79
|
+
The formula for exponential growth _never_ underestimates. I haven't measured by how much it overestimates.
|
|
80
|
+
|
|
81
|
+
"""
|
|
82
|
+
|
|
83
|
+
bucketsTotalAtMaximum: bool = state.kOfMatrix <= ((state.n - 1 - (state.kOfMatrix % 2)) // 3)
|
|
84
|
+
bucketsTotalGrowsExponentially: bool = state.kOfMatrix > nLess_k
|
|
85
|
+
bucketsTotalGrowsLogarithmically: bool = state.kOfMatrix > ((state.n - (state.n % 3)) // 3)
|
|
86
|
+
|
|
87
|
+
if bucketsTotalAtMaximum:
|
|
88
|
+
if state.kOfMatrix in bucketsTotalMaximumBy_kOfMatrix:
|
|
89
|
+
bucketsTotal = bucketsTotalMaximumBy_kOfMatrix[state.kOfMatrix]
|
|
90
|
+
else:
|
|
91
|
+
c = 0.95037
|
|
92
|
+
r = 3.3591258254
|
|
93
|
+
if kIsOdd:
|
|
94
|
+
c = 0.92444
|
|
95
|
+
r = 3.35776
|
|
96
|
+
bucketsTotal = int(c * r**state.kOfMatrix * safetyMultiplicand)
|
|
97
|
+
|
|
98
|
+
elif bucketsTotalGrowsExponentially:
|
|
99
|
+
if (state.oeisID == 'A005316') and kIsOdd and (nLess_k in bucketsIf_k_ODD_by_nLess_k):
|
|
100
|
+
# If I already know bucketsTotal.
|
|
101
|
+
bucketsTotal = bucketsIf_k_ODD_by_nLess_k[nLess_k]
|
|
102
|
+
elif (state.oeisID == 'A005316') and kIsEven and (nLess_k in bucketsIf_k_EVEN_by_nLess_k):
|
|
103
|
+
# If I already know bucketsTotal.
|
|
104
|
+
bucketsTotal = bucketsIf_k_EVEN_by_nLess_k[nLess_k]
|
|
105
|
+
else: # I estimate bucketsTotal during exponential growth.
|
|
106
|
+
xInstant: int = math.ceil(nLess_k / 2)
|
|
107
|
+
A000682adjustStartingCurveLocations: float = 0.25
|
|
108
|
+
startingConditionsCoefficient: float = dictionaryExponentialCoefficients[ImaKey('', kIsOdd, nLess_kIsOdd)]
|
|
109
|
+
if kIsOdd and nLess_kIsOdd:
|
|
110
|
+
A000682adjustStartingCurveLocations = 0.0
|
|
111
|
+
if state.oeisID == 'A000682': # NOTE Net effect is between `*= n` and `*= n * 2.2` if n=46.
|
|
112
|
+
startingConditionsCoefficient *= state.n * (((state.n // 2) + 2) ** A000682adjustStartingCurveLocations)
|
|
113
|
+
bucketsTotal = int(startingConditionsCoefficient * math.exp(xCommon * xInstant))
|
|
114
|
+
|
|
115
|
+
elif state.kOfMatrix <= max(bucketsTotalMaximumBy_kOfMatrix.keys()):
|
|
116
|
+
# If `kOfMatrix` is low, use maximum bucketsTotal. 1. Can't underestimate. 2. Skip computation that can underestimate.
|
|
117
|
+
# 3. The potential difference in memory use is relatively small.
|
|
118
|
+
bucketsTotal = bucketsTotalMaximumBy_kOfMatrix[state.kOfMatrix]
|
|
119
|
+
|
|
120
|
+
elif bucketsTotalGrowsLogarithmically:
|
|
121
|
+
xPower: float = (0
|
|
122
|
+
+ logarithmicParameters['intercept']
|
|
123
|
+
+ logarithmicParameters['log(n)'] * log(state.n)
|
|
124
|
+
+ logarithmicParameters['log(k)'] * log(state.kOfMatrix)
|
|
125
|
+
+ logarithmicParameters['log(nLess_k)'] * log(nLess_k)
|
|
126
|
+
+ logarithmicParameters['k/n'] * (state.kOfMatrix / state.n)
|
|
127
|
+
+ logarithmicParameters['(k/n)^2'] * (state.kOfMatrix / state.n)**2
|
|
128
|
+
+ logarithmicParameters['normalized k'] * nLess_k / state.n
|
|
129
|
+
+ logarithmicOffsets[ImaKey(state.oeisID, kIsOdd, nLess_kIsOdd)]
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
bucketsTotal = int(exp(xPower * safetyMultiplicand))
|
|
133
|
+
|
|
134
|
+
else:
|
|
135
|
+
message = "I shouldn't be here."
|
|
136
|
+
raise SystemError(message)
|
|
137
|
+
return bucketsTotal
|