Cypress  1.0
C++ Spiking Neural Network Simulation Framework
Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
cypress::NetworkBase Class Reference

#include <network_base.hpp>

Inheritance diagram for cypress::NetworkBase:
Inheritance graph
[legend]

Public Member Functions

 NetworkBase ()
 
 NetworkBase (std::shared_ptr< internal::NetworkData > impl)
 
 ~NetworkBase ()
 
Loggerlogger () const
 
void logger (Logger &logger)
 
std::shared_ptr< PopulationDatapopulation_data (PopulationIndex pid)
 
std::shared_ptr< const PopulationDatapopulation_data (PopulationIndex pid) const
 
bool operator== (const NetworkBase &o) const
 
bool operator!= (const NetworkBase &o) const
 
NetworkBase clone () const
 
size_t population_count () const
 
size_t population_count (const NeuronType &type) const
 
template<typename T >
size_t population_count () const
 
size_t neuron_count () const
 
size_t neuron_count (const NeuronType &type) const
 
template<typename T >
size_t neuron_count () const
 
PopulationBase population (PopulationIndex pid)
 
const PopulationBase population (PopulationIndex pid) const
 
PopulationBase operator[] (PopulationIndex pid)
 
const PopulationBase operator[] (PopulationIndex pid) const
 
const std::vector< PopulationBasepopulations (const std::string &name=std::string(), const NeuronType &type=NullNeuron::inst()) const
 
const std::vector< PopulationBasepopulations (const NeuronType &type) const
 
PopulationBase population (const std::string &name=std::string())
 
const std::vector< ConnectionDescriptor > & connections () const
 
const ConnectionDescriptorconnection (std::string name) const
 
void update_connection (std::unique_ptr< Connector > connector, const char *name)
 
bool use_lossy_trafos () const
 
void use_lossy_trafos (bool use_lossy) const
 
const std::unordered_set< std::string > & disabled_trafo_ids () const
 
std::unordered_set< std::string > & disabled_trafo_ids ()
 
void run (const Backend &backend, Real duration=0.0)
 
void run (const std::string &backend_id, Real duration=0.0, int argc=0, const char *argv[]=nullptr)
 
Real duration () const
 
NetworkRuntime runtime () const
 
void runtime (const NetworkRuntime &runtime)
 

Static Public Member Functions

static std::unique_ptr< Backendmake_backend (std::string backend_id, int argc=0, const char *argv[]=nullptr, Json setup=Json())
 

Protected Member Functions

void connect (PopulationIndex pid_src, NeuronIndex nid_src0, NeuronIndex nid_src1, PopulationIndex pid_tar, NeuronIndex nid_tar0, NeuronIndex nid_tar1, std::unique_ptr< Connector > connector, const char *name="")
 
PopulationIndex create_population_index (size_t size, const NeuronType &type, const NeuronParameters &params, const NeuronSignals &signals, const std::string &name)
 

Friends

template<typename Impl , typename Accessor >
class PopulationMixin
 
template<typename Impl , typename Accessor , typename Params , typename Signals >
class DataMixin
 
template<typename Impl , typename Accessor >
class ConnectableMixin
 

Detailed Description

The NetworkBase class represents an entire spiking neural network. Note that this class only represents a lightweight handle at the actual network, copying this handle does not create a new network instance. Use the clone() method to create a new NetworkBase instance.

Constructor & Destructor Documentation

cypress::NetworkBase::NetworkBase ( )

Default constructor. Creates a new network.

cypress::NetworkBase::NetworkBase ( std::shared_ptr< internal::NetworkData >  impl)
inline

Creates a network instance with a reference at an already existing network. Used internally.

cypress::NetworkBase::~NetworkBase ( )

Destructor. Destroys this network instance and the handle pointing at underlying network.

Member Function Documentation

NetworkBase cypress::NetworkBase::clone ( ) const

Creates and returns a copy of the network.

void cypress::NetworkBase::connect ( PopulationIndex  pid_src,
NeuronIndex  nid_src0,
NeuronIndex  nid_src1,
PopulationIndex  pid_tar,
NeuronIndex  nid_tar0,
NeuronIndex  nid_tar1,
std::unique_ptr< Connector connector,
const char *  name = "" 
)
protected

Base connection method. Connects a range of neurons in the source population to a range of neurons in the target population. All connection methods in ConnectableMixin are relayed to this method.

Parameters
pid_srcis the index of the source population.
nid_src0is the index of the first neuron in this population that is going to be connected.
nid_src1is the index of the last-plus-one neuron in this population being connected.
pid_taris the index of the target population.
nid_tar0is the index of the first neuron in the target population that is going to be connected.
nid_tar1is the index of the last-plus-one neuron in the target population that is going to be connected.
connectoris a connector which is used to construct the actual neuron-to-neuron connections on demand.
const ConnectionDescriptor& cypress::NetworkBase::connection ( std::string  name) const

Returns a a reference at ConnectionDescriptor instances with name, describing the connection between the individual populations.

Returns
a reference at the first connection stored in the network instance with name
const std::vector<ConnectionDescriptor>& cypress::NetworkBase::connections ( ) const

Returns a a reference at a list of ConnectionDescriptor instances, describing the connections between the individual populations.

Returns
a reference at the internal list of connections stored in the network instance.
PopulationIndex cypress::NetworkBase::create_population_index ( size_t  size,
const NeuronType type,
const NeuronParameters params,
const NeuronSignals signals,
const std::string &  name 
)
protected

Internally used to add a new population. Use the templated public create_population method in the Network class instead.

Parameters
sizeis the number of neurons in the population.
typeis the type of the neurons in the population.
paramscontains the initial neuron parameters. The parameters may be a list of neuron parameters, in which case the size of the list must be equal to the size of the population.
signalscontains the initial flags describing which signals should be recorded. The signals object may contain a list of signal instances, in which case the size of the list must be equal to the size of the population.
nameis the name of the population.
const std::unordered_set<std::string>& cypress::NetworkBase::disabled_trafo_ids ( ) const

Returns the list of currently disabled transformation ids.

std::unordered_set<std::string>& cypress::NetworkBase::disabled_trafo_ids ( )

Returns the list of currently disabled transformation ids.

Real cypress::NetworkBase::duration ( ) const

Returns the duration of the network. The duration is defined as the last spike stored in a SpikeSourceArray.

Returns
the duration of the network in milliseconds.
Logger& cypress::NetworkBase::logger ( ) const

Returns the logger that should be used to log messages related to this network. The "global_logger()" is used per default.

void cypress::NetworkBase::logger ( Logger logger)

Sets a new logger that should be used to log messages related to this network.

static std::unique_ptr<Backend> cypress::NetworkBase::make_backend ( std::string  backend_id,
int  argc = 0,
const char *  argv[] = nullptr,
Json  setup = Json() 
)
static

Returns the backend instance for the given backend string. The backend string may be one of the following:

  • nest: executes the network using the native nest backend
  • pynn.*: executes the network using the given PyNN backend
  • nmpi.*: executes the network using NMPI and the given PyNN backend.
  • nmpi.pynn.*: same as above.
Parameters
backend_idis the id of the backend that should be created.
argcis the number of command line arguments. Needed when the NMPI backend should be used.
argvis the array containing the command line arguments. Needed when the NMPI backend should be used.
setupis an optional Json object which contains backend configuration.
Returns
a pointer at a new backend instance.
size_t cypress::NetworkBase::neuron_count ( ) const

Returns the total number of neurons in the network.

size_t cypress::NetworkBase::neuron_count ( const NeuronType type) const

Returns the number of neurons of a given type.

template<typename T >
size_t cypress::NetworkBase::neuron_count ( ) const
inline

Returns the number of neurons of a certain neuron type.

bool cypress::NetworkBase::operator!= ( const NetworkBase o) const
inline

Compares whether two NetworkBase instances point at different underlying network instances.

bool cypress::NetworkBase::operator== ( const NetworkBase o) const
inline

Compares whether two NetworkBase instances point at the same underlying network.

PopulationBase cypress::NetworkBase::operator[] ( PopulationIndex  pid)
const PopulationBase cypress::NetworkBase::operator[] ( PopulationIndex  pid) const
PopulationBase cypress::NetworkBase::population ( PopulationIndex  pid)

Returns a PopulationBase instance pointing at the population with the given index.

const PopulationBase cypress::NetworkBase::population ( PopulationIndex  pid) const
PopulationBase cypress::NetworkBase::population ( const std::string &  name = std::string())

Returns a Population object pointing at the last created population with the given name. If no such population exists, an exception is thrown.

Parameters
nameis the name of the population that should be looked up. If empty, the last created population is returned.
Returns
a population handle pointing at the requested population.
size_t cypress::NetworkBase::population_count ( ) const

Returns the number of created populations.

size_t cypress::NetworkBase::population_count ( const NeuronType type) const

Returns the number of populations of a certain neuron type.

template<typename T >
size_t cypress::NetworkBase::population_count ( ) const
inline

Returns the number of populations of a certain neuron type.

std::shared_ptr<PopulationData> cypress::NetworkBase::population_data ( PopulationIndex  pid)

Returns the raw population data associated with the given population index. Try to avoid using this function directly. Proper use cases are network transformations.

Parameters
pidis the index of the population for which a reference at the internal data should be returned.
std::shared_ptr<const PopulationData> cypress::NetworkBase::population_data ( PopulationIndex  pid) const

Returns the raw population data associated with the given population index. Try to avoid using this function directly. Proper use cases are network transformations.

Parameters
pidis the index of the population for which a reference at the internal data should be returned.
const std::vector<PopulationBase> cypress::NetworkBase::populations ( const std::string &  name = std::string(),
const NeuronType type = NullNeuron::inst() 
) const

Returns a list of populations available in the network, filtered by the given name and type.

Parameters
nameis the name the returned populations should be filtered by. If an empty string is given, no filtering is performed (default).
typeis the neuron type the list should be filtered for. If a pointer at the special NullNeuron instance is given, no filtering by type is performed (default).
Returns
a list of PopulationBase instances, pointing at the populations matching the given requirements.
const std::vector<PopulationBase> cypress::NetworkBase::populations ( const NeuronType type) const

Returns a list of populations filtered by the given neuron type.

Parameters
typeis the neuron type the list should be filtered for. If a pointer at the special NullNeuron instance is given, no filtering by type is performed (default).
Returns
a list of PopulationBase instances, pointing at the populations matching the given requirements.
void cypress::NetworkBase::run ( const Backend backend,
Real  duration = 0.0 
)

Executes the network on the given backend and stores the results in the population objects. This function is simply a wrapper for Backend.run(). If there is an error during execution, the run function will throw a exception.

Parameters
backendis a reference at the backend instance the network should be executed on.
durationis the simulation-time. If a value smaller or equal to zero is given, the simulation time is automatically chosen.
void cypress::NetworkBase::run ( const std::string &  backend_id,
Real  duration = 0.0,
int  argc = 0,
const char *  argv[] = nullptr 
)

Executes the network on the given backend and stores the results in the population objects. This function is simply a wrapper for Backend.run(). If there is an error during execution, the run function will throw a exception.

Parameters
backend_idis a string describing the backend instance. See make_backend() for more information on available backend strings.
argcis the number of command line arguments. Needed when the NMPI backend should be used.
argvis the array containing the command line arguments. Needed when the NMPI backend should be used.
durationis the simulation-time. If a value smaller or equal to zero is given, the simulation time is automatically chosen.
NetworkRuntime cypress::NetworkBase::runtime ( ) const

Returns information about the network runtime. Behaviour is undefined if the network has not yet been executed.

void cypress::NetworkBase::runtime ( const NetworkRuntime runtime)

Allows to set the runtime information to the given values.

void cypress::NetworkBase::update_connection ( std::unique_ptr< Connector connector,
const char *  name 
)

Change the connector from an existing connection.

Parameters
connectorThe new connector
nameName tag of the target connection
bool cypress::NetworkBase::use_lossy_trafos ( ) const

Returns the state of the "use_lossy_trafos" flag. If true, applies possibly lossy transformations to the network in order to run it on the target platform. The default value is "true".

void cypress::NetworkBase::use_lossy_trafos ( bool  use_lossy) const

Sets the "use_lossy_trafos" flag. If true, allows to apply lossy transformations to allow running a network on the target platform. The defautl value is "true".

Friends And Related Function Documentation

template<typename Impl , typename Accessor >
friend class ConnectableMixin
friend
template<typename Impl , typename Accessor , typename Params , typename Signals >
friend class DataMixin
friend
template<typename Impl , typename Accessor >
friend class PopulationMixin
friend

The documentation for this class was generated from the following file: