yawning_titan.envs.specific.core.nsa_node_collection#

Classes

NodeCollection

Class representing a collection of nodes for the 18-node Ridley Environment.

class yawning_titan.envs.specific.core.nsa_node_collection.NodeCollection(network, chance_to_spread_during_patch)[source]#

Class representing a collection of nodes for the 18-node Ridley Environment.

__init__(network, chance_to_spread_during_patch)[source]#
get_number_of_nodes()[source]#

Return the number of nodes in the network.

Returns:

The number of nodes in the network (int)

get_observation()[source]#

Get the states of all the nodes in the network.

Returns:

The current state of the environment (numpy array)

Return type:

observation

modify_node(number, changes)[source]#

Change the state of a single node.

Parameters:
  • number – the number of the node to change

  • changes

    a list with two variables in [isolate, compromise] isolate: A boolean that will if true change the isolation status of the node (true -> false,

    false -> true) (boolean)

    compromise: a mode signal that will change the state of a node. 0 does nothing, 1 makes it safe and

    2 compromises the node (int)

get_compromised_nodes()[source]#

Create a list of all the nodes in the network that are compromised.

Returns:

A list of nodes that are compromised (list of ints)

Return type:

compromised_nodes

get_un_compromised_nodes()[source]#

Create a list of all the safe nodes in the network.

Returns:

A list of nodes that are safe (list of ints)

Return type:

un_compromised_nodes

get_isolated_nodes()[source]#

Create a list of all the isolated nodes in the network.

Returns:

A list of nodes that are isolated (list of ints)

Return type:

isolated_nodes

get_number_of_isolated()[source]#

Get the number of isolated nodes in the network.

Returns:

the number of isolated nodes in the network (int)

get_number_of_un_compromised()[source]#

Get the number of safe nodes in the network.

Returns:

the number of safe nodes in the network (int)

get_connected_nodes(number)[source]#

When given a node returns a list of all of the nodes connected to that node.

Parameters:

number – the number of the node to run on

Returns:

a list of all the nodes connected to a specified node (list of ints)

spread(number)[source]#

Spread the red agent through all connected nodes.

Parameters:

number – the number of the node to spread from

calculate_reward()[source]#

Calculate a reward for the current network state.

Returns:

the reward for being in the current state

Return type:

reward

get_netx_graph()[source]#

Get the underlying networkx graph.

Returns:

A networkx graph object

get_netx_pos()[source]#

Get graph positions.