Skip to content

Commit

Permalink
New environments: DELTA and MAX rewards
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Olle committed May 22, 2024
1 parent d62242c commit d67668d
Show file tree
Hide file tree
Showing 4 changed files with 720 additions and 5 deletions.
32 changes: 28 additions & 4 deletions qdx/code_finder.py
Original file line number Diff line number Diff line change
@@ -1,5 1,7 @@
from qdx.envs.code_discovery import CodeDiscovery
from qdx.envs.meta_code_discovery import MetaCodeDiscovery
from qdx.envs.delta_code_discovery import DeltaCodeDiscovery
from qdx.envs.max_code_discovery import MaxCodeDiscovery
from qdx.simulators.clifford_gates import CliffordGates
import os
import jax
Expand Down Expand Up @@ -60,7 62,7 @@ def make_environment(self):
## For some reason this throws out the error: "'gates' is not defined"
#gate_set = [eval("gates.%s" % g) for g in self.config["WHICH_GATES"]]

if not self.config["NOISE_AWARE"]:
if self.config["ENV_TYPE"] == "STANDARD":
self.env = CodeDiscovery(self.config["N"],
self.config["K"],
self.config["D"],
Expand All @@ -71,7 73,7 @@ def make_environment(self):
pI = self.config["P_I"],
softness = self.config["SOFTNESS"])

elif self.config["NOISE_AWARE"]:
elif self.config["ENV_TYPE"] == "NOISE-AWARE":
self.env = MetaCodeDiscovery(self.config["N"],
self.config["K"],
self.config["D"],
Expand All @@ -81,6 83,28 @@ def make_environment(self):
lbda = self.config["LAMBDA"],
pI = self.config["P_I"],
softness = self.config["SOFTNESS"])

elif self.config["ENV_TYPE"] == "DELTA":
self.env = DeltaCodeDiscovery(self.config["N"],
self.config["K"],
self.config["D"],
gate_set,
graph = self.graph,
max_steps = self.config["MAX_STEPS"],
lbda = self.config["LAMBDA"],
pI = self.config["P_I"],
softness = self.config["SOFTNESS"])

elif self.config["ENV_TYPE"] == "MAX":
self.env = MaxCodeDiscovery(self.config["N"],
self.config["K"],
self.config["D"],
gate_set,
graph = self.graph,
max_steps = self.config["MAX_STEPS"],
lbda = self.config["LAMBDA"],
pI = self.config["P_I"],
softness = self.config["SOFTNESS"])

return

Expand Down Expand Up @@ -111,7 135,7 @@ def train(self):

def evaluate(self):

if not self.config["NOISE_AWARE"]:
if self.config["ENV_TYPE"] != "NOISE-AWARE":

data = []

Expand Down Expand Up @@ -160,7 184,7 @@ def evaluate(self):

data.append({'n': self.config["N"], 'k': self.config["K"], 'd': code_distance, 'gates': gates})

elif self.config["NOISE_AWARE"]:
elif self.config["ENV_TYPE"] == "NOISE-AWARE":

data = self.evaluate_noise_aware()

Expand Down
4 changes: 3 additions & 1 deletion qdx/envs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 1,4 @@
from qdx.envs.code_discovery import CodeDiscovery
from qdx.envs.meta_code_discovery import MetaCodeDiscovery
from qdx.envs.meta_code_discovery import MetaCodeDiscovery
from qdx.envs.delta_code_discovery import DeltaCodeDiscovery
from qdx.envs.max_code_discovery import MaxCodeDiscovery
Loading

0 comments on commit d67668d

Please sign in to comment.