rlmesh.trial_index
The reserved trial_index reset option, or None when absent.
trial_index(
options: Mapping[str, Any] | None,
*,
lane: int | None = None,
) -> int | NoneThe ordinal of the episode a reset starts, 0-based and walked in order by
the runtime (from run(trial_index_base=...), 0 by default), so an env
can sweep a fixed list of initial states / goals exactly as its upstream
benchmark does instead of re-deriving one from a hashed seed. Delivered only
to an env that declared "trial_index" in
EnvFactory.reset_options; absent on a hand-driven Session.reset()
that passed none::
class MyEnv(rlmesh.EnvFactory): reset_options = (“trial_index”,)
def reset(self, *, seed=None, options=None): trial = rlmesh.trial_index(options) n = len(self.init_states) state = self.init_states[(trial if trial is not None else seed or 0) % n]
The option takes one of two forms. A reset covering one lane carries a bare
integer; a reset covering several lanes of a vector env carries a list, one
ordinal per lane being reset, in the same order as the reset’s seeds. A
vector env reads its lanes with lane=, the position among the lanes
this reset covers (not the env index, when only some lanes are reset)::
for i in range(len(lanes_being_reset)): trial = rlmesh.trial_index(options, lane=i)
Parameters
| Name | Type | Description |
|---|---|---|
options | Mapping[str, Any] | None | The options mapping reset received, or None. |
lane | int | None | Position among the lanes this reset covers. None (the default) reads the single-lane form; a bare integer also answers lane=0. |
Returns
| Type | Description |
|---|---|
int | None | The ordinal, or None when the key is absent or not an integer. |
Raises
| Type | Description |
|---|---|
ValueError | The option is the multi-lane list and lane was not given, or lane is outside the lanes the option covers. |