Auryn simulator  v0.8.1-206-gb56e451
Plastic Spiking Neural Network Simulator
Public Member Functions | Protected Attributes | Static Protected Attributes | List of all members
auryn::ProfilePoissonGroup Class Reference

A SpikingGroup that creates poissonian spikes with a given rate and spatial profile. More...

#include <ProfilePoissonGroup.h>

Inheritance diagram for auryn::ProfilePoissonGroup:
Inheritance graph
[legend]
Collaboration diagram for auryn::ProfilePoissonGroup:
Collaboration graph
[legend]

Public Member Functions

 ProfilePoissonGroup (NeuronID n, AurynDouble rate=5.)
 
virtual ~ProfilePoissonGroup ()
 
virtual void evolve ()
 
void set_rate (AurynDouble rate)
 
void normalize_profile ()
 
void set_profile (AurynFloat *newprofile)
 
void set_profile (auryn_vector_float *newprofile)
 
void set_flat_profile ()
 
void set_gaussian_profile (AurynDouble mean, AurynDouble sigma, AurynDouble floor=0.0)
 
AurynDouble get_rate ()
 
void seed (int s)
 
- Public Member Functions inherited from auryn::SpikingGroup
void add_state_vector (std::string key, AurynStateVector *state_vector)
 Adds a state vector passed as an argument to the dictinary. More...
 
void remove_state_vector (std::string key)
 Removes a state vector passed as an argument to the dictinary. More...
 
AurynStateVectorfind_state_vector (std::string key)
 Returns existing state vector by name or NULL if it does not exist. More...
 
AurynStateVectorget_state_vector (std::string key)
 Creates a new or returns an existing state vector by name. More...
 
AurynStateVectorget_existing_state_vector (std::string key)
 Returns an existing state with the supplied name. More...
 
AurynStateVectorcreate_state_vector (std::string key)
 Creates a new state vector and throws an exception if a vector with the same name exists. More...
 
AurynStateget_state_variable (std::string key)
 Creates a new group-wide state variable or returns an existing group-wide variable by name then returns a pointer to it. More...
 
void randomize_state_vector_gauss (std::string state_vector_name, AurynState mean, AurynState sigma, int seed=12239)
 Randomizes the content of a state vector with Gaussian random numbers. Seeding is MPI save. More...
 
 SpikingGroup (NeuronID size, NodeDistributionMode mode=AUTO)
 Default constructor. More...
 
virtual ~SpikingGroup ()
 Default destructor. More...
 
virtual void evolve_traces ()
 Evolves traces. More...
 
void set_name (std::string s)
 Set connection name. More...
 
std::string get_name ()
 Retrieves the groups name. More...
 
std::string get_file_name ()
 Extracts the class name of the connection from the file name. More...
 
std::string get_log_name ()
 Returns a string which is the combination of file and connection name for logging. More...
 
void inc_num_spike_attributes (int x)
 Instructs SpikingGroup to increase the number of spike attributes by x. More...
 
int get_num_spike_attributes ()
 
void conditional_evolve ()
 Conditional evolve functino which is called by System. More...
 
unsigned int get_locked_rank ()
 Returns locked rank for SpikingGroups which are not distributed across all ranks. More...
 
unsigned int get_locked_range ()
 Returns locked range of ranks for SpikingGroups which are not distributed across all ranks. More...
 
SpikeContainerget_spikes ()
 Returns pointer to a spike container that contains spikes which arrive in this timestep from all neurons in this group. More...
 
SpikeContainerget_spikes_immediate ()
 Returns pointer to SpikeContainer of spikes generated during the last evolve() step. More...
 
AttributeContainerget_attributes ()
 Returns pointer to Attributecontainer for usage in propagating Connection objects. Same as get_spikes_immediate(), however might be overwritten to contain Spikes that have been delayed. More...
 
AttributeContainerget_attributes_immediate ()
 Returns pointer to Attributecontainer of spikes generated during the last evolve() step. More...
 
NeuronID get_size ()
 Returns the size of the group. More...
 
NeuronID get_pre_size ()
 Returns the size of the group. More...
 
NeuronID calculate_rank_size (int rank=-1)
 Determines rank size and stores it in local variable. More...
 
NeuronID get_rank_size ()
 Returns the size on this rank. More...
 
NeuronID get_post_size ()
 Returns the size on this rank. More...
 
void set_clock_ptr (AurynTime *clock)
 
bool evolve_locally ()
 Returns true if the calling instance has units which are integrated on the current rank. More...
 
NeuronID get_uid ()
 Get the unique ID of the class. More...
 
Traceget_pre_trace (AurynFloat x)
 Returns a pre trace with time constant x. More...
 
void add_pre_trace (Trace *tr)
 Adds trace to pretrace stack of a connection. More...
 
Traceget_post_trace (AurynFloat x)
 Returns a post trace with time constant x. More...
 
void add_post_trace (Trace *tr)
 Adds trace to posttrace stack of a connection. More...
 
void push_spike (NeuronID spike)
 Pushes a local NeuronID as spike into the axonal SpikeDelay buffer. More...
 
void push_attribute (AurynFloat attrib)
 Pushes a spike attribute into the axonal SpikeDelay buffer. More...
 
void clear_spikes ()
 Clears all spikes stored in the delays which is useful to reset a network during runtime. More...
 
Traceget_post_state_trace (std::string state_name="mem", AurynFloat tau=10e-3, AurynFloat b=0.0)
 Returns a post trace of a neuronal state variable e.g. the membrane potential with time constant tau. More...
 
Traceget_post_state_trace (AurynStateVector *state, AurynFloat tau=10e-3, AurynFloat b=0.0)
 Returns a post trace of a neuronal state variable specified by pointer. More...
 
void set_delay (int d)
 Sets axonal delay for this SpikingGroup. More...
 
virtual bool write_to_file (const char *filename)
 Writes current states of SpikingGroup to human-readible textfile if implemented in derived class. More...
 
virtual bool load_from_file (const char *filename)
 Reads current states of SpikingGroup to human-readible textfile if implemented in derived class. More...
 
NeuronID ranksize ()
 Returns size (num of neurons) on the current rank. More...
 
NeuronID global2rank (NeuronID i)
 Converts global NeuronID within the SpikingGroup to the local NeuronID on this rank. More...
 
NeuronID rank2global (NeuronID i)
 Converts local NeuronID from the local rank to a global NeuronID. More...
 
bool localrank (NeuronID i)
 Checks if the global NeuronID i is integrated on this MPI rank. More...
 
NeuronID get_vector_size ()
 Rank size but rounded up to multiples of 4 (or potentially some other and larger number in future versions) for SSE compatibility. More...
 

Protected Attributes

NeuronID x
 
AurynDouble jumpsize
 
boost::uniform_01 * dist
 
boost::variate_generator< boost::mt19937 &, boost::uniform_01<> > * die
 
auryn_vector_floatprofile
 stores the spatial distribution of relative firing rates More...
 
- Protected Attributes inherited from auryn::SpikingGroup
std::vector< Trace * > pretraces
 Pretraces. More...
 
std::vector< Trace * > posttraces
 Posttraces. More...
 
std::vector< Trace * > post_state_traces
 Post state traces. More...
 
std::vector< AurynFloatpost_state_traces_spike_biases
 
std::vector< AurynStateVector * > post_state_traces_states
 
std::string group_name
 Identifying name for object. More...
 
NeuronID size
 Stores the size of the group. More...
 
NeuronID rank_size
 Stores the size of the group on this rank. More...
 
SpikeContainerspikes
 SpikeContainers to store spikes produced during one step of evolve. More...
 
AttributeContainerattribs
 

Static Protected Attributes

static boost::mt19937 gen = boost::mt19937()
 
- Static Protected Attributes inherited from auryn::SpikingGroup
static AurynTimeclock_ptr = NULL
 

Additional Inherited Members

- Public Attributes inherited from auryn::SpikingGroup
SpikeDelaydelay
 
bool active
 Toggles group active. More...
 
std::map< std::string, AurynStateVector * > state_vectors
 
std::map< std::string, AurynStatestate_variables
 
- Protected Member Functions inherited from auryn::SpikingGroup
virtual void load_input_line (NeuronID i, const char *buf)
 
virtual std::string get_output_line (NeuronID i)
 
virtual void virtual_serialize (boost::archive::binary_oarchive &ar, const unsigned int version)
 Implementatinon of serialize function for writing. More...
 
virtual void virtual_serialize (boost::archive::binary_iarchive &ar, const unsigned int version)
 Implementatinon of serialize function for reading. More...
 
void free ()
 Frees potentially allocated memory. More...
 

Detailed Description

A SpikingGroup that creates poissonian spikes with a given rate and spatial profile.

This SpikingGroup is a logic extension of PoissonGroup for (relatively) stationary, but not uniform firing rates. It uses a similar algorithm as PoissonGroup to generate spikes in which each random number yields a spike, but uses a warped output array in which neurons can have different firing probabilities in each timestep. The resulting implementation requires the computation of the cumulative firing probability accross the group in every timestep. It is therefore substantially slower than PoissonGroup, but presumably much faster than drawing random numbers for each neuron in each time step. To set the firing rate profile use the function set_profile which needs to point to an array at which the firing rate profile is stored.

Constructor & Destructor Documentation

◆ ProfilePoissonGroup()

ProfilePoissonGroup::ProfilePoissonGroup ( NeuronID  n,
AurynDouble  rate = 5. 
)

Standard constructor.

Parameters
nis the size of the SpikingGroup, i.e. the number of Poisson neurons.
rateis the mean firing rate of all poisson neurons in the group.
54  : SpikingGroup( n )
55 {
56  init(rate);
57 }
SpikingGroup(NeuronID size, NodeDistributionMode mode=AUTO)
Default constructor.
Definition: SpikingGroup.cpp:38
int n
Definition: mkpat.py:5

◆ ~ProfilePoissonGroup()

ProfilePoissonGroup::~ProfilePoissonGroup ( )
virtual

Default destructor

60 {
61  if ( evolve_locally() ) {
62  delete dist;
63  delete die;
64  }
65 }
boost::uniform_01 * dist
Definition: ProfilePoissonGroup.h:68
bool evolve_locally()
Returns true if the calling instance has units which are integrated on the current rank...
Definition: SpikingGroup.cpp:323
boost::variate_generator< boost::mt19937 &, boost::uniform_01<> > * die
Definition: ProfilePoissonGroup.h:69
Here is the call graph for this function:

Member Function Documentation

◆ evolve()

void ProfilePoissonGroup::evolve ( )
virtual

Evolve function for internal use by System

Implements auryn::SpikingGroup.

Reimplemented in auryn::MovingBumpGroup, and auryn::AuditoryBeepGroup.

158 {
159  while ( x < get_rank_size() ) {
160  // std::cout << x << std::endl;
161  jumpsize -= profile->data[x];
162  if ( jumpsize < 0 ) { // reached jump target -> spike
163  push_spike ( x );
164  AurynDouble r = -log((*die)()+1e-20)/lambda;
166  }
167  x++;
168  }
169  x -= get_rank_size();
170 }
NeuronID get_rank_size()
Returns the size on this rank.
Definition: SpikingGroup.h:450
r
Definition: mkpat.py:9
auryn_vector_float * profile
stores the spatial distribution of relative firing rates
Definition: ProfilePoissonGroup.h:71
T * data
Pointer to the array housing the data.
Definition: AurynVector.h:154
AurynDouble jumpsize
Definition: ProfilePoissonGroup.h:65
double AurynDouble
Higher precision floating point datatype.
Definition: auryn_definitions.h:158
double auryn_timestep
Simulation timestep in seconds.
Definition: auryn_definitions.cpp:31
void push_spike(NeuronID spike)
Pushes a local NeuronID as spike into the axonal SpikeDelay buffer.
Definition: SpikingGroup.cpp:270
NeuronID x
Definition: ProfilePoissonGroup.h:64
boost::variate_generator< boost::mt19937 &, boost::uniform_01<> > * die
Definition: ProfilePoissonGroup.h:69
Here is the call graph for this function:

◆ get_rate()

AurynDouble ProfilePoissonGroup::get_rate ( )

Standard getter for the firing rate variable.

152 {
153  return lambda;
154 }

◆ normalize_profile()

void ProfilePoissonGroup::normalize_profile ( )
85 {
86  AurynDouble sum = 0.0;
87  for ( NeuronID i = 0 ; i < get_rank_size() ; ++i ) {
88  sum += profile->data[i];
89  }
90 
91  AurynDouble normalization_factor = get_rank_size()/sum;
92  for ( NeuronID i = 0 ; i < get_rank_size() ; ++i ) {
93  profile->data[i] *= normalization_factor ;
94  }
95 }
NeuronID get_rank_size()
Returns the size on this rank.
Definition: SpikingGroup.h:450
auryn_vector_float * profile
stores the spatial distribution of relative firing rates
Definition: ProfilePoissonGroup.h:71
T * data
Pointer to the array housing the data.
Definition: AurynVector.h:154
double AurynDouble
Higher precision floating point datatype.
Definition: auryn_definitions.h:158
unsigned int NeuronID
NeuronID is an unsigned integeger type used to index neurons in Auryn.
Definition: auryn_definitions.h:151
Here is the call graph for this function:

◆ seed()

void ProfilePoissonGroup::seed ( int  s)

Use this to seed the random number generator.

173 {
174  gen.seed(s);
175 }
static boost::mt19937 gen
Definition: ProfilePoissonGroup.h:67

◆ set_flat_profile()

void ProfilePoissonGroup::set_flat_profile ( )
98 {
99  for ( NeuronID i = 0 ; i < get_rank_size() ; ++i ) {
100  profile->data[i] = 1.0;
101  }
102 }
NeuronID get_rank_size()
Returns the size on this rank.
Definition: SpikingGroup.h:450
auryn_vector_float * profile
stores the spatial distribution of relative firing rates
Definition: ProfilePoissonGroup.h:71
T * data
Pointer to the array housing the data.
Definition: AurynVector.h:154
unsigned int NeuronID
NeuronID is an unsigned integeger type used to index neurons in Auryn.
Definition: auryn_definitions.h:151
Here is the call graph for this function:

◆ set_gaussian_profile()

void ProfilePoissonGroup::set_gaussian_profile ( AurynDouble  mean,
AurynDouble  sigma,
AurynDouble  floor = 0.0 
)
133 {
134  for ( NeuronID i = 0 ; i < get_size() ; ++i ) {
135  if ( localrank(i) )
136  profile->data[global2rank(i)] = exp(-pow((i-mean),2)/(2*sigma*sigma))*(1.0-floor)+floor;
137  }
138 
140 
141  std::stringstream oss;
142  oss << "ProfilePoissonGroup:: Setting gaussian profile with mean="
143  << mean
144  << " and sigma="
145  << sigma
146  << " and floor="
147  << floor;
148  auryn::logger->msg(oss.str(),VERBOSE);
149 }
auryn_vector_float * profile
stores the spatial distribution of relative firing rates
Definition: ProfilePoissonGroup.h:71
bool localrank(NeuronID i)
Checks if the global NeuronID i is integrated on this MPI rank.
Definition: SpikingGroup.cpp:531
NeuronID global2rank(NeuronID i)
Converts global NeuronID within the SpikingGroup to the local NeuronID on this rank.
Definition: SpikingGroup.h:446
T * data
Pointer to the array housing the data.
Definition: AurynVector.h:154
Logger * logger
Global pointer to instance of Logger which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:36
void normalize_profile()
Definition: ProfilePoissonGroup.cpp:84
NeuronID get_size()
Returns the size of the group.
Definition: SpikingGroup.cpp:304
Definition: Logger.h:41
void msg(std::string text, LogMessageType type=NOTIFICATION, bool global=false, int line=-1, std::string srcfile="")
Definition: Logger.cpp:74
unsigned int NeuronID
NeuronID is an unsigned integeger type used to index neurons in Auryn.
Definition: auryn_definitions.h:151
Here is the call graph for this function:

◆ set_profile() [1/2]

void ProfilePoissonGroup::set_profile ( AurynFloat newprofile)

Sets firing rate profile to the array elements given in newprofile

Expects a vector of the size n of the SpikingGroup.

105 {
106  for ( NeuronID i = 0 ; i < get_size() ; ++i ) {
107  if ( localrank( i ) )
108  profile->data[global2rank(i)] = newprofile[i];
109  }
110 
112 
113  std::stringstream oss;
114  oss << "ProfilePoissonGroup:: Successfully set external profile." ;
115  auryn::logger->msg(oss.str(),NOTIFICATION);
116 }
auryn_vector_float * profile
stores the spatial distribution of relative firing rates
Definition: ProfilePoissonGroup.h:71
bool localrank(NeuronID i)
Checks if the global NeuronID i is integrated on this MPI rank.
Definition: SpikingGroup.cpp:531
NeuronID global2rank(NeuronID i)
Converts global NeuronID within the SpikingGroup to the local NeuronID on this rank.
Definition: SpikingGroup.h:446
T * data
Pointer to the array housing the data.
Definition: AurynVector.h:154
Definition: Logger.h:41
Logger * logger
Global pointer to instance of Logger which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:36
void normalize_profile()
Definition: ProfilePoissonGroup.cpp:84
NeuronID get_size()
Returns the size of the group.
Definition: SpikingGroup.cpp:304
void msg(std::string text, LogMessageType type=NOTIFICATION, bool global=false, int line=-1, std::string srcfile="")
Definition: Logger.cpp:74
unsigned int NeuronID
NeuronID is an unsigned integeger type used to index neurons in Auryn.
Definition: auryn_definitions.h:151
Here is the call graph for this function:

◆ set_profile() [2/2]

void ProfilePoissonGroup::set_profile ( auryn_vector_float newprofile)

Sets firing rate profile to a state vector

Note, does not normalize the profile to a probability distribution! Net firing rate can change! Expects a state vector with appropriate size on the rank which is smaller than or equal to the size of this group.

119 {
120  for ( NeuronID i = 0 ; i < get_rank_size() ; ++i ) {
121  profile->data[i] = newprofile->data[i];
122  }
123 
124  // normalize_profile();
125 
126  std::stringstream oss;
127  oss << "ProfilePoissonGroup:: Successfully set external profile." ;
128  auryn::logger->msg(oss.str(),NOTIFICATION);
129 }
NeuronID get_rank_size()
Returns the size on this rank.
Definition: SpikingGroup.h:450
auryn_vector_float * profile
stores the spatial distribution of relative firing rates
Definition: ProfilePoissonGroup.h:71
T * data
Pointer to the array housing the data.
Definition: AurynVector.h:154
Definition: Logger.h:41
Logger * logger
Global pointer to instance of Logger which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:36
void msg(std::string text, LogMessageType type=NOTIFICATION, bool global=false, int line=-1, std::string srcfile="")
Definition: Logger.cpp:74
unsigned int NeuronID
NeuronID is an unsigned integeger type used to index neurons in Auryn.
Definition: auryn_definitions.h:151
Here is the call graph for this function:

◆ set_rate()

void ProfilePoissonGroup::set_rate ( AurynDouble  rate)

Setter for the firing rate of all neurons. This can be used to change the firing rate during the simulation. Note that changes might have a short latency due to the internal workings of the simulator. Try avoid setting the firing rate in every other timestep because it will reduce performance.

68 {
69  lambda = rate;
70  if ( evolve_locally() ) {
71  if ( rate > 0.0 ) {
72  AurynDouble r = -log((*die)())/lambda;
74  x = 0;
75  } else {
76  // if the rate is zero this triggers one spike at the end of time/groupsize
77  // this is the easiest way to take care of the zero rate case, which should
78  // be avoided in any case.
79  x = std::numeric_limits<NeuronID>::max();
80  }
81  }
82 }
r
Definition: mkpat.py:9
AurynDouble jumpsize
Definition: ProfilePoissonGroup.h:65
double AurynDouble
Higher precision floating point datatype.
Definition: auryn_definitions.h:158
bool evolve_locally()
Returns true if the calling instance has units which are integrated on the current rank...
Definition: SpikingGroup.cpp:323
double auryn_timestep
Simulation timestep in seconds.
Definition: auryn_definitions.cpp:31
NeuronID x
Definition: ProfilePoissonGroup.h:64
boost::variate_generator< boost::mt19937 &, boost::uniform_01<> > * die
Definition: ProfilePoissonGroup.h:69
Here is the call graph for this function:

Member Data Documentation

◆ die

boost::variate_generator<boost::mt19937&, boost::uniform_01<> >* auryn::ProfilePoissonGroup::die
protected

◆ dist

boost::uniform_01* auryn::ProfilePoissonGroup::dist
protected

◆ gen

boost::mt19937 ProfilePoissonGroup::gen = boost::mt19937()
staticprotected

◆ jumpsize

AurynDouble auryn::ProfilePoissonGroup::jumpsize
protected

◆ profile

auryn_vector_float* auryn::ProfilePoissonGroup::profile
protected

stores the spatial distribution of relative firing rates

◆ x

NeuronID auryn::ProfilePoissonGroup::x
protected

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