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::Network Class Reference

#include <network.hpp>

Inheritance diagram for cypress::Network:
Inheritance graph
[legend]
Collaboration diagram for cypress::Network:
Collaboration graph
[legend]

Public Member Functions

 Network ()=default
 
 Network (const Network &)=default
 
 Network (Network &&) noexcept=default
 
Networkoperator= (const Network &)=default
 
Networkoperator= (Network &&)=default
 
 ~Network ()=default
 
 Network (const NetworkBase &network)
 
Networkoperator= (const NetworkBase &o)
 
template<typename T >
std::vector< Population< T > > populations (const std::string &name=std::string())
 
PopulationBase population (const std::string &name=std::string())
 
template<typename T >
Population< T > population (const std::string &name=std::string())
 
template<typename T >
Population< T > create_population (size_t size, const typename T::Parameters &params, const typename T::Signals &signals, const char *name="")
 
template<typename T >
Population< T > create_population (size_t size, const typename T::Parameters &params=typename T::Parameters(), const char *name="")
 
template<typename T >
Networkadd_population (const char *name, size_t size, const typename T::Parameters &params, const typename T::Signals &signals=typename T::Signals())
 
template<typename Source , typename Target >
Networkadd_connection (const Source &source, const Target &target, std::unique_ptr< Connector > connector, const char *name="")
 
Networkrun (const Backend &backend, Real duration=0.0)
 
Networkrun (const std::string &backend_id, Real duration=0.0, int argc=0, const char *argv[]=nullptr)
 
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
 
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 ()
 
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 T >
class Population
 

Detailed Description

Class representing the entire spiking neural network.

Constructor & Destructor Documentation

cypress::Network::Network ( )
default
cypress::Network::Network ( const Network )
default
cypress::Network::Network ( Network &&  )
defaultnoexcept
cypress::Network::~Network ( )
default
cypress::Network::Network ( const NetworkBase network)
inline

Allow creation of a network instance from a NetworkBase instance.

Member Function Documentation

template<typename Source , typename Target >
Network& cypress::Network::add_connection ( const Source &  source,
const Target &  target,
std::unique_ptr< Connector connector,
const char *  name = "" 
)
inline
template<typename T >
Network& cypress::Network::add_population ( const char *  name,
size_t  size,
const typename T::Parameters &  params,
const typename T::Signals &  signals = typename T::Signals() 
)
inline
NetworkBase cypress::NetworkBase::clone ( ) const
inherited

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 = "" 
)
protectedinherited

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
inherited

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
inherited

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.
template<typename T >
Population<T> cypress::Network::create_population ( size_t  size,
const typename T::Parameters &  params,
const typename T::Signals &  signals,
const char *  name = "" 
)
inline
template<typename T >
Population<T> cypress::Network::create_population ( size_t  size,
const typename T::Parameters &  params = typename T::Parameters(),
const char *  name = "" 
)
inline
PopulationIndex cypress::NetworkBase::create_population_index ( size_t  size,
const NeuronType type,
const NeuronParameters params,
const NeuronSignals signals,
const std::string &  name 
)
protectedinherited

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
inherited

Returns the list of currently disabled transformation ids.

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

Returns the list of currently disabled transformation ids.

Real cypress::NetworkBase::duration ( ) const
inherited

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
inherited

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)
inherited

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() 
)
staticinherited

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
inherited

Returns the total number of neurons in the network.

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

Returns the number of neurons of a given type.

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

Returns the number of neurons of a certain neuron type.

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

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

Network& cypress::Network::operator= ( const Network )
default
Network& cypress::Network::operator= ( Network &&  )
default
Network& cypress::Network::operator= ( const NetworkBase o)
inline

Allow assigning a NetworkBase instance to a Network instance.

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

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

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

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

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

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

Template Parameters
Tis the neuron type of the population that should be returned.
Parameters
nameis the name of the population that should be looked up. If empty, the last created population of the given type is returned.
Returns
a population handle pointing at the requested population.
template<typename T >
Population<T> cypress::Network::population ( const std::string &  name = std::string())
inline

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

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

Returns the number of created populations.

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

Returns the number of populations of a certain neuron type.

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

Returns the number of populations of a certain neuron type.

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

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
inherited

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
inherited

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
inherited

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.
template<typename T >
std::vector<Population<T> > cypress::Network::populations ( const std::string &  name = std::string())
inline

Returns population objects pointing at the population with the given name.

Template Parameters
Tis the neuron type of the population that should be returned.
Parameters
nameis the name of the population that is being searched for. If empty, all populations are matched.
Returns
a vector of population objects.
Network& cypress::Network::run ( const Backend backend,
Real  duration = 0.0 
)
inline

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.
Returns
a reference at this network for method chaining.
Network& cypress::Network::run ( const std::string &  backend_id,
Real  duration = 0.0,
int  argc = 0,
const char *  argv[] = nullptr 
)
inline

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. 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 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.
Returns
a reference at this network for method chaining.
NetworkRuntime cypress::NetworkBase::runtime ( ) const
inherited

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

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

Allows to set the runtime information to the given values.

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

Change the connector from an existing connection.

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

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
inherited

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 T >
friend class Population
friend

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