Skip to content

Commit c340f34

Browse files
Welcome to a brave new world of bugs
1 parent 9dfbba8 commit c340f34

3 files changed

Lines changed: 18 additions & 14 deletions

File tree

pyqrackising/solve_maxcut_exact.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,10 +329,12 @@ def solve_maxcut_exact(
329329
print(f"Heuristic value: {cut_value:.6f} ({time.monotonic()-t0:.3f}s)")
330330

331331
best_theta = np.array([b == "1" for b in list(bitstring)], dtype=np.bool_)
332-
max_energy = (
333-
compute_energy(best_theta, G_m, n_qubits) if is_spin_glass
334-
else compute_cut(best_theta, G_m, n_qubits)
335-
)
332+
if is_spin_glass:
333+
max_energy = compute_energy(best_theta, G_m, n_qubits)
334+
elif cut_value is None:
335+
max_energy = compute_cut(best_theta, G_m, n_qubits)
336+
else:
337+
max_energy = cut_value
336338

337339
if verbose:
338340
print("Starting branch and bound...")

pyqrackising/solve_maxcut_exact_sparse.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -374,11 +374,12 @@ def solve_maxcut_exact_sparse(
374374
print(f"Heuristic value: {cut_value:.6f} ({time.monotonic()-t0:.3f}s)")
375375

376376
best_theta = np.array([b == "1" for b in list(bitstring)], dtype=np.bool_)
377-
max_energy = (
378-
compute_energy_sparse(best_theta, G_data, G_rows, G_cols, n_qubits)
379-
if is_spin_glass
380-
else compute_cut_sparse(best_theta, G_data, G_rows, G_cols, n_qubits)
381-
)
377+
if is_spin_glass:
378+
max_energy = compute_energy(best_theta, G_m, n_qubits)
379+
elif cut_value is None:
380+
max_energy = compute_cut(best_theta, G_m, n_qubits)
381+
else:
382+
max_energy = cut_value
382383

383384
if verbose:
384385
print("Starting branch and bound...")

pyqrackising/solve_maxcut_exact_streaming.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -330,11 +330,12 @@ def solve_maxcut_exact_streaming(
330330
print(f"Heuristic value: {cut_value:.6f} ({time.monotonic()-t0:.3f}s)")
331331

332332
best_theta = np.array([b == "1" for b in list(bitstring)], dtype=np.bool_)
333-
max_energy = (
334-
compute_energy_streaming(best_theta, G_func, nodes, n_qubits)
335-
if is_spin_glass
336-
else compute_cut_streaming(best_theta, G_func, nodes, n_qubits)
337-
)
333+
if is_spin_glass:
334+
max_energy = compute_energy(best_theta, G_m, n_qubits)
335+
elif cut_value is None:
336+
max_energy = compute_cut(best_theta, G_m, n_qubits)
337+
else:
338+
max_energy = cut_value
338339

339340
if verbose:
340341
print("Starting branch and bound...")

0 commit comments

Comments
 (0)