PyQrackIsing 2.0.2__tar.gz → 3.0.0__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 (22) hide show
  1. {pyqrackising-2.0.2/pyqrackising.egg-info → pyqrackising-3.0.0}/PKG-INFO +1 -1
  2. {pyqrackising-2.0.2 → pyqrackising-3.0.0}/README.md +2 -3
  3. {pyqrackising-2.0.2 → pyqrackising-3.0.0}/pyproject.toml +1 -1
  4. {pyqrackising-2.0.2 → pyqrackising-3.0.0}/pyqrackising/tsp_symmetric.py +13 -20
  5. {pyqrackising-2.0.2 → pyqrackising-3.0.0/pyqrackising.egg-info}/PKG-INFO +1 -1
  6. {pyqrackising-2.0.2 → pyqrackising-3.0.0}/setup.py +1 -1
  7. {pyqrackising-2.0.2 → pyqrackising-3.0.0}/CMakeLists.txt +0 -0
  8. {pyqrackising-2.0.2 → pyqrackising-3.0.0}/LICENSE.md +0 -0
  9. {pyqrackising-2.0.2 → pyqrackising-3.0.0}/MANIFEST.in +0 -0
  10. {pyqrackising-2.0.2 → pyqrackising-3.0.0}/pyqrackising/__init__.py +0 -0
  11. {pyqrackising-2.0.2 → pyqrackising-3.0.0}/pyqrackising/_pyqrack_ising.cpp +0 -0
  12. {pyqrackising-2.0.2 → pyqrackising-3.0.0}/pyqrackising/generate_tfim_samples.py +0 -0
  13. {pyqrackising-2.0.2 → pyqrackising-3.0.0}/pyqrackising/kernels.cl +0 -0
  14. {pyqrackising-2.0.2 → pyqrackising-3.0.0}/pyqrackising/maxcut_tfim.py +0 -0
  15. {pyqrackising-2.0.2 → pyqrackising-3.0.0}/pyqrackising/spin_glass_solver.py +0 -0
  16. {pyqrackising-2.0.2 → pyqrackising-3.0.0}/pyqrackising/tfim_magnetization.py +0 -0
  17. {pyqrackising-2.0.2 → pyqrackising-3.0.0}/pyqrackising/tfim_square_magnetization.py +0 -0
  18. {pyqrackising-2.0.2 → pyqrackising-3.0.0}/pyqrackising.egg-info/SOURCES.txt +0 -0
  19. {pyqrackising-2.0.2 → pyqrackising-3.0.0}/pyqrackising.egg-info/dependency_links.txt +0 -0
  20. {pyqrackising-2.0.2 → pyqrackising-3.0.0}/pyqrackising.egg-info/not-zip-safe +0 -0
  21. {pyqrackising-2.0.2 → pyqrackising-3.0.0}/pyqrackising.egg-info/top_level.txt +0 -0
  22. {pyqrackising-2.0.2 → pyqrackising-3.0.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyqrackising
3
- Version: 2.0.2
3
+ Version: 3.0.0
4
4
  Summary: Near-ideal closed-form solutions for transverse field Ising model (TFIM)
5
5
  Home-page: https://github.com/vm6502q/PyQrackIsing
6
6
  Author: Dan Strano
@@ -101,12 +101,11 @@ circuit, path_length = tsp_symmetric(
101
101
  G,
102
102
  start_node=None,
103
103
  end_node=None,
104
- is_monte_carlo=False,
104
+ monte_carlo=False,
105
105
  quality=1,
106
106
  correction_quality=2,
107
107
  is_cyclic=True,
108
108
  multi_start=1,
109
- is_3_opt=True,
110
109
  k_neighbors=20
111
110
  )
112
111
 
@@ -114,7 +113,7 @@ print(f"Node count: {n_nodes}")
114
113
  print(f"Path: {circuit}")
115
114
  print(f"Path length: {path_length}")
116
115
  ```
117
- We only provide a solver for the symmetric version of the TSP (i.e., the distance from "A" to "B" is considered the same as from "B" to "A"). `is_monte_carlo=True` switches out the MAXCUT-based heuristic for pure Monte Carlo recursive bipartitioning. `multi_start` controls how many stochastic repeats of MAXCUT are tried to select the best result, at every level of recursion.
116
+ We only provide a solver for the symmetric version of the TSP (i.e., the distance from "A" to "B" is considered the same as from "B" to "A"). `monte_carlo=True` switches out the MAXCUT-based heuristic for pure Monte Carlo recursive bipartitioning. `multi_start` controls how many stochastic repeats of MAXCUT are tried to select the best result, at every level of recursion.
118
117
 
119
118
  ## About
120
119
  Transverse field Ising model (TFIM) is the basis of most claimed algorithmic "quantum advantage," circa 2025, with the notable exception of Shor's integer factoring algorithm.
@@ -11,7 +11,7 @@ build-backend = "setuptools.build_meta"
11
11
 
12
12
  [project]
13
13
  name = "pyqrackising"
14
- version = "2.0.2"
14
+ version = "3.0.0"
15
15
  requires-python = ">=3.8"
16
16
  description = "Near-ideal closed-form solutions for transverse field Ising model (TFIM)"
17
17
  readme = {file = "README.txt", content-type = "text/markdown"}
@@ -1,15 +1,9 @@
1
1
  from .spin_glass_solver import spin_glass_solver
2
2
  import networkx as nx
3
- from numba import njit, prange
3
+ from numba import njit
4
4
  import numpy as np
5
5
 
6
6
 
7
-
8
- # By Gemini (Google Search AI)
9
- def int_to_bitstring(integer, length):
10
- return (bin(integer)[2:].zfill(length))[::-1]
11
-
12
-
13
7
  # two_opt() and targeted_three_opt() written by Elara (OpenAI ChatGPT instance)
14
8
  @njit
15
9
  def path_length(path, G_m):
@@ -30,7 +24,7 @@ def one_way_two_opt(path, G):
30
24
  while improved:
31
25
  improved = False
32
26
  for i in range(1, path_len - 1):
33
- for j in range(i + 2, path_len + 1):
27
+ for j in range(i + 2, path_len):
34
28
  new_path = best_path[:]
35
29
  new_path[i:j] = best_path[j-1:i-1:-1]
36
30
  new_dist = path_length(new_path, G)
@@ -50,7 +44,7 @@ def anchored_two_opt(path, G):
50
44
 
51
45
  while improved:
52
46
  improved = False
53
- for i in range(1, path_len - 1):
47
+ for i in range(2, path_len - 1):
54
48
  for j in range(i + 2, path_len):
55
49
  new_path = best_path[:]
56
50
  new_path[i:j] = best_path[j-1:i-1:-1]
@@ -67,11 +61,12 @@ def two_opt(path, G):
67
61
  improved = True
68
62
  best_path = path
69
63
  best_dist = path_length(best_path, G)
64
+ path_len = len(path)
70
65
 
71
66
  while improved:
72
67
  improved = False
73
- for i in range(1, len(path) - 2):
74
- for j in range(i + 2, len(path) - 1):
68
+ for i in range(1, path_len - 2):
69
+ for j in range(i + 2, path_len - 1):
75
70
  new_path = best_path[:]
76
71
  new_path[i:j] = best_path[j-1:i-1:-1] # reverse segment
77
72
  new_dist = path_length(new_path, G)
@@ -169,18 +164,18 @@ def targeted_three_opt(path, W, k_neighbors=20):
169
164
  return best_path, best_dist
170
165
 
171
166
 
172
- @njit(parallel=True)
167
+ @njit
173
168
  def init_G_a_b(G_m, a, b):
174
169
  n_a_nodes = len(a)
175
170
  n_b_nodes = len(b)
176
171
  G_a = np.zeros((n_a_nodes, n_a_nodes), dtype=np.float64)
177
172
  G_b = np.zeros((n_b_nodes, n_b_nodes), dtype=np.float64)
178
- for i in prange(n_a_nodes):
173
+ for i in range(n_a_nodes):
179
174
  for j in range(n_a_nodes):
180
175
  if i == j:
181
176
  continue
182
177
  G_a[i, j] = G_m[a[i], a[j]]
183
- for i in prange(n_b_nodes):
178
+ for i in range(n_b_nodes):
184
179
  for j in range(n_b_nodes):
185
180
  if i == j:
186
181
  continue
@@ -264,7 +259,7 @@ def monte_carlo_loop(n_nodes):
264
259
  return bits
265
260
 
266
261
 
267
- def tsp_symmetric(G, start_node=None, end_node=None, quality=1, shots=None, correction_quality=2, monte_carlo=False, is_3_opt=True, k_neighbors=20, is_cyclic=True, multi_start=1, is_top_level=True):
262
+ def tsp_symmetric(G, start_node=None, end_node=None, quality=1, shots=None, correction_quality=2, monte_carlo=False, k_neighbors=20, is_cyclic=True, multi_start=1, is_top_level=True):
268
263
  nodes = None
269
264
  n_nodes = 0
270
265
  G_m = None
@@ -317,8 +312,8 @@ def tsp_symmetric(G, start_node=None, end_node=None, quality=1, shots=None, corr
317
312
 
318
313
  G_a, G_b = init_G_a_b(G_m, a, b)
319
314
 
320
- sol_a = tsp_symmetric(G_a, quality=quality, correction_quality=correction_quality, monte_carlo=monte_carlo, is_cyclic=False, is_top_level=False, is_3_opt=False, multi_start=multi_start)
321
- sol_b = tsp_symmetric(G_b, quality=quality, correction_quality=correction_quality, monte_carlo=monte_carlo, is_cyclic=False, is_top_level=False, is_3_opt=False, multi_start=multi_start)
315
+ sol_a = tsp_symmetric(G_a, quality=quality, correction_quality=correction_quality, monte_carlo=monte_carlo, is_cyclic=False, is_top_level=False, k_neighbors=0, multi_start=multi_start)
316
+ sol_b = tsp_symmetric(G_b, quality=quality, correction_quality=correction_quality, monte_carlo=monte_carlo, is_cyclic=False, is_top_level=False, k_neighbors=0, multi_start=multi_start)
322
317
 
323
318
  path_a = [a[x] for x in sol_a[0]]
324
319
  path_b = [b[x] for x in sol_b[0]]
@@ -356,13 +351,11 @@ def tsp_symmetric(G, start_node=None, end_node=None, quality=1, shots=None, corr
356
351
  elif not end_node is None:
357
352
  best_path, best_weight = two_opt(best_path, G_m)
358
353
  elif not start_node is None:
359
- best_path.reverse()
360
354
  best_path, best_weight = anchored_two_opt(best_path, G_m)
361
- best_path.reverse()
362
355
  else:
363
356
  best_path, best_weight = one_way_two_opt(best_path, G_m)
364
357
 
365
- if is_3_opt:
358
+ if k_neighbors > 0:
366
359
  best_path, best_weight = targeted_three_opt(best_path, G_m, k_neighbors)
367
360
  else:
368
361
  best_path, best_weight = one_way_two_opt(best_path, G_m)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyqrackising
3
- Version: 2.0.2
3
+ Version: 3.0.0
4
4
  Summary: Near-ideal closed-form solutions for transverse field Ising model (TFIM)
5
5
  Home-page: https://github.com/vm6502q/PyQrackIsing
6
6
  Author: Dan Strano
@@ -51,7 +51,7 @@ ext_modules = [CMakeExtension('tfim_sampler')]
51
51
 
52
52
  setup(
53
53
  name='pyqrackising',
54
- version='2.0.2',
54
+ version='3.0.0',
55
55
  author='Dan Strano',
56
56
  author_email='stranoj@gmail.com',
57
57
  description='Near-ideal closed-form solutions for transverse field Ising model (TFIM)',
File without changes
File without changes
File without changes