-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_environment.py
More file actions
31 lines (24 loc) · 994 Bytes
/
test_environment.py
File metadata and controls
31 lines (24 loc) · 994 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from environment import QubitEnv
from plot_utils import render_episode
# Experiment 1: Initialize in excited state and do nothing
dt = 0.01
length_episode = 3 # in units of natural lifetime
env = QubitEnv(initial_state=[1, 0, 0], target_state=[1, 0, 0], dt=dt)
state = env.reset()
states_epsiode = []
for _ in range(int(length_episode/dt)):
action = [0, 0, 0] # Do nothing
state, reward, done, _ = env.step(action) # Apply the action
states_epsiode.append(state)
render_episode(states_epsiode, delay=0.001)
# Experiment 2: Initialize in ground state and apply resonant field
dt = 0.01
length_episode = 3 # in units of natural lifetime
env = QubitEnv(initial_state=[0, 0, 0], target_state=[1, 0, 0], dt=dt)
state = env.reset()
states_epsiode = []
for _ in range(int(length_episode/dt)):
action = [10, 0, 0] # Resonant field
state, reward, done, _ = env.step(action) # Apply the action
states_epsiode.append(state)
render_episode(states_epsiode, delay=0.001)