PyQrackIsing 9.2.1__tar.gz → 9.2.3__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 (27) hide show
  1. {pyqrackising-9.2.1/pyqrackising.egg-info → pyqrackising-9.2.3}/PKG-INFO +1 -1
  2. {pyqrackising-9.2.1 → pyqrackising-9.2.3}/pyproject.toml +1 -1
  3. {pyqrackising-9.2.1 → pyqrackising-9.2.3}/pyqrackising/spin_glass_solver.py +18 -9
  4. {pyqrackising-9.2.1 → pyqrackising-9.2.3}/pyqrackising/spin_glass_solver_sparse.py +18 -9
  5. {pyqrackising-9.2.1 → pyqrackising-9.2.3}/pyqrackising/spin_glass_solver_streaming.py +18 -9
  6. {pyqrackising-9.2.1 → pyqrackising-9.2.3/pyqrackising.egg-info}/PKG-INFO +1 -1
  7. {pyqrackising-9.2.1 → pyqrackising-9.2.3}/setup.py +1 -1
  8. {pyqrackising-9.2.1 → pyqrackising-9.2.3}/LICENSE.md +0 -0
  9. {pyqrackising-9.2.1 → pyqrackising-9.2.3}/MANIFEST.in +0 -0
  10. {pyqrackising-9.2.1 → pyqrackising-9.2.3}/README.md +0 -0
  11. {pyqrackising-9.2.1 → pyqrackising-9.2.3}/pyqrackising/__init__.py +0 -0
  12. {pyqrackising-9.2.1 → pyqrackising-9.2.3}/pyqrackising/convert_tensor_network_to_tsp.py +0 -0
  13. {pyqrackising-9.2.1 → pyqrackising-9.2.3}/pyqrackising/generate_tfim_samples.py +0 -0
  14. {pyqrackising-9.2.1 → pyqrackising-9.2.3}/pyqrackising/kernels.cl +0 -0
  15. {pyqrackising-9.2.1 → pyqrackising-9.2.3}/pyqrackising/maxcut_tfim.py +0 -0
  16. {pyqrackising-9.2.1 → pyqrackising-9.2.3}/pyqrackising/maxcut_tfim_sparse.py +0 -0
  17. {pyqrackising-9.2.1 → pyqrackising-9.2.3}/pyqrackising/maxcut_tfim_streaming.py +0 -0
  18. {pyqrackising-9.2.1 → pyqrackising-9.2.3}/pyqrackising/maxcut_tfim_util.py +0 -0
  19. {pyqrackising-9.2.1 → pyqrackising-9.2.3}/pyqrackising/tfim_magnetization.py +0 -0
  20. {pyqrackising-9.2.1 → pyqrackising-9.2.3}/pyqrackising/tfim_square_magnetization.py +0 -0
  21. {pyqrackising-9.2.1 → pyqrackising-9.2.3}/pyqrackising/tsp.py +0 -0
  22. {pyqrackising-9.2.1 → pyqrackising-9.2.3}/pyqrackising/tsp_maxcut.py +0 -0
  23. {pyqrackising-9.2.1 → pyqrackising-9.2.3}/pyqrackising.egg-info/SOURCES.txt +0 -0
  24. {pyqrackising-9.2.1 → pyqrackising-9.2.3}/pyqrackising.egg-info/dependency_links.txt +0 -0
  25. {pyqrackising-9.2.1 → pyqrackising-9.2.3}/pyqrackising.egg-info/not-zip-safe +0 -0
  26. {pyqrackising-9.2.1 → pyqrackising-9.2.3}/pyqrackising.egg-info/top_level.txt +0 -0
  27. {pyqrackising-9.2.1 → pyqrackising-9.2.3}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyqrackising
3
- Version: 9.2.1
3
+ Version: 9.2.3
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
@@ -10,7 +10,7 @@ build-backend = "setuptools.build_meta"
10
10
 
11
11
  [project]
12
12
  name = "pyqrackising"
13
- version = "9.2.1"
13
+ version = "9.2.3"
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"}
@@ -140,32 +140,41 @@ def pick_gray_seeds(best_theta, thread_count, gray_seed_multiple, G_m, n, is_spi
140
140
  return best_seeds, best_energies
141
141
 
142
142
  @njit(parallel=True)
143
- def run_gray_optimization(best_theta, iterators, gray_iterations, thread_count, is_spin_glass, G_m):
143
+ def run_gray_optimization(best_theta, iterators, energies, gray_iterations, thread_count, is_spin_glass, G_m):
144
144
  n = len(best_theta)
145
145
  thread_iterations = (gray_iterations + thread_count - 1) // thread_count
146
146
  blocks = (n + 63) // 64
147
147
 
148
148
  states = np.empty((thread_count, n), dtype=np.bool_)
149
- energies = np.full(thread_count, np.finfo(dtype).min, dtype=dtype)
150
149
 
151
150
  if is_spin_glass:
152
151
  for i in prange(thread_count):
153
- iterator = iterators[i]
152
+ iterator = iterators[i].copy()
153
+ best_energy, best_iterator = energies[i], iterator.copy()
154
154
  for curr_idx in range(thread_iterations):
155
155
  for block in range(blocks):
156
156
  gray_code_next(iterator, curr_idx, block * 64)
157
157
  energy = compute_energy(iterator, G_m, n)
158
- if energy > energies[i]:
159
- states[i], energies[i] = iterator.copy(), energy
158
+ if energy > best_energy:
159
+ best_iterator, best_energy = iterator.copy(), energy
160
+ else:
161
+ iterator = best_iterator.copy()
162
+ if best_energy > energies[i]:
163
+ states[i], energies[i] = best_iterator.copy(), best_energy
160
164
  else:
161
165
  for i in prange(thread_count):
162
- iterator = iterators[i]
166
+ iterator = iterators[i].copy()
167
+ best_energy, best_iterator = energies[i], iterator.copy()
163
168
  for curr_idx in range(thread_iterations):
164
169
  for block in range(blocks):
165
170
  gray_code_next(iterator, curr_idx, block * 64)
166
171
  energy = compute_cut(iterator, G_m, n)
167
- if energy > energies[i]:
168
- states[i], energies[i] = iterator.copy(), energy
172
+ if energy > best_energy:
173
+ best_iterator, best_energy = iterator.copy(), energy
174
+ else:
175
+ iterator = best_iterator.copy()
176
+ if best_energy > energies[i]:
177
+ states[i], energies[i] = best_iterator.copy(), best_energy
169
178
 
170
179
  best_index = np.argmax(energies)
171
180
  best_energy = energies[best_index]
@@ -362,7 +371,7 @@ def spin_glass_solver(
362
371
  improved = True
363
372
  continue
364
373
 
365
- energy, state = run_gray_optimization(best_theta, iterators, gray_iterations, thread_count, is_spin_glass, G_m)
374
+ energy, state = run_gray_optimization(best_theta, iterators, energies, gray_iterations, thread_count, is_spin_glass, G_m)
366
375
  if energy > max_energy:
367
376
  max_energy = energy
368
377
  best_theta = state
@@ -140,32 +140,41 @@ def pick_gray_seeds(best_theta, thread_count, gray_seed_multiple, G_data, G_rows
140
140
  return best_seeds, best_energies
141
141
 
142
142
  @njit(parallel=True)
143
- def run_gray_optimization(best_theta, iterators, gray_iterations, thread_count, is_spin_glass, G_data, G_rows, G_cols):
143
+ def run_gray_optimization(best_theta, iterators, energies, gray_iterations, thread_count, is_spin_glass, G_data, G_rows, G_cols):
144
144
  n = len(best_theta)
145
145
  thread_iterations = (gray_iterations + thread_count - 1) // thread_count
146
146
  blocks = (n + 63) // 64
147
147
 
148
148
  states = np.empty((thread_count, n), dtype=np.bool_)
149
- energies = np.full(thread_count, np.finfo(dtype).min, dtype=dtype)
150
149
 
151
150
  if is_spin_glass:
152
151
  for i in prange(thread_count):
153
- iterator = iterators[i]
152
+ iterator = iterators[i].copy()
153
+ best_energy, best_iterator = energies[i], iterator.copy()
154
154
  for curr_idx in range(thread_iterations):
155
155
  for block in range(blocks):
156
156
  gray_code_next(iterator, curr_idx, block * 64)
157
157
  energy = compute_energy_sparse(iterator, G_data, G_rows, G_cols, n)
158
- if energy > energies[i]:
159
- states[i], energies[i] = iterator.copy(), energy
158
+ if energy > best_energy:
159
+ best_iterator, best_energy = iterator.copy(), energy
160
+ else:
161
+ iterator = best_iterator.copy()
162
+ if best_energy > energies[i]:
163
+ states[i], energies[i] = best_iterator.copy(), best_energy
160
164
  else:
161
165
  for i in prange(thread_count):
162
- iterator = iterators[i]
166
+ iterator = iterators[i].copy()
167
+ best_energy, best_iterator = energies[i], iterator.copy()
163
168
  for curr_idx in range(thread_iterations):
164
169
  for block in range(blocks):
165
170
  gray_code_next(iterator, curr_idx, block * 64)
166
171
  energy = compute_cut_sparse(iterator, G_data, G_rows, G_cols, n)
167
- if energy > energies[i]:
168
- states[i], energies[i] = iterator.copy(), energy
172
+ if energy > best_energy:
173
+ best_iterator, best_energy = iterator.copy(), energy
174
+ else:
175
+ iterator = best_iterator.copy()
176
+ if best_energy > energies[i]:
177
+ states[i], energies[i] = best_iterator.copy(), best_energy
169
178
 
170
179
  best_index = np.argmax(energies)
171
180
  best_energy = energies[best_index]
@@ -366,7 +375,7 @@ def spin_glass_solver_sparse(
366
375
  improved = True
367
376
  continue
368
377
 
369
- energy, state = run_gray_optimization(best_theta, iterators, gray_iterations, thread_count, is_spin_glass, G_m.data, G_m.indptr, G_m.indices)
378
+ energy, state = run_gray_optimization(best_theta, iterators, energies, gray_iterations, thread_count, is_spin_glass, G_m.data, G_m.indptr, G_m.indices)
370
379
  if energy > max_energy:
371
380
  max_energy = energy
372
381
  best_theta = state
@@ -132,32 +132,41 @@ def pick_gray_seeds(best_theta, thread_count, gray_seed_multiple, G_func, nodes,
132
132
  return best_seeds, best_energies
133
133
 
134
134
  @njit(parallel=True)
135
- def run_gray_optimization(best_theta, iterators, gray_iterations, thread_count, is_spin_glass, G_func, nodes):
135
+ def run_gray_optimization(best_theta, iterators, energies, gray_iterations, thread_count, is_spin_glass, G_func, nodes):
136
136
  n = len(best_theta)
137
137
  thread_iterations = (gray_iterations + thread_count - 1) // thread_count
138
138
  blocks = (n + 63) // 64
139
139
 
140
140
  states = np.empty((thread_count, n), dtype=np.bool_)
141
- energies = np.full(thread_count, np.finfo(dtype).min, dtype=dtype)
142
141
 
143
142
  if is_spin_glass:
144
143
  for i in prange(thread_count):
145
- iterator = iterators[i]
144
+ iterator = iterators[i].copy()
145
+ best_energy, best_iterator = energies[i], iterator.copy()
146
146
  for curr_idx in range(thread_iterations):
147
147
  for block in range(blocks):
148
148
  gray_code_next(iterator, curr_idx, block * 64)
149
149
  energy = compute_energy_streaming(iterator, G_func, nodes, n)
150
- if energy > energies[i]:
151
- states[i], energies[i] = iterator.copy(), energy
150
+ if energy > best_energy:
151
+ best_iterator, best_energy = iterator.copy(), energy
152
+ else:
153
+ iterator = best_iterator.copy()
154
+ if best_energy > energies[i]:
155
+ states[i], energies[i] = best_iterator.copy(), best_energy
152
156
  else:
153
157
  for i in prange(thread_count):
154
- iterator = iterators[i]
158
+ iterator = iterators[i].copy()
159
+ best_energy, best_iterator = energies[i], iterator.copy()
155
160
  for curr_idx in range(thread_iterations):
156
161
  for block in range(blocks):
157
162
  gray_code_next(iterator, curr_idx, block * 64)
158
163
  energy = compute_cut_streaming(iterator, G_func, nodes, n)
159
- if energy > energies[i]:
160
- states[i], energies[i] = iterator.copy(), energy
164
+ if energy > best_energy:
165
+ best_iterator, best_energy = iterator.copy(), energy
166
+ else:
167
+ iterator = best_iterator.copy()
168
+ if best_energy > energies[i]:
169
+ states[i], energies[i] = best_iterator.copy(), best_energy
161
170
 
162
171
  best_index = np.argmax(energies)
163
172
  best_energy = energies[best_index]
@@ -247,7 +256,7 @@ def spin_glass_solver_streaming(
247
256
  improved = True
248
257
  continue
249
258
 
250
- energy, state = run_gray_optimization(best_theta, iterators, gray_iterations, thread_count, is_spin_glass, G_func, nodes)
259
+ energy, state = run_gray_optimization(best_theta, iterators, energies, gray_iterations, thread_count, is_spin_glass, G_func, nodes)
251
260
  if energy > max_energy:
252
261
  max_energy = energy
253
262
  best_theta = state
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyqrackising
3
- Version: 9.2.1
3
+ Version: 9.2.3
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
@@ -7,7 +7,7 @@ with open(README_PATH) as readme_file:
7
7
 
8
8
  setup(
9
9
  name='pyqrackising',
10
- version='9.2.1',
10
+ version='9.2.3',
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