Skip to content

Commit

Permalink
Encountered rare bug whereby multiprocessing queue gets out of order …
Browse files Browse the repository at this point in the history
…and so noncon energies not matched up with correct eigenvalue assignments - fixed by returning nu alongside e_nu in get_noncon_energy
  • Loading branch information
TimWeaving committed Apr 22, 2024
1 parent 852b2e0 commit 751d6fe
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions symmer/operators/noncontextual_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
return noncon_H.get_energy(nu), nu

0 comments on commit 751d6fe

Please sign in to comment.