PyQrackIsing 7.4.10__tar.gz → 7.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.
Files changed (30) hide show
  1. {pyqrackising-7.4.10/pyqrackising.egg-info → pyqrackising-7.5.1}/PKG-INFO +1 -1
  2. {pyqrackising-7.4.10 → pyqrackising-7.5.1}/pyproject.toml +1 -1
  3. {pyqrackising-7.4.10 → pyqrackising-7.5.1}/pyqrackising/maxcut_tfim.py +24 -13
  4. {pyqrackising-7.4.10 → pyqrackising-7.5.1}/pyqrackising/maxcut_tfim_sparse.py +26 -13
  5. {pyqrackising-7.4.10 → pyqrackising-7.5.1}/pyqrackising/maxcut_tfim_streaming.py +25 -13
  6. {pyqrackising-7.4.10 → pyqrackising-7.5.1/pyqrackising.egg-info}/PKG-INFO +1 -1
  7. {pyqrackising-7.4.10 → pyqrackising-7.5.1}/setup.py +1 -1
  8. {pyqrackising-7.4.10 → pyqrackising-7.5.1}/CMakeLists.txt +0 -0
  9. {pyqrackising-7.4.10 → pyqrackising-7.5.1}/LICENSE.md +0 -0
  10. {pyqrackising-7.4.10 → pyqrackising-7.5.1}/MANIFEST.in +0 -0
  11. {pyqrackising-7.4.10 → pyqrackising-7.5.1}/README.md +0 -0
  12. {pyqrackising-7.4.10 → pyqrackising-7.5.1}/pyqrackising/__init__.py +0 -0
  13. {pyqrackising-7.4.10 → pyqrackising-7.5.1}/pyqrackising/_pyqrack_ising.cpp +0 -0
  14. {pyqrackising-7.4.10 → pyqrackising-7.5.1}/pyqrackising/convert_tensor_network_to_tsp.py +0 -0
  15. {pyqrackising-7.4.10 → pyqrackising-7.5.1}/pyqrackising/generate_tfim_samples.py +0 -0
  16. {pyqrackising-7.4.10 → pyqrackising-7.5.1}/pyqrackising/kernels.cl +0 -0
  17. {pyqrackising-7.4.10 → pyqrackising-7.5.1}/pyqrackising/maxcut_tfim_util.py +0 -0
  18. {pyqrackising-7.4.10 → pyqrackising-7.5.1}/pyqrackising/spin_glass_solver.py +0 -0
  19. {pyqrackising-7.4.10 → pyqrackising-7.5.1}/pyqrackising/spin_glass_solver_sparse.py +0 -0
  20. {pyqrackising-7.4.10 → pyqrackising-7.5.1}/pyqrackising/spin_glass_solver_streaming.py +0 -0
  21. {pyqrackising-7.4.10 → pyqrackising-7.5.1}/pyqrackising/spin_glass_solver_util.py +0 -0
  22. {pyqrackising-7.4.10 → pyqrackising-7.5.1}/pyqrackising/tfim_magnetization.py +0 -0
  23. {pyqrackising-7.4.10 → pyqrackising-7.5.1}/pyqrackising/tfim_square_magnetization.py +0 -0
  24. {pyqrackising-7.4.10 → pyqrackising-7.5.1}/pyqrackising/tsp.py +0 -0
  25. {pyqrackising-7.4.10 → pyqrackising-7.5.1}/pyqrackising/tsp_maxcut.py +0 -0
  26. {pyqrackising-7.4.10 → pyqrackising-7.5.1}/pyqrackising.egg-info/SOURCES.txt +0 -0
  27. {pyqrackising-7.4.10 → pyqrackising-7.5.1}/pyqrackising.egg-info/dependency_links.txt +0 -0
  28. {pyqrackising-7.4.10 → pyqrackising-7.5.1}/pyqrackising.egg-info/not-zip-safe +0 -0
  29. {pyqrackising-7.4.10 → pyqrackising-7.5.1}/pyqrackising.egg-info/top_level.txt +0 -0
  30. {pyqrackising-7.4.10 → pyqrackising-7.5.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyqrackising
3
- Version: 7.4.10
3
+ Version: 7.5.1
4
4
  Summary: Fast MAXCUT, TSP, and sampling heuristics from near-ideal transverse field Ising model (TFIM)
5
5
  Home-page: https://github.com/vm6502q/PyQrackIsing
6
6
  Author: Dan Strano
@@ -12,7 +12,7 @@ build-backend = "setuptools.build_meta"
12
12
 
13
13
  [project]
14
14
  name = "pyqrackising"
15
- version = "7.4.10"
15
+ version = "7.5.1"
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
- for s in prange(shots):
95
- # First dimension: Hamming weight
96
- mag_prob = np.random.random()
97
- m = 0
98
- while thresholds[m] < mag_prob:
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
- # Second dimension: permutation within Hamming weight
103
- sample = local_repulsion_choice(G_m, max_weight, weights, n, m, s)
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)
104
113
 
105
- solutions[s] = sample
106
- energies[s] = compute_energy(sample, G_m, n)
107
-
108
- best_solution = solutions[np.argmin(energies)]
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):
@@ -282,7 +293,7 @@ def maxcut_tfim(
282
293
  is_alt_gpu_sampling = False
283
294
 
284
295
  if quality is None:
285
- quality = 3
296
+ quality = 2
286
297
 
287
298
  if shots is None:
288
299
  # Number of measurement shots
@@ -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
- energy += G_data[col] * (1 if sample[u] == sample[v] else -1)
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
- for s in prange(shots):
107
- # First dimension: Hamming weight
108
- mag_prob = np.random.random()
109
- m = 0
110
- while thresholds[m] < mag_prob:
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
- # Second dimension: permutation within Hamming weight
115
- sample = local_repulsion_choice(G_cols, G_data, G_rows, max_weight, weights, n, m, s)
116
- solutions[s] = sample
117
- energies[s] = compute_energy(sample, G_data, G_rows, G_cols)
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)
118
126
 
119
- best_solution = solutions[np.argmin(energies)]
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):
@@ -315,7 +328,7 @@ def maxcut_tfim_sparse(
315
328
  is_alt_gpu_sampling = False
316
329
 
317
330
  if quality is None:
318
- quality = 3
331
+ quality = 2
319
332
 
320
333
  if shots is None:
321
334
  # Number of measurement shots
@@ -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
- for s in prange(shots):
96
- # First dimension: Hamming weight
97
- mag_prob = np.random.random()
98
- m = 0
99
- while thresholds[m] < mag_prob:
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
110
 
106
- solutions[s] = sample
107
- energies[s] = compute_energy(sample, G_func, nodes, n)
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)
108
115
 
109
- best_solution = solutions[np.argmin(energies)]
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):
@@ -199,7 +211,7 @@ def maxcut_tfim_streaming(
199
211
  return "01", weight, ([nodes[0]], [nodes[1]])
200
212
 
201
213
  if quality is None:
202
- quality = 3
214
+ quality = 2
203
215
 
204
216
  if shots is None:
205
217
  # Number of measurement shots
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyqrackising
3
- Version: 7.4.10
3
+ Version: 7.5.1
4
4
  Summary: Fast MAXCUT, TSP, and sampling heuristics from near-ideal transverse field Ising model (TFIM)
5
5
  Home-page: https://github.com/vm6502q/PyQrackIsing
6
6
  Author: Dan Strano
@@ -51,7 +51,7 @@ ext_modules = [CMakeExtension('tfim_sampler')]
51
51
 
52
52
  setup(
53
53
  name='pyqrackising',
54
- version='7.4.10',
54
+ version='7.5.1',
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