Skip to content

library_actuator

RL4CRN.agent2env_interface.library_actuator

Library actuator.

Concrete actuator that maps a policy action to a reaction sampled from a reaction library.

The policy selects a reaction via an integer (or otherwise indexable) identifier, and provides a set of parameters that are applied to the selected reaction before returning it as the environment action.

Expected policy_action structure:

  • "reaction index": key used to select a reaction from the library
  • "parameters": parameter container passed to reaction.set_parameters(...)

Assumptions about reaction_library:

  • provides method get_reaction(index) returning a reaction-like object
  • the returned reaction provides set_parameters(parameters)

LibraryActuator

Bases: AbstractActuator

Actuator that selects and parameterizes a reaction from a reaction library.

__init__(reaction_library)

Initialize the actuator.

PARAMETER DESCRIPTION
reaction_library

Object providing get_reaction(index) to retrieve a reaction template or instance given a policy-selected index.

actuate(policy_action)

Convert a policy action into a parameterized reaction.

PARAMETER DESCRIPTION
policy_action

Dictionary specifying which reaction to select and which parameters to apply. Must contain "reaction index" and "parameters".

RETURNS DESCRIPTION

A reaction object obtained from the library and updated via reaction.set_parameters(...).

RAISES DESCRIPTION
KeyError

If required keys ("reaction index" or "parameters") are missing.

AttributeError

If the library or reaction does not provide the required methods (get_reaction / set_parameters).