dynsimf.models.components package

Subpackages

Submodules

dynsimf.models.components.Memory module

class dynsimf.models.components.Memory.MemoryConfiguration(memory_type, cfg=None)

Bases: object

A configuration for storing and writing utility/states/graphs

Variables:
  • memory_type (MemoryConfigurationType) – Indicates what type the config specifies using the MemoryConfigurationType enum

  • save_disk (bool) – A boolean indicating whether to save the states to the disk, defaults to False

  • memory_size (int) – The amount of iterations to keep in memory, -1 to not keep any, 0 to store every iteration, defaults to -1

  • save_interval (int) – The amount of iterations between a save, defaults to 0

  • memory_interval (int) – The amount of iterations between the storing of memory, defaults to 1

  • path (str) – If save_disk is set, the path to save the data to, defaults to: ./output/memory_type_name.txt where memory_type_name is the name of the memory type enum

get_description_string(n, rows, cols)

Returns a description for the output when writing to disk

Parameters:
  • n (int) – Total amount of simulation iterations

  • rows (int) – Amount of rows to write per iteration

  • cols (int) – Amount of columns to write per iteration

Returns:

A string containing data about the output that can be read in to parse the information after

Return type:

str

validate()

Validate the memory configuration

Raises:
  • ValueError – if any of the members does not match their specified type

  • ValueError – if the save interval is negative when the save_disk member is set to True

  • ValueError – if the memory_interval member is less than -1

class dynsimf.models.components.Memory.MemoryConfigurationType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

Enumeration for the type of the memory configuration

ADJACENCY = 1
EDGE_VALUES = 3
STATE = 0
UTILITY = 2

dynsimf.models.components.PropertyFunction module

class dynsimf.models.components.PropertyFunction.PropertyFunction(name, function, iteration_interval, params)

Bases: object

Class used to specify property functions, that are meta analysis functions that can be ran during any iteration to run custom values.

E.g: Calculate the network cluster coeffecient every 5 iterations

execute()

Executes the function with the specified arguments and returns the result

Returns:

The result of the property function

dynsimf.models.components.Scheme module

class dynsimf.models.components.Scheme.Scheme(sample_function: Callable, config: dict)

Bases: object

A class used to select iteration bounds for an update and to sample a select amount of nodes to apply updates on

Variables:
  • sample_function (function) – The sample function to select the nodes to apply the updates on

  • args (dict) – The arguments to provide for the sample function, defaults to an empty dictionary

  • lower_bound (int or None) – The lower bound of the updates to be executed, defaults to None

  • upper_bound (int or None) – The upper bound of the updates to be executed, defaults to None

  • updates (list) – A list of Update objects, defaults to empty list

add_update(update: Update) None

Add a Update object to the list of updates of the scheme

Parameters:

update (Update) – The update to add to the list of updates

sample()

Run the sample function with the configured arguments and return the result

Returns:

A list of nodes sampled by the sample_function member

Return type:

list

set_bounds(lower: int, upper: int) None

Set the bounds of the scheme

Parameters:
  • lower (int) – The lower bound to set

  • upper (int) – The upper bound to set

validate()

Validate the config using the ConfigValidator class

Raises:

ValueError – if any member does not match its type or range

dynsimf.models.components.Update module

class dynsimf.models.components.Update.Update(fun, config=None)

Bases: object

Update class

Variables:
  • fun (function) – The update function that should be executed

  • config (UpdateConfiguration) – UpdateConfiguration object, defaults to a new UpdateConfiguration object

  • arguments (dict) – A dictionary with arguments for the update function, defaults to empty dict

  • condition (Condition or None) – A condition for nodes that must be met before the update is executed on them

  • get_nodes – A boolean indicating whether the update function should receive a list of sampled nodes as argument, defaults to None

  • update_type (UpdateType) – A value from the UpdateType enum, indicating what kind of update is being performed, defaults to UpdateType.STATE

execute(nodes=None)

Execute the update function with or without the sampled nodes from the scheme/condition and return the output

Parameters:

nodes (list, optional) – An optional list of nodes that the update function should be applied on. The given nodes are filtered by the schemes and conditions

class dynsimf.models.components.Update.UpdateConfiguration(config=None)

Bases: object

Configuration for Updates

Variables:
  • config (dict) – The dictionary containing the key/value pairs of the members of this class, if no key/value pair is provided, a default value is used instead

  • arguments (dict) – A dictionary with arguments for the update function, defaults to empty dict

  • condition (Condition or None) – A condition for nodes that must be met before the update is executed on them

  • get_nodes – A boolean indicating whether the update function should receive a list of sampled nodes as argument, defaults to None

  • update_type (UpdateType) – A value from the UpdateType enum, indicating what kind of update is being performed, defaults to UpdateType.STATE

set_config(config)

Set the values for the members of the class by reading them from the config or setting their default values

Parameters:

config (dict) – The configuration dictionary with the key/value pairs for the class members

validate()

Validate the update configuration

Raises:

ValueError – if the update_type member is not of type UpdateType

class dynsimf.models.components.Update.UpdateType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

An Enum to specify the type of the update

EDGE_VALUES = 2
NETWORK = 1
STATE = 0

Module contents