From 751d6fe95a711cb1818d54181b7953c8a65a55ad Mon Sep 17 00:00:00 2001 From: TimWeaving Date: Mon, 22 Apr 2024 10:19:16 +0100 Subject: [PATCH] Encountered rare bug whereby multiprocessing queue gets out of order and so noncon energies not matched up with correct eigenvalue assignments - fixed by returning nu alongside e_nu in get_noncon_energy --- symmer/operators/noncontextual_op.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/symmer/operators/noncontextual_op.py b/symmer/operators/noncontextual_op.py index c49fc278..4463449c 100644 --- a/symmer/operators/noncontextual_op.py +++ b/symmer/operators/noncontextual_op.py @@ -698,8 +698,7 @@ def energy_via_brute_force(self) -> Tuple[float, np.array, np.array]: nu_list[:,~self.fixed_ev_mask] = np.array(list(itertools.product([-1,1],repeat=np.sum(~self.fixed_ev_mask)))) # # optimize over all discrete value assignments of nu in parallel - tracker = get_noncon_energy(nu_list, self.NC_op) - full_search_results = zip(tracker, nu_list) + full_search_results = get_noncon_energy(nu_list, self.NC_op) energy, fixed_nu = min(full_search_results, key=lambda x:x[0]) return energy, fixed_nu @@ -736,4 +735,4 @@ def get_noncon_energy(nu: np.array, noncon_H:NoncontextualOp) -> float: """ The classical objective function that encodes the noncontextual energies. """ - return noncon_H.get_energy(nu) \ No newline at end of file + return noncon_H.get_energy(nu), nu \ No newline at end of file