PyQrackIsing 2.0.3__tar.gz → 3.0.1__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.3/pyqrackising.egg-info → pyqrackising-3.0.1}/PKG-INFO +1 -1
  2. {pyqrackising-2.0.3 → pyqrackising-3.0.1}/README.md +2 -3
  3. {pyqrackising-2.0.3 → pyqrackising-3.0.1}/pyproject.toml +1 -1
  4. {pyqrackising-2.0.3 → pyqrackising-3.0.1}/pyqrackising/tsp_symmetric.py +20 -13
  5. {pyqrackising-2.0.3 → pyqrackising-3.0.1/pyqrackising.egg-info}/PKG-INFO +1 -1
  6. {pyqrackising-2.0.3 → pyqrackising-3.0.1}/setup.py +1 -1
  7. {pyqrackising-2.0.3 → pyqrackising-3.0.1}/CMakeLists.txt +0 -0
  8. {pyqrackising-2.0.3 → pyqrackising-3.0.1}/LICENSE.md +0 -0
  9. {pyqrackising-2.0.3 → pyqrackising-3.0.1}/MANIFEST.in +0 -0
  10. {pyqrackising-2.0.3 → pyqrackising-3.0.1}/pyqrackising/__init__.py +0 -0
  11. {pyqrackising-2.0.3 → pyqrackising-3.0.1}/pyqrackising/_pyqrack_ising.cpp +0 -0
  12. {pyqrackising-2.0.3 → pyqrackising-3.0.1}/pyqrackising/generate_tfim_samples.py +0 -0
  13. {pyqrackising-2.0.3 → pyqrackising-3.0.1}/pyqrackising/kernels.cl +0 -0
  14. {pyqrackising-2.0.3 → pyqrackising-3.0.1}/pyqrackising/maxcut_tfim.py +0 -0
  15. {pyqrackising-2.0.3 → pyqrackising-3.0.1}/pyqrackising/spin_glass_solver.py +0 -0
  16. {pyqrackising-2.0.3 → pyqrackising-3.0.1}/pyqrackising/tfim_magnetization.py +0 -0
  17. {pyqrackising-2.0.3 → pyqrackising-3.0.1}/pyqrackising/tfim_square_magnetization.py +0 -0
  18. {pyqrackising-2.0.3 → pyqrackising-3.0.1}/pyqrackising.egg-info/SOURCES.txt +0 -0
  19. {pyqrackising-2.0.3 → pyqrackising-3.0.1}/pyqrackising.egg-info/dependency_links.txt +0 -0
  20. {pyqrackising-2.0.3 → pyqrackising-3.0.1}/pyqrackising.egg-info/not-zip-safe +0 -0
  21. {pyqrackising-2.0.3 → pyqrackising-3.0.1}/pyqrackising.egg-info/top_level.txt +0 -0
  22. {pyqrackising-2.0.3 → pyqrackising-3.0.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyqrackising
3
- Version: 2.0.3
3
+ Version: 3.0.1
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.3"
14
+ version = "3.0.1"
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,6 +1,6 @@
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
 
@@ -164,18 +164,18 @@ def targeted_three_opt(path, W, k_neighbors=20):
164
164
  return best_path, best_dist
165
165
 
166
166
 
167
- @njit(parallel=True)
167
+ @njit
168
168
  def init_G_a_b(G_m, a, b):
169
169
  n_a_nodes = len(a)
170
170
  n_b_nodes = len(b)
171
171
  G_a = np.zeros((n_a_nodes, n_a_nodes), dtype=np.float64)
172
172
  G_b = np.zeros((n_b_nodes, n_b_nodes), dtype=np.float64)
173
- for i in prange(n_a_nodes):
173
+ for i in range(n_a_nodes):
174
174
  for j in range(n_a_nodes):
175
175
  if i == j:
176
176
  continue
177
177
  G_a[i, j] = G_m[a[i], a[j]]
178
- for i in prange(n_b_nodes):
178
+ for i in range(n_b_nodes):
179
179
  for j in range(n_b_nodes):
180
180
  if i == j:
181
181
  continue
@@ -196,16 +196,19 @@ def stitch(G_m, path_a, path_b, sol_weight):
196
196
  if is_single_a:
197
197
  singlet = path_a[0]
198
198
  bulk = path_b
199
- elif is_single_b:
199
+ else:
200
200
  singlet = path_b[0]
201
201
  bulk = path_a
202
202
 
203
+ best_path = bulk.copy()
203
204
  best_weight = G_m[singlet, bulk[0]]
204
- best_path = [singlet] + bulk
205
205
  weight = G_m[singlet, bulk[-1]]
206
206
  if weight < best_weight:
207
207
  best_weight = weight
208
- best_path = bulk + [singlet]
208
+ best_path += [singlet]
209
+ else:
210
+ best_path = [singlet] + best_path
211
+
209
212
  for i in range(1, len(bulk)):
210
213
  weight = (
211
214
  G_m[singlet, bulk[i - 1]] +
@@ -221,11 +224,14 @@ def stitch(G_m, path_a, path_b, sol_weight):
221
224
  terminals_b = [path_b[0], path_b[-1]]
222
225
 
223
226
  best_weight = G_m[terminals_a[1], terminals_b[0]]
224
- best_path = path_a + path_b
227
+ best_path = path_b.copy()
225
228
  weight = G_m[terminals_a[0], terminals_b[1]]
226
229
  if weight < best_weight:
227
230
  best_weight = weight
228
- best_path = path_b + path_a
231
+ best_path += path_a
232
+ else:
233
+ best_path = path_a + best_path
234
+
229
235
  for _ in range(2):
230
236
  for _ in range(2):
231
237
  for i in range(1, len(path_b)):
@@ -246,6 +252,7 @@ def stitch(G_m, path_a, path_b, sol_weight):
246
252
  return best_path, best_weight
247
253
 
248
254
 
255
+
249
256
  def monte_carlo_loop(n_nodes):
250
257
  bits = ([], [])
251
258
  while (len(bits[0]) == 0) or (len(bits[1]) == 0):
@@ -259,7 +266,7 @@ def monte_carlo_loop(n_nodes):
259
266
  return bits
260
267
 
261
268
 
262
- 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):
269
+ 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):
263
270
  nodes = None
264
271
  n_nodes = 0
265
272
  G_m = None
@@ -312,8 +319,8 @@ def tsp_symmetric(G, start_node=None, end_node=None, quality=1, shots=None, corr
312
319
 
313
320
  G_a, G_b = init_G_a_b(G_m, a, b)
314
321
 
315
- 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)
316
- 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)
322
+ 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)
323
+ 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)
317
324
 
318
325
  path_a = [a[x] for x in sol_a[0]]
319
326
  path_b = [b[x] for x in sol_b[0]]
@@ -355,7 +362,7 @@ def tsp_symmetric(G, start_node=None, end_node=None, quality=1, shots=None, corr
355
362
  else:
356
363
  best_path, best_weight = one_way_two_opt(best_path, G_m)
357
364
 
358
- if is_3_opt:
365
+ if k_neighbors > 0:
359
366
  best_path, best_weight = targeted_three_opt(best_path, G_m, k_neighbors)
360
367
  else:
361
368
  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.3
3
+ Version: 3.0.1
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.3',
54
+ version='3.0.1',
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