pyqrackising 9.5.0__tar.gz → 9.5.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.
Potentially problematic release.
This version of pyqrackising might be problematic. Click here for more details.
- {pyqrackising-9.5.0/pyqrackising.egg-info → pyqrackising-9.5.1}/PKG-INFO +1 -1
- {pyqrackising-9.5.0 → pyqrackising-9.5.1}/pyproject.toml +1 -1
- {pyqrackising-9.5.0 → pyqrackising-9.5.1}/pyqrackising/maxcut_tfim_util.py +42 -7
- {pyqrackising-9.5.0 → pyqrackising-9.5.1}/pyqrackising/otoc.py +21 -0
- {pyqrackising-9.5.0 → pyqrackising-9.5.1/pyqrackising.egg-info}/PKG-INFO +1 -1
- {pyqrackising-9.5.0 → pyqrackising-9.5.1}/setup.py +1 -1
- {pyqrackising-9.5.0 → pyqrackising-9.5.1}/LICENSE.md +0 -0
- {pyqrackising-9.5.0 → pyqrackising-9.5.1}/MANIFEST.in +0 -0
- {pyqrackising-9.5.0 → pyqrackising-9.5.1}/README.md +0 -0
- {pyqrackising-9.5.0 → pyqrackising-9.5.1}/pyqrackising/__init__.py +0 -0
- {pyqrackising-9.5.0 → pyqrackising-9.5.1}/pyqrackising/convert_tensor_network_to_tsp.py +0 -0
- {pyqrackising-9.5.0 → pyqrackising-9.5.1}/pyqrackising/generate_tfim_samples.py +0 -0
- {pyqrackising-9.5.0 → pyqrackising-9.5.1}/pyqrackising/kernels.cl +0 -0
- {pyqrackising-9.5.0 → pyqrackising-9.5.1}/pyqrackising/maxcut_tfim.py +0 -0
- {pyqrackising-9.5.0 → pyqrackising-9.5.1}/pyqrackising/maxcut_tfim_sparse.py +0 -0
- {pyqrackising-9.5.0 → pyqrackising-9.5.1}/pyqrackising/maxcut_tfim_streaming.py +0 -0
- {pyqrackising-9.5.0 → pyqrackising-9.5.1}/pyqrackising/spin_glass_solver.py +0 -0
- {pyqrackising-9.5.0 → pyqrackising-9.5.1}/pyqrackising/spin_glass_solver_sparse.py +0 -0
- {pyqrackising-9.5.0 → pyqrackising-9.5.1}/pyqrackising/spin_glass_solver_streaming.py +0 -0
- {pyqrackising-9.5.0 → pyqrackising-9.5.1}/pyqrackising/tfim_magnetization.py +0 -0
- {pyqrackising-9.5.0 → pyqrackising-9.5.1}/pyqrackising/tfim_square_magnetization.py +0 -0
- {pyqrackising-9.5.0 → pyqrackising-9.5.1}/pyqrackising/tsp.py +0 -0
- {pyqrackising-9.5.0 → pyqrackising-9.5.1}/pyqrackising/tsp_maxcut.py +0 -0
- {pyqrackising-9.5.0 → pyqrackising-9.5.1}/pyqrackising.egg-info/SOURCES.txt +0 -0
- {pyqrackising-9.5.0 → pyqrackising-9.5.1}/pyqrackising.egg-info/dependency_links.txt +0 -0
- {pyqrackising-9.5.0 → pyqrackising-9.5.1}/pyqrackising.egg-info/not-zip-safe +0 -0
- {pyqrackising-9.5.0 → pyqrackising-9.5.1}/pyqrackising.egg-info/top_level.txt +0 -0
- {pyqrackising-9.5.0 → pyqrackising-9.5.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.5.
|
|
13
|
+
version = "9.5.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"}
|
|
@@ -389,22 +389,57 @@ def init_theta(h_mult, n_qubits, J_eff, degrees):
|
|
|
389
389
|
return theta
|
|
390
390
|
|
|
391
391
|
|
|
392
|
+
# From Google Search AI
|
|
393
|
+
@njit
|
|
394
|
+
def factorial(num):
|
|
395
|
+
"""Calculates the factorial of a non-negative integer."""
|
|
396
|
+
if num == 0:
|
|
397
|
+
return 1
|
|
398
|
+
|
|
399
|
+
result = 1
|
|
400
|
+
for i in range(1, num + 1):
|
|
401
|
+
result *= i
|
|
402
|
+
|
|
403
|
+
return result
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
# From Google Search AI
|
|
407
|
+
@njit
|
|
408
|
+
def comb(n, k):
|
|
409
|
+
"""
|
|
410
|
+
Calculates the number of combinations (n choose k) from scratch.
|
|
411
|
+
n: The total number of items.
|
|
412
|
+
k: The number of items to choose.
|
|
413
|
+
"""
|
|
414
|
+
# Optimize by choosing the smaller of k and (n-k)
|
|
415
|
+
# This reduces the number of multiplications in the factorial calculation
|
|
416
|
+
k = min(k, n - k)
|
|
417
|
+
|
|
418
|
+
# Calculate the numerator: n * (n-1) * ... * (n-k+1)
|
|
419
|
+
numerator = 1
|
|
420
|
+
for i in range(k):
|
|
421
|
+
numerator *= (n - i)
|
|
422
|
+
|
|
423
|
+
# Calculate the denominator: k!
|
|
424
|
+
denominator = factorial(k)
|
|
425
|
+
|
|
426
|
+
return numerator // denominator
|
|
427
|
+
|
|
428
|
+
|
|
392
429
|
@njit
|
|
393
430
|
def init_thresholds(n_qubits):
|
|
394
431
|
n_bias = n_qubits - 1
|
|
395
432
|
thresholds = np.empty(n_bias, dtype=np.float64)
|
|
396
433
|
tot_prob = 0
|
|
397
|
-
p =
|
|
398
|
-
if n_qubits & 1:
|
|
399
|
-
q = n_qubits // 2
|
|
400
|
-
thresholds[q - 1] = p
|
|
401
|
-
tot_prob = p
|
|
402
|
-
p /= 2
|
|
434
|
+
p = n_qubits
|
|
403
435
|
for q in range(1, n_qubits // 2):
|
|
404
436
|
thresholds[q - 1] = p
|
|
405
437
|
thresholds[n_bias - q] = p
|
|
406
438
|
tot_prob += 2 * p
|
|
407
|
-
p
|
|
439
|
+
p = comb(n_qubits, q + 1)
|
|
440
|
+
if n_qubits & 1:
|
|
441
|
+
thresholds[q - 1] = p
|
|
442
|
+
tot_prob += p
|
|
408
443
|
thresholds /= tot_prob
|
|
409
444
|
|
|
410
445
|
return thresholds
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from .maxcut_tfim_util import probability_by_hamming_weight, sample_mag, opencl_context
|
|
2
|
+
import math
|
|
2
3
|
from numba import njit
|
|
3
4
|
import numpy as np
|
|
4
5
|
import sys
|
|
@@ -14,6 +15,19 @@ def get_otoc_hamming_distribution(J=-1.0, h=2.0, z=4, theta=0.0, t=5, n_qubits=6
|
|
|
14
15
|
bias[0] = 1.0
|
|
15
16
|
return bias
|
|
16
17
|
|
|
18
|
+
max_entropy = np.empty(n_bias, dtype=np.float64)
|
|
19
|
+
tot_prob = 0
|
|
20
|
+
p = 1.0
|
|
21
|
+
for q in range(n_qubits // 2):
|
|
22
|
+
max_entropy[q] = p
|
|
23
|
+
max_entropy[n_bias - (q + 1)] = p
|
|
24
|
+
tot_prob += 2 * p
|
|
25
|
+
p = math.comb(n_qubits, q + 1)
|
|
26
|
+
if n_qubits & 1:
|
|
27
|
+
max_entropy[q - 1] = p
|
|
28
|
+
tot_prob += p
|
|
29
|
+
max_entropy /= tot_prob
|
|
30
|
+
|
|
17
31
|
diff_z = np.zeros(n_bias, dtype=np.float64)
|
|
18
32
|
for pauli_string in pauli_strings:
|
|
19
33
|
pauli_string = list(pauli_string)
|
|
@@ -33,17 +47,24 @@ def get_otoc_hamming_distribution(J=-1.0, h=2.0, z=4, theta=0.0, t=5, n_qubits=6
|
|
|
33
47
|
# so there is no difference in this dimension.
|
|
34
48
|
|
|
35
49
|
diff_z[0] += n_qubits
|
|
50
|
+
entropy_frac = 0
|
|
36
51
|
for b in pauli_string:
|
|
37
52
|
match b:
|
|
38
53
|
case 'X':
|
|
39
54
|
diff_z += diff_theta
|
|
55
|
+
entropy_frac += 1
|
|
40
56
|
case 'Z':
|
|
41
57
|
diff_z += diff_phi
|
|
58
|
+
entropy_frac += 1
|
|
42
59
|
case 'Y':
|
|
43
60
|
diff_z += diff_theta + diff_phi
|
|
61
|
+
entropy_frac += 1
|
|
44
62
|
case _:
|
|
45
63
|
pass
|
|
46
64
|
|
|
65
|
+
entropy_frac /= n_qubits
|
|
66
|
+
diff_z = ((1 - entropy_frac) / n_qubits) * diff_z + entropy_frac * max_entropy
|
|
67
|
+
|
|
47
68
|
# Normalize:
|
|
48
69
|
diff_z /= diff_z.sum()
|
|
49
70
|
|
|
@@ -7,7 +7,7 @@ with open(README_PATH) as readme_file:
|
|
|
7
7
|
|
|
8
8
|
setup(
|
|
9
9
|
name='pyqrackising',
|
|
10
|
-
version='9.5.
|
|
10
|
+
version='9.5.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
|
|
File without changes
|
|
File without changes
|