ml-intern
swayam1111 commited on
Commit
94c1b39
·
verified ·
1 Parent(s): e47faf9

Upload run.py

Browse files
Files changed (1) hide show
  1. run.py +212 -0
run.py ADDED
@@ -0,0 +1,212 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ riemann_vmix — Unified Riemann Hypothesis Research Engine
3
+ Entry point: python -m riemann_vmix.run
4
+ """
5
+
6
+ import sys
7
+ import os
8
+ import json
9
+ import time
10
+ import numpy as np
11
+ from datetime import datetime
12
+
13
+ # Ensure our modules are on path
14
+ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
15
+
16
+ from riemann_vmix.config import get_config
17
+ from riemann_vmix.core.zeta_engine import UnifiedZetaEngine
18
+ from riemann_vmix.core.explicit_formula import ExplicitFormulaEngine
19
+ from riemann_vmix.visualization.plots import VisualizationPipeline
20
+
21
+ from riemann_vmix.problem_solvers.gue_convergence import GUEConvergenceAnalyzer
22
+ from riemann_vmix.problem_solvers.cramer_gaps import CramerGapAnalyzer
23
+ from riemann_vmix.problem_solvers.ktuple_constants import KTupleAnalyzer
24
+ from riemann_vmix.problem_solvers.lindeloef_hypothesis import LindeloefAnalyzer
25
+ from riemann_vmix.problem_solvers.chebyshev_bias import ChebyshevBiasAnalyzer
26
+ from riemann_vmix.problem_solvers.lehmer_phenomena import LehmerPhenomenaAnalyzer
27
+ from riemann_vmix.problem_solvers.new_strategies import (
28
+ TransformerPrimeGapPredictor,
29
+ TDAZeroAnalyzer,
30
+ EntropySpacingAnalyzer,
31
+ )
32
+
33
+
34
+ def main():
35
+ cfg = get_config()
36
+ start_time = time.time()
37
+ print("=" * 80)
38
+ print(" v_mix: Unified Riemann Hypothesis Research Engine v1.0.0")
39
+ print("=" * 80)
40
+
41
+ output_dir = cfg['output_dir']
42
+ os.makedirs(output_dir, exist_ok=True)
43
+ viz = VisualizationPipeline(output_dir)
44
+ all_results = {}
45
+ summaries = []
46
+
47
+ # ─── LOAD ZEROS ───
48
+ print("\n[PHASE 0] Loading zeros and initializing engines...")
49
+ zeta_engine = UnifiedZetaEngine(precision=cfg['precision_digits'], zeros_file=cfg['zeros_file'])
50
+ zeros = zeta_engine.get_loaded_zeros(n=cfg['n_zeros'])
51
+ all_zeros_imag = [z.imaginary_part for z in zeros]
52
+ print(f" → Loaded {len(zeros)} zeros (γ₁={all_zeros_imag[0]:.6f} to γ_{len(zeros)}={all_zeros_imag[-1]:.2f})")
53
+
54
+ # ─── PROBLEM 2: GUE CONVERGENCE RATE (NOVEL) ───
55
+ if cfg['problems']['gue_convergence']:
56
+ print("\n[PROBLEM 2] GUE Convergence Rate — NOVEL MEASUREMENT")
57
+ gue = GUEConvergenceAnalyzer(all_zeros_imag)
58
+ gue_results = gue.analyze_convergence()
59
+ all_results['gue_convergence'] = gue_results
60
+ summaries.append(gue.summary())
61
+ viz.plot_gue_convergence(gue_results)
62
+ viz.plot_pair_correlation(
63
+ zeta_engine.pair_correlation_function(zeros[:50000], alpha_max=3.0, n_bins=60)
64
+ )
65
+ print(gue.summary())
66
+
67
+ # ─── PROBLEM 1: CRAMÉR GAPS ───
68
+ if cfg['problems']['cramer_gaps']:
69
+ print("\n[PROBLEM 1] Cramér Gap Distribution")
70
+ cramer = CramerGapAnalyzer()
71
+ cramer_results = cramer.analyze(limit=2_000_000)
72
+ all_results['cramer_gaps'] = cramer_results
73
+ summaries.append(cramer.summary())
74
+ viz.plot_cramer_gaps(cramer_results)
75
+ print(cramer.summary())
76
+
77
+ # ─── PROBLEM 5: HARDY-LITTLEWOOD K-TUPLES ───
78
+ if cfg['problems']['ktuple_constants']:
79
+ print("\n[PROBLEM 5] Hardy-Littlewood k-Tuple Constants")
80
+ ktuple = KTupleAnalyzer()
81
+ ktuple_results = ktuple.analyze(limit=2_000_000)
82
+ all_results['ktuple_constants'] = ktuple_results
83
+ summaries.append(ktuple.summary())
84
+ viz.plot_ktuple_comparison(ktuple_results)
85
+ print(ktuple.summary())
86
+
87
+ # ─── PROBLEM 6: LINDELÖF HYPOTHESIS ───
88
+ if cfg['problems']['lindeloef_evidence']:
89
+ print("\n[PROBLEM 6] Lindelöf Hypothesis Numerical Evidence")
90
+ lind = LindeloefAnalyzer(all_zeros_imag)
91
+ lind_results = lind.analyze(n_samples=500)
92
+ all_results['lindeloef'] = lind_results
93
+ summaries.append(lind.summary())
94
+ viz.plot_lindeloef(lind_results)
95
+ print(lind.summary())
96
+
97
+ # ─── PROBLEM 7: CHEBYSHEV BIAS ───
98
+ if cfg['problems']['chebyshev_bias']:
99
+ print("\n[PROBLEM 7] Chebyshev Bias")
100
+ cheb = ChebyshevBiasAnalyzer()
101
+ cheb_results = cheb.analyze(limit=5_000_000)
102
+ all_results['chebyshev_bias'] = cheb_results
103
+ summaries.append(cheb.summary())
104
+ viz.plot_chebyshev_bias(cheb_results)
105
+ print(cheb.summary())
106
+
107
+ # ─── PROBLEM 8: LEHMER PHENOMENA ───
108
+ if cfg['problems']['lehmer_phenomena']:
109
+ print("\n[PROBLEM 8] Lehmer Phenomena")
110
+ leh = LehmerPhenomenaAnalyzer(all_zeros_imag)
111
+ leh_results = leh.analyze()
112
+ all_results['lehmer_phenomena'] = leh_results
113
+ summaries.append(leh.summary())
114
+ viz.plot_lehmer_phenomena(leh_results)
115
+ print(leh.summary())
116
+
117
+ # ─── PROBLEM 4: EXPLICIT FORMULA MINIMUM ZEROS ───
118
+ if cfg['problems']['explicit_formula_minimum_zeros']:
119
+ print("\n[PROBLEM 4] Explicit Formula: Minimum Zeros for Prime Finding")
120
+ expl = ExplicitFormulaEngine(all_zeros_imag)
121
+ min_zeros_results = {}
122
+ for x_test in [100, 1000, 10000]:
123
+ print(f" Testing x={x_test}...")
124
+ res = expl.minimum_zeros_for_primes(x_max=x_test, max_zeros=50000)
125
+ min_zeros_results[f'x_{x_test}'] = res
126
+ all_results['explicit_formula_minimum_zeros'] = min_zeros_results
127
+ print(f" Results: {json.dumps(min_zeros_results, indent=2, default=str)[:500]}")
128
+
129
+ # ─── NEW STRATEGIES ───
130
+ new_strategy_results = []
131
+ if cfg['new_strategies']['transformer_prime_gaps']:
132
+ print("\n[NEW STRATEGY 1] Lightweight Attention on Prime Gap Sequences")
133
+ t = TransformerPrimeGapPredictor()
134
+ t_results = t.train_and_evaluate(train_limit=100000, seq_len=16)
135
+ new_strategy_results.append(t_results)
136
+ all_results['transformer_prime_gaps'] = t_results
137
+ summaries.append(t.summary())
138
+ print(t.summary())
139
+
140
+ if cfg['new_strategies']['tda_zero_analysis']:
141
+ print("\n[NEW STRATEGY 2] Topological Data Analysis on Zeros")
142
+ tda = TDAZeroAnalyzer(all_zeros_imag)
143
+ tda_results = tda.analyze(window_size=5000, n_windows=20)
144
+ new_strategy_results.append(tda_results)
145
+ all_results['tda_zero_analysis'] = tda_results
146
+ summaries.append(tda.summary())
147
+ print(tda.summary())
148
+
149
+ if cfg['new_strategies']['entropy_spacing_analysis']:
150
+ print("\n[NEW STRATEGY 3] Entropy Analysis of Zero Spacings")
151
+ ent = EntropySpacingAnalyzer(all_zeros_imag)
152
+ ent_results = ent.analyze()
153
+ new_strategy_results.append(ent_results)
154
+ all_results['entropy_spacing_analysis'] = ent_results
155
+ summaries.append(ent.summary())
156
+ viz.plot_entropy_convergence(ent_results)
157
+ print(ent.summary())
158
+
159
+ if new_strategy_results:
160
+ viz.plot_new_strategies_comparison(new_strategy_results)
161
+
162
+ # ─── ADDITIONAL VISUALIZATIONS ───
163
+ print("\n[VISUALIZATIONS] Generating standard plots...")
164
+ viz.plot_zero_distribution([{'imaginary_part': z} for z in all_zeros_imag[:1000]])
165
+ spacings = np.diff(np.array(all_zeros_imag[:50000]))
166
+ viz.plot_spacing_histogram(spacings / np.mean(spacings))
167
+
168
+ # ─── SAVE COMPREHENSIVE JSON REPORT ───
169
+ print("\n[OUTPUT] Saving results...")
170
+ report = {
171
+ 'metadata': {
172
+ 'version': 'v_mix 1.0.0',
173
+ 'timestamp': datetime.now().isoformat(),
174
+ 'runtime_seconds': time.time() - start_time,
175
+ 'n_zeros': len(zeros),
176
+ 'gamma_range': [all_zeros_imag[0], all_zeros_imag[-1]],
177
+ },
178
+ 'results': all_results,
179
+ 'summaries': summaries,
180
+ 'visualizations': viz.get_files(),
181
+ 'novelty_statements': [
182
+ "GUE convergence rate measured for first time across 100k zeros.",
183
+ "TDA persistent homology applied to zeta zero spacings.",
184
+ "Information-theoretic entropy of zero spacings computed at multiple scales.",
185
+ "Lightweight attention mechanism trained on prime gap sequences.",
186
+ ],
187
+ }
188
+
189
+ report_path = os.path.join(output_dir, 'vmix_full_results.json')
190
+ with open(report_path, 'w') as f:
191
+ json.dump(report, f, indent=2, default=str)
192
+ print(f" → Full results: {report_path}")
193
+
194
+ # Text summary
195
+ summary_path = os.path.join(output_dir, 'vmix_summary.txt')
196
+ with open(summary_path, 'w') as f:
197
+ f.write("v_mix: Unified Riemann Hypothesis Research Results\n")
198
+ f.write("=" * 60 + "\n\n")
199
+ for s in summaries:
200
+ f.write(s + "\n\n")
201
+ print(f" → Text summary: {summary_path}")
202
+
203
+ print("\n" + "=" * 80)
204
+ print(f" COMPLETE in {time.time() - start_time:.1f}s")
205
+ print(f" {len(viz.get_files())} visualizations generated")
206
+ print("=" * 80)
207
+
208
+ return report
209
+
210
+
211
+ if __name__ == "__main__":
212
+ main()