yawning_titan.envs.generic.wrappers.graph_embedding_observations#

Classes

FeatherGraphEmbedObservation

Gym Observation Space Wrapper that embeds the underlying environment graph using the Feather-G algorithm.

class yawning_titan.envs.generic.wrappers.graph_embedding_observations.FeatherGraphEmbedObservation(env, max_num_nodes=100)[source]#

Gym Observation Space Wrapper that embeds the underlying environment graph using the Feather-G algorithm.

This wrapper uses the Feather-G Whole Graph embedding algorithm to embed the underlying environment graph and then re-creates the observation space to include the embedding and all other observation space settings from the configuration file.

Initialise a Feather-G observation space wrapper.

Parameters:
  • env – the OpenAI Gym environment to be wrapped

  • max_num_nodes – the maximum number of nodes required to be supported in the observation space

Note

The max_num_nodes is for defining the maximum number of nodes you want the agent to support within its observation space. This is in order to support the training of agents which can work across a number of YAWNING TITAN environments with variable node counts.

For example, if set to 100 (like the default), the agent could be trained in an environment with 10 nodes, 50 nodes or 100 nodes.

__init__(env, max_num_nodes=100)[source]#

Initialise a Feather-G observation space wrapper.

Parameters:
  • env – the OpenAI Gym environment to be wrapped

  • max_num_nodes – the maximum number of nodes required to be supported in the observation space

Note

The max_num_nodes is for defining the maximum number of nodes you want the agent to support within its observation space. This is in order to support the training of agents which can work across a number of YAWNING TITAN environments with variable node counts.

For example, if set to 100 (like the default), the agent could be trained in an environment with 10 nodes, 50 nodes or 100 nodes.

observation(observation)[source]#

Observation Transformation Function.

  1. Generates a networkx graph object from the current adjacency matrix

  2. Collects the current vulnerability scores and node status’s

  3. Pads the returned arrays to ensure length is 100 (currently arbitrarily set)

  4. Embeds the networkx graph using the Feather Graph algorithm from Karateclub

  5. Concatenates the graph embedding, padded vulnerability scores and padded node status’s together

  6. Returns new observation

Parameters:

observation – The base, unwrapped observation generated by the environment

Returns:

A newly formatted environment observation

make_embedding()[source]#

Create a FeaterGraph embedding from the inputted NetworkX graph.

Returns:

A numpy array containing the Feather embedding