smarts.env.gymnasium.wrappers.metric.metrics module

class smarts.env.gymnasium.wrappers.metric.metrics.Metrics(*args: Any, **kwargs: Any)[source]

Metrics class wraps an underlying MetricsBase class. The underlying MetricsBase class computes agents’ performance metrics in a SMARTS environment. Whereas, this Metrics class is a basic gym.Wrapper class which prevents external users from accessing or modifying (i) protected attributes or (ii) attributes beginning with an underscore, to ensure security of the metrics computed.

Parameters:

env (gym.Env) – The gym environment to be wrapped.

Raises:

AttributeError – Upon accessing (i) a protected attribute or (ii) an attribute beginning with an underscore.

Returns:

A wrapped gym environment which computes agents’ performance metrics.

Return type:

gym.Env

class smarts.env.gymnasium.wrappers.metric.metrics.MetricsBase(*args: Any, **kwargs: Any)[source]

Computes agents’ performance metrics in a SMARTS environment.

records() Dict[str, Dict[str, Record]][source]

Fine grained performance metric for each agent in each scenario.

$ env.records()
$ {
      scen1: {
          agent1: Record(costs, counts, metadata),
          agent2: Record(costs, counts, metadata),
      },
      scen2: {
          agent1: Record(costs, counts, metadata),
      },
  }
Returns:

Performance record in a nested dictionary for each agent in each scenario.

Return type:

Dict[str, Dict[str, Record]]

reset(**kwargs)[source]

Resets the environment.

score() Score[source]

Computes score according to environment specific formula from the Formula class.

Returns:

Contains key-value pairs denoting score components.

Return type:

Dict[str, float]

step(action: Dict[str, Any])[source]

Steps the environment by one step.

exception smarts.env.gymnasium.wrappers.metric.metrics.MetricsError[source]

Raised when the Metrics environment wrapper fails.