yawning_titan.envs.generic.generic_env#

A generic class that creates Open AI environments within YAWNING TITAN.

This class has several key inputs which determine aspects of the environment such as how the red agent behaves, what the red team and blue team objectives are, the size and topology of the network being defended and what data should be collected during the simulation.

Classes

GenericNetworkEnv

Class to create a generic YAWNING TITAN gym environment.

class yawning_titan.envs.generic.generic_env.GenericNetworkEnv(red_agent, blue_agent, network_interface, print_metrics=False, show_metrics_every=1, collect_additional_per_ts_data=True, print_per_ts_data=False)[source]#

Class to create a generic YAWNING TITAN gym environment.

Initialise the generic network environment.

Parameters:
  • red_agent – Object from the RedInterface class

  • blue_agent – Object from the BlueInterface class

  • network_interface – Object from the NetworkInterface class

  • print_metrics – Whether or not to print metrics (boolean)

  • show_metrics_every – Number of timesteps to show summary metrics (int)

  • collect_additional_per_ts_data – Whether or not to collect additional per timestep data (boolean)

  • print_per_ts_data – Whether or not to print collected per timestep data (boolean)

Note: The notes variable returned at the end of each timestep contains the per timestep data. By default it contains a base level of info required for some of the reward functions. When collect_additional_per_ts_data is toggled on, a lot more data is collected.

__init__(red_agent, blue_agent, network_interface, print_metrics=False, show_metrics_every=1, collect_additional_per_ts_data=True, print_per_ts_data=False)[source]#

Initialise the generic network environment.

Parameters:
  • red_agent – Object from the RedInterface class

  • blue_agent – Object from the BlueInterface class

  • network_interface – Object from the NetworkInterface class

  • print_metrics – Whether or not to print metrics (boolean)

  • show_metrics_every – Number of timesteps to show summary metrics (int)

  • collect_additional_per_ts_data – Whether or not to collect additional per timestep data (boolean)

  • print_per_ts_data – Whether or not to print collected per timestep data (boolean)

Note: The notes variable returned at the end of each timestep contains the per timestep data. By default it contains a base level of info required for some of the reward functions. When collect_additional_per_ts_data is toggled on, a lot more data is collected.

reset()[source]#

Reset the environment to the default state.

Todo:

May need to add customization of cuda setting.

Returns:

A new starting observation (numpy array).

step(action)[source]#

Take a time step and executes the actions for both Blue RL agent and non-learning Red agent.

Parameters:

action – The action value generated from the Blue RL agent (int)

Returns:

A four tuple containing the next observation as a numpy array, the reward for that timesteps, a boolean for whether complete and additional notes containing timestep information from the environment.

render(mode='human', show_only_blue_view=False, show_node_names=False)[source]#

Render the environment using Matplotlib to create an animation.

Parameters:
  • mode – the mode of the rendering

  • show_only_blue_view – If true shows only what the blue agent can see

  • show_node_names – Show the names of the nodes

calculate_observation_space_size(with_feather)[source]#

Calculate the observation space size.

This is done using the current active observation space configuration and the number of nodes within the environment.

Parameters:

with_feather – Whether to include the size of the Feather Wrapper output

Returns:

The observation space size