PyQrackIsing 9.11.1__tar.gz → 9.11.3__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.1/pyqrackising.egg-info → pyqrackising-9.11.3}/PKG-INFO +1 -1
- {pyqrackising-9.11.1 → pyqrackising-9.11.3}/pyproject.toml +1 -1
- {pyqrackising-9.11.1 → pyqrackising-9.11.3}/pyqrackising/generate_tfim_samples.py +15 -7
- {pyqrackising-9.11.1 → pyqrackising-9.11.3}/pyqrackising/spin_glass_solver.py +3 -2
- {pyqrackising-9.11.1 → pyqrackising-9.11.3}/pyqrackising/spin_glass_solver_sparse.py +3 -2
- {pyqrackising-9.11.1 → pyqrackising-9.11.3}/pyqrackising/spin_glass_solver_streaming.py +2 -1
- {pyqrackising-9.11.1 → pyqrackising-9.11.3}/pyqrackising/tsp.py +12 -12
- {pyqrackising-9.11.1 → pyqrackising-9.11.3/pyqrackising.egg-info}/PKG-INFO +1 -1
- {pyqrackising-9.11.1 → pyqrackising-9.11.3}/setup.py +1 -1
- {pyqrackising-9.11.1 → pyqrackising-9.11.3}/LICENSE.md +0 -0
- {pyqrackising-9.11.1 → pyqrackising-9.11.3}/MANIFEST.in +0 -0
- {pyqrackising-9.11.1 → pyqrackising-9.11.3}/README.md +0 -0
- {pyqrackising-9.11.1 → pyqrackising-9.11.3}/pyqrackising/__init__.py +0 -0
- {pyqrackising-9.11.1 → pyqrackising-9.11.3}/pyqrackising/convert_tensor_network_to_tsp.py +0 -0
- {pyqrackising-9.11.1 → pyqrackising-9.11.3}/pyqrackising/kernels.cl +0 -0
- {pyqrackising-9.11.1 → pyqrackising-9.11.3}/pyqrackising/maxcut_tfim.py +0 -0
- {pyqrackising-9.11.1 → pyqrackising-9.11.3}/pyqrackising/maxcut_tfim_sparse.py +0 -0
- {pyqrackising-9.11.1 → pyqrackising-9.11.3}/pyqrackising/maxcut_tfim_streaming.py +0 -0
- {pyqrackising-9.11.1 → pyqrackising-9.11.3}/pyqrackising/maxcut_tfim_util.py +0 -0
- {pyqrackising-9.11.1 → pyqrackising-9.11.3}/pyqrackising/otoc.py +0 -0
- {pyqrackising-9.11.1 → pyqrackising-9.11.3}/pyqrackising/tfim_magnetization.py +0 -0
- {pyqrackising-9.11.1 → pyqrackising-9.11.3}/pyqrackising/tfim_square_magnetization.py +0 -0
- {pyqrackising-9.11.1 → pyqrackising-9.11.3}/pyqrackising/tsp_maxcut.py +0 -0
- {pyqrackising-9.11.1 → pyqrackising-9.11.3}/pyqrackising.egg-info/SOURCES.txt +0 -0
- {pyqrackising-9.11.1 → pyqrackising-9.11.3}/pyqrackising.egg-info/dependency_links.txt +0 -0
- {pyqrackising-9.11.1 → pyqrackising-9.11.3}/pyqrackising.egg-info/not-zip-safe +0 -0
- {pyqrackising-9.11.1 → pyqrackising-9.11.3}/pyqrackising.egg-info/requires.txt +0 -0
- {pyqrackising-9.11.1 → pyqrackising-9.11.3}/pyqrackising.egg-info/top_level.txt +0 -0
- {pyqrackising-9.11.1 → pyqrackising-9.11.3}/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.3"
|
|
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"}
|
|
@@ -105,15 +105,17 @@ def sample_fixed_hamming_weight(h_weight, count, n_rows, n_cols, burnin=10):
|
|
|
105
105
|
|
|
106
106
|
samples = []
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
burn = burnin * n_qubits
|
|
109
|
+
thinning = n_qubits
|
|
109
110
|
|
|
110
|
-
for
|
|
111
|
+
ones = set([i for i in range(n_qubits) if (state >> i) & 1])
|
|
112
|
+
zeros = set([i for i in range(n_qubits) if not (state >> i) & 1])
|
|
113
|
+
|
|
114
|
+
for step in range(burn + thinning * count):
|
|
111
115
|
# choose random 1-bit and 0-bit
|
|
112
|
-
ones = [i for i in range(n_qubits) if (state >> i) & 1]
|
|
113
|
-
zeros = [i for i in range(n_qubits) if not (state >> i) & 1]
|
|
114
116
|
|
|
115
|
-
i = random.choice(ones)
|
|
116
|
-
j = random.choice(zeros)
|
|
117
|
+
i = random.choice(tuple(ones))
|
|
118
|
+
j = random.choice(tuple(zeros))
|
|
117
119
|
|
|
118
120
|
delta = delta_like_edges(state, i, j, neighbors)
|
|
119
121
|
new_like = like_edges + delta
|
|
@@ -122,10 +124,16 @@ def sample_fixed_hamming_weight(h_weight, count, n_rows, n_cols, burnin=10):
|
|
|
122
124
|
accept_prob = new_like / like_edges
|
|
123
125
|
if np.random.random() < accept_prob:
|
|
124
126
|
state ^= 1 << i
|
|
127
|
+
ones.remove(i)
|
|
128
|
+
zeros.add(i)
|
|
129
|
+
|
|
125
130
|
state ^= 1 << j
|
|
131
|
+
zeros.remove(j)
|
|
132
|
+
ones.add(j)
|
|
133
|
+
|
|
126
134
|
like_edges = new_like
|
|
127
135
|
|
|
128
|
-
if step >=
|
|
136
|
+
if step >= burn and (step - burn) % thinning == 0:
|
|
129
137
|
samples.append(state)
|
|
130
138
|
|
|
131
139
|
return samples
|
|
@@ -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):
|
|
@@ -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
|
|
@@ -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
|
|
@@ -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):
|
|
@@ -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.3",
|
|
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
|