ostatslib.actions.actions_space#

ActionsSpace module

Classes

ActionsSpace()

Actions space initializes actions and make them available to the environment.

class ActionsSpace[source]#

Actions space initializes actions and make them available to the environment. Extends Gymnasium MultiBinary space.

property actions_dict: dict[int, ostatslib.actions.base.Action | None]#

Actions in actions space

Returns:

dictionary of actions in actions space

Return type:

dict[int, Action | None]

property actions_list: list[ostatslib.actions.base.Action]#

List of valid actions available in actions space

Returns:

list of available actions

Return type:

list[Action]

property encoding_length: int#

Returns encoding length (# of digits in the encoding)

Returns:

# of digits in the encoding

Return type:

int

get_action(numeric_key: int | numpy.ndarray) ostatslib.actions.base.Action | None[source]#

Get action by numeric key. Numeric key may be an integer or ndarray binary representation (from policy network)

Parameters:

numeric_key (int | np.ndarray) – action numeric key

Returns:

action or None if dict key is not an action

Return type:

Action | None

get_action_by_class(action: type) Action[source]#

Get action instance in actions space by class

Parameters:

action (type) – action type

Raises:

ValueError – raised if no action of type is found

Returns:

action instance in actions space

Return type:

Action

sample(mask: numpy.ndarray[Any, numpy.dtype[numpy.int8]] | None = None) ndarray[source]#

Generates a single random sample from this space.

A sample is drawn by independent, fair coin tosses (one toss per binary variable of the space).

Parameters:

mask – An optional np.ndarray to mask samples with expected shape of space.shape. For mask == 0 then the samples will be 0 and mask == 1 then random samples will be generated. The expected mask shape is the space shape and mask dtype is np.int8.

Returns:

Sampled values from space