Table of Contents

Class ClipReward<TObs, TAct>

Namespace
Gym.Wrappers
Assembly
Gym.dll

Clips every reward into [min_reward, max_reward], as Gymnasium's ClipReward does; either bound may be left out.

public class ClipReward<TObs, TAct> : TransformReward<TObs, TAct>, IDynamicAttributes, IWrapper, IEnv, IDisposable, IRecordConstructorArgs

Type Parameters

TObs

The observation type, passed through.

TAct

The action type, passed through.

Inheritance
Env<TObs, TAct>
Wrapper<TObs, TAct, TObs, TAct>
RewardWrapper<TObs, TAct>
TransformReward<TObs, TAct>
ClipReward<TObs, TAct>
Implements
Inherited Members
Extension Methods

Remarks

The clip is np.clip(reward, a_min=min_reward, a_max=max_reward): a NaN reward stays NaN. Bounds may be numbers or arrays, as in Gymnasium, and are checked the same way; a reward is a double here, so an array bound must clip it to a single value (a 0-d or one-element array) — the vector wrapper is the one for per-env bounds. Gymnasium's np.clip returns an np.float64 (or an np.int64 for an int reward and int bounds); the value is the same.

Reference: gymnasium/wrappers/transform_reward.py.

Constructors

ClipReward(Env<TObs, TAct>, ClipRewardOptions)

Builds the instance from its options record: the properties set, the constructor's defaults for the rest.

public ClipReward(Env<TObs, TAct> env, ClipRewardOptions options)

Parameters

env Env<TObs, TAct>

The env to wrap.

options ClipRewardOptions

The options.

Exceptions

ArgumentNullException

Thrown when options is null.

ClipReward(Env<TObs, TAct>, object?, object?)

Wraps env.

public ClipReward(Env<TObs, TAct> env, object? minReward = null, object? maxReward = null)

Parameters

env Env<TObs, TAct>

The env.

minReward object

The lower bound, a number or an array; null for none.

maxReward object

The upper bound, a number or an array; null for none.

Exceptions

InvalidBound

Thrown when both bounds are null, or a lower bound exceeds its upper bound, with Gymnasium's messages.

TypeError

Thrown when a bound is neither a number nor an array, or env is null.

Properties

MaxReward

The upper bound as given (max_reward), or null.

public object? MaxReward { get; }

Property Value

object

MinReward

The lower bound as given (min_reward), or null.

public object? MinReward { get; }

Property Value

object