Observation¶
-
class
nasim.envs.observation.
Observation
(state_shape)¶ An observation for NASim.
Each observation is a 2D tensor with a row for each host and an additional row containing auxiliary observations. Each host row is a host_vector (for details see
HostVector
) while the auxiliary row contains non-host specific observations (see Notes section).…
-
obs_shape
¶ the shape of the observation
Type: (int, int)
-
aux_row
¶ the row index for the auxiliary row
Type: int
-
tensor
¶ 2D Numpy array storing the observation
Type: numpy.ndarray
Notes
The auxiliary row is the final row in the observation tensor and has the following features (in order):
- Action success - True (1) or False (0)
- indicates whether the action succeeded or failed
- Connection error - True (1) or False (0)
- indicates whether there was a connection error or not
- Permission error - True (1) or False (0)
- indicates whether there was a permission error or not
- Undefined error - True (1) or False (0)
- indicates whether there was an undefined error or not (e.g. failure due to stochastic nature of exploits)
Since the number of features in the auxiliary row is less than the number of features in each host row, the remainder of the row is all zeros.
-
__init__
(state_shape)¶ Parameters: state_shape ((int, int)) – 2D shape of the state (i.e. num_hosts, host_vector_size)
-
connection_error
¶ Whether there was a connection error or not
Returns: True if there was a connection error, otherwise False Return type: bool
-
get_readable
()¶ Get a human readable version of the observation
Returns: - list[dict] – list of host observations as human-readable dictionary
- dict[str, bool] – auxiliary observation dictionary
-
numpy
()¶ Get the observation tensor
Returns: the (2D) observation tenser Return type: numpy.ndarray
-
numpy_flat
()¶ Get the flattened observation tensor
Returns: the flattened (1D) observation tenser Return type: numpy.ndarray
-
permission_error
¶ Whether there was a permission error or not
Returns: True if there was a permission error, otherwise False Return type: bool
-
shape
()¶ Get the (2D) shape of the observation
Returns: the 2D shape of the observation Return type: (int, int)
-
shape_flat
()¶ Get the flat (1D) shape of the Observation.
Returns: the flattened shape of observation Return type: (int, )
-
success
¶ Whether the action succeded or not
Returns: True if the action succeeded, otherwise False Return type: bool
-
undefined_error
¶ Whether there was an undefined error or not
Returns: True if there was a undefined error, otherwise False Return type: bool
-