PyQrackIsing 7.4.10__tar.gz → 7.5.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-7.4.10/pyqrackising.egg-info → pyqrackising-7.5.0}/PKG-INFO +1 -1
- {pyqrackising-7.4.10 → pyqrackising-7.5.0}/pyproject.toml +1 -1
- {pyqrackising-7.4.10 → pyqrackising-7.5.0}/pyqrackising/maxcut_tfim.py +24 -13
- {pyqrackising-7.4.10 → pyqrackising-7.5.0}/pyqrackising/maxcut_tfim_sparse.py +26 -13
- {pyqrackising-7.4.10 → pyqrackising-7.5.0}/pyqrackising/maxcut_tfim_streaming.py +25 -13
- {pyqrackising-7.4.10 → pyqrackising-7.5.0/pyqrackising.egg-info}/PKG-INFO +1 -1
- {pyqrackising-7.4.10 → pyqrackising-7.5.0}/setup.py +1 -1
- {pyqrackising-7.4.10 → pyqrackising-7.5.0}/CMakeLists.txt +0 -0
- {pyqrackising-7.4.10 → pyqrackising-7.5.0}/LICENSE.md +0 -0
- {pyqrackising-7.4.10 → pyqrackising-7.5.0}/MANIFEST.in +0 -0
- {pyqrackising-7.4.10 → pyqrackising-7.5.0}/README.md +0 -0
- {pyqrackising-7.4.10 → pyqrackising-7.5.0}/pyqrackising/__init__.py +0 -0
- {pyqrackising-7.4.10 → pyqrackising-7.5.0}/pyqrackising/_pyqrack_ising.cpp +0 -0
- {pyqrackising-7.4.10 → pyqrackising-7.5.0}/pyqrackising/convert_tensor_network_to_tsp.py +0 -0
- {pyqrackising-7.4.10 → pyqrackising-7.5.0}/pyqrackising/generate_tfim_samples.py +0 -0
- {pyqrackising-7.4.10 → pyqrackising-7.5.0}/pyqrackising/kernels.cl +0 -0
- {pyqrackising-7.4.10 → pyqrackising-7.5.0}/pyqrackising/maxcut_tfim_util.py +0 -0
- {pyqrackising-7.4.10 → pyqrackising-7.5.0}/pyqrackising/spin_glass_solver.py +0 -0
- {pyqrackising-7.4.10 → pyqrackising-7.5.0}/pyqrackising/spin_glass_solver_sparse.py +0 -0
- {pyqrackising-7.4.10 → pyqrackising-7.5.0}/pyqrackising/spin_glass_solver_streaming.py +0 -0
- {pyqrackising-7.4.10 → pyqrackising-7.5.0}/pyqrackising/spin_glass_solver_util.py +0 -0
- {pyqrackising-7.4.10 → pyqrackising-7.5.0}/pyqrackising/tfim_magnetization.py +0 -0
- {pyqrackising-7.4.10 → pyqrackising-7.5.0}/pyqrackising/tfim_square_magnetization.py +0 -0
- {pyqrackising-7.4.10 → pyqrackising-7.5.0}/pyqrackising/tsp.py +0 -0
- {pyqrackising-7.4.10 → pyqrackising-7.5.0}/pyqrackising/tsp_maxcut.py +0 -0
- {pyqrackising-7.4.10 → pyqrackising-7.5.0}/pyqrackising.egg-info/SOURCES.txt +0 -0
- {pyqrackising-7.4.10 → pyqrackising-7.5.0}/pyqrackising.egg-info/dependency_links.txt +0 -0
- {pyqrackising-7.4.10 → pyqrackising-7.5.0}/pyqrackising.egg-info/not-zip-safe +0 -0
- {pyqrackising-7.4.10 → pyqrackising-7.5.0}/pyqrackising.egg-info/top_level.txt +0 -0
- {pyqrackising-7.4.10 → pyqrackising-7.5.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 = "7.
|
|
15
|
+
version = "7.5.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"}
|
|
@@ -85,27 +85,38 @@ def compute_energy(sample, G_m, n_qubits):
|
|
|
85
85
|
|
|
86
86
|
@njit(parallel=True)
|
|
87
87
|
def sample_for_solution(G_m, shots, thresholds, weights, dtype):
|
|
88
|
+
shots = max(1, shots >> 1)
|
|
88
89
|
n = len(G_m)
|
|
89
90
|
max_weight = G_m.max()
|
|
90
91
|
|
|
91
92
|
solutions = np.empty((shots, n), dtype=np.bool_)
|
|
92
93
|
energies = np.empty(shots, dtype=dtype)
|
|
93
94
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
best_solution = solutions[0]
|
|
96
|
+
best_energy = float("inf")
|
|
97
|
+
|
|
98
|
+
improved = True
|
|
99
|
+
while improved:
|
|
100
|
+
improved = False
|
|
101
|
+
for s in prange(shots):
|
|
102
|
+
# First dimension: Hamming weight
|
|
103
|
+
mag_prob = np.random.random()
|
|
104
|
+
m = 0
|
|
105
|
+
while thresholds[m] < mag_prob:
|
|
106
|
+
m += 1
|
|
99
107
|
m += 1
|
|
100
|
-
m += 1
|
|
101
108
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
+
# Second dimension: permutation within Hamming weight
|
|
110
|
+
sample = local_repulsion_choice(G_m, max_weight, weights, n, m, s)
|
|
111
|
+
solutions[s] = sample
|
|
112
|
+
energies[s] = compute_energy(sample, G_m, n)
|
|
113
|
+
|
|
114
|
+
best_index = np.argmin(energies)
|
|
115
|
+
energy = energies[best_index]
|
|
116
|
+
if energy < best_energy:
|
|
117
|
+
best_energy = energy
|
|
118
|
+
best_solution = solutions[best_index].copy()
|
|
119
|
+
improved = True
|
|
109
120
|
|
|
110
121
|
best_value = 0.0
|
|
111
122
|
for u in range(n):
|
|
@@ -90,33 +90,46 @@ def compute_energy(sample, G_data, G_rows, G_cols):
|
|
|
90
90
|
for u in range(n_qubits):
|
|
91
91
|
for col in range(G_rows[u], G_rows[u + 1]):
|
|
92
92
|
v = G_cols[col]
|
|
93
|
-
|
|
93
|
+
val = G_data[col]
|
|
94
|
+
energy += val if sample[u] == sample[v] else -val
|
|
94
95
|
|
|
95
96
|
return energy
|
|
96
97
|
|
|
97
98
|
|
|
98
99
|
@njit(parallel=True)
|
|
99
100
|
def sample_for_solution(G_data, G_rows, G_cols, shots, thresholds, weights, dtype):
|
|
101
|
+
shots = max(1, shots >> 1)
|
|
100
102
|
n = G_rows.shape[0] - 1
|
|
101
103
|
max_weight = G_data.max()
|
|
102
104
|
|
|
103
105
|
solutions = np.empty((shots, n), dtype=np.bool_)
|
|
104
106
|
energies = np.empty(shots, dtype=dtype)
|
|
105
107
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
108
|
+
best_solution = solutions[0]
|
|
109
|
+
best_energy = float("inf")
|
|
110
|
+
|
|
111
|
+
improved = True
|
|
112
|
+
while improved:
|
|
113
|
+
improved = False
|
|
114
|
+
for s in prange(shots):
|
|
115
|
+
# First dimension: Hamming weight
|
|
116
|
+
mag_prob = np.random.random()
|
|
117
|
+
m = 0
|
|
118
|
+
while thresholds[m] < mag_prob:
|
|
119
|
+
m += 1
|
|
111
120
|
m += 1
|
|
112
|
-
m += 1
|
|
113
121
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
122
|
+
# Second dimension: permutation within Hamming weight
|
|
123
|
+
sample = local_repulsion_choice(G_cols, G_data, G_rows, max_weight, weights, n, m, s)
|
|
124
|
+
solutions[s] = sample
|
|
125
|
+
energies[s] = compute_energy(sample, G_data, G_rows, G_cols)
|
|
126
|
+
|
|
127
|
+
best_index = np.argmin(energies)
|
|
128
|
+
energy = energies[best_index]
|
|
129
|
+
if energy < best_energy:
|
|
130
|
+
best_energy = energy
|
|
131
|
+
best_solution = solutions[best_index].copy()
|
|
132
|
+
improved = True
|
|
120
133
|
|
|
121
134
|
best_value = 0.0
|
|
122
135
|
for u in range(n):
|
|
@@ -89,24 +89,36 @@ def compute_energy(sample, G_func, nodes, n_qubits):
|
|
|
89
89
|
|
|
90
90
|
@njit(parallel=True)
|
|
91
91
|
def sample_for_solution(G_func, nodes, max_weight, shots, thresholds, degrees_sum, weights, n, dtype):
|
|
92
|
+
shots = max(1, shots >> 1)
|
|
93
|
+
|
|
92
94
|
solutions = np.empty((shots, n), dtype=np.bool_)
|
|
93
95
|
energies = np.empty(shots, dtype=dtype)
|
|
94
96
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
best_solution = solutions[0]
|
|
98
|
+
best_energy = float("inf")
|
|
99
|
+
|
|
100
|
+
improved = True
|
|
101
|
+
while improved:
|
|
102
|
+
improved = False
|
|
103
|
+
for s in prange(shots):
|
|
104
|
+
# First dimension: Hamming weight
|
|
105
|
+
mag_prob = np.random.random()
|
|
106
|
+
m = 0
|
|
107
|
+
while thresholds[m] < mag_prob:
|
|
108
|
+
m += 1
|
|
100
109
|
m += 1
|
|
101
|
-
m += 1
|
|
102
|
-
|
|
103
|
-
# Second dimension: permutation within Hamming weight
|
|
104
|
-
sample = local_repulsion_choice(G_func, nodes, max_weight, weights, n, m, s)
|
|
105
|
-
|
|
106
|
-
solutions[s] = sample
|
|
107
|
-
energies[s] = compute_energy(sample, G_func, nodes, n)
|
|
108
110
|
|
|
109
|
-
|
|
111
|
+
# Second dimension: permutation within Hamming weight
|
|
112
|
+
sample = local_repulsion_choice(G_func, nodes, max_weight, weights, n, m, s)
|
|
113
|
+
solutions[s] = sample
|
|
114
|
+
energies[s] = compute_energy(sample, G_func, nodes, n)
|
|
115
|
+
|
|
116
|
+
best_index = np.argmin(energies)
|
|
117
|
+
energy = energies[best_index]
|
|
118
|
+
if energy < best_energy:
|
|
119
|
+
best_energy = energy
|
|
120
|
+
best_solution = solutions[best_index].copy()
|
|
121
|
+
improved = True
|
|
110
122
|
|
|
111
123
|
best_value = 0.0
|
|
112
124
|
for u in range(n):
|
|
@@ -51,7 +51,7 @@ ext_modules = [CMakeExtension('tfim_sampler')]
|
|
|
51
51
|
|
|
52
52
|
setup(
|
|
53
53
|
name='pyqrackising',
|
|
54
|
-
version='7.
|
|
54
|
+
version='7.5.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
|