smarts.env.gymnasium.wrappers.metric.formula module

class smarts.env.gymnasium.wrappers.metric.formula.Formula[source]

Sets the (i) cost function parameters, and (ii) score computation formula, for an environment.

params() Params[source]

Return parameters to configure and initialize cost functions.

Returns:

Cost function parameters.

Return type:

Params

score(records: Dict[str, Dict[str, Record]]) Score[source]

Computes sub-component scores and one total combined score named “Overall” on the wrapped environment.

Parameters:

records (Dict[str, Dict[str, Record]]) – Records.

Returns:

“Overall” score and other sub-component scores.

Return type:

Score

class smarts.env.gymnasium.wrappers.metric.formula.FormulaBase[source]

Interface, for cost function parameters and score computation formula, to be implemented by other formula classes.

params() Params[source]

Return parameters to configure and initialize cost functions.

Returns:

Cost function parameters.

Return type:

Params

score(records: Dict[str, Dict[str, Record]]) Score[source]

Computes sub-component scores and one total combined score named “Overall” on the wrapped environment.

Parameters:

records (Dict[str, Dict[str, Record]]) – Records.

Returns:

“Overall” score and other sub-component scores.

smarts.env.gymnasium.wrappers.metric.formula.agent_scores(records: Dict[str, Dict[str, Record]], func: Callable[[Costs], Score]) Dict[str, Dict[str, Score]][source]

Computes score for each agent in every scenario.

Parameters:
  • records (Dict[str, Dict[str, Record]]) – Records.

  • func (Callable[[Costs],Score]) – Function which computes Score given Costs.

Returns:

Score for each agent in every scenario.

Return type:

Dict[str,Dict[str,Score]]

smarts.env.gymnasium.wrappers.metric.formula.agent_weights(records: Dict[str, Dict[str, Record]]) Dict[str, Dict[str, float]][source]

Retrieves weight for each agent in every scenario.

Parameters:

records (Dict[str, Dict[str, Record]]) – Records.

Returns:

Weight for each agent in every scenario.

Return type:

Dict[str,Dict[str,float]]

smarts.env.gymnasium.wrappers.metric.formula.costs_to_score(costs: Costs) Score[source]

Compute score from costs.

Range

Remarks

Overall

[0, 1]

Total score. The higher, the better.

DistToDestination

[0, 1]

Remaining distance to destination. The lower, the better.

Time

[0, 1]

Time taken to complete scenario. The lower, the better.

HumannessError

[0, 1]

Humanness indicator. The lower, the better.

RuleViolation

[0, 1]

Traffic rules compliance. The lower, the better.

Parameters:

costs (Costs) – Costs.

Returns:

Score.

Return type:

Score

smarts.env.gymnasium.wrappers.metric.formula.score_rule_violation(costs: Costs) float[source]

Default rule violation scoring formula.

Parameters:

costs (Costs) – Costs.

Returns:

Rule violation score.

Return type:

float

smarts.env.gymnasium.wrappers.metric.formula.weighted_score(scores: Dict[str, Dict[str, Score]], weights: Dict[str, Dict[str, float]]) Score[source]

Computes single overall weighted score using weights.

Parameters:
  • scores (Dict[str,Dict[str,Score]]) – Score for each agent in every scenario.

  • weights (Dict[str,Dict[str,float]]) – Weight for each agent in every scenario.

Returns:

Weighted score.

Return type:

Score