Class HalfCheetahEnvV4
- Namespace
- Gym.Environments.Envs.MuJoCo
- Assembly
- Gym.Environments.dll
HalfCheetah-v4: the planar cheetah of HalfCheetahEnvV5 with v4's fixed model and frame skip, the same
dynamics and reward, an info of x_position, x_velocity, reward_run and reward_ctrl,
and an empty reset info. Byte for byte what Gymnasium's HalfCheetah-v4 computes on MuJoCo 4.0.0 (DR-61, DR-64).
[PyName("HalfCheetahEnv")]
public class HalfCheetahEnvV4 : MujocoEnv, IEnv, IDisposable, IDynamicAttributes
- Inheritance
-
HalfCheetahEnvV4
- Implements
- Inherited Members
- Extension Methods
Remarks
The observation space is 17 (18 with the root's x) float64 values whatever the model, as v4 declares it.
make warns that the id is out of date (v5 exists), as Gymnasium does.
Not thread-safe. Reference: gymnasium/envs/mujoco/half_cheetah_v4.py.
Its info reads typed (DR-91): HalfCheetahInfoV4 info = step.Info; (HalfCheetahInfoV4), with the dict's own values still behind the indexer.
Constructors
HalfCheetahEnvV4(HalfCheetahEnvV4Options)
Builds the instance from its options record: the properties set, the constructor's defaults for the rest.
public HalfCheetahEnvV4(HalfCheetahEnvV4Options options)
Parameters
optionsHalfCheetahEnvV4OptionsThe options.
Exceptions
- ArgumentNullException
Thrown when
optionsis null.
HalfCheetahEnvV4(RenderMode, double, double, double, bool, int, int, int?, string?, int, IReadOnlyDictionary<int, bool>?, EnvViewerFactory?)
Builds the env with the render mode given as the RenderMode enum (DR-84, DR-93), as
HalfCheetahEnvV4(double, double, double, bool, string?, int, int, int?, string?, int, IReadOnlyDictionary<int, bool>?, EnvViewerFactory?)
builds it from the mode's string: new HalfCheetahEnvV4(RenderMode.RgbArray) builds what
new HalfCheetahEnvV4(renderMode: "rgb_array") builds, the member reaching the env as Gymnasium's string
(Name(RenderMode)), which its RenderMode property then holds.
public HalfCheetahEnvV4(RenderMode renderMode, double forwardRewardWeight = 1, double ctrlCostWeight = 0.1, double resetNoiseScale = 0.1, bool excludeCurrentPositionsFromObservation = true, int width = 480, int height = 480, int? cameraId = null, string? cameraName = null, int maxGeom = 1000, IReadOnlyDictionary<int, bool>? visualOptions = null, EnvViewerFactory? viewerFactory = null)
Parameters
renderModeRenderModeThe render mode, which the env must list in its
metadata["render_modes"]as for the string; it behaves exactly as its Gymnasium string does in the other constructor.forwardRewardWeightdoubleThe weight of the forward velocity (
forward_reward_weight).ctrlCostWeightdoubleThe weight of the squared torques (
ctrl_cost_weight).resetNoiseScaledoubleThe scale of the reset's noise (
reset_noise_scale).excludeCurrentPositionsFromObservationboolWhether the root's x leaves the observation (
exclude_current_positions_from_observation).widthintThe rendered frame's width (
width).heightintThe rendered frame's height (
height).cameraIdint?The camera to render from (
camera_id).cameraNamestringThe camera to render from by name (
camera_name).maxGeomintThe most geoms a frame draws (
max_geom).visualOptionsIReadOnlyDictionary<int, bool>MuJoCo visual flags to switch (
visual_options).viewerFactoryEnvViewerFactoryGym.NET's
viewer_factory(DR-20) forhumanmode.
Remarks
The mode is required and comes first, so new HalfCheetahEnvV4() keeps meaning the other constructor, without a
mode; leave the mode out there for no rendering. Every other parameter means what it means there.
Exceptions
- ArgumentOutOfRangeException
Thrown for a value RenderMode does not declare (a cast integer such as
(RenderMode)99).- ValueError
Both a camera id and a camera name.
HalfCheetahEnvV4(double, double, double, bool, string?, int, int, int?, string?, int, IReadOnlyDictionary<int, bool>?, EnvViewerFactory?)
Creates the env (Gymnasium's HalfCheetahEnv.init): half_cheetah.xml with a frame skip of 5.
public HalfCheetahEnvV4(double forwardRewardWeight = 1, double ctrlCostWeight = 0.1, double resetNoiseScale = 0.1, bool excludeCurrentPositionsFromObservation = true, string? renderMode = null, int width = 480, int height = 480, int? cameraId = null, string? cameraName = null, int maxGeom = 1000, IReadOnlyDictionary<int, bool>? visualOptions = null, EnvViewerFactory? viewerFactory = null)
Parameters
forwardRewardWeightdoubleThe weight of the forward velocity (
forward_reward_weight).ctrlCostWeightdoubleThe weight of the squared torques (
ctrl_cost_weight).resetNoiseScaledoubleThe scale of the reset's noise (
reset_noise_scale).excludeCurrentPositionsFromObservationboolWhether the root's x leaves the observation (
exclude_current_positions_from_observation).renderModestringGymnasium's
render_mode:human,rgb_array,depth_array,rgbd_tupleor null.widthintThe rendered frame's width (
width).heightintThe rendered frame's height (
height).cameraIdint?The camera to render from (
camera_id).cameraNamestringThe camera to render from by name (
camera_name).maxGeomintThe most geoms a frame draws (
max_geom).visualOptionsIReadOnlyDictionary<int, bool>MuJoCo visual flags to switch (
visual_options).viewerFactoryEnvViewerFactoryGym.NET's
viewer_factory(DR-20) forhumanmode.
Exceptions
- ValueError
Both a camera id and a camera name.
Properties
ClassMetadata
Gymnasium's class attribute metadata: the four render modes at 20 frames per second. A new dict on every read.
public static Metadata ClassMetadata { get; }
Property Value
CtrlCostWeight
The weight of the squared torques (_ctrl_cost_weight), read every step.
[PyName("_ctrl_cost_weight")]
public double CtrlCostWeight { get; set; }
Property Value
ExcludeCurrentPositionsFromObservation
Whether the root's x leaves the observation (_exclude_current_positions_from_observation). Footgun:
changing it after construction changes the observation's length but not the observation space, as in Gymnasium.
[PyName("_exclude_current_positions_from_observation")]
public bool ExcludeCurrentPositionsFromObservation { get; set; }
Property Value
ForwardRewardWeight
The weight of the forward velocity (_forward_reward_weight), read every step.
[PyName("_forward_reward_weight")]
public double ForwardRewardWeight { get; set; }
Property Value
ResetNoiseScale
The scale of the reset's noise (_reset_noise_scale), read every reset.
[PyName("_reset_noise_scale")]
public double ResetNoiseScale { get; set; }
Property Value
Methods
ControlCost(NDArray)
The control cost of action (control_cost): ctrl_cost_weight * sum(action**2),
computed in the action's dtype and returned widened exactly.
[PyName("control_cost")]
public double ControlCost(NDArray action)
Parameters
actionNDArrayThe action.
Returns
- double
The cost.
Exceptions
- ArgumentNullException
actionis null.- NotSupportedException
An action of a dtype whose cost NumPy keeps in that dtype (float16, complex).
ResetModel()
The episode's start (reset_model): positions init_qpos + uniform(-scale, scale, nq), then
velocities init_qvel + scale * standard_normal(nv), drawn in that order.
protected override NDArray ResetModel()
Returns
- NDArray
The first observation.
Step(NDArray)
Applies action for 5 physics steps and reports the transition (step).
public override StepResult<NDArray> Step(NDArray action)
Parameters
actionNDArrayThe 6 torques, float32 (the action space's samples) or any real dtype.
Returns
- StepResult<NDArray>
The observation, the float64 reward,
terminated=False,truncated=Falseand the info.
Exceptions
- ArgumentNullException
actionis null.- ValueError
The action is not of shape
(6,), with Gymnasium's message.- NotSupportedException
An action of a dtype whose cost NumPy keeps in that dtype (float16, complex).