Kaspersky Neuromorphic Platform  1.0.0
API Reference
Loading...
Searching...
No Matches
knp::framework::Network Class Reference

The Network class is a definition of a neural network that contains populations and projections. More...

#include <knp/framework/network.h>

+ Collaboration diagram for knp::framework::Network:

Public Types

using AllPopulations = boost::mp11::mp_transform<knp::core::Population, knp::neuron_traits::AllNeurons>
 List of population types based on neuron types specified in knp::neuron_traits::AllNeurons.
 
using AllProjections = boost::mp11::mp_transform<knp::core::Projection, knp::synapse_traits::AllSynapses>
 List of projection types based on synapse types specified in knp::synapse_traits::AllSynapses.
 
using AllPopulationVariants = boost::mp11::mp_rename<AllPopulations, std::variant>
 Population variant that contains any population type specified in AllPopulations.
 
using AllProjectionVariants = boost::mp11::mp_rename<AllProjections, std::variant>
 Projection variant that contains any projection type specified in AllProjections.
 
using PopulationContainer = std::vector<core::AllPopulationsVariant>
 Type of population container.
 
using ProjectionContainer = std::vector<core::AllProjectionsVariant>
 Type of projection container.
 
using PopulationIterator = PopulationContainer::iterator
 Types of population iterators.
 
using PopulationConstIterator = PopulationContainer::const_iterator
 Types of constant population iterators.
 
using ProjectionIterator = ProjectionContainer::iterator
 Types of projection iterators.
 
using ProjectionConstIterator = ProjectionContainer::const_iterator
 Types of constant projection iterators.
 

Public Member Functions

 Network ()=default
 Default network constructor.
 
 Network (const core::UID &uid)
 Network constructor with pre-defined UID.
 
void add_population (core::AllPopulationsVariant &&population)
 Add a population to the network.
 
template<typename PopulationType >
void add_population (typename std::decay< PopulationType >::type &&population)
 Add a population to the network.
 
template<typename PopulationType >
void add_population (typename std::decay< PopulationType >::type &population)
 Add a population to the network.
 
bool is_population_exists (const knp::core::UID &population_uid) const
 Check if population exists.
 
template<typename NeuronType >
knp::core::Population< NeuronType > & get_population (const knp::core::UID &population_uid)
 Get a population with the given UID from the network.
 
template<typename NeuronType >
const knp::core::Population< NeuronType > & get_population (const knp::core::UID &population_uid) const
 Get a population with the given UID from the network.
 
core::AllPopulationsVariantget_population (const knp::core::UID &population_uid)
 Get a population with the given UID from the network.
 
void remove_population (const knp::core::UID &population_uid)
 Remove a population with the given UID from the network.
 
void add_projection (core::AllProjectionsVariant &&projection)
 Add a projection to the network.
 
template<typename ProjectionType >
void add_projection (typename std::decay< ProjectionType >::type &&projection)
 Add a projection to the network.
 
template<typename ProjectionType >
void add_projection (typename std::decay< ProjectionType >::type &projection)
 Add a projection to the network.
 
template<typename SynapseType >
void add_projection (knp::core::UID projection_uid, knp::core::UID pre_population_uid, knp::core::UID post_population_uid, typename knp::core::Projection< SynapseType >::SynapseGenerator generator, size_t synapse_count)
 Add a projection to the network.
 
bool is_projection_exists (const knp::core::UID &projection_uid) const
 Check if projection exists.
 
template<typename SynapseType >
knp::core::Projection< SynapseType > & get_projection (const knp::core::UID &projection_uid)
 Get a projection with the given UID from the network.
 
template<typename SynapseType >
const knp::core::Projection< SynapseType > & get_projection (const knp::core::UID &projection_uid) const
 Get a projection with the given UID from the network.
 
core::AllProjectionsVariantget_projection (const knp::core::UID &projection_uid)
 Get a projection with the given UID from the network.
 
void remove_projection (const knp::core::UID &projection_uid)
 Remove a projection with the given UID from the network.
 
template<typename SynapseType , typename SourceNeuronType , typename DestinationNeuronType >
knp::core::UID connect_populations (const core::Population< SourceNeuronType > &src, const core::Population< DestinationNeuronType > &dst, typename projection::parameters_generators::SynGen2ParamsType< SynapseType > syn_gen=projection::parameters_generators::default_synapse_gen< SynapseType >)
 Connect presynaptic and postsynaptic populations and add projection to the network.
 
template<typename SynapseType , typename SourceNeuronType , typename DestinationNeuronType >
knp::core::UID connect_populations (const core::Population< SourceNeuronType > &src, const core::Population< DestinationNeuronType > &dst, typename knp::core::Projection< SynapseType >::SynapseGenerator syn_gen, size_t num_iterations)
 Connect presynaptic and postsynaptic populations and add projection to the network.
 
PopulationIterator begin_populations ()
 Get an iterator pointing to the first element of the population.
 
PopulationConstIterator begin_populations () const
 Get an iterator pointing to the first element of the population.
 
PopulationIterator end_populations ()
 Get an iterator pointing to the last element of the population.
 
PopulationConstIterator end_populations () const
 Get an iterator pointing to the last element of the population.
 
ProjectionIterator begin_projections ()
 Get an iterator pointing to the first element of the projection.
 
ProjectionConstIterator begin_projections () const
 Get an iterator pointing to the first element of the projection.
 
ProjectionIterator end_projections ()
 Get an iterator pointing to the last element of the projection.
 
ProjectionConstIterator end_projections () const
 Get an iterator pointing to the last element of the projection.
 
const PopulationContainerget_populations () const
 Get population container from the network.
 
const ProjectionContainerget_projections () const
 Get projection container from the network.
 
size_t populations_count () const
 Count populations in the network.
 
size_t projections_count () const
 Count projections in the network.
 
const knp::core::UIDget_uid () const
 Get network UID.
 
auto & get_tags ()
 Get tags used by the network.
 

Detailed Description

The Network class is a definition of a neural network that contains populations and projections.

Definition at line 52 of file network.h.

Member Typedef Documentation

◆ AllPopulations

List of population types based on neuron types specified in knp::neuron_traits::AllNeurons.

AllPopulations takes the value of Population<NeuronType_1>, Population<NeuronType_2>, ..., Population<NeuronType_n>, where NeuronType_[1..n] is the neuron type specified in knp::neuron_traits::AllNeurons.
For example, if knp::neuron_traits::AllNeurons contains BLIFATNeuron and IzhikevichNeuron types, then AllPopulations = Population<BLIFATNeuron>, Population<IzhikevichNeuron>.

Definition at line 62 of file network.h.

◆ AllPopulationVariants

using knp::framework::Network::AllPopulationVariants = boost::mp11::mp_rename<AllPopulations, std::variant>

Population variant that contains any population type specified in AllPopulations.

AllPopulationVariants takes the value of std::variant<PopulationType_1,..., PopulationType_n>, where PopulationType_[1..n] is the population type specified in AllPopulations.
For example, if AllPopulations contains BLIFATNeuron and IzhikevichNeuron types, then AllPopulationVariants = std::variant<BLIFATNeuron, IzhikevichNeuron>.
AllPopulationVariants retains the same order of message types as defined in AllPopulations.

See also
ALL_NEURONS.

Definition at line 83 of file network.h.

◆ AllProjections

List of projection types based on synapse types specified in knp::synapse_traits::AllSynapses.

AllProjections takes the value of Projection<SynapseType_1>, Projection<SynapseType_2>, ..., Projection<SynapseType_n>, where SynapseType_[1..n] is the synapse type specified in knp::synapse_traits::AllSynapses.
For example, if knp::synapse_traits::AllSynapses contains DeltaSynapse and AdditiveSTDPSynapse types, then AllProjections = Population<DeltaSynapse>, Population<AdditiveSTDPSynapse>.

Definition at line 72 of file network.h.

◆ AllProjectionVariants

using knp::framework::Network::AllProjectionVariants = boost::mp11::mp_rename<AllProjections, std::variant>

Projection variant that contains any projection type specified in AllProjections.

AllProjectionVariants takes the value of std::variant<ProjectionType_1,..., ProjectionType_n>, where ProjectionType_[1..n] is the projection type specified in AllProjections.
For example, if AllProjections contains DeltaSynapse and AdditiveSTDPSynapse types, then AllProjectionVariants = std::variant<DeltaSynapse, AdditiveSTDPSynapse>.
AllProjectionVariants retains the same order of message types as defined in AllProjections.

See also
ALL_SYNAPSES.

Definition at line 93 of file network.h.

◆ PopulationConstIterator

using knp::framework::Network::PopulationConstIterator = PopulationContainer::const_iterator

Types of constant population iterators.

Definition at line 112 of file network.h.

◆ PopulationContainer

Type of population container.

Definition at line 99 of file network.h.

◆ PopulationIterator

using knp::framework::Network::PopulationIterator = PopulationContainer::iterator

Types of population iterators.

Definition at line 108 of file network.h.

◆ ProjectionConstIterator

using knp::framework::Network::ProjectionConstIterator = ProjectionContainer::const_iterator

Types of constant projection iterators.

Definition at line 121 of file network.h.

◆ ProjectionContainer

Type of projection container.

Definition at line 103 of file network.h.

◆ ProjectionIterator

using knp::framework::Network::ProjectionIterator = ProjectionContainer::iterator

Types of projection iterators.

Definition at line 117 of file network.h.

Constructor & Destructor Documentation

◆ Network()

knp::framework::Network::Network ( const core::UID & uid)
inlineexplicit

Network constructor with pre-defined UID.

Parameters
uidnetwork UID.

Definition at line 133 of file network.h.

Member Function Documentation

◆ add_population() [1/3]

void knp::framework::Network::add_population ( core::AllPopulationsVariant && population)

Add a population to the network.

Parameters
populationpopulation to add.

◆ add_population() [2/3]

template<typename PopulationType >
void knp::framework::Network::add_population ( typename std::decay< PopulationType >::type && population)

Add a population to the network.

Template Parameters
PopulationTypetype of population to add (derived automatically from population if not specified).
Parameters
populationpopulation to add.

◆ add_population() [3/3]

template<typename PopulationType >
void knp::framework::Network::add_population ( typename std::decay< PopulationType >::type & population)

Add a population to the network.

Template Parameters
PopulationTypetype of population to add (derived automatically from population if not specified).
Parameters
populationpopulation to add.

◆ add_projection() [1/4]

void knp::framework::Network::add_projection ( core::AllProjectionsVariant && projection)

Add a projection to the network.

Parameters
projectionprojection to add.

◆ add_projection() [2/4]

template<typename SynapseType >
void knp::framework::Network::add_projection ( knp::core::UID projection_uid,
knp::core::UID pre_population_uid,
knp::core::UID post_population_uid,
typename knp::core::Projection< SynapseType >::SynapseGenerator generator,
size_t synapse_count )

Add a projection to the network.

Template Parameters
SynapseTypetype of projection synapses.
Parameters
projection_uidUID of projection to add.
generatorsynapse generator.
pre_population_uidUID of the presynaptic population.
post_population_uidUID of the postsynaptic population.
synapse_countnumber of projection synapses.

◆ add_projection() [3/4]

template<typename ProjectionType >
void knp::framework::Network::add_projection ( typename std::decay< ProjectionType >::type && projection)

Add a projection to the network.

Template Parameters
ProjectionTypetype of projection to add (derived automatically from projection if not specified).
Parameters
projectionprojection to add.

◆ add_projection() [4/4]

template<typename ProjectionType >
void knp::framework::Network::add_projection ( typename std::decay< ProjectionType >::type & projection)

Add a projection to the network.

Template Parameters
ProjectionTypetype of projection to add (derived automatically from projection if not specified).
Parameters
projectionprojection to add.

◆ begin_populations() [1/2]

PopulationIterator knp::framework::Network::begin_populations ( )
nodiscard

Get an iterator pointing to the first element of the population.

Returns
population iterator.

◆ begin_populations() [2/2]

PopulationConstIterator knp::framework::Network::begin_populations ( ) const
nodiscard

Get an iterator pointing to the first element of the population.

Returns
constant population iterator.

◆ begin_projections() [1/2]

ProjectionIterator knp::framework::Network::begin_projections ( )
nodiscard

Get an iterator pointing to the first element of the projection.

Returns
projection iterator.

◆ begin_projections() [2/2]

ProjectionConstIterator knp::framework::Network::begin_projections ( ) const
nodiscard

Get an iterator pointing to the first element of the projection.

Returns
constant projection iterator.

◆ connect_populations() [1/2]

template<typename SynapseType , typename SourceNeuronType , typename DestinationNeuronType >
knp::core::UID knp::framework::Network::connect_populations ( const core::Population< SourceNeuronType > & src,
const core::Population< DestinationNeuronType > & dst,
typename knp::core::Projection< SynapseType >::SynapseGenerator syn_gen,
size_t num_iterations )
inline

Connect presynaptic and postsynaptic populations and add projection to the network.

Template Parameters
SourceNeuronTypetype of the presynaptic population neuron.
DestinationNeuronTypetype of the postsynaptic population neuron.
SynapseTypenew projection synapse type.
Parameters
srcpresynaptic population.
dstpostsynaptic population.
syn_gensynapse generator.
num_iterationsnumber of iterations.
Returns
new projection UID.

Definition at line 312 of file network.h.

◆ connect_populations() [2/2]

template<typename SynapseType , typename SourceNeuronType , typename DestinationNeuronType >
knp::core::UID knp::framework::Network::connect_populations ( const core::Population< SourceNeuronType > & src,
const core::Population< DestinationNeuronType > & dst,
typename projection::parameters_generators::SynGen2ParamsType< SynapseType > syn_gen = projection::parameters_generators::default_synapse_gen<SynapseType> )
inline

Connect presynaptic and postsynaptic populations and add projection to the network.

The method makes connections between each presynaptic population (source) neuron to each postsynaptic population (destination) neuron.

Template Parameters
SourceNeuronTypetype of the presynaptic population neuron.
DestinationNeuronTypetype of the postsynaptic population neuron.
SynapseTypenew projection synapse type.
Parameters
srcpresynaptic population.
dstpostsynaptic population.
syn_gensynapse parameters generator.
Returns
new projection UID.

Definition at line 285 of file network.h.

◆ end_populations() [1/2]

PopulationIterator knp::framework::Network::end_populations ( )
nodiscard

Get an iterator pointing to the last element of the population.

Returns
iterator.

◆ end_populations() [2/2]

PopulationConstIterator knp::framework::Network::end_populations ( ) const
nodiscard

Get an iterator pointing to the last element of the population.

Returns
constant iterator.

◆ end_projections() [1/2]

ProjectionIterator knp::framework::Network::end_projections ( )
nodiscard

Get an iterator pointing to the last element of the projection.

Returns
iterator.

◆ end_projections() [2/2]

ProjectionConstIterator knp::framework::Network::end_projections ( ) const
nodiscard

Get an iterator pointing to the last element of the projection.

Returns
constant iterator.

◆ get_population() [1/3]

template<typename NeuronType >
knp::core::Population< NeuronType > & knp::framework::Network::get_population ( const knp::core::UID & population_uid)
nodiscard

Get a population with the given UID from the network.

Template Parameters
NeuronTypetype of population neuron.
Parameters
population_uidpopulation UID.
Exceptions
std::logic_errorif population is not found in the network.
Returns
population.

◆ get_population() [2/3]

core::AllPopulationsVariant & knp::framework::Network::get_population ( const knp::core::UID & population_uid)
nodiscard

Get a population with the given UID from the network.

Parameters
population_uidpopulation UID.
Exceptions
std::logic_errorif population is not found in the network.
Returns
population.

◆ get_population() [3/3]

template<typename NeuronType >
const knp::core::Population< NeuronType > & knp::framework::Network::get_population ( const knp::core::UID & population_uid) const
nodiscard

Get a population with the given UID from the network.

Note
Constant method.
Template Parameters
NeuronTypetype of population neuron.
Parameters
population_uidpopulation UID.
Exceptions
std::logic_errorif population is not found in the network.
Returns
population.

◆ get_populations()

const PopulationContainer & knp::framework::Network::get_populations ( ) const
inlinenodiscard

Get population container from the network.

Returns
container of populations.

Definition at line 373 of file network.h.

◆ get_projection() [1/3]

template<typename SynapseType >
knp::core::Projection< SynapseType > & knp::framework::Network::get_projection ( const knp::core::UID & projection_uid)
nodiscard

Get a projection with the given UID from the network.

Template Parameters
SynapseTypetype of projection synapse.
Parameters
projection_uidprojection UID.
Exceptions
std::logic_errorif projection is not found in the network.
Returns
projection.

◆ get_projection() [2/3]

core::AllProjectionsVariant & knp::framework::Network::get_projection ( const knp::core::UID & projection_uid)
nodiscard

Get a projection with the given UID from the network.

Parameters
projection_uidprojection UID.
Exceptions
std::logic_errorif projection is not found in the network.
Returns
projection.

◆ get_projection() [3/3]

template<typename SynapseType >
const knp::core::Projection< SynapseType > & knp::framework::Network::get_projection ( const knp::core::UID & projection_uid) const
nodiscard

Get a projection with the given UID from the network.

Note
Constant method.
Template Parameters
SynapseTypetype of projection synapse.
Parameters
projection_uidprojection UID.
Exceptions
std::logic_errorif projection is not found in the network.
Returns
projection.

◆ get_projections()

const ProjectionContainer & knp::framework::Network::get_projections ( ) const
inlinenodiscard

Get projection container from the network.

Returns
container of projections.

Definition at line 378 of file network.h.

◆ get_tags()

auto & knp::framework::Network::get_tags ( )
inlinenodiscard

Get tags used by the network.

Returns
tag map.
See also
TagMap.

Definition at line 404 of file network.h.

◆ get_uid()

const knp::core::UID & knp::framework::Network::get_uid ( ) const
inlinenodiscard

Get network UID.

Returns
UID.

Definition at line 397 of file network.h.

◆ is_population_exists()

bool knp::framework::Network::is_population_exists ( const knp::core::UID & population_uid) const
nodiscard

Check if population exists.

Parameters
population_uidUID of the population to check.
Returns
true if population exists, false otherwise.

◆ is_projection_exists()

bool knp::framework::Network::is_projection_exists ( const knp::core::UID & projection_uid) const
nodiscard

Check if projection exists.

Parameters
projection_uidUID of the projection to check.
Returns
true if projection exists, false otherwise.

◆ populations_count()

size_t knp::framework::Network::populations_count ( ) const
inlinenodiscard

Count populations in the network.

Returns
number of populations.

Definition at line 385 of file network.h.

◆ projections_count()

size_t knp::framework::Network::projections_count ( ) const
inlinenodiscard

Count projections in the network.

Returns
number of projections.

Definition at line 390 of file network.h.

◆ remove_population()

void knp::framework::Network::remove_population ( const knp::core::UID & population_uid)

Remove a population with the given UID from the network.

Parameters
population_uidUID of the population to remove.

◆ remove_projection()

void knp::framework::Network::remove_projection ( const knp::core::UID & projection_uid)

Remove a projection with the given UID from the network.

Parameters
projection_uidUID of the projection to remove.

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