gyx v0.1.1 Gyx.Core.Spaces protocol
This protocol defines basic functions to interact with action and observation spaces.
Link to this section Summary
Functions
Verifies if a particular action or observation point lies inside a given space
Samples a random point from a space. Note that sampled points are very different in nature depending on the underlying space. This sampling is pretty important for an agent, as it is the way the agent might decide which actions to take from an action space defined on the environment the agent is interacting with.
Parameters
Sets the random generator used by sample/1
with the
space defined seed
Link to this section Types
box_point()
box_point() :: [[float()]]
box_point() :: [[float()]]
discrete_point()
discrete_point() :: integer()
discrete_point() :: integer()
point()
point() :: box_point() | discrete_point() | tuple_point()
point() :: box_point() | discrete_point() | tuple_point()
space()
space() ::
Gyx.Core.Spaces.Discrete.t()
| Gyx.Core.Spaces.Box.t()
| Gyx.Core.Spaces.Tuple.t()
space() :: Gyx.Core.Spaces.Discrete.t() | Gyx.Core.Spaces.Box.t() | Gyx.Core.Spaces.Tuple.t()
t()
t() :: term()
t() :: term()
tuple_point()
tuple_point() :: [discrete_point() | box_point()]
tuple_point() :: [discrete_point() | box_point()]
Link to this section Functions
contains?(space, point)
Verifies if a particular action or observation point lies inside a given space.
Examples
iex> box_space = %Box{shape: {1, 2}}
iex> {:ok, box_point} = Spaces.sample(box_space)
iex> Spaces.contains(box_space, box_point)
true
sample(space)
Samples a random point from a space. Note that sampled points are very different in nature depending on the underlying space. This sampling is pretty important for an agent, as it is the way the agent might decide which actions to take from an action space defined on the environment the agent is interacting with.
Parameters
- space: Any module representing a space.
Examples
iex> discrete_space = %Gyx.Core.Spaces.Discrete{n: 42}
%Gyx.Core.Spaces.Discrete{n: 42, random_algorithm: :exsplus, seed: {1,2,3}}
iex> Gyx.Core.Spaces.set_seed(discrete_space)
{%{
jump: #Function<16.10897371/1 in :rand.ml_alg/1>
max: 288230376151711743,
next: #Function<15.1089737/1 in :rand.mk_alg/1>
type: :explus
}, [72022415603679006 | 144185572652843231]}
iex> Gyx.Core.Spaces.sample(discrete_space)
{:ok, 35}
iex> Gyx.Core.Spaces.sample(%Gyx.Core.Spaces.Box{shape: {2}, high: 7}
{:ok, [[3.173570417347619, 0.286615818442874]]}
set_seed(space)
Sets the random generator used by sample/1
with the
space defined seed.