PyQrackIsing 9.11.2__tar.gz → 9.11.4__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.
- {pyqrackising-9.11.2/pyqrackising.egg-info → pyqrackising-9.11.4}/PKG-INFO +1 -1
- {pyqrackising-9.11.2 → pyqrackising-9.11.4}/pyproject.toml +1 -1
- {pyqrackising-9.11.2 → pyqrackising-9.11.4}/pyqrackising/spin_glass_solver.py +11 -4
- {pyqrackising-9.11.2 → pyqrackising-9.11.4}/pyqrackising/spin_glass_solver_sparse.py +10 -3
- {pyqrackising-9.11.2 → pyqrackising-9.11.4}/pyqrackising/spin_glass_solver_streaming.py +10 -3
- {pyqrackising-9.11.2 → pyqrackising-9.11.4}/pyqrackising/tsp.py +12 -12
- {pyqrackising-9.11.2 → pyqrackising-9.11.4/pyqrackising.egg-info}/PKG-INFO +1 -1
- {pyqrackising-9.11.2 → pyqrackising-9.11.4}/setup.py +1 -1
- {pyqrackising-9.11.2 → pyqrackising-9.11.4}/LICENSE.md +0 -0
- {pyqrackising-9.11.2 → pyqrackising-9.11.4}/MANIFEST.in +0 -0
- {pyqrackising-9.11.2 → pyqrackising-9.11.4}/README.md +0 -0
- {pyqrackising-9.11.2 → pyqrackising-9.11.4}/pyqrackising/__init__.py +0 -0
- {pyqrackising-9.11.2 → pyqrackising-9.11.4}/pyqrackising/convert_tensor_network_to_tsp.py +0 -0
- {pyqrackising-9.11.2 → pyqrackising-9.11.4}/pyqrackising/generate_tfim_samples.py +0 -0
- {pyqrackising-9.11.2 → pyqrackising-9.11.4}/pyqrackising/kernels.cl +0 -0
- {pyqrackising-9.11.2 → pyqrackising-9.11.4}/pyqrackising/maxcut_tfim.py +0 -0
- {pyqrackising-9.11.2 → pyqrackising-9.11.4}/pyqrackising/maxcut_tfim_sparse.py +0 -0
- {pyqrackising-9.11.2 → pyqrackising-9.11.4}/pyqrackising/maxcut_tfim_streaming.py +0 -0
- {pyqrackising-9.11.2 → pyqrackising-9.11.4}/pyqrackising/maxcut_tfim_util.py +0 -0
- {pyqrackising-9.11.2 → pyqrackising-9.11.4}/pyqrackising/otoc.py +0 -0
- {pyqrackising-9.11.2 → pyqrackising-9.11.4}/pyqrackising/tfim_magnetization.py +0 -0
- {pyqrackising-9.11.2 → pyqrackising-9.11.4}/pyqrackising/tfim_square_magnetization.py +0 -0
- {pyqrackising-9.11.2 → pyqrackising-9.11.4}/pyqrackising/tsp_maxcut.py +0 -0
- {pyqrackising-9.11.2 → pyqrackising-9.11.4}/pyqrackising.egg-info/SOURCES.txt +0 -0
- {pyqrackising-9.11.2 → pyqrackising-9.11.4}/pyqrackising.egg-info/dependency_links.txt +0 -0
- {pyqrackising-9.11.2 → pyqrackising-9.11.4}/pyqrackising.egg-info/not-zip-safe +0 -0
- {pyqrackising-9.11.2 → pyqrackising-9.11.4}/pyqrackising.egg-info/requires.txt +0 -0
- {pyqrackising-9.11.2 → pyqrackising-9.11.4}/pyqrackising.egg-info/top_level.txt +0 -0
- {pyqrackising-9.11.2 → pyqrackising-9.11.4}/setup.cfg +0 -0
|
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
|
|
|
7
7
|
|
|
8
8
|
[project]
|
|
9
9
|
name = "pyqrackising"
|
|
10
|
-
version = "9.11.
|
|
10
|
+
version = "9.11.4"
|
|
11
11
|
requires-python = ">=3.8"
|
|
12
12
|
description = "Fast MAXCUT, TSP, and sampling heuristics from near-ideal transverse field Ising model (TFIM)"
|
|
13
13
|
readme = {file = "README.txt", content-type = "text/markdown"}
|
|
@@ -108,7 +108,8 @@ def pick_gray_seeds(best_theta, thread_count, gray_seed_multiple, G_m, n, is_spi
|
|
|
108
108
|
energies[s] = compute_cut_diff_between(best_theta, seed, G_m, n)
|
|
109
109
|
seeds[s] = seed
|
|
110
110
|
|
|
111
|
-
indices = np.
|
|
111
|
+
indices = np.argpartition(energies, -thread_count)[-thread_count:]
|
|
112
|
+
indices = indices[np.argsort(energies[indices])[::-1]]
|
|
112
113
|
best_seeds = np.empty((thread_count, n), dtype=np.bool_)
|
|
113
114
|
best_energies = np.empty(thread_count, dtype=dtype)
|
|
114
115
|
for i in prange(thread_count):
|
|
@@ -117,7 +118,7 @@ def pick_gray_seeds(best_theta, thread_count, gray_seed_multiple, G_m, n, is_spi
|
|
|
117
118
|
best_energies[i] = energies[idx]
|
|
118
119
|
|
|
119
120
|
if is_spin_glass:
|
|
120
|
-
best_energies
|
|
121
|
+
best_energies *= 2.0
|
|
121
122
|
|
|
122
123
|
return best_seeds, best_energies[0]
|
|
123
124
|
|
|
@@ -295,7 +296,7 @@ def run_gray_search_opencl(
|
|
|
295
296
|
blocks = (n + 63) // 64
|
|
296
297
|
offset = best_x * blocks
|
|
297
298
|
for b in range(blocks):
|
|
298
|
-
s = max_theta_host[
|
|
299
|
+
s = max_theta_host[offset + b]
|
|
299
300
|
b_offset = b << 6
|
|
300
301
|
for i in range(64):
|
|
301
302
|
j = b_offset + i
|
|
@@ -351,6 +352,7 @@ def spin_glass_solver(
|
|
|
351
352
|
best_guess = None
|
|
352
353
|
|
|
353
354
|
bitstring = ""
|
|
355
|
+
cut_value = None
|
|
354
356
|
if isinstance(best_guess, str):
|
|
355
357
|
bitstring = best_guess
|
|
356
358
|
elif isinstance(best_guess, int):
|
|
@@ -371,7 +373,12 @@ def spin_glass_solver(
|
|
|
371
373
|
)
|
|
372
374
|
|
|
373
375
|
best_theta = np.array([b == "1" for b in list(bitstring)], dtype=np.bool_)
|
|
374
|
-
|
|
376
|
+
if is_spin_glass:
|
|
377
|
+
max_energy = compute_energy(best_theta, G_m, n_qubits)
|
|
378
|
+
elif cut_value is None:
|
|
379
|
+
max_energy = compute_cut(best_theta, G_m, n_qubits)
|
|
380
|
+
else:
|
|
381
|
+
max_energy = cut_value
|
|
375
382
|
|
|
376
383
|
if n_qubits < heuristic_threshold:
|
|
377
384
|
bitstring, l, r = get_cut(best_theta, nodes, n_qubits)
|
|
@@ -142,7 +142,8 @@ def pick_gray_seeds(best_theta, thread_count, gray_seed_multiple, G_data, G_rows
|
|
|
142
142
|
energies[s] = compute_cut_sparse(seed, G_data, G_rows, G_cols, n)
|
|
143
143
|
seeds[s] = seed
|
|
144
144
|
|
|
145
|
-
indices = np.
|
|
145
|
+
indices = np.argpartition(energies, -thread_count)[-thread_count:]
|
|
146
|
+
indices = indices[np.argsort(energies[indices])[::-1]]
|
|
146
147
|
best_seeds = np.empty((thread_count, n), dtype=np.bool_)
|
|
147
148
|
best_energies = np.empty(thread_count, dtype=dtype)
|
|
148
149
|
for i in prange(thread_count):
|
|
@@ -362,7 +363,7 @@ def run_gray_search_opencl(
|
|
|
362
363
|
blocks = (n + 63) // 64
|
|
363
364
|
offset = best_x * blocks
|
|
364
365
|
for b in range(blocks):
|
|
365
|
-
s = max_theta_host[
|
|
366
|
+
s = max_theta_host[offset + b]
|
|
366
367
|
b_offset = b << 6
|
|
367
368
|
for i in range(64):
|
|
368
369
|
j = b_offset + i
|
|
@@ -418,6 +419,7 @@ def spin_glass_solver_sparse(
|
|
|
418
419
|
best_guess = None
|
|
419
420
|
|
|
420
421
|
bitstring = ""
|
|
422
|
+
cut_value = None
|
|
421
423
|
if isinstance(best_guess, str):
|
|
422
424
|
bitstring = best_guess
|
|
423
425
|
elif isinstance(best_guess, int):
|
|
@@ -438,7 +440,12 @@ def spin_glass_solver_sparse(
|
|
|
438
440
|
)
|
|
439
441
|
|
|
440
442
|
best_theta = np.array([b == "1" for b in list(bitstring)], dtype=np.bool_)
|
|
441
|
-
|
|
443
|
+
if is_spin_glass:
|
|
444
|
+
max_energy = compute_energy_sparse(best_theta, G_m.data, G_m.indptr, G_m.indices, n_qubits)
|
|
445
|
+
elif cut_value is None:
|
|
446
|
+
max_energy = compute_cut_sparse(best_theta, G_m.data, G_m.indptr, G_m.indices, n_qubits)
|
|
447
|
+
else:
|
|
448
|
+
max_energy = cut_value
|
|
442
449
|
|
|
443
450
|
if n_qubits < heuristic_threshold_sparse:
|
|
444
451
|
bitstring, l, r = get_cut(best_theta, nodes, n_qubits)
|
|
@@ -99,7 +99,8 @@ def pick_gray_seeds(best_theta, thread_count, gray_seed_multiple, G_func, nodes,
|
|
|
99
99
|
energies[s] = compute_cut_diff_between_streaming(best_theta, seed, G_func, nodes, n)
|
|
100
100
|
seeds[s] = seed
|
|
101
101
|
|
|
102
|
-
indices = np.
|
|
102
|
+
indices = np.argpartition(energies, -thread_count)[-thread_count:]
|
|
103
|
+
indices = indices[np.argsort(energies[indices])[::-1]]
|
|
103
104
|
best_seeds = np.empty((thread_count, n), dtype=np.bool_)
|
|
104
105
|
best_energies = np.empty(thread_count, dtype=dtype)
|
|
105
106
|
for i in prange(thread_count):
|
|
@@ -108,7 +109,7 @@ def pick_gray_seeds(best_theta, thread_count, gray_seed_multiple, G_func, nodes,
|
|
|
108
109
|
best_energies[i] = energies[idx]
|
|
109
110
|
|
|
110
111
|
if is_spin_glass:
|
|
111
|
-
best_energies
|
|
112
|
+
best_energies *= 2.0
|
|
112
113
|
|
|
113
114
|
return best_seeds, best_energies[0]
|
|
114
115
|
|
|
@@ -179,6 +180,7 @@ def spin_glass_solver_streaming(
|
|
|
179
180
|
best_guess = None
|
|
180
181
|
|
|
181
182
|
bitstring = ""
|
|
183
|
+
cut_value = None
|
|
182
184
|
if isinstance(best_guess, str):
|
|
183
185
|
bitstring = best_guess
|
|
184
186
|
elif isinstance(best_guess, int):
|
|
@@ -198,7 +200,12 @@ def spin_glass_solver_streaming(
|
|
|
198
200
|
)
|
|
199
201
|
|
|
200
202
|
best_theta = np.array([b == "1" for b in list(bitstring)], dtype=np.bool_)
|
|
201
|
-
|
|
203
|
+
if is_spin_glass:
|
|
204
|
+
max_energy = compute_energy_streaming(best_theta, G_func, nodes, n_qubits)
|
|
205
|
+
elif cut_value is None:
|
|
206
|
+
max_energy = compute_cut_streaming(best_theta, G_func, nodes, n_qubits)
|
|
207
|
+
else:
|
|
208
|
+
max_energy = cut_value
|
|
202
209
|
|
|
203
210
|
if n_qubits < heuristic_threshold:
|
|
204
211
|
bitstring, l, r = get_cut(best_theta, nodes, n_qubits)
|
|
@@ -321,7 +321,7 @@ def init_G_a_b(G_m, a, b):
|
|
|
321
321
|
|
|
322
322
|
|
|
323
323
|
@njit
|
|
324
|
-
def
|
|
324
|
+
def stitch_singlet(G_m, singlet, bulk):
|
|
325
325
|
best_path = bulk.copy()
|
|
326
326
|
best_weight = G_m[singlet, bulk[0]]
|
|
327
327
|
weight = G_m[singlet, bulk[-1]]
|
|
@@ -344,10 +344,10 @@ def stich_singlet(G_m, singlet, bulk):
|
|
|
344
344
|
@njit
|
|
345
345
|
def stitch_symmetric(G_m, path_a, path_b):
|
|
346
346
|
if len(path_a) == 1:
|
|
347
|
-
return
|
|
347
|
+
return stitch_singlet(G_m, path_a[0], path_b)
|
|
348
348
|
|
|
349
349
|
if len(path_b) == 1:
|
|
350
|
-
return
|
|
350
|
+
return stitch_singlet(G_m, path_b[0], path_a)
|
|
351
351
|
|
|
352
352
|
terminals_a = [path_a[0], path_a[-1]]
|
|
353
353
|
terminals_b = [path_b[0], path_b[-1]]
|
|
@@ -380,10 +380,10 @@ def stitch_symmetric(G_m, path_a, path_b):
|
|
|
380
380
|
@njit
|
|
381
381
|
def stitch_asymmetric(G_m, path_a, path_b):
|
|
382
382
|
if len(path_a) == 1:
|
|
383
|
-
return
|
|
383
|
+
return stitch_singlet(G_m, path_a[0], path_b)
|
|
384
384
|
|
|
385
385
|
if len(path_b) == 1:
|
|
386
|
-
return
|
|
386
|
+
return stitch_singlet(G_m, path_b[0], path_a)
|
|
387
387
|
|
|
388
388
|
terminals_a = [path_a[0], path_a[-1]]
|
|
389
389
|
terminals_b = [path_b[0], path_b[-1]]
|
|
@@ -399,7 +399,7 @@ def stitch_asymmetric(G_m, path_a, path_b):
|
|
|
399
399
|
|
|
400
400
|
for _ in range(2):
|
|
401
401
|
for _ in range(2):
|
|
402
|
-
path_weight = path_length(path_a, G_m) + path_length(
|
|
402
|
+
path_weight = path_length(path_a, G_m) + path_length(path_b, G_m)
|
|
403
403
|
best_weight = best_connect + path_weight
|
|
404
404
|
for i in range(1, len(path_b)):
|
|
405
405
|
weight = G_m[terminals_a[0], path_b[i - 1]] + G_m[terminals_a[1], path_b[i]] - G_m[path_b[i - 1], path_b[i]]
|
|
@@ -1374,7 +1374,7 @@ def targeted_three_opt_sparse_parallel(path, G_data, G_rows, G_cols, neighbor_li
|
|
|
1374
1374
|
|
|
1375
1375
|
|
|
1376
1376
|
@njit
|
|
1377
|
-
def
|
|
1377
|
+
def stitch_singlet_sparse(G_data, G_rows, G_cols, singlet, bulk):
|
|
1378
1378
|
best_path = bulk.copy()
|
|
1379
1379
|
best_weight = get_G_m(G_data, G_rows, G_cols, singlet, bulk[0])
|
|
1380
1380
|
weight = get_G_m(G_data, G_rows, G_cols, singlet, bulk[-1])
|
|
@@ -1401,10 +1401,10 @@ def stich_singlet_sparse(G_data, G_rows, G_cols, singlet, bulk):
|
|
|
1401
1401
|
@njit
|
|
1402
1402
|
def stitch_sparse_symmetric(G_data, G_rows, G_cols, path_a, path_b):
|
|
1403
1403
|
if len(path_a) == 1:
|
|
1404
|
-
return
|
|
1404
|
+
return stitch_singlet_sparse(G_data, G_rows, G_cols, path_a[0], path_b)
|
|
1405
1405
|
|
|
1406
1406
|
if len(path_b) == 1:
|
|
1407
|
-
return
|
|
1407
|
+
return stitch_singlet_sparse(G_data, G_rows, G_cols, path_b[0], path_a)
|
|
1408
1408
|
|
|
1409
1409
|
terminals_a = [path_a[0], path_a[-1]]
|
|
1410
1410
|
terminals_b = [path_b[0], path_b[-1]]
|
|
@@ -1827,7 +1827,7 @@ def targeted_three_opt_streaming_parallel(path, G_func, neighbor_lists, k_neighb
|
|
|
1827
1827
|
|
|
1828
1828
|
|
|
1829
1829
|
@njit
|
|
1830
|
-
def
|
|
1830
|
+
def stitch_singlet_streaming(G_func, singlet, bulk):
|
|
1831
1831
|
best_path = bulk.copy()
|
|
1832
1832
|
best_weight = G_func(singlet, bulk[0])
|
|
1833
1833
|
weight = G_func(singlet, bulk[-1])
|
|
@@ -1850,10 +1850,10 @@ def stich_singlet_streaming(G_func, singlet, bulk):
|
|
|
1850
1850
|
@njit
|
|
1851
1851
|
def stitch_streaming_symmetric(G_func, path_a, path_b):
|
|
1852
1852
|
if len(path_a) == 1:
|
|
1853
|
-
return
|
|
1853
|
+
return stitch_singlet_streaming(G_func, path_a[0], path_b)
|
|
1854
1854
|
|
|
1855
1855
|
if len(path_b) == 1:
|
|
1856
|
-
return
|
|
1856
|
+
return stitch_singlet_streaming(G_func, path_b[0], path_a)
|
|
1857
1857
|
|
|
1858
1858
|
terminals_a = [path_a[0], path_a[-1]]
|
|
1859
1859
|
terminals_b = [path_b[0], path_b[-1]]
|
|
@@ -7,7 +7,7 @@ with open(README_PATH) as readme_file:
|
|
|
7
7
|
|
|
8
8
|
setup(
|
|
9
9
|
name="pyqrackising",
|
|
10
|
-
version="9.11.
|
|
10
|
+
version="9.11.4",
|
|
11
11
|
author="Dan Strano",
|
|
12
12
|
author_email="stranoj@gmail.com",
|
|
13
13
|
description="Fast MAXCUT, TSP, and sampling heuristics from near-ideal transverse field Ising model (TFIM)",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|