PyQrackIsing 8.8.0__tar.gz → 8.9.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.
- {pyqrackising-8.8.0/pyqrackising.egg-info → pyqrackising-8.9.0}/PKG-INFO +1 -1
- {pyqrackising-8.8.0 → pyqrackising-8.9.0}/pyproject.toml +1 -1
- {pyqrackising-8.8.0 → pyqrackising-8.9.0}/pyqrackising/spin_glass_solver.py +56 -38
- {pyqrackising-8.8.0 → pyqrackising-8.9.0}/pyqrackising/spin_glass_solver_sparse.py +56 -38
- {pyqrackising-8.8.0 → pyqrackising-8.9.0}/pyqrackising/spin_glass_solver_streaming.py +53 -35
- {pyqrackising-8.8.0 → pyqrackising-8.9.0/pyqrackising.egg-info}/PKG-INFO +1 -1
- {pyqrackising-8.8.0 → pyqrackising-8.9.0}/setup.py +1 -1
- {pyqrackising-8.8.0 → pyqrackising-8.9.0}/CMakeLists.txt +0 -0
- {pyqrackising-8.8.0 → pyqrackising-8.9.0}/LICENSE.md +0 -0
- {pyqrackising-8.8.0 → pyqrackising-8.9.0}/MANIFEST.in +0 -0
- {pyqrackising-8.8.0 → pyqrackising-8.9.0}/README.md +0 -0
- {pyqrackising-8.8.0 → pyqrackising-8.9.0}/pyqrackising/__init__.py +0 -0
- {pyqrackising-8.8.0 → pyqrackising-8.9.0}/pyqrackising/_pyqrack_ising.cpp +0 -0
- {pyqrackising-8.8.0 → pyqrackising-8.9.0}/pyqrackising/convert_tensor_network_to_tsp.py +0 -0
- {pyqrackising-8.8.0 → pyqrackising-8.9.0}/pyqrackising/generate_tfim_samples.py +0 -0
- {pyqrackising-8.8.0 → pyqrackising-8.9.0}/pyqrackising/kernels.cl +0 -0
- {pyqrackising-8.8.0 → pyqrackising-8.9.0}/pyqrackising/maxcut_tfim.py +0 -0
- {pyqrackising-8.8.0 → pyqrackising-8.9.0}/pyqrackising/maxcut_tfim_sparse.py +0 -0
- {pyqrackising-8.8.0 → pyqrackising-8.9.0}/pyqrackising/maxcut_tfim_streaming.py +0 -0
- {pyqrackising-8.8.0 → pyqrackising-8.9.0}/pyqrackising/maxcut_tfim_util.py +0 -0
- {pyqrackising-8.8.0 → pyqrackising-8.9.0}/pyqrackising/spin_glass_solver_util.py +0 -0
- {pyqrackising-8.8.0 → pyqrackising-8.9.0}/pyqrackising/tfim_magnetization.py +0 -0
- {pyqrackising-8.8.0 → pyqrackising-8.9.0}/pyqrackising/tfim_square_magnetization.py +0 -0
- {pyqrackising-8.8.0 → pyqrackising-8.9.0}/pyqrackising/tsp.py +0 -0
- {pyqrackising-8.8.0 → pyqrackising-8.9.0}/pyqrackising/tsp_maxcut.py +0 -0
- {pyqrackising-8.8.0 → pyqrackising-8.9.0}/pyqrackising.egg-info/SOURCES.txt +0 -0
- {pyqrackising-8.8.0 → pyqrackising-8.9.0}/pyqrackising.egg-info/dependency_links.txt +0 -0
- {pyqrackising-8.8.0 → pyqrackising-8.9.0}/pyqrackising.egg-info/not-zip-safe +0 -0
- {pyqrackising-8.8.0 → pyqrackising-8.9.0}/pyqrackising.egg-info/top_level.txt +0 -0
- {pyqrackising-8.8.0 → pyqrackising-8.9.0}/setup.cfg +0 -0
|
@@ -12,7 +12,7 @@ build-backend = "setuptools.build_meta"
|
|
|
12
12
|
|
|
13
13
|
[project]
|
|
14
14
|
name = "pyqrackising"
|
|
15
|
-
version = "8.
|
|
15
|
+
version = "8.9.0"
|
|
16
16
|
requires-python = ">=3.8"
|
|
17
17
|
description = "Fast MAXCUT, TSP, and sampling heuristics from near-ideal transverse field Ising model (TFIM)"
|
|
18
18
|
readme = {file = "README.txt", content-type = "text/markdown"}
|
|
@@ -6,6 +6,7 @@ import networkx as nx
|
|
|
6
6
|
import numpy as np
|
|
7
7
|
from numba import njit, prange
|
|
8
8
|
import os
|
|
9
|
+
import random
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
IS_OPENCL_AVAILABLE = True
|
|
@@ -170,7 +171,8 @@ def spin_glass_solver(
|
|
|
170
171
|
repulsion_base=None,
|
|
171
172
|
min_order=1,
|
|
172
173
|
max_order=None,
|
|
173
|
-
is_log=False
|
|
174
|
+
is_log=False,
|
|
175
|
+
reheat_tries=0
|
|
174
176
|
):
|
|
175
177
|
dtype = opencl_context.dtype
|
|
176
178
|
nodes = None
|
|
@@ -249,44 +251,60 @@ def spin_glass_solver(
|
|
|
249
251
|
cut_value = evaluate_cut_edges(best_theta, G_m)
|
|
250
252
|
print(bitstring, float(cut_value), (l, r), float(min_energy))
|
|
251
253
|
|
|
252
|
-
improved = True
|
|
253
|
-
correction_quality = min_order
|
|
254
254
|
combos_list = []
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
255
|
+
reheat_theta = best_theta.copy()
|
|
256
|
+
reheat_min_energy = min_energy
|
|
257
|
+
for reheat_round in range(reheat_tries + 1):
|
|
258
|
+
improved = True
|
|
259
|
+
correction_quality = min_order
|
|
260
|
+
while improved:
|
|
261
|
+
improved = False
|
|
262
|
+
k = 1
|
|
263
|
+
while (k <= correction_quality) and (k <= max_order):
|
|
264
|
+
if n_qubits < k:
|
|
265
|
+
break
|
|
266
|
+
|
|
267
|
+
combos = []
|
|
268
|
+
if len(combos_list) < k:
|
|
269
|
+
combos = np.array(list(
|
|
270
|
+
item for sublist in itertools.combinations(range(n_qubits), k) for item in sublist
|
|
271
|
+
))
|
|
272
|
+
combos_list.append(combos)
|
|
273
|
+
else:
|
|
274
|
+
combos = combos_list[k - 1]
|
|
275
|
+
|
|
276
|
+
if is_combo_maxcut_gpu and IS_OPENCL_AVAILABLE:
|
|
277
|
+
energy = run_bootstrap_opencl(reheat_theta, G_m_buf, combos, k, reheat_min_energy, is_segmented, segment_size)
|
|
278
|
+
else:
|
|
279
|
+
energy = bootstrap(reheat_theta, G_m, combos, k, reheat_min_energy, dtype)
|
|
280
|
+
|
|
281
|
+
if energy < reheat_min_energy:
|
|
282
|
+
reheat_min_energy = energy
|
|
283
|
+
improved = True
|
|
284
|
+
if correction_quality < (k + 1):
|
|
285
|
+
correction_quality = k + 1
|
|
286
|
+
|
|
287
|
+
if is_log:
|
|
288
|
+
bitstring, l, r = get_cut_from_bit_array(reheat_theta, nodes)
|
|
289
|
+
cut_value = evaluate_cut_edges(reheat_theta, G_m)
|
|
290
|
+
print(bitstring, float(cut_value), (l, r), float(reheat_min_energy))
|
|
291
|
+
|
|
292
|
+
break
|
|
293
|
+
|
|
294
|
+
k = k + 1
|
|
295
|
+
|
|
296
|
+
if min_energy < reheat_min_energy:
|
|
297
|
+
reheat_theta = best_theta.copy()
|
|
298
|
+
else:
|
|
299
|
+
best_theta = reheat_theta.copy()
|
|
300
|
+
min_energy = reheat_min_energy
|
|
301
|
+
|
|
302
|
+
if reheat_round < reheat_tries:
|
|
303
|
+
num_to_flip = int(np.round(np.log2(n_qubits)))
|
|
304
|
+
bits_to_flip = random.sample(list(range(n_qubits)), num_to_flip)
|
|
305
|
+
for bit in bits_to_flip:
|
|
306
|
+
reheat_theta[bit] = not reheat_theta[bit]
|
|
307
|
+
reheat_min_energy = compute_energy(reheat_theta, G_m)
|
|
290
308
|
|
|
291
309
|
bitstring, l, r = get_cut_from_bit_array(best_theta, nodes)
|
|
292
310
|
cut_value = evaluate_cut_edges(best_theta, G_m)
|
|
@@ -6,6 +6,7 @@ import networkx as nx
|
|
|
6
6
|
import numpy as np
|
|
7
7
|
from numba import njit, prange
|
|
8
8
|
import os
|
|
9
|
+
import random
|
|
9
10
|
from scipy.sparse import lil_matrix, csr_matrix
|
|
10
11
|
|
|
11
12
|
|
|
@@ -189,7 +190,8 @@ def spin_glass_solver_sparse(
|
|
|
189
190
|
repulsion_base=None,
|
|
190
191
|
min_order=1,
|
|
191
192
|
max_order=None,
|
|
192
|
-
is_log=False
|
|
193
|
+
is_log=False,
|
|
194
|
+
reheat_tries=0
|
|
193
195
|
):
|
|
194
196
|
dtype = opencl_context.dtype
|
|
195
197
|
nodes = None
|
|
@@ -272,44 +274,60 @@ def spin_glass_solver_sparse(
|
|
|
272
274
|
cut_value = evaluate_cut_edges(best_theta, G_m.data, G_m.indptr, G_m.indices)
|
|
273
275
|
print(bitstring, float(cut_value), (l, r), float(min_energy))
|
|
274
276
|
|
|
275
|
-
improved = True
|
|
276
|
-
correction_quality = min_order
|
|
277
277
|
combos_list = []
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
278
|
+
reheat_theta = best_theta.copy()
|
|
279
|
+
reheat_min_energy = min_energy
|
|
280
|
+
for reheat_round in range(reheat_tries + 1):
|
|
281
|
+
improved = True
|
|
282
|
+
correction_quality = min_order
|
|
283
|
+
while improved:
|
|
284
|
+
improved = False
|
|
285
|
+
k = 1
|
|
286
|
+
while (k <= correction_quality) and (k <= max_order):
|
|
287
|
+
if n_qubits < k:
|
|
288
|
+
break
|
|
289
|
+
|
|
290
|
+
combos = []
|
|
291
|
+
if len(combos_list) < k:
|
|
292
|
+
combos = np.array(list(
|
|
293
|
+
item for sublist in itertools.combinations(range(n_qubits), k) for item in sublist
|
|
294
|
+
))
|
|
295
|
+
combos_list.append(combos)
|
|
296
|
+
else:
|
|
297
|
+
combos = combos_list[k - 1]
|
|
298
|
+
|
|
299
|
+
if is_combo_maxcut_gpu and IS_OPENCL_AVAILABLE:
|
|
300
|
+
energy = run_bootstrap_opencl(reheat_theta, G_data_buf, G_rows_buf, G_cols_buf, combos, k, reheat_min_energy, is_segmented, segment_size)
|
|
301
|
+
else:
|
|
302
|
+
energy = bootstrap(reheat_theta, G_m.data, G_m.indptr, G_m.indices, combos, k, reheat_min_energy, dtype)
|
|
303
|
+
|
|
304
|
+
if energy < reheat_min_energy:
|
|
305
|
+
reheat_min_energy = energy
|
|
306
|
+
improved = True
|
|
307
|
+
if correction_quality < (k + 1):
|
|
308
|
+
correction_quality = k + 1
|
|
309
|
+
|
|
310
|
+
if is_log:
|
|
311
|
+
bitstring, l, r = get_cut_from_bit_array(reheat_theta, nodes)
|
|
312
|
+
cut_value = evaluate_cut_edges(reheat_theta, G_m.data, G_m.indptr, G_m.indices)
|
|
313
|
+
print(bitstring, float(cut_value), (l, r), float(reheat_min_energy))
|
|
314
|
+
|
|
315
|
+
break
|
|
316
|
+
|
|
317
|
+
k = k + 1
|
|
318
|
+
|
|
319
|
+
if min_energy < reheat_min_energy:
|
|
320
|
+
reheat_theta = best_theta.copy()
|
|
321
|
+
else:
|
|
322
|
+
best_theta = reheat_theta.copy()
|
|
323
|
+
min_energy = reheat_min_energy
|
|
324
|
+
|
|
325
|
+
if reheat_round < reheat_tries:
|
|
326
|
+
num_to_flip = int(np.round(np.log2(n_qubits)))
|
|
327
|
+
bits_to_flip = random.sample(list(range(n_qubits)), num_to_flip)
|
|
328
|
+
for bit in bits_to_flip:
|
|
329
|
+
reheat_theta[bit] = not reheat_theta[bit]
|
|
330
|
+
reheat_min_energy = compute_energy(reheat_theta, G_m.data, G_m.indptr, G_m.indices)
|
|
313
331
|
|
|
314
332
|
bitstring, l, r = get_cut_from_bit_array(best_theta, nodes)
|
|
315
333
|
cut_value = evaluate_cut_edges(best_theta, G_m.data, G_m.indptr, G_m.indices)
|
|
@@ -6,6 +6,7 @@ import networkx as nx
|
|
|
6
6
|
import numpy as np
|
|
7
7
|
from numba import njit, prange
|
|
8
8
|
import os
|
|
9
|
+
import random
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
epsilon = opencl_context.epsilon
|
|
@@ -78,7 +79,8 @@ def spin_glass_solver_streaming(
|
|
|
78
79
|
repulsion_base=None,
|
|
79
80
|
min_order=1,
|
|
80
81
|
max_order=None,
|
|
81
|
-
is_log=False
|
|
82
|
+
is_log=False,
|
|
83
|
+
reheat_tries=0
|
|
82
84
|
):
|
|
83
85
|
dtype = opencl_context.dtype
|
|
84
86
|
n_qubits = len(nodes)
|
|
@@ -118,41 +120,57 @@ def spin_glass_solver_streaming(
|
|
|
118
120
|
cut_value = evaluate_cut_edges(best_theta, G_func, nodes)
|
|
119
121
|
print(bitstring, float(cut_value), (l, r), float(min_energy))
|
|
120
122
|
|
|
121
|
-
improved = True
|
|
122
|
-
correction_quality = min_order
|
|
123
123
|
combos_list = []
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
124
|
+
reheat_theta = best_theta.copy()
|
|
125
|
+
reheat_min_energy = min_energy
|
|
126
|
+
for reheat_round in range(reheat_tries + 1):
|
|
127
|
+
improved = True
|
|
128
|
+
correction_quality = min_order
|
|
129
|
+
while improved:
|
|
130
|
+
improved = False
|
|
131
|
+
k = 1
|
|
132
|
+
while (k <= correction_quality) and (k <= max_order):
|
|
133
|
+
if n_qubits < k:
|
|
134
|
+
break
|
|
135
|
+
|
|
136
|
+
combos = []
|
|
137
|
+
if len(combos_list) < k:
|
|
138
|
+
combos = np.array(list(
|
|
139
|
+
item for sublist in itertools.combinations(range(n_qubits), k) for item in sublist
|
|
140
|
+
))
|
|
141
|
+
combos_list.append(combos)
|
|
142
|
+
else:
|
|
143
|
+
combos = combos_list[k - 1]
|
|
144
|
+
|
|
145
|
+
energy = bootstrap(best_theta, G_func, nodes, combos, k, min_energy, dtype)
|
|
146
|
+
|
|
147
|
+
if energy < reheat_min_energy:
|
|
148
|
+
reheat_min_energy = energy
|
|
149
|
+
improved = True
|
|
150
|
+
if correction_quality < (k + 1):
|
|
151
|
+
correction_quality = k + 1
|
|
152
|
+
|
|
153
|
+
if is_log:
|
|
154
|
+
bitstring, l, r = get_cut_from_bit_array(reheat_theta, nodes)
|
|
155
|
+
cut_value = evaluate_cut_edges(best_theta, G_func, nodes)
|
|
156
|
+
print(bitstring, float(cut_value), (l, r), float(reheat_min_energy))
|
|
157
|
+
|
|
158
|
+
break
|
|
159
|
+
|
|
160
|
+
k = k + 1
|
|
161
|
+
|
|
162
|
+
if min_energy < reheat_min_energy:
|
|
163
|
+
reheat_theta = best_theta.copy()
|
|
164
|
+
else:
|
|
165
|
+
best_theta = reheat_theta.copy()
|
|
166
|
+
min_energy = reheat_min_energy
|
|
167
|
+
|
|
168
|
+
if reheat_round < reheat_tries:
|
|
169
|
+
num_to_flip = int(np.round(np.log2(n_qubits)))
|
|
170
|
+
bits_to_flip = random.sample(list(range(n_qubits)), num_to_flip)
|
|
171
|
+
for bit in bits_to_flip:
|
|
172
|
+
reheat_theta[bit] = not reheat_theta[bit]
|
|
173
|
+
reheat_min_energy = compute_energy(reheat_theta, G_func, nodes)
|
|
156
174
|
|
|
157
175
|
bitstring, l, r = get_cut_from_bit_array(best_theta, nodes)
|
|
158
176
|
cut_value = evaluate_cut_edges(best_theta, G_func, nodes)
|
|
@@ -51,7 +51,7 @@ ext_modules = [CMakeExtension('tfim_sampler')]
|
|
|
51
51
|
|
|
52
52
|
setup(
|
|
53
53
|
name='pyqrackising',
|
|
54
|
-
version='8.
|
|
54
|
+
version='8.9.0',
|
|
55
55
|
author='Dan Strano',
|
|
56
56
|
author_email='stranoj@gmail.com',
|
|
57
57
|
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
|
|
File without changes
|
|
File without changes
|