chemistrylab.lab package
- class chemistrylab.lab.shelf.Shelf(vessels, n_working=1)[source]
Bases:
object
The shelf class holds vessels from experiments.
pop, __getitem__, __delitem__, and append are implemented so shelves can be used similar to a list of vessels
- get_working_vessels()[source]
Returns a tuple of the ‘working’ vessels used for observations and rewards.
- load_vessel(path: str)[source]
TODO: Implement this Args: - path (str): the path to the vessel that is to be loaded
- class chemistrylab.lab.shelf.VariableShelf(variable_vessels: list, fixed_vessels: list, n_working=1)[source]
Bases:
Shelf
Shelf which is given a set of fixed and variable vessels. On reset the original vessels are deepcopied into new vessel objects
- class chemistrylab.lab.manager.Manager(config_filename: str)[source]
Bases:
Env
- build_actions(actions: Tuple[ManagerAction])[source]
Construct the list of actions (different for each bench)
- Parameters:
actions (Tuple[ManagerAction]) – A list of actions the bench can perform
- characterize(observation_list)[source]
Provide an observation of the vessel in the manager’s hand using a characterization bench
- Parameters:
observation_list (Tuple[str]) – A list of observations to make about the vessel
- create_vessel(label='')[source]
Creates an empty vessel and places it in the manager’s hand (as long as the hand is empty)
- Parameters:
label (str) – A name for the vessel
- encode_bench()[source]
- Returns:
A vector containing a one-hot encoding of which bench is selected, as well as some information about the contents of the benches shelf.
- Return type:
np.ndarray
- end_experiment()[source]
After calling this, the next call to step() will result in a terminal state.
- get_observation()[source]
Creates an observation of the manager’s state
TODO: Give info about the manager’s shelf
- Returns:
The observation
- Return type:
np.ndarray
- insert_vessel(bench_idx, vessel_idx)[source]
Inserts the vessel in the manager’s hand into the benches shelf
- reset(*args, seed=None, options=None)[source]
Resets the environment to an initial internal state, returning an initial observation and info.
This method generates a new starting state often with some randomness to ensure that the agent explores the state space and learns a generalised policy about the environment. This randomness can be controlled with the
seed
parameter otherwise if the environment already has a random number generator andreset()
is called withseed=None
, the RNG is not reset.Therefore,
reset()
should (in the typical use case) be called with a seed right after initialization and then never again.For Custom environments, the first line of
reset()
should besuper().reset(seed=seed)
which implements the seeding correctly.Changed in version v0.25: The
return_info
parameter was removed and now info is expected to be returned.- Parameters:
seed (optional int) – The seed that is used to initialize the environment’s PRNG (np_random). If the environment does not already have a PRNG and
seed=None
(the default option) is passed, a seed will be chosen from some source of entropy (e.g. timestamp or /dev/urandom). However, if the environment already has a PRNG andseed=None
is passed, the PRNG will not be reset. If you pass an integer, the PRNG will be reset even if it already exists. Usually, you want to pass an integer right after the environment has been initialized and then never again. Please refer to the minimal example above to see this paradigm in action.options (optional dict) – Additional information to specify how the environment is reset (optional, depending on the specific environment)
- Returns:
- Observation of the initial state. This will be an element of
observation_space
(typically a numpy array) and is analogous to the observation returned by
step()
.- info (dictionary): This dictionary contains auxiliary information complementing
observation
. It should be analogous to the
info
returned bystep()
.
- Observation of the initial state. This will be an element of
- Return type:
observation (ObsType)
- reset_with_target(target: str)[source]
Resets the bench with a specific target material.
- Parameters:
target (str) – The target material
- restock_bench(bench_idx)[source]
Restocks the shelf of a specified bench.
NOTE: I may modify this later
- run_bench(bench_idx, policy_idx)[source]
Wraps use_bench
- Parameters:
bench_idx (GenBench) – The index of the bench to run
policy_idx (Policy) – The index of the policy to use for the bench
- set_cur_bench(idx)[source]
Sets the bench the manager is currently focused on.
- Parameters:
idx (int) – The bench index
- set_target(target)[source]
Sets the manager’s target material
- Parameters:
target (str) – The smiles code of the target material
- setup(benches: Tuple[GenBench], bench_names: Tuple[str], bench_agents: Tuple, targets: Tuple[str], actions: list = [])[source]
- Parameters:
benches (Tuple[GenBench]) – The benches available to this manager
bench_names (Tuple[str]) – A name for each bench.
bench_agents (Tuple) – A Tuple of (name, Policy) pairs.
targets (Tuple[str]) – A list of targets yo give to benches.
actions (Tuple[ManagerAction]) – A list of actions the bench can perform
- step(action: int)[source]
Run one timestep of the environment’s dynamics using the agent actions.
When the end of an episode is reached (
terminated or truncated
), it is necessary to callreset()
to reset this environment’s state for the next episode.Changed in version 0.26: The Step API was changed removing
done
in favor ofterminated
andtruncated
to make it clearer to users when the environment had terminated or truncated which is critical for reinforcement learning bootstrapping algorithms.- Parameters:
action (ActType) – an action provided by the agent to update the environment state.
- Returns:
- An element of the environment’s
observation_space
as the next observation due to the agent actions. An example is a numpy array containing the positions and velocities of the pole in CartPole.
reward (SupportsFloat): The reward as a result of taking the action. terminated (bool): Whether the agent reaches the terminal state (as defined under the MDP of the task)
which can be positive or negative. An example is reaching the goal state or moving into the lava from the Sutton and Barton, Gridworld. If true, the user needs to call
reset()
.- truncated (bool): Whether the truncation condition outside the scope of the MDP is satisfied.
Typically, this is a timelimit, but could also be used to indicate an agent physically going out of bounds. Can be used to end the episode prematurely before a terminal state is reached. If true, the user needs to call
reset()
.- info (dict): Contains auxiliary diagnostic information (helpful for debugging, learning, and logging).
This might, for instance, contain: metrics that describe the agent’s performance state, variables that are hidden from observations, or individual reward terms that are combined to produce the total reward. In OpenAI Gym <v26, it contains “TimeLimit.truncated” to distinguish truncation and termination, however this is deprecated in favour of returning terminated and truncated variables.
- done (bool): (Deprecated) A boolean value for if the episode has ended, in which case further
step()
calls will return undefined results. This was removed in OpenAI Gym v26 in favor of terminated and truncated attributes. A done signal may be emitted for different reasons: Maybe the task underlying the environment was solved successfully, a certain timelimit was exceeded, or the physics simulation has entered an invalid state.
- An element of the environment’s
- Return type:
observation (ObsType)
- class chemistrylab.lab.manager.ManagerAction(name, args, cost, bench)[source]
Bases:
NamedTuple
- chemistrylab.lab.manager.Manager_v0()
Action Index
Required Bench
Function Call
0
None
set_cur_bench(idx = 0)
1
None
set_cur_bench(idx = 1)
2
None
set_cur_bench(idx = 2)
3
None
end_experiment()
4
None
swap_vessels(bench_idx = -1, vessel_idx = 0)
5
None
swap_vessels(bench_idx = -1, vessel_idx = 1)
6
None
swap_vessels(bench_idx = -1, vessel_idx = 2)
7
None
characterize(observation_list = [‘PVT’])
8
Reaction
run_bench(bench_idx = 0, policy_idx = 0)
9
Reaction
swap_vessels(bench_idx = 0, vessel_idx = 0)
8
Distillation
run_bench(bench_idx = 1, policy_idx = 0)
9
Distillation
swap_vessels(bench_idx = 1, vessel_idx = 0)
8
Extraction
run_bench(bench_idx = 2, policy_idx = 0)
9
Extraction
swap_vessels(bench_idx = 2, vessel_idx = 0)