PyQrackIsing 9.1.0__tar.gz → 9.1.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.
- {pyqrackising-9.1.0/pyqrackising.egg-info → pyqrackising-9.1.1}/PKG-INFO +1 -1
- {pyqrackising-9.1.0 → pyqrackising-9.1.1}/pyproject.toml +1 -1
- {pyqrackising-9.1.0 → pyqrackising-9.1.1}/pyqrackising/spin_glass_solver.py +24 -26
- {pyqrackising-9.1.0 → pyqrackising-9.1.1}/pyqrackising/spin_glass_solver_sparse.py +24 -26
- {pyqrackising-9.1.0 → pyqrackising-9.1.1}/pyqrackising/spin_glass_solver_streaming.py +24 -26
- {pyqrackising-9.1.0 → pyqrackising-9.1.1/pyqrackising.egg-info}/PKG-INFO +1 -1
- {pyqrackising-9.1.0 → pyqrackising-9.1.1}/setup.py +1 -1
- {pyqrackising-9.1.0 → pyqrackising-9.1.1}/LICENSE.md +0 -0
- {pyqrackising-9.1.0 → pyqrackising-9.1.1}/MANIFEST.in +0 -0
- {pyqrackising-9.1.0 → pyqrackising-9.1.1}/README.md +0 -0
- {pyqrackising-9.1.0 → pyqrackising-9.1.1}/pyqrackising/__init__.py +0 -0
- {pyqrackising-9.1.0 → pyqrackising-9.1.1}/pyqrackising/convert_tensor_network_to_tsp.py +0 -0
- {pyqrackising-9.1.0 → pyqrackising-9.1.1}/pyqrackising/generate_tfim_samples.py +0 -0
- {pyqrackising-9.1.0 → pyqrackising-9.1.1}/pyqrackising/kernels.cl +0 -0
- {pyqrackising-9.1.0 → pyqrackising-9.1.1}/pyqrackising/maxcut_tfim.py +0 -0
- {pyqrackising-9.1.0 → pyqrackising-9.1.1}/pyqrackising/maxcut_tfim_sparse.py +0 -0
- {pyqrackising-9.1.0 → pyqrackising-9.1.1}/pyqrackising/maxcut_tfim_streaming.py +0 -0
- {pyqrackising-9.1.0 → pyqrackising-9.1.1}/pyqrackising/maxcut_tfim_util.py +0 -0
- {pyqrackising-9.1.0 → pyqrackising-9.1.1}/pyqrackising/tfim_magnetization.py +0 -0
- {pyqrackising-9.1.0 → pyqrackising-9.1.1}/pyqrackising/tfim_square_magnetization.py +0 -0
- {pyqrackising-9.1.0 → pyqrackising-9.1.1}/pyqrackising/tsp.py +0 -0
- {pyqrackising-9.1.0 → pyqrackising-9.1.1}/pyqrackising/tsp_maxcut.py +0 -0
- {pyqrackising-9.1.0 → pyqrackising-9.1.1}/pyqrackising.egg-info/SOURCES.txt +0 -0
- {pyqrackising-9.1.0 → pyqrackising-9.1.1}/pyqrackising.egg-info/dependency_links.txt +0 -0
- {pyqrackising-9.1.0 → pyqrackising-9.1.1}/pyqrackising.egg-info/not-zip-safe +0 -0
- {pyqrackising-9.1.0 → pyqrackising-9.1.1}/pyqrackising.egg-info/top_level.txt +0 -0
- {pyqrackising-9.1.0 → pyqrackising-9.1.1}/setup.cfg +0 -0
|
@@ -10,7 +10,7 @@ build-backend = "setuptools.build_meta"
|
|
|
10
10
|
|
|
11
11
|
[project]
|
|
12
12
|
name = "pyqrackising"
|
|
13
|
-
version = "9.1.
|
|
13
|
+
version = "9.1.1"
|
|
14
14
|
requires-python = ">=3.8"
|
|
15
15
|
description = "Fast MAXCUT, TSP, and sampling heuristics from near-ideal transverse field Ising model (TFIM)"
|
|
16
16
|
readme = {file = "README.txt", content-type = "text/markdown"}
|
|
@@ -44,36 +44,33 @@ def run_single_bit_flips(best_theta, is_spin_glass, G_m):
|
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
@njit(parallel=True)
|
|
47
|
-
def run_double_bit_flips(best_theta, is_spin_glass, G_m):
|
|
47
|
+
def run_double_bit_flips(best_theta, is_spin_glass, G_m, combos):
|
|
48
48
|
n = len(best_theta)
|
|
49
|
+
combo_count = (n * (n - 1)) >> 1
|
|
49
50
|
|
|
50
|
-
states = np.empty((
|
|
51
|
-
energies = np.
|
|
51
|
+
states = np.empty((combo_count, n), dtype=np.bool_)
|
|
52
|
+
energies = np.empty(combo_count, dtype=dtype)
|
|
52
53
|
|
|
53
54
|
if is_spin_glass:
|
|
54
|
-
for
|
|
55
|
+
for c in prange(combo_count):
|
|
55
56
|
state = best_theta.copy()
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
states[i], energies[i] = state.copy(), energy
|
|
64
|
-
state[j] = not state[j]
|
|
57
|
+
c2 = c << 1
|
|
58
|
+
b = combos[c2]
|
|
59
|
+
state[b] = not state[b]
|
|
60
|
+
b = combos[c2 + 1]
|
|
61
|
+
state[b] = not state[b]
|
|
62
|
+
|
|
63
|
+
states[c], energies[c] = state, compute_energy(state, G_m, n)
|
|
65
64
|
else:
|
|
66
|
-
for
|
|
65
|
+
for c in prange(combo_count):
|
|
67
66
|
state = best_theta.copy()
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
states[i], energies[i] = state.copy(), energy
|
|
76
|
-
state[j] = not state[j]
|
|
67
|
+
c2 = c << 1
|
|
68
|
+
b = combos[c2]
|
|
69
|
+
state[b] = not state[b]
|
|
70
|
+
b = combos[c2 + 1]
|
|
71
|
+
state[b] = not state[b]
|
|
72
|
+
|
|
73
|
+
states[c], energies[c] = state, compute_cut(state, G_m, n)
|
|
77
74
|
|
|
78
75
|
best_index = np.argmax(energies)
|
|
79
76
|
best_energy = energies[best_index]
|
|
@@ -204,6 +201,8 @@ def spin_glass_solver(
|
|
|
204
201
|
|
|
205
202
|
max_energy = compute_energy(best_theta, G_m, n_qubits) if is_spin_glass else cut_value
|
|
206
203
|
|
|
204
|
+
combos2 = np.array(list(itertools.combinations(range(n_qubits), 2))).flatten()
|
|
205
|
+
|
|
207
206
|
thread_count = os.cpu_count() ** 2
|
|
208
207
|
improved = True
|
|
209
208
|
while improved:
|
|
@@ -218,7 +217,7 @@ def spin_glass_solver(
|
|
|
218
217
|
continue
|
|
219
218
|
|
|
220
219
|
# Double bit flips with O(n^3)
|
|
221
|
-
energy, state = run_double_bit_flips(best_theta, is_spin_glass, G_m)
|
|
220
|
+
energy, state = run_double_bit_flips(best_theta, is_spin_glass, G_m, combos2)
|
|
222
221
|
if energy > max_energy:
|
|
223
222
|
max_energy = energy
|
|
224
223
|
best_theta = state
|
|
@@ -227,8 +226,7 @@ def spin_glass_solver(
|
|
|
227
226
|
|
|
228
227
|
# Gray code with default O(n^3)
|
|
229
228
|
iterators, energies = pick_gray_seeds(best_theta, thread_count, gray_seed_multiple, G_m, n_qubits, is_spin_glass)
|
|
230
|
-
|
|
231
|
-
energy, state = energies[best_i], iterators[best_i]
|
|
229
|
+
energy, state = energies[0], iterators[0]
|
|
232
230
|
if energy > max_energy:
|
|
233
231
|
max_energy = energy
|
|
234
232
|
best_theta = state
|
|
@@ -45,36 +45,33 @@ def run_single_bit_flips(best_theta, is_spin_glass, G_data, G_rows, G_cols):
|
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
@njit(parallel=True)
|
|
48
|
-
def run_double_bit_flips(best_theta, is_spin_glass, G_data, G_rows, G_cols):
|
|
48
|
+
def run_double_bit_flips(best_theta, is_spin_glass, G_data, G_rows, G_cols, combos):
|
|
49
49
|
n = len(best_theta)
|
|
50
|
+
combo_count = (n * (n - 1)) >> 1
|
|
50
51
|
|
|
51
|
-
states = np.empty((
|
|
52
|
-
energies = np.
|
|
52
|
+
states = np.empty((combo_count, n), dtype=np.bool_)
|
|
53
|
+
energies = np.empty(combo_count, dtype=dtype)
|
|
53
54
|
|
|
54
55
|
if is_spin_glass:
|
|
55
|
-
for
|
|
56
|
+
for c in prange(combo_count):
|
|
56
57
|
state = best_theta.copy()
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
states[i], energies[i] = state.copy(), energy
|
|
65
|
-
state[j] = not state[j]
|
|
58
|
+
c2 = c << 1
|
|
59
|
+
b = combos[c2]
|
|
60
|
+
state[b] = not state[b]
|
|
61
|
+
b = combos[c2 + 1]
|
|
62
|
+
state[b] = not state[b]
|
|
63
|
+
|
|
64
|
+
states[c], energies[c] = state, compute_energy_sparse(state, G_data, G_rows, G_cols, n)
|
|
66
65
|
else:
|
|
67
|
-
for
|
|
66
|
+
for c in prange(combo_count):
|
|
68
67
|
state = best_theta.copy()
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
states[i], energies[i] = state.copy(), energy
|
|
77
|
-
state[j] = not state[j]
|
|
68
|
+
c2 = c << 1
|
|
69
|
+
b = combos[c2]
|
|
70
|
+
state[b] = not state[b]
|
|
71
|
+
b = combos[c2 + 1]
|
|
72
|
+
state[b] = not state[b]
|
|
73
|
+
|
|
74
|
+
states[c], energies[c] = state, compute_cut_sparse(state, G_data, G_rows, G_cols, n)
|
|
78
75
|
|
|
79
76
|
best_index = np.argmax(energies)
|
|
80
77
|
best_energy = energies[best_index]
|
|
@@ -205,6 +202,8 @@ def spin_glass_solver_sparse(
|
|
|
205
202
|
|
|
206
203
|
max_energy = compute_energy_sparse(best_theta, G_m.data, G_m.indptr, G_m.indices, n_qubits) if is_spin_glass else cut_value
|
|
207
204
|
|
|
205
|
+
combos2 = np.array(list(itertools.combinations(range(n_qubits), 2))).flatten()
|
|
206
|
+
|
|
208
207
|
thread_count = os.cpu_count() ** 2
|
|
209
208
|
improved = True
|
|
210
209
|
while improved:
|
|
@@ -219,7 +218,7 @@ def spin_glass_solver_sparse(
|
|
|
219
218
|
continue
|
|
220
219
|
|
|
221
220
|
# Double bit flips with O(n^3)
|
|
222
|
-
energy, state = run_double_bit_flips(best_theta, is_spin_glass, G_m.data, G_m.indptr, G_m.indices)
|
|
221
|
+
energy, state = run_double_bit_flips(best_theta, is_spin_glass, G_m.data, G_m.indptr, G_m.indices, combos2)
|
|
223
222
|
if energy > max_energy:
|
|
224
223
|
max_energy = energy
|
|
225
224
|
best_theta = state
|
|
@@ -228,8 +227,7 @@ def spin_glass_solver_sparse(
|
|
|
228
227
|
|
|
229
228
|
# Gray code with default O(n^3)
|
|
230
229
|
iterators, energies = pick_gray_seeds(best_theta, thread_count, gray_seed_multiple, G_m.data, G_m.indptr, G_m.indices, n_qubits, is_spin_glass)
|
|
231
|
-
|
|
232
|
-
energy, state = energies[best_i], iterators[best_i]
|
|
230
|
+
energy, state = energies[0], iterators[0]
|
|
233
231
|
if energy > max_energy:
|
|
234
232
|
max_energy = energy
|
|
235
233
|
best_theta = state
|
|
@@ -37,36 +37,33 @@ def run_single_bit_flips(best_theta, is_spin_glass, G_func, nodes):
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
@njit(parallel=True)
|
|
40
|
-
def run_double_bit_flips(best_theta, is_spin_glass, G_func, nodes):
|
|
40
|
+
def run_double_bit_flips(best_theta, is_spin_glass, G_func, nodes, combos):
|
|
41
41
|
n = len(best_theta)
|
|
42
|
+
combo_count = (n * (n - 1)) >> 1
|
|
42
43
|
|
|
43
|
-
states = np.empty((
|
|
44
|
-
energies = np.
|
|
44
|
+
states = np.empty((combo_count, n), dtype=np.bool_)
|
|
45
|
+
energies = np.empty(combo_count, dtype=dtype)
|
|
45
46
|
|
|
46
47
|
if is_spin_glass:
|
|
47
|
-
for
|
|
48
|
+
for c in prange(combo_count):
|
|
48
49
|
state = best_theta.copy()
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
states[i], energies[i] = state.copy(), energy
|
|
57
|
-
state[j] = not state[j]
|
|
50
|
+
c2 = c << 1
|
|
51
|
+
b = combos[c2]
|
|
52
|
+
state[b] = not state[b]
|
|
53
|
+
b = combos[c2 + 1]
|
|
54
|
+
state[b] = not state[b]
|
|
55
|
+
|
|
56
|
+
states[c], energies[c] = state, compute_energy_streaming(state, G_func, nodes, n)
|
|
58
57
|
else:
|
|
59
|
-
for
|
|
58
|
+
for c in prange(combo_count):
|
|
60
59
|
state = best_theta.copy()
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
states[i], energies[i] = state.copy(), energy
|
|
69
|
-
state[j] = not state[j]
|
|
60
|
+
c2 = c << 1
|
|
61
|
+
b = combos[c2]
|
|
62
|
+
state[b] = not state[b]
|
|
63
|
+
b = combos[c2 + 1]
|
|
64
|
+
state[b] = not state[b]
|
|
65
|
+
|
|
66
|
+
states[c], energies[c] = state, compute_cut_streaming(state, G_func, nodes, n)
|
|
70
67
|
|
|
71
68
|
best_index = np.argmax(energies)
|
|
72
69
|
best_energy = energies[best_index]
|
|
@@ -189,6 +186,8 @@ def spin_glass_solver_streaming(
|
|
|
189
186
|
|
|
190
187
|
max_energy = compute_energy_streaming(best_theta, G_func, nodes, n_qubits) if is_spin_glass else cut_value
|
|
191
188
|
|
|
189
|
+
combos2 = np.array(list(itertools.combinations(range(n_qubits), 2))).flatten()
|
|
190
|
+
|
|
192
191
|
thread_count = os.cpu_count() ** 2
|
|
193
192
|
improved = True
|
|
194
193
|
while improved:
|
|
@@ -203,7 +202,7 @@ def spin_glass_solver_streaming(
|
|
|
203
202
|
continue
|
|
204
203
|
|
|
205
204
|
# Double bit flips with O(n^3)
|
|
206
|
-
energy, state = run_double_bit_flips(best_theta, is_spin_glass, G_func, nodes)
|
|
205
|
+
energy, state = run_double_bit_flips(best_theta, is_spin_glass, G_func, nodes, combos2)
|
|
207
206
|
if energy > max_energy:
|
|
208
207
|
max_energy = energy
|
|
209
208
|
best_theta = state
|
|
@@ -212,8 +211,7 @@ def spin_glass_solver_streaming(
|
|
|
212
211
|
|
|
213
212
|
# Gray code with default O(n^3)
|
|
214
213
|
iterators, energies = pick_gray_seeds(best_theta, thread_count, gray_seed_multiple, G_func, nodes, n_qubits, is_spin_glass)
|
|
215
|
-
|
|
216
|
-
energy, state = energies[best_i], iterators[best_i]
|
|
214
|
+
energy, state = energies[0], iterators[0]
|
|
217
215
|
if energy > max_energy:
|
|
218
216
|
max_energy = energy
|
|
219
217
|
best_theta = state
|
|
@@ -7,7 +7,7 @@ with open(README_PATH) as readme_file:
|
|
|
7
7
|
|
|
8
8
|
setup(
|
|
9
9
|
name='pyqrackising',
|
|
10
|
-
version='9.1.
|
|
10
|
+
version='9.1.1',
|
|
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
|