Class ClipReward<TObs, TAct>
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
TObsThe observation type, passed through.
TActThe 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
envEnv<TObs, TAct>The env to wrap.
optionsClipRewardOptionsThe options.
Exceptions
- ArgumentNullException
Thrown when
optionsis null.
ClipReward(Env<TObs, TAct>, object?, object?)
Wraps env.
public ClipReward(Env<TObs, TAct> env, object? minReward = null, object? maxReward = null)
Parameters
envEnv<TObs, TAct>The env.
minRewardobjectThe lower bound, a number or an array; null for none.
maxRewardobjectThe 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
envis null.
Properties
MaxReward
The upper bound as given (max_reward), or null.
public object? MaxReward { get; }
Property Value
MinReward
The lower bound as given (min_reward), or null.
public object? MinReward { get; }