chemistrylab.benches

Characterization Bench

class chemistrylab.benches.characterization_bench.CharacterizationBench(observation_list, targets, n_vessels)[source]

Bases: object

A set of methods made available to inspect an inputted vessel.

Parameters:
  • observation_list (Tuple[str]) – Ordered list of observations to make (see Method Map)

  • targets (Tuple[str]) – A list of target materials

  • n_vessels (int) – The (maximum) number of vessels included in an observation

Method Map:

Key

Method

‘spectra’

get_spectra

‘layers’

get_layers

‘targets’

encode_target

‘PVT’

encode_PVT

encode_PVT(vessel: Vessel)[source]
Returns:

a size 3 array containing [temperature,volume,pressure]

Return type:

np.array

encode_target(vessel: Vessel)[source]
Returns:

a 1D one-hot encoding of the target material (note self.target must be set before doing this)

Return type:

np.array

get_layers(vessel: Vessel)[source]
Returns:

a 1D array of vessel layer information

Return type:

np.array

get_observation(vessels: Vessel, target: str)[source]

Returns a concatenation of observations of the vessels provided, using the list of observations provided in __init__

Parameters:
  • vessels (Tuple[Vessel]) – A list of vessels you want an observtation of.

  • target (str) – The current target material

get_spectra(vessel: Vessel, materials: Tuple[Material] | None = None, overlap: bool = True)[source]

Class method to generate total spectral data using a gaussian decay.

Parameters:
  • vessel (Vessel) – The vessel inputted for spectroscopic analysis.

  • materials (Optional[Tuple[material.Material]]) – List of materials to get the spectra from

  • overlap (bool) – Indicates if the spectral plots show overlapping signatures. Defaults to False.

Returns:

A 1D array containing the absorption data of the present materials.

Return type:

np.array

chemistrylab.benches.characterization_bench.calc_absorb3(item, C, x, w_min, w_max, absorb)[source]

Distillation Bench

class chemistrylab.benches.distillation_bench.GeneralWurtzDistill_v2[source]

Bases: GenBench

Class to define an environment which performs a Wurtz extraction on materials in a vessel. Here is a breakdown of the action space:

Action

Vessel

Event Performed

Event Parameters

Other Vessel

0

boil_vessel

heat contact

Tf: 270.0, ht: 200.0

Beaker 1

1

boil_vessel

heat contact

Tf: 277.5, ht: 200.0

Beaker 1

2

boil_vessel

heat contact

Tf: 285.0, ht: 200.0

Beaker 1

3

boil_vessel

heat contact

Tf: 292.5, ht: 200.0

Beaker 1

4

boil_vessel

heat contact

Tf: 300.0, ht: 200.0

Beaker 1

5

boil_vessel

heat contact

Tf: 370.0, ht: 30.0

Beaker 1

6

boil_vessel

heat contact

Tf: 527.5, ht: 30.0

Beaker 1

7

boil_vessel

heat contact

Tf: 685.0, ht: 30.0

Beaker 1

8

boil_vessel

heat contact

Tf: 842.5, ht: 30.0

Beaker 1

9

boil_vessel

heat contact

Tf: 1000.0, ht: 30.0

Beaker 1

10

boil_vessel

pour by volume

volume: 0.0

Beaker 1

11

boil_vessel

pour by volume

volume: 0.111

Beaker 1

12

boil_vessel

pour by volume

volume: 0.222

Beaker 1

13

boil_vessel

pour by volume

volume: 0.333

Beaker 1

14

boil_vessel

pour by volume

volume: 0.444

Beaker 1

15

boil_vessel

pour by volume

volume: 0.556

Beaker 1

16

boil_vessel

pour by volume

volume: 0.667

Beaker 1

17

boil_vessel

pour by volume

volume: 0.778

Beaker 1

18

boil_vessel

pour by volume

volume: 0.889

Beaker 1

19

boil_vessel

pour by volume

volume: 1.0

Beaker 1

20

Beaker 1

pour by volume

volume: 0.0

Beaker 2

21

Beaker 1

pour by volume

volume: 0.111

Beaker 2

22

Beaker 1

pour by volume

volume: 0.222

Beaker 2

23

Beaker 1

pour by volume

volume: 0.333

Beaker 2

24

Beaker 1

pour by volume

volume: 0.444

Beaker 2

25

Beaker 1

pour by volume

volume: 0.556

Beaker 2

26

Beaker 1

pour by volume

volume: 0.667

Beaker 2

27

Beaker 1

pour by volume

volume: 0.778

Beaker 2

28

Beaker 1

pour by volume

volume: 0.889

Beaker 2

29

Beaker 1

pour by volume

volume: 1.0

Beaker 2

30

N/A

End Experiment

N/A

N/A

metadata: dict[str, Any] = {'render_fps': 10, 'render_modes': ['rgb_array']}
class chemistrylab.benches.distillation_bench.WurtzDistillDemo_v0[source]

Bases: GenBench

Class to define an environment which performs a Wurtz extraction on materials in a vessel. Here is a breakdown of the action space:

Action

Vessel

Event Performed

Event Parameters

Other Vessel

0

boil_vessel

heat contact

Tf: 300, ht: 20

Beaker 1

1

boil_vessel

heat contact

Tf: 270, ht: 20

Beaker 1

2

boil_vessel

heat contact

Tf: 1000, ht: 3

Beaker 1

3

boil_vessel

pour by volume

volume: 0.02

Beaker 1

4

Beaker 1

pour by volume

volume: 0.02

Beaker 2

5

N/A

End Experiment

N/A

N/A

get_keys_to_action()[source]
metadata: dict[str, Any] = {'render_fps': 60, 'render_modes': ['rgb_array']}
chemistrylab.benches.distillation_bench.wurtz_vessel(add_mat)[source]

Function to generate an input vessel for the wurtz distillation experiment.

Parameters:

add_mat (str) – The target material to include in the vessel

Returns:

A vessel containing add_mat and some undesired materials

Return type:

Vessel

Extraction Bench

class chemistrylab.benches.extract_bench.GeneralWurtzExtract_v2[source]

Bases: GenBench

Class to define an environment which performs a Wurtz extraction on materials in a vessel. Here is a breakdown of the action space:

Action

Vessel

Event Performed

Event Parameters

Other Vessel

0

extraction_vessel

drain by pixel

n_pixel: 2

Beaker 1

1

extraction_vessel

drain by pixel

n_pixel: 4

Beaker 1

2

extraction_vessel

drain by pixel

n_pixel: 6

Beaker 1

3

extraction_vessel

drain by pixel

n_pixel: 8

Beaker 1

4

extraction_vessel

drain by pixel

n_pixel: 10

Beaker 1

5

extraction_vessel

mix

t: -0.2

N/A

6

extraction_vessel

mix

t: -0.4

N/A

7

extraction_vessel

mix

t: -0.6

N/A

8

extraction_vessel

mix

t: -0.8

N/A

9

extraction_vessel

mix

t: -1.0

N/A

10

Beaker 1

pour by volume

volume: 0.2

extraction_vessel

11

Beaker 1

pour by volume

volume: 0.4

extraction_vessel

12

Beaker 1

pour by volume

volume: 0.6

extraction_vessel

13

Beaker 1

pour by volume

volume: 0.8

extraction_vessel

14

Beaker 1

pour by volume

volume: 1.0

extraction_vessel

15

Beaker 2

pour by volume

volume: 0.2

extraction_vessel

16

Beaker 2

pour by volume

volume: 0.4

extraction_vessel

17

Beaker 2

pour by volume

volume: 0.6

extraction_vessel

18

Beaker 2

pour by volume

volume: 0.8

extraction_vessel

19

Beaker 2

pour by volume

volume: 1.0

extraction_vessel

20

extraction_vessel

pour by volume

volume: 0.2

Beaker 2

21

extraction_vessel

pour by volume

volume: 0.4

Beaker 2

22

extraction_vessel

pour by volume

volume: 0.6

Beaker 2

23

extraction_vessel

pour by volume

volume: 0.8

Beaker 2

24

extraction_vessel

pour by volume

volume: 1.0

Beaker 2

25

C6H14 Vessel

pour by volume

volume: 0.1

extraction_vessel

26

C6H14 Vessel

pour by volume

volume: 0.2

extraction_vessel

27

C6H14 Vessel

pour by volume

volume: 0.3

extraction_vessel

28

C6H14 Vessel

pour by volume

volume: 0.4

extraction_vessel

29

C6H14 Vessel

pour by volume

volume: 0.5

extraction_vessel

30

diethyl ether Vessel

pour by volume

volume: 0.1

extraction_vessel

31

diethyl ether Vessel

pour by volume

volume: 0.2

extraction_vessel

32

diethyl ether Vessel

pour by volume

volume: 0.3

extraction_vessel

33

diethyl ether Vessel

pour by volume

volume: 0.4

extraction_vessel

34

diethyl ether Vessel

pour by volume

volume: 0.5

extraction_vessel

35

extraction_vessel, Beaker 1, Beaker 2

mix

t: 0.01

N/A

36

extraction_vessel, Beaker 1, Beaker 2

mix

t: 0.02

N/A

37

extraction_vessel, Beaker 1, Beaker 2

mix

t: 0.04

N/A

38

extraction_vessel, Beaker 1, Beaker 2

mix

t: 0.08

N/A

39

extraction_vessel, Beaker 1, Beaker 2

mix

t: 0.16

N/A

40

N/A

End Experiment

N/A

N/A

metadata: dict[str, Any] = {'render_fps': 10, 'render_modes': ['rgb_array']}
class chemistrylab.benches.extract_bench.SeparateTest_v0[source]

Bases: GenBench

Class to define an environment which performs a Wurtz extraction on materials in a vessel. Here is a breakdown of the action space:

Action

Vessel

Event Performed

Event Parameters

Other Vessel

0

extraction_vessel

drain by pixel

n_pixel: 1

Beaker 1

1

extraction_vessel

mix

t: -0.02

N/A

2

Beaker 1

pour by volume

volume: 0.02

extraction_vessel

3

Beaker 2

pour by volume

volume: 0.02

extraction_vessel

4

extraction_vessel

pour by volume

volume: 0.02

Beaker 2

5

C6H14 Vessel

pour by volume

volume: 0.01

extraction_vessel

6

diethyl ether Vessel

pour by volume

volume: 0.01

extraction_vessel

7

H2O Vessel

pour by volume

volume: 0.01

extraction_vessel

8

ethoxyethane Vessel

pour by volume

volume: 0.01

extraction_vessel

9

ethyl acetate Vessel

pour by volume

volume: 0.01

extraction_vessel

10

extraction_vessel, Beaker 1, Beaker 2

mix

t: 0.001

N/A

11

extraction_vessel, Beaker 1, Beaker 2

mix

t: 0.016

N/A

12

N/A

End Experiment

N/A

N/A

metadata: dict[str, Any] = {'render_fps': 60, 'render_modes': ['rgb_array']}
class chemistrylab.benches.extract_bench.WaterOilExtract_v0[source]

Bases: GenBench

Class to define an environment which performs a Wurtz extraction on materials in a vessel. Here is a breakdown of the action space:

Action

Vessel

Event Performed

Event Parameters

Other Vessel

0

extraction_vessel

drain by pixel

n_pixel: 2

Beaker 1

1

extraction_vessel

drain by pixel

n_pixel: 4

Beaker 1

2

extraction_vessel

drain by pixel

n_pixel: 6

Beaker 1

3

extraction_vessel

drain by pixel

n_pixel: 8

Beaker 1

4

extraction_vessel

drain by pixel

n_pixel: 10

Beaker 1

5

extraction_vessel

mix

t: -0.2

N/A

6

extraction_vessel

mix

t: -0.4

N/A

7

extraction_vessel

mix

t: -0.6

N/A

8

extraction_vessel

mix

t: -0.8

N/A

9

extraction_vessel

mix

t: -1.0

N/A

10

Beaker 1

pour by volume

volume: 0.2

extraction_vessel

11

Beaker 1

pour by volume

volume: 0.4

extraction_vessel

12

Beaker 1

pour by volume

volume: 0.6

extraction_vessel

13

Beaker 1

pour by volume

volume: 0.8

extraction_vessel

14

Beaker 1

pour by volume

volume: 1.0

extraction_vessel

15

Waste Vessel

pour by volume

volume: 0.2

extraction_vessel

16

Waste Vessel

pour by volume

volume: 0.4

extraction_vessel

17

Waste Vessel

pour by volume

volume: 0.6

extraction_vessel

18

Waste Vessel

pour by volume

volume: 0.8

extraction_vessel

19

Waste Vessel

pour by volume

volume: 1.0

extraction_vessel

20

extraction_vessel

pour by volume

volume: 0.2

Waste Vessel

21

extraction_vessel

pour by volume

volume: 0.4

Waste Vessel

22

extraction_vessel

pour by volume

volume: 0.6

Waste Vessel

23

extraction_vessel

pour by volume

volume: 0.8

Waste Vessel

24

extraction_vessel

pour by volume

volume: 1.0

Waste Vessel

25

C6H14 Vessel

pour by volume

volume: 0.1

extraction_vessel

26

C6H14 Vessel

pour by volume

volume: 0.2

extraction_vessel

27

C6H14 Vessel

pour by volume

volume: 0.3

extraction_vessel

28

C6H14 Vessel

pour by volume

volume: 0.4

extraction_vessel

29

C6H14 Vessel

pour by volume

volume: 0.5

extraction_vessel

30

H2O Vessel

pour by volume

volume: 0.1

extraction_vessel

31

H2O Vessel

pour by volume

volume: 0.2

extraction_vessel

32

H2O Vessel

pour by volume

volume: 0.3

extraction_vessel

33

H2O Vessel

pour by volume

volume: 0.4

extraction_vessel

34

H2O Vessel

pour by volume

volume: 0.5

extraction_vessel

35

extraction_vessel, Beaker 1, Waste Vessel

mix

t: 0.01

N/A

36

extraction_vessel, Beaker 1, Waste Vessel

mix

t: 0.02

N/A

37

extraction_vessel, Beaker 1, Waste Vessel

mix

t: 0.04

N/A

38

extraction_vessel, Beaker 1, Waste Vessel

mix

t: 0.08

N/A

39

extraction_vessel, Beaker 1, Waste Vessel

mix

t: 0.16

N/A

40

N/A

End Experiment

N/A

N/A

metadata: dict[str, Any] = {'render_fps': 10, 'render_modes': ['rgb_array']}
class chemistrylab.benches.extract_bench.WurtzExtractDemo_v0[source]

Bases: GenBench

Class to define an environment which performs a Wurtz extraction on materials in a vessel. Here is a breakdown of the action space:

Action

Vessel

Event Performed

Event Parameters

Other Vessel

0

extraction_vessel

drain by pixel

n_pixel: 1

Beaker 1

1

extraction_vessel

mix

t: -0.02

N/A

2

Beaker 1

pour by volume

volume: 0.02

extraction_vessel

3

Beaker 2

pour by volume

volume: 0.02

extraction_vessel

4

extraction_vessel

pour by volume

volume: 0.02

Beaker 2

5

C6H14 Vessel

pour by volume

volume: 0.01

extraction_vessel

6

diethyl ether Vessel

pour by volume

volume: 0.01

extraction_vessel

7

extraction_vessel, Beaker 1, Beaker 2

mix

t: 0.001

N/A

8

extraction_vessel, Beaker 1, Beaker 2

mix

t: 0.016

N/A

9

N/A

End Experiment

N/A

N/A

get_keys_to_action()[source]
metadata: dict[str, Any] = {'render_fps': 60, 'render_modes': ['rgb_array']}
chemistrylab.benches.extract_bench.make_solvent(mat)[source]

Makes a Vessel with a single material

chemistrylab.benches.extract_bench.oil_vessel()[source]

Function to generate an input vessel for the oil extraction bench.

Returns: - extract_vessel (Vessel): A vessel containing oil and NaCl

chemistrylab.benches.extract_bench.wurtz_vessel(add_mat='')[source]

Function to generate an input vessel for the wurtz extraction bench.

Args: - add_mat (str): The target material to include in the vessel

Returns: - extract_vessel (Vessel): A vessel containing add_mat and some undesired materials

Reaction Bench

class chemistrylab.benches.reaction_bench.FictReactBandit_v0(targets=None)[source]

Bases: GenBench

Class to define an environment which performs a Wurtz extraction on materials in a vessel. Here is a breakdown of the action space:

Action Index

Vessel

Event Performed

Event Parameters

Other Vessel

0

Reaction Vessel

heat contact

Tf: [273,373], ht: 300

Reaction Vessel

1

fict_A Vessel

pour by percent

fraction: [0,1]

Reaction Vessel

2

fict_B Vessel

pour by percent

fraction: [0,1]

Reaction Vessel

3

fict_C Vessel

pour by percent

fraction: [0,1]

Reaction Vessel

4

fict_D Vessel

pour by percent

fraction: [0,1]

Reaction Vessel

step(action)[source]

Here, actions are performed by ‘_perform_discrete_action’ or ‘_perform_continuous_action’. Afterwards, all vessels in react_list have their concentrations updated by a reaction (specified in __init__). Finally, a CharacterizationBench is used to generate an observation, and a reward function provides a reward (if a terminal state was reached).

Parameters:

action (int or 1D array) – The action to be performed

class chemistrylab.benches.reaction_bench.FictReactDemo_v0[source]

Bases: GenBench

Class to define an environment which performs a Wurtz extraction on materials in a vessel. Here is a breakdown of the action space:

Action Index

Vessel

Event Performed

Event Parameters

Other Vessel

0

Reaction Vessel

heat contact

Tf: [273,373], ht: 12

Reaction Vessel

1

fict_A Vessel

pour by percent

fraction: [0,1]

Reaction Vessel

2

fict_B Vessel

pour by percent

fraction: [0,1]

Reaction Vessel

3

fict_C Vessel

pour by percent

fraction: [0,1]

Reaction Vessel

4

fict_D Vessel

pour by percent

fraction: [0,1]

Reaction Vessel

get_keys_to_action()[source]
metadata: dict[str, Any] = {'render_fps': 60, 'render_modes': ['rgb_array']}
class chemistrylab.benches.reaction_bench.FictReact_v2[source]

Bases: GenBench

Class to define an environment which performs a Wurtz extraction on materials in a vessel. Here is a breakdown of the action space:

Action Index

Vessel

Event Performed

Event Parameters

Other Vessel

0

Reaction Vessel

heat contact

Tf: [273,373], ht: 300

Reaction Vessel

1

fict_A Vessel

pour by percent

fraction: [0,1]

Reaction Vessel

2

fict_B Vessel

pour by percent

fraction: [0,1]

Reaction Vessel

3

fict_C Vessel

pour by percent

fraction: [0,1]

Reaction Vessel

4

fict_D Vessel

pour by percent

fraction: [0,1]

Reaction Vessel

metadata: dict[str, Any] = {'render_fps': 10, 'render_modes': ['rgb_array']}
class chemistrylab.benches.reaction_bench.GeneralWurtzReact_v0[source]

Bases: GenBench

Class to define an environment which performs a Wurtz extraction on materials in a vessel. Here is a breakdown of the action space:

Action Index

Vessel

Event Performed

Event Parameters

Other Vessel

0

Reaction Vessel

heat contact

Tf: [156,307], ht: 500

Reaction Vessel

1

1-chlorohexane Vessel

pour by percent

fraction: [0,1]

Reaction Vessel

2

2-chlorohexane Vessel

pour by percent

fraction: [0,1]

Reaction Vessel

3

3-chlorohexane Vessel

pour by percent

fraction: [0,1]

Reaction Vessel

4

Na Vessel

pour by percent

fraction: [0,1]

Reaction Vessel

metadata: dict[str, Any] = {'render_fps': 10, 'render_modes': ['rgb_array']}
class chemistrylab.benches.reaction_bench.GeneralWurtzReact_v2[source]

Bases: GenBench

Class to define an environment which performs a Wurtz extraction on materials in a vessel. Here is a breakdown of the action space:

Action Index

Vessel

Event Performed

Event Parameters

Other Vessel

0

Reaction Vessel

heat contact

Tf: [156,307], ht: 500

Reaction Vessel

1

1-chlorohexane Vessel

pour by percent

fraction: [0,1]

Reaction Vessel

2

2-chlorohexane Vessel

pour by percent

fraction: [0,1]

Reaction Vessel

3

3-chlorohexane Vessel

pour by percent

fraction: [0,1]

Reaction Vessel

4

Na Vessel

pour by percent

fraction: [0,1]

Reaction Vessel

metadata: dict[str, Any] = {'render_fps': 10, 'render_modes': ['rgb_array']}
chemistrylab.benches.reaction_bench.get_mat(mat, amount, name=None)[source]

Makes a Vessel with a single material

General Bench

class chemistrylab.benches.general_bench.Action(vessels, parameters, event_name, affected_vessels, dt, terminal)[source]

Bases: NamedTuple

affected_vessels: Tuple[int] | None

Alias for field number 3

dt: float

Alias for field number 4

event_name: str

Alias for field number 2

parameters: Tuple[tuple]

Alias for field number 1

terminal: bool

Alias for field number 5

vessels: Tuple[int]

Alias for field number 0

class chemistrylab.benches.general_bench.ContinuousParam(min_val, max_val, thresh, other)[source]

Bases: NamedTuple

max_val: float

Alias for field number 1

min_val: float

Alias for field number 0

other: tuple

Alias for field number 3

thresh: float

Alias for field number 2

class chemistrylab.benches.general_bench.GenBench(shelf: ~chemistrylab.lab.shelf.Shelf, action_list: ~typing.Tuple[~chemistrylab.benches.general_bench.Action], observation_list: ~typing.Tuple[str], targets: ~typing.Tuple[str], default_events: ~typing.Tuple[~chemistrylab.vessel.Event] = (), reward_function: ~typing.Callable = <function default_reward>, discrete=True, max_steps=50)[source]

Bases: Env

A class representing an bench setup for conducting experiments.

This class represents a bench setup. The setup consists of a shelf with vessels, an action list that describes the actions that can be performed on the vessels by the agent, and a set of events which are performed on the vessels at the end of each step to update it’s state (ex. a chemical reaction).

Parameters:
  • shelf (Shelf) – A shelf object to store vessels.

  • action_list (list) – A list of Action objects containing information describing what each action is.

  • observation_list (Tuple[str]) – List of observations to obtain from the characteriation bench

  • targets (Tuple[str]) – The target materials for this bench

  • default_events (Tuple[Event]) – A list of events to be performed on all working vessels in a bench at the end of each step.

  • reward_function (Callable) – A function which accepts a target and a list of vessels and outputs a reward.

  • discrete (bool) – set to True for a discrete action space and False for a continuous one

  • max_steps (int) – Maximum number of steps for an episode

build_event(action, param)[source]

Builds a list of (index, Event) tuples where index is the index of the vessel the Event will occur in.

Parameters:
  • action (Action) – An action containing information about the vessels and parameters involved in the event.

  • param (tuple) – A tuple containing parameters for the event.

Returns:

A list of (index, Event) tuples, where index is the index of the vessel the Event will occur in.

Return type:

List[Tuple]

get_vessels()[source]
render()[source]

Compute the render frames as specified by render_mode during the initialization of the environment.

The environment’s metadata render modes (env.metadata[“render_modes”]) should contain the possible ways to implement the render modes. In addition, list versions for most render modes is achieved through gymnasium.make which automatically applies a wrapper to collect rendered frames.

Note

As the render_mode is known during __init__, the objects used to render the environment state should be initialised in __init__.

By convention, if the render_mode is:

  • None (default): no render is computed.

  • “human”: The environment is continuously rendered in the current display or terminal, usually for human consumption. This rendering should occur during step() and render() doesn’t need to be called. Returns None.

  • “rgb_array”: Return a single frame representing the current state of the environment. A frame is a np.ndarray with shape (x, y, 3) representing RGB values for an x-by-y pixel image.

  • “ansi”: Return a strings (str) or StringIO.StringIO containing a terminal-style text representation for each time step. The text can include newlines and ANSI escape sequences (e.g. for colors).

  • “rgb_array_list” and “ansi_list”: List based version of render modes are possible (except Human) through the wrapper, gymnasium.wrappers.RenderCollection that is automatically applied during gymnasium.make(..., render_mode="rgb_array_list"). The frames collected are popped after render() is called or reset().

Note

Make sure that your class’s metadata "render_modes" key includes the list of supported modes.

Changed in version 0.25.0: The render function was changed to no longer accept parameters, rather these parameters should be specified in the environment initialised, i.e., gymnasium.make("CartPole-v1", render_mode="human")

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 and reset() is called with seed=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 be super().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 and seed=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 by step().

Return type:

observation (ObsType)

step(action)[source]

Here, actions are performed by ‘_perform_discrete_action’ or ‘_perform_continuous_action’. Afterwards, all vessels in react_list have their concentrations updated by a reaction (specified in __init__). Finally, a CharacterizationBench is used to generate an observation, and a reward function provides a reward (if a terminal state was reached).

Parameters:

action (int or 1D array) – The action to be performed

update_vessels(new_vessels)[source]
chemistrylab.benches.general_bench.default_reward(vessels, targ)[source]

Module contents