class ModelSpec

Overview

Object used for specifying a neuronal network model. More…

#include <modelSpec.h>

class ModelSpec
{
public:
    // typedefs

    typedef std::map<std::string, NeuronGroupInternal>::value_type NeuronGroupValueType;
    typedef std::map<std::string, SynapseGroupInternal>::value_type SynapseGroupValueType;

    // methods

    ModelSpec();
    ModelSpec(const ModelSpec&);
    ModelSpec& operator = (const ModelSpec&);
    ~ModelSpec();
    void setName(const std::string& name);
    void setPrecision(FloatType floattype);
    void setTimePrecision(TimePrecision timePrecision);
    void setDT(double dt);
    void setTiming(bool timingEnabled);
    void setSeed(unsigned int rngSeed);
    void setDefaultVarLocation(VarLocation loc);
    void setDefaultExtraGlobalParamLocation(VarLocation loc);
    void setDefaultSparseConnectivityLocation(VarLocation loc);
    void setMergePostsynapticModels(bool merge);
    const std::string& getName() const;
    const std::string& getPrecision() const;
    std::string getTimePrecision() const;
    double getDT() const;
    unsigned int getSeed() const;
    bool isTimingEnabled() const;
    unsigned int getNumLocalNeurons() const;
    unsigned int getNumRemoteNeurons() const;
    unsigned int getNumNeurons() const;
    NeuronGroup* findNeuronGroup(const std::string& name);

    template <typename NeuronModel>
    NeuronGroup* addNeuronPopulation(
        const std::string& name,
        unsigned int size,
        const NeuronModel* model,
        const typename NeuronModel::ParamValues& paramValues,
        const typename NeuronModel::VarValues& varInitialisers,
        int hostID = 0
        );

    template <typename NeuronModel>
    NeuronGroup* addNeuronPopulation(
        const std::string& name,
        unsigned int size,
        const typename NeuronModel::ParamValues& paramValues,
        const typename NeuronModel::VarValues& varInitialisers,
        int hostID = 0
        );

    SynapseGroup* findSynapseGroup(const std::string& name);

    template <typename WeightUpdateModel, typename PostsynapticModel>
    SynapseGroup* addSynapsePopulation(
        const std::string& name,
        SynapseMatrixType mtype,
        unsigned int delaySteps,
        const std::string& src,
        const std::string& trg,
        const WeightUpdateModel* wum,
        const typename WeightUpdateModel::ParamValues& weightParamValues,
        const typename WeightUpdateModel::VarValues& weightVarInitialisers,
        const typename WeightUpdateModel::PreVarValues& weightPreVarInitialisers,
        const typename WeightUpdateModel::PostVarValues& weightPostVarInitialisers,
        const PostsynapticModel* psm,
        const typename PostsynapticModel::ParamValues& postsynapticParamValues,
        const typename PostsynapticModel::VarValues& postsynapticVarInitialisers,
        const InitSparseConnectivitySnippet::Init& connectivityInitialiser = uninitialisedConnectivity()
        );

    template <typename WeightUpdateModel, typename PostsynapticModel>
    SynapseGroup* addSynapsePopulation(
        const std::string& name,
        SynapseMatrixType mtype,
        unsigned int delaySteps,
        const std::string& src,
        const std::string& trg,
        const typename WeightUpdateModel::ParamValues& weightParamValues,
        const typename WeightUpdateModel::VarValues& weightVarInitialisers,
        const typename PostsynapticModel::ParamValues& postsynapticParamValues,
        const typename PostsynapticModel::VarValues& postsynapticVarInitialisers,
        const InitSparseConnectivitySnippet::Init& connectivityInitialiser = uninitialisedConnectivity()
        );

    template <typename WeightUpdateModel, typename PostsynapticModel>
    SynapseGroup* addSynapsePopulation(
        const std::string& name,
        SynapseMatrixType mtype,
        unsigned int delaySteps,
        const std::string& src,
        const std::string& trg,
        const typename WeightUpdateModel::ParamValues& weightParamValues,
        const typename WeightUpdateModel::VarValues& weightVarInitialisers,
        const typename WeightUpdateModel::PreVarValues& weightPreVarInitialisers,
        const typename WeightUpdateModel::PostVarValues& weightPostVarInitialisers,
        const typename PostsynapticModel::ParamValues& postsynapticParamValues,
        const typename PostsynapticModel::VarValues& postsynapticVarInitialisers,
        const InitSparseConnectivitySnippet::Init& connectivityInitialiser = uninitialisedConnectivity()
        );

    CurrentSource* findCurrentSource(const std::string& name);

    template <typename CurrentSourceModel>
    CurrentSource* addCurrentSource(
        const std::string& currentSourceName,
        const CurrentSourceModel* model,
        const std::string& targetNeuronGroupName,
        const typename CurrentSourceModel::ParamValues& paramValues,
        const typename CurrentSourceModel::VarValues& varInitialisers
        );

    template <typename CurrentSourceModel>
    CurrentSource* addCurrentSource(
        const std::string& currentSourceName,
        const std::string& targetNeuronGroupName,
        const typename CurrentSourceModel::ParamValues& paramValues,
        const typename CurrentSourceModel::VarValues& varInitialisers
        );
};

// direct descendants

class ModelSpecInternal;

Detailed Documentation

Object used for specifying a neuronal network model.

Methods

void setName(const std::string& name)

Method to set the neuronal network model name.

void setPrecision(FloatType floattype)

Set numerical precision for floating point.

This function sets the numerical precision of floating type variables. By default, it is GENN_GENN_FLOAT.

void setTimePrecision(TimePrecision timePrecision)

Set numerical precision for time.

void setDT(double dt)

Set the integration step size of the model.

void setTiming(bool timingEnabled)

Set whether timers and timing commands are to be included.

void setSeed(unsigned int rngSeed)

Set the random seed (disables automatic seeding if argument not 0).

void setDefaultVarLocation(VarLocation loc)

What is the default location for model state variables?

Historically, everything was allocated on both the host AND device

void setDefaultExtraGlobalParamLocation(VarLocation loc)

What is the default location for model extra global parameters?

Historically, this was just left up to the user to handle

void setDefaultSparseConnectivityLocation(VarLocation loc)

What is the default location for sparse synaptic connectivity?

Historically, everything was allocated on both the host AND device

void setMergePostsynapticModels(bool merge)

Should compatible postsynaptic models and dendritic delay buffers be merged?

This can significantly reduce the cost of updating neuron population but means that per-synapse group inSyn arrays can not be retrieved

const std::string& getName() const

Gets the name of the neuronal network model.

const std::string& getPrecision() const

Gets the floating point numerical precision.

std::string getTimePrecision() const

Gets the floating point numerical precision used to represent time.

double getDT() const

Gets the model integration step size.

unsigned int getSeed() const

Get the random seed.

bool isTimingEnabled() const

Are timers and timing commands enabled.

unsigned int getNumLocalNeurons() const

How many neurons are simulated locally in this model.

unsigned int getNumRemoteNeurons() const

How many neurons are simulated remotely in this model.

unsigned int getNumNeurons() const

How many neurons make up the entire model.

NeuronGroup* findNeuronGroup(const std::string& name)

Find a neuron group by name.

template <typename NeuronModel>
NeuronGroup* addNeuronPopulation(
    const std::string& name,
    unsigned int size,
    const NeuronModel* model,
    const typename NeuronModel::ParamValues& paramValues,
    const typename NeuronModel::VarValues& varInitialisers,
    int hostID = 0
    )

Adds a new neuron group to the model using a neuron model managed by the user.

Parameters:

NeuronModel type of neuron model (derived from NeuronModels::Base).
name string containing unique name of neuron population.
size integer specifying how many neurons are in the population.
model neuron model to use for neuron group.
paramValues parameters for model wrapped in NeuronModel::ParamValues object.
varInitialisers state variable initialiser snippets and parameters wrapped in NeuronModel::VarValues object.
hostID if using MPI, the ID of the node to simulate this population on.

Returns:

pointer to newly created NeuronGroup

template <typename NeuronModel>
NeuronGroup* addNeuronPopulation(
    const std::string& name,
    unsigned int size,
    const typename NeuronModel::ParamValues& paramValues,
    const typename NeuronModel::VarValues& varInitialisers,
    int hostID = 0
    )

Adds a new neuron group to the model using a singleton neuron model created using standard DECLARE_MODEL and IMPLEMENT_MODEL macros.

Parameters:

NeuronModel type of neuron model (derived from NeuronModels::Base).
name string containing unique name of neuron population.
size integer specifying how many neurons are in the population.
paramValues parameters for model wrapped in NeuronModel::ParamValues object.
varInitialisers state variable initialiser snippets and parameters wrapped in NeuronModel::VarValues object.
hostID if using MPI, the ID of the node to simulate this population on.

Returns:

pointer to newly created NeuronGroup

SynapseGroup* findSynapseGroup(const std::string& name)

Find a synapse group by name.

template <typename WeightUpdateModel, typename PostsynapticModel>
SynapseGroup* addSynapsePopulation(
    const std::string& name,
    SynapseMatrixType mtype,
    unsigned int delaySteps,
    const std::string& src,
    const std::string& trg,
    const WeightUpdateModel* wum,
    const typename WeightUpdateModel::ParamValues& weightParamValues,
    const typename WeightUpdateModel::VarValues& weightVarInitialisers,
    const typename WeightUpdateModel::PreVarValues& weightPreVarInitialisers,
    const typename WeightUpdateModel::PostVarValues& weightPostVarInitialisers,
    const PostsynapticModel* psm,
    const typename PostsynapticModel::ParamValues& postsynapticParamValues,
    const typename PostsynapticModel::VarValues& postsynapticVarInitialisers,
    const InitSparseConnectivitySnippet::Init& connectivityInitialiser = uninitialisedConnectivity()
    )

Adds a synapse population to the model using weight update and postsynaptic models managed by the user.

Parameters:

WeightUpdateModel type of weight update model (derived from WeightUpdateModels::Base).
PostsynapticModel type of postsynaptic model (derived from PostsynapticModels::Base).
name string containing unique name of neuron population.
mtype how the synaptic matrix associated with this synapse population should be represented.
delaySteps integer specifying number of timesteps delay this synaptic connection should incur (or NO_DELAY for none)
src string specifying name of presynaptic (source) population
trg string specifying name of postsynaptic (target) population
wum weight update model to use for synapse group.
weightParamValues parameters for weight update model wrapped in WeightUpdateModel::ParamValues object.
weightVarInitialisers weight update model state variable initialiser snippets and parameters wrapped in WeightUpdateModel::VarValues object.
weightPreVarInitialisers weight update model presynaptic state variable initialiser snippets and parameters wrapped in WeightUpdateModel::VarValues object.
weightPostVarInitialisers weight update model postsynaptic state variable initialiser snippets and parameters wrapped in WeightUpdateModel::VarValues object.
psm postsynaptic model to use for synapse group.
postsynapticParamValues parameters for postsynaptic model wrapped in PostsynapticModel::ParamValues object.
postsynapticVarInitialisers postsynaptic model state variable initialiser snippets and parameters wrapped in NeuronModel::VarValues object.
connectivityInitialiser sparse connectivity initialisation snippet used to initialise connectivity for SynapseMatrixConnectivity::SPARSE or SynapseMatrixConnectivity::BITMASK. Typically wrapped with it’s parameters using initConnectivity function

Returns:

pointer to newly created SynapseGroup

template <typename WeightUpdateModel, typename PostsynapticModel>
SynapseGroup* addSynapsePopulation(
    const std::string& name,
    SynapseMatrixType mtype,
    unsigned int delaySteps,
    const std::string& src,
    const std::string& trg,
    const typename WeightUpdateModel::ParamValues& weightParamValues,
    const typename WeightUpdateModel::VarValues& weightVarInitialisers,
    const typename PostsynapticModel::ParamValues& postsynapticParamValues,
    const typename PostsynapticModel::VarValues& postsynapticVarInitialisers,
    const InitSparseConnectivitySnippet::Init& connectivityInitialiser = uninitialisedConnectivity()
    )

Adds a synapse population to the model using singleton weight update and postsynaptic models created using standard DECLARE_MODEL and IMPLEMENT_MODEL macros.

Parameters:

WeightUpdateModel type of weight update model (derived from WeightUpdateModels::Base).
PostsynapticModel type of postsynaptic model (derived from PostsynapticModels::Base).
name string containing unique name of neuron population.
mtype how the synaptic matrix associated with this synapse population should be represented.
delaySteps integer specifying number of timesteps delay this synaptic connection should incur (or NO_DELAY for none)
src string specifying name of presynaptic (source) population
trg string specifying name of postsynaptic (target) population
weightParamValues parameters for weight update model wrapped in WeightUpdateModel::ParamValues object.
weightVarInitialisers weight update model state variable initialiser snippets and parameters wrapped in WeightUpdateModel::VarValues object.
postsynapticParamValues parameters for postsynaptic model wrapped in PostsynapticModel::ParamValues object.
postsynapticVarInitialisers postsynaptic model state variable initialiser snippets and parameters wrapped in NeuronModel::VarValues object.
connectivityInitialiser sparse connectivity initialisation snippet used to initialise connectivity for SynapseMatrixConnectivity::SPARSE or SynapseMatrixConnectivity::BITMASK. Typically wrapped with it’s parameters using initConnectivity function

Returns:

pointer to newly created SynapseGroup

template <typename WeightUpdateModel, typename PostsynapticModel>
SynapseGroup* addSynapsePopulation(
    const std::string& name,
    SynapseMatrixType mtype,
    unsigned int delaySteps,
    const std::string& src,
    const std::string& trg,
    const typename WeightUpdateModel::ParamValues& weightParamValues,
    const typename WeightUpdateModel::VarValues& weightVarInitialisers,
    const typename WeightUpdateModel::PreVarValues& weightPreVarInitialisers,
    const typename WeightUpdateModel::PostVarValues& weightPostVarInitialisers,
    const typename PostsynapticModel::ParamValues& postsynapticParamValues,
    const typename PostsynapticModel::VarValues& postsynapticVarInitialisers,
    const InitSparseConnectivitySnippet::Init& connectivityInitialiser = uninitialisedConnectivity()
    )

Adds a synapse population to the model using singleton weight update and postsynaptic models created using standard DECLARE_MODEL and IMPLEMENT_MODEL macros.

Parameters:

WeightUpdateModel type of weight update model (derived from WeightUpdateModels::Base).
PostsynapticModel type of postsynaptic model (derived from PostsynapticModels::Base).
name string containing unique name of neuron population.
mtype how the synaptic matrix associated with this synapse population should be represented.
delaySteps integer specifying number of timesteps delay this synaptic connection should incur (or NO_DELAY for none)
src string specifying name of presynaptic (source) population
trg string specifying name of postsynaptic (target) population
weightParamValues parameters for weight update model wrapped in WeightUpdateModel::ParamValues object.
weightVarInitialisers weight update model per-synapse state variable initialiser snippets and parameters wrapped in WeightUpdateModel::VarValues object.
weightPreVarInitialisers weight update model presynaptic state variable initialiser snippets and parameters wrapped in WeightUpdateModel::VarValues object.
weightPostVarInitialisers weight update model postsynaptic state variable initialiser snippets and parameters wrapped in WeightUpdateModel::VarValues object.
postsynapticParamValues parameters for postsynaptic model wrapped in PostsynapticModel::ParamValues object.
postsynapticVarInitialisers postsynaptic model state variable initialiser snippets and parameters wrapped in NeuronModel::VarValues object.
connectivityInitialiser sparse connectivity initialisation snippet used to initialise connectivity for SynapseMatrixConnectivity::SPARSE or SynapseMatrixConnectivity::BITMASK. Typically wrapped with it’s parameters using initConnectivity function

Returns:

pointer to newly created SynapseGroup

CurrentSource* findCurrentSource(const std::string& name)

Find a current source by name.

This function attempts to find an existing current source.

template <typename CurrentSourceModel>
CurrentSource* addCurrentSource(
    const std::string& currentSourceName,
    const CurrentSourceModel* model,
    const std::string& targetNeuronGroupName,
    const typename CurrentSourceModel::ParamValues& paramValues,
    const typename CurrentSourceModel::VarValues& varInitialisers
    )

Adds a new current source to the model using a current source model managed by the user.

Parameters:

CurrentSourceModel type of current source model (derived from CurrentSourceModels::Base).
currentSourceName string containing unique name of current source.
model current source model to use for current source.
targetNeuronGroupName string name of the target neuron group
paramValues parameters for model wrapped in CurrentSourceModel::ParamValues object.
varInitialisers state variable initialiser snippets and parameters wrapped in CurrentSource::VarValues object.

Returns:

pointer to newly created CurrentSource

template <typename CurrentSourceModel>
CurrentSource* addCurrentSource(
    const std::string& currentSourceName,
    const std::string& targetNeuronGroupName,
    const typename CurrentSourceModel::ParamValues& paramValues,
    const typename CurrentSourceModel::VarValues& varInitialisers
    )

Adds a new current source to the model using a singleton current source model created using standard DECLARE_MODEL and IMPLEMENT_MODEL macros.

Parameters:

CurrentSourceModel type of neuron model (derived from CurrentSourceModel::Base).
currentSourceName string containing unique name of current source.
targetNeuronGroupName string name of the target neuron group
paramValues parameters for model wrapped in CurrentSourceModel::ParamValues object.
varInitialisers state variable initialiser snippets and parameters wrapped in CurrentSourceModel::VarValues object.

Returns:

pointer to newly created CurrentSource