PyQrackIsing 1.26.1__tar.gz → 1.26.2__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-1.26.1/PyQrackIsing.egg-info → pyqrackising-1.26.2}/PKG-INFO +1 -1
- {pyqrackising-1.26.1 → pyqrackising-1.26.2}/PyQrackIsing/maxcut_tfim.py +27 -45
- {pyqrackising-1.26.1 → pyqrackising-1.26.2}/PyQrackIsing/spin_glass_solver.py +2 -3
- {pyqrackising-1.26.1 → pyqrackising-1.26.2/PyQrackIsing.egg-info}/PKG-INFO +1 -1
- {pyqrackising-1.26.1 → pyqrackising-1.26.2}/pyproject.toml +1 -1
- {pyqrackising-1.26.1 → pyqrackising-1.26.2}/setup.py +1 -1
- {pyqrackising-1.26.1 → pyqrackising-1.26.2}/CMakeLists.txt +0 -0
- {pyqrackising-1.26.1 → pyqrackising-1.26.2}/LICENSE.md +0 -0
- {pyqrackising-1.26.1 → pyqrackising-1.26.2}/MANIFEST.in +0 -0
- {pyqrackising-1.26.1 → pyqrackising-1.26.2}/PyQrackIsing/__init__.py +0 -0
- {pyqrackising-1.26.1 → pyqrackising-1.26.2}/PyQrackIsing/_pyqrack_ising.cpp +0 -0
- {pyqrackising-1.26.1 → pyqrackising-1.26.2}/PyQrackIsing/generate_tfim_samples.py +0 -0
- {pyqrackising-1.26.1 → pyqrackising-1.26.2}/PyQrackIsing/tfim_magnetization.py +0 -0
- {pyqrackising-1.26.1 → pyqrackising-1.26.2}/PyQrackIsing/tfim_square_magnetization.py +0 -0
- {pyqrackising-1.26.1 → pyqrackising-1.26.2}/PyQrackIsing/tsp_symmetric.py +0 -0
- {pyqrackising-1.26.1 → pyqrackising-1.26.2}/PyQrackIsing.egg-info/SOURCES.txt +0 -0
- {pyqrackising-1.26.1 → pyqrackising-1.26.2}/PyQrackIsing.egg-info/dependency_links.txt +0 -0
- {pyqrackising-1.26.1 → pyqrackising-1.26.2}/PyQrackIsing.egg-info/not-zip-safe +0 -0
- {pyqrackising-1.26.1 → pyqrackising-1.26.2}/PyQrackIsing.egg-info/top_level.txt +0 -0
- {pyqrackising-1.26.1 → pyqrackising-1.26.2}/README.md +0 -0
- {pyqrackising-1.26.1 → pyqrackising-1.26.2}/setup.cfg +0 -0
|
@@ -205,9 +205,21 @@ def local_repulsion_choice(adjacency, degrees, weights, n, m):
|
|
|
205
205
|
return mask
|
|
206
206
|
|
|
207
207
|
|
|
208
|
+
@njit
|
|
209
|
+
def compute_energy(sample, G_m, n_qubits):
|
|
210
|
+
energy = 0
|
|
211
|
+
for u in range(n_qubits):
|
|
212
|
+
for v in range(u + 1, n_qubits):
|
|
213
|
+
eigen = 1 if sample[u] == sample[v] else -1
|
|
214
|
+
energy += G_m[u, v] * eigen
|
|
215
|
+
|
|
216
|
+
return energy
|
|
217
|
+
|
|
218
|
+
|
|
208
219
|
@njit(parallel=True)
|
|
209
|
-
def
|
|
210
|
-
|
|
220
|
+
def sample_for_solution(G_m, shots, thresholds, adjacency, degrees, weights, n):
|
|
221
|
+
best_solution = np.zeros(n, dtype=np.bool_)
|
|
222
|
+
best_energy = compute_energy(best_solution, G_m, n)
|
|
211
223
|
|
|
212
224
|
for s in prange(shots):
|
|
213
225
|
# First dimension: Hamming weight
|
|
@@ -218,40 +230,18 @@ def local_repulsion_choice_sample(shots, thresholds, adjacency, degrees, weights
|
|
|
218
230
|
m += 1
|
|
219
231
|
|
|
220
232
|
# Second dimension: permutation within Hamming weight
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
return samples
|
|
224
|
-
|
|
233
|
+
sample = local_repulsion_choice(adjacency, degrees, weights, n, m)
|
|
225
234
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
for b in reversed(mask):
|
|
231
|
-
sample <<= 1
|
|
232
|
-
if b:
|
|
233
|
-
sample |= 1
|
|
234
|
-
samples.append(sample)
|
|
235
|
+
energy = compute_energy(sample, G_m, n)
|
|
236
|
+
if energy < best_energy:
|
|
237
|
+
best_energy = energy
|
|
238
|
+
best_solution = sample
|
|
235
239
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
best_value = float("-inf")
|
|
242
|
-
best_solution = None
|
|
243
|
-
best_cut_edges = None
|
|
244
|
-
|
|
245
|
-
for state in samples:
|
|
246
|
-
cut_edges = []
|
|
247
|
-
cut_value = 0
|
|
248
|
-
for u in range(n_qubits):
|
|
249
|
-
for v in range(u + 1, n_qubits):
|
|
250
|
-
if ((state >> u) & 1) != ((state >> v) & 1):
|
|
251
|
-
cut_value += G_m[u, v]
|
|
252
|
-
if cut_value > best_value:
|
|
253
|
-
best_value = cut_value
|
|
254
|
-
best_solution = state
|
|
240
|
+
best_value = 0
|
|
241
|
+
for u in range(n):
|
|
242
|
+
for v in range(u + 1, n):
|
|
243
|
+
if best_solution[u] != best_solution[v]:
|
|
244
|
+
best_value += G_m[u, v]
|
|
255
245
|
|
|
256
246
|
return best_solution, float(best_value)
|
|
257
247
|
|
|
@@ -329,11 +319,6 @@ def compute_adjacency(G_m):
|
|
|
329
319
|
return adjacency
|
|
330
320
|
|
|
331
321
|
|
|
332
|
-
# By Gemini (Google Search AI)
|
|
333
|
-
def int_to_bitstring(integer, length):
|
|
334
|
-
return (bin(integer)[2:].zfill(length))[::-1]
|
|
335
|
-
|
|
336
|
-
|
|
337
322
|
def maxcut_tfim(
|
|
338
323
|
G,
|
|
339
324
|
quality=None,
|
|
@@ -399,13 +384,10 @@ def maxcut_tfim(
|
|
|
399
384
|
maxcut_hamming_cdf(n_qubits, J_eff, degrees, quality, thresholds)
|
|
400
385
|
|
|
401
386
|
adjacency = compute_adjacency(G_m)
|
|
402
|
-
weights = 1.0 / (1.0 + (2 ** -
|
|
403
|
-
|
|
404
|
-
samples = list(set(mask_array_to_python_ints(local_repulsion_choice_sample(shots, thresholds, adjacency, degrees, weights, n_qubits))))
|
|
405
|
-
|
|
406
|
-
best_solution, best_value = evaluate_cut_edges(G_m, samples)
|
|
387
|
+
weights = 1.0 / (1.0 + (2 ** -52) - J_eff)
|
|
388
|
+
best_solution, best_value = sample_for_solution(G_m, shots, thresholds, adjacency, degrees, weights, n_qubits)
|
|
407
389
|
|
|
408
|
-
bit_string =
|
|
390
|
+
bit_string = "".join(["1" if b else "0" for b in best_solution])
|
|
409
391
|
bit_list = list(bit_string)
|
|
410
392
|
l, r = [], []
|
|
411
393
|
for i in range(len(bit_list)):
|
|
@@ -23,9 +23,8 @@ def compute_energy(theta_bits, G_m):
|
|
|
23
23
|
energy = 0
|
|
24
24
|
for u in range(n_qubits):
|
|
25
25
|
for v in range(u + 1, n_qubits):
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
energy += G_m[u, v] * spin_u * spin_v
|
|
26
|
+
eigen = 1 if theta_bits[u] == theta_bits[v] else -1
|
|
27
|
+
energy += G_m[u, v] * eigen
|
|
29
28
|
|
|
30
29
|
return energy
|
|
31
30
|
|
|
@@ -12,7 +12,7 @@ build-backend = "setuptools.build_meta"
|
|
|
12
12
|
|
|
13
13
|
[project]
|
|
14
14
|
name = "PyQrackIsing"
|
|
15
|
-
version = "1.26.
|
|
15
|
+
version = "1.26.2"
|
|
16
16
|
requires-python = ">=3.8"
|
|
17
17
|
description = "Near-ideal closed-form solutions for transverse field Ising model (TFIM)"
|
|
18
18
|
readme = {file = "README.txt", content-type = "text/markdown"}
|
|
@@ -51,7 +51,7 @@ ext_modules = [CMakeExtension('tfim_sampler')]
|
|
|
51
51
|
|
|
52
52
|
setup(
|
|
53
53
|
name='PyQrackIsing',
|
|
54
|
-
version='1.26.
|
|
54
|
+
version='1.26.2',
|
|
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
|
|
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
|