network module

class network.Network[source]

Bases: object

Cortix network.

num_networks

int – Number of instances of this class.

__init__()[source]

Module super class constructor.

max_n_modules_for_data_copy_on_root

int – When using MPI the network will copy the data from all modules on the root process. This can generate an out of memory condition. This variable sets the maximum number of processes for which the data will be copied. Default is 1000.

add_module(m)[source]

Alternative name to module().

connect(module_port_a, module_port_b, info=None)[source]

Connect two modules using either their ports directly or inferred ports.

A connection always opens a channel for data communication in both ways. That is, both sends and receives are allowed.

Note

The simplest form of usage is with arguments: (module_a, module_b). In this case, a port with the name of module_a must exist in module_b, and vice-versa (port names as str in lower case). In addition, the connect must not be called again with these same two modules, else the underlying connection will be overriden.

For more rigorous connection, the user is advised to fully specify the module and the port in each list argument.

Parameters:
  • module_port_a (list([Module,Port]) or list([Module,str]) or Module) – First module-port to connect.
  • module_port_b (list([Module,Port]) or list([Module,str]) or Module) – Second module-port to connect.
  • info (str) – Information on the directionality of the information flow. This is for graph visualization purposes only. The default value will use the order in the argument list to define the direction. Default: None. If set to bidiretional, will create a double headed arrow in the graph figure.
draw(graph_attr=None, node_attr=None, engine='twopi', lr=False, ports=False, node_shape='hexagon')[source]
module(m)[source]

Add a module.

num_networks = 0
run()[source]

Run the network simulation.

This function concurrently executes the cortix.src.module.run function for each module in the network. Modules are run using either MPI or Multiprocessing, depending on the user configuration.

Note

When using multiprocessing, data from the modules state are copied to the master process after the run() method of the modules is finished.