# builders.domain.memory
Domain specification
# History
A domain must inherit this class if its full state history must be stored to compute its dynamics (non-Markovian domain).
# _get_memory_maxlen History
_get_memory_maxlen(
self
) -> Optional[int]
Get the memory max length (or None if unbounded).
TIP
This function returns always None by default because the memory length is unbounded at this level.
# Returns
The memory max length (or None if unbounded).
# _init_memory History
_init_memory(
self,
state: Optional[D.T_state] = None
) -> Memory[D.T_state]
Initialize memory (possibly with a state) according to its specification and return it.
This function is automatically called by Initializable._reset()
to reinitialize the internal memory whenever
the domain is used as an environment.
# Parameters
- state: An optional state to initialize the memory with (typically the initial state).
# Returns
The new initialized memory.
# FiniteHistory
A domain must inherit this class if the last N states must be stored to compute its dynamics (Markovian domain of order N).
N is specified by the return value of the FiniteHistory._get_memory_maxlen()
function.
# _get_memory_maxlen History
_get_memory_maxlen(
self
) -> int
Get the (cached) memory max length.
By default, FiniteHistory._get_memory_maxlen()
internally calls FiniteHistory._get_memory_maxlen_()
the first
time and automatically caches its value to make future calls more efficient (since the memory max length is
assumed to be constant).
# Returns
The memory max length.
# _get_memory_maxlen_ FiniteHistory
_get_memory_maxlen_(
self
) -> int
Get the memory max length.
This is a helper function called by default from FiniteHistory._get_memory_maxlen()
, the difference being that
the result is not cached here.
TIP
The underscore at the end of this function's name is a convention to remind that its result should be constant.
# Returns
The memory max length.
# _init_memory History
_init_memory(
self,
state: Optional[D.T_state] = None
) -> Memory[D.T_state]
Initialize memory (possibly with a state) according to its specification and return it.
This function is automatically called by Initializable._reset()
to reinitialize the internal memory whenever
the domain is used as an environment.
# Parameters
- state: An optional state to initialize the memory with (typically the initial state).
# Returns
The new initialized memory.
# Markovian
A domain must inherit this class if only its last state must be stored to compute its dynamics (pure Markovian domain).
# _get_memory_maxlen History
_get_memory_maxlen(
self
) -> int
Get the (cached) memory max length.
By default, FiniteHistory._get_memory_maxlen()
internally calls FiniteHistory._get_memory_maxlen_()
the first
time and automatically caches its value to make future calls more efficient (since the memory max length is
assumed to be constant).
# Returns
The memory max length.
# _get_memory_maxlen_ FiniteHistory
_get_memory_maxlen_(
self
) -> int
Get the memory max length.
This is a helper function called by default from FiniteHistory._get_memory_maxlen()
, the difference being that
the result is not cached here.
TIP
The underscore at the end of this function's name is a convention to remind that its result should be constant.
# Returns
The memory max length.
# _init_memory History
_init_memory(
self,
state: Optional[D.T_state] = None
) -> Memory[D.T_state]
Initialize memory (possibly with a state) according to its specification and return it.
This function is automatically called by Initializable._reset()
to reinitialize the internal memory whenever
the domain is used as an environment.
# Parameters
- state: An optional state to initialize the memory with (typically the initial state).
# Returns
The new initialized memory.
# Memoryless
A domain must inherit this class if it does not require any previous state(s) to be stored to compute its dynamics.
A dice roll simulator is an example of memoryless domain (next states are independent of previous ones).
TIP
Whenever an existing domain (environment, simulator...) needs to be wrapped instead of implemented fully in scikit-decide (e.g. compiled ATARI games), Memoryless can be used because the domain memory (if any) would be handled externally.
# _get_memory_maxlen History
_get_memory_maxlen(
self
) -> int
Get the (cached) memory max length.
By default, FiniteHistory._get_memory_maxlen()
internally calls FiniteHistory._get_memory_maxlen_()
the first
time and automatically caches its value to make future calls more efficient (since the memory max length is
assumed to be constant).
# Returns
The memory max length.
# _get_memory_maxlen_ FiniteHistory
_get_memory_maxlen_(
self
) -> int
Get the memory max length.
This is a helper function called by default from FiniteHistory._get_memory_maxlen()
, the difference being that
the result is not cached here.
TIP
The underscore at the end of this function's name is a convention to remind that its result should be constant.
# Returns
The memory max length.
# _init_memory History
_init_memory(
self,
state: Optional[D.T_state] = None
) -> Memory[D.T_state]
Initialize memory (possibly with a state) according to its specification and return it.
This function is automatically called by Initializable._reset()
to reinitialize the internal memory whenever
the domain is used as an environment.
# Parameters
- state: An optional state to initialize the memory with (typically the initial state).
# Returns
The new initialized memory.