carl.envs.carl_env

Classes

CARLEnv(env[, contexts, ...])

Interfaces

class carl.envs.carl_env.CARLEnv(env, contexts=None, obs_context_features=None, obs_context_as_dict=True, context_selector=None, context_selector_kwargs=None, **kwargs)[source]

Bases: Wrapper, ABC

abstract static get_context_features()[source]

Get the context features

Defined per environment.

Returns:

Context feature definitions

Return type:

dict[str, ContextFeature]

classmethod get_context_space()[source]

Get context space

Returns:

Context space with utility methods holding information about defaults, types, bounds, etc.

Return type:

ContextSpace

classmethod get_default_context()[source]

Get the default context

Returns:

Default context.

Return type:

Context

get_observation_space(obs_context_feature_names=None)[source]

Get the observation space for the context.

Parameters:

obs_context_feature_names (list[str] | None, optional) – Name of the context features to be included in the observation, by default None. If it is None, we add all context features.

Returns:

Gymnasium observation space which contains the observation space of the underlying environment (“state”) and for the context (“context”).

Return type:

gymnasium.spaces.Dict

reset(*, seed=None, options=None)[source]

Reset the environment.

First, we progress the instance, i.e. select a new context with the context selector. Then we update the context in the wrapped environment. Finally, we reset the underlying environment and add context information to the observation.

Parameters:
  • seed (int | None, optional) – Seed, by default None

  • options (dict[str, Any] | None, optional) – Options, by default None

Returns:

Observation, info.

Return type:

tuple[Any, dict[str, Any]]

step(action)[source]

Step the environment.

The context is added to the observation returned by the wrapped environment.

Parameters:

action (Any) – Action

Returns:

Observation, rewar, terminated, truncated, info.

Return type:

tuple[Any, SupportsFloat, bool, bool, dict[str, Any]]