Skip to content

Commit

Permalink
Significant update to NoncontextualOp: the solvers have been moved in…
Browse files Browse the repository at this point in the history
…to a NoncontextualSolver class to tidy things up a bit and added the discrete-then-convex optimizer for xUSO.
  • Loading branch information
TimWeaving committed Feb 22, 2023
1 parent 369f990 commit ce2f6c3
Show file tree
Hide file tree
Showing 2 changed files with 232 additions and 235 deletions.
9 changes: 8 additions & 1 deletion symmer/projection/contextual_subspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def __init__(self,
noncontextual_strategy: str = 'diag',
noncontextual_solver: str = 'brute_force',
num_anneals:Optional[int] = 1000,
discrete_optimization_order = 'first',
unitary_partitioning_method: str = 'LCU',
reference_state: np.array = None,
noncontextual_operator: NoncontextualOp = None,
Expand All @@ -41,6 +42,7 @@ def __init__(self,
self.nc_strategy = extract_noncon_strat[0]
self.noncontextual_solver = noncontextual_solver
self.num_anneals = num_anneals
self.discrete_optimization_order = discrete_optimization_order
if self.nc_strategy=='StabilizeFirst':
self.stabilize_first_method = extract_noncon_strat[1]

Expand All @@ -64,7 +66,12 @@ def _noncontextual_update(self):
self.contextual_operator = self.operator - self.noncontextual_operator
if self.contextual_operator.n_terms == 0:
raise ValueError('The Hamiltonian is noncontextual, the contextual subspace is empty.')
self.noncontextual_operator.solve(strategy=self.noncontextual_solver, ref_state=self.ref_state, num_anneals=self.num_anneals)
self.noncontextual_operator.solve(
strategy=self.noncontextual_solver,
ref_state=self.ref_state,
num_anneals=self.num_anneals,
discrete_optimization_order=self.discrete_optimization_order
)
self.n_cliques = self.noncontextual_operator.n_cliques

def manual_stabilizers(self, S: Union[List[str], IndependentOp]) -> None:
Expand Down
Loading

0 comments on commit ce2f6c3

Please sign in to comment.