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

Abstract base class of all objects producing spikes. More...

#include <SpikingGroup.h>

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

Public Member Functions

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 ()
 
virtual void evolve ()=0
 Virtual pure evolve function which needs to be implemented by derived classes. More...
 
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...
 

Public Attributes

SpikeDelaydelay
 
bool active
 Toggles group active. More...
 
std::map< std::string, AurynStateVector * > state_vectors
 
std::map< std::string, AurynStatestate_variables
 

Protected Member Functions

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...
 

Protected Attributes

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 AurynTimeclock_ptr = NULL
 

Friends

class boost::serialization::access
 

Detailed Description

Abstract base class of all objects producing spikes.

This is the abstract/virtual base class from which all spiking objects should be derived. All classes derived from SpikingGroup have in common that they can emit spikes. Furthermore they should implement the method evolve() for carring out internal state changes such as integration of the e.g. Euler Step. Other classes interact with inheritants of SpikingGroup by calling the functions get_spikes() and get_spikes_immediate().

Constructor & Destructor Documentation

◆ SpikingGroup()

SpikingGroup::SpikingGroup ( NeuronID  size,
NodeDistributionMode  mode = AUTO 
)

Default constructor.

39 {
40  init( n, mode );
41 }
int n
Definition: mkpat.py:5

◆ ~SpikingGroup()

SpikingGroup::~SpikingGroup ( )
virtual

Default destructor.

44 {
45  free();
46 }
void free()
Frees potentially allocated memory.
Definition: SpikingGroup.cpp:182
Here is the call graph for this function:

Member Function Documentation

◆ add_post_trace()

void SpikingGroup::add_post_trace ( Trace tr)

Adds trace to posttrace stack of a connection.

Mostly for internal use by get_post_trace()

409 {
410  if ( tr->size != get_vector_size() ) {
411  std::stringstream oss;
412  oss << "Trying to add as post trace, but its size does not match the SpikinGroup. "
413  << "Trace size: " << tr->size
414  << " Post size: " << get_post_size()
415  << " Expected trace size: " << get_vector_size();
416  logger->warning(oss.str());
417  return;
418  }
419  posttraces.push_back(tr);
420 }
std::vector< Trace * > posttraces
Posttraces.
Definition: SpikingGroup.h:108
IndexType size
Size of the vector.
Definition: AurynVector.h:151
void warning(std::string text)
Definition: Logger.cpp:136
Logger * logger
Global pointer to instance of Logger which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:36
NeuronID get_vector_size()
Rank size but rounded up to multiples of 4 (or potentially some other and larger number in future ver...
Definition: SpikingGroup.cpp:901
NeuronID get_post_size()
Returns the size on this rank.
Definition: SpikingGroup.cpp:314
Here is the call graph for this function:

◆ add_pre_trace()

void SpikingGroup::add_pre_trace ( Trace tr)

Adds trace to pretrace stack of a connection.

Mostly for internal use by get_pre_trace()

Parameters
trA pointer to a presynaptic trace instance to be added to the present SpikingGroup
377 {
378  if ( tr->size != calculate_vector_size(get_pre_size()) ) {
379  std::stringstream oss;
380  oss << "Trying to add as pre trace, but its size does not match the SpikinGroup. "
381  << "Trace size: " << tr->size
382  << " Pre size: " << get_pre_size()
383  << " Expected trace size: " << calculate_vector_size(get_pre_size());
384  logger->warning(oss.str());
385  return;
386  }
387  pretraces.push_back(tr);
388 }
NeuronID calculate_vector_size(NeuronID i)
Rounds vector size to multiple of four to allow using the SSE optimizations.
Definition: auryn_definitions.cpp:50
std::vector< Trace * > pretraces
Pretraces.
Definition: SpikingGroup.h:105
IndexType size
Size of the vector.
Definition: AurynVector.h:151
void warning(std::string text)
Definition: Logger.cpp:136
Logger * logger
Global pointer to instance of Logger which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:36
NeuronID get_pre_size()
Returns the size of the group.
Definition: SpikingGroup.cpp:309
Here is the call graph for this function:

◆ add_state_vector()

void SpikingGroup::add_state_vector ( std::string  key,
AurynStateVector state_vector 
)

Adds a state vector passed as an argument to the dictinary.

730 {
731 
732  if ( key[0] == '_' ) {
733  std::stringstream oss;
734  oss << "SpikingGroup:: State vector "
735  << key
736  << " marked as volatile alias vector."
737  << " It will neither be saved nor freed.";
738  auryn::logger->msg(oss.str(), VERBOSE);
739  }
740  state_vectors[key] = state_vector;
741 }
Logger * logger
Global pointer to instance of Logger which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:36
std::map< std::string, AurynStateVector * > state_vectors
Definition: SpikingGroup.h:153
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
Here is the call graph for this function:

◆ calculate_rank_size()

NeuronID SpikingGroup::calculate_rank_size ( int  rank = -1)

Determines rank size and stores it in local variable.

282 {
283  unsigned int comrank ;
284  if ( rank >= 0 )
285  comrank = rank;
286  else
287  comrank = (unsigned int) mpi_rank;
288 
289  if ( comrank >= locked_rank && comrank < (locked_rank+locked_range) ) {
290  if (comrank-locked_rank >= size%locked_range)
291  return size/locked_range; // abgerundete groesse
292  else
293  return size/locked_range+1; // groesse plus rest
294  }
295 
296  return 0;
297 }
NeuronID size
Stores the size of the group.
Definition: SpikingGroup.h:119

◆ clear_spikes()

void SpikingGroup::clear_spikes ( )

Clears all spikes stored in the delays which is useful to reset a network during runtime.

340 {
341  delay->clear();
342  get_spikes_immediate()->clear();
343 }
void clear()
Definition: SpikeDelay.cpp:72
SpikeDelay * delay
Definition: SpikingGroup.h:144
SpikeContainer * get_spikes_immediate()
Returns pointer to SpikeContainer of spikes generated during the last evolve() step.
Definition: SpikingGroup.cpp:250
Here is the call graph for this function:

◆ conditional_evolve()

void SpikingGroup::conditional_evolve ( )

Conditional evolve functino which is called by System.

This function invoces evolve if the present group has work to be done on the current rank. Thus the call of evolve is made conditional on the fact if there is work to be done for this group on the present rank. This is only important for MPI parallel simulations.

235 {
237  spikes->clear();
239  attribs->clear();
240  if ( evolve_locally() ) {
241  evolve();
242  }
243 }
bool evolve_locally()
Returns true if the calling instance has units which are integrated on the current rank...
Definition: SpikingGroup.cpp:323
SpikeContainer * spikes
SpikeContainers to store spikes produced during one step of evolve.
Definition: SpikingGroup.h:123
AttributeContainer * attribs
Definition: SpikingGroup.h:124
SpikeContainer * get_spikes_immediate()
Returns pointer to SpikeContainer of spikes generated during the last evolve() step.
Definition: SpikingGroup.cpp:250
AttributeContainer * get_attributes_immediate()
Returns pointer to Attributecontainer of spikes generated during the last evolve() step...
Definition: SpikingGroup.cpp:260
virtual void evolve()=0
Virtual pure evolve function which needs to be implemented by derived classes.
Here is the call graph for this function:

◆ create_state_vector()

AurynStateVector * SpikingGroup::create_state_vector ( std::string  key)

Creates a new state vector and throws an exception if a vector with the same name exists.

Returns a new state vector with the given key and returns an exception if a vector with the same key already exists. Moreover, NULL is returned if the state vector would have length 0 otherwise.

Exceptions
AurynDelayTooSmallExceptionif a state vector with the same key already exists.
Parameters
keyThe key of the state vector to be created.
Returns
An AurynStateVector with the provided key.
764  {
765  if ( get_vector_size() == 0 ) return NULL;
766  AurynStateVector * vec = find_state_vector(key);
767  if ( vec == NULL ) {
768  vec = new AurynStateVector(get_vector_size());
769  add_state_vector(key, vec);
770 
771  if ( auryn_AlignOffset( vec->size, vec->data, sizeof(float), 16) ) {
773  }
774  return vec;
775  } else {
776  auryn::logger->error("Failed to creat a new state because a vector with the same key already exists.");
778  }
779 }
T * data
Pointer to the array housing the data.
Definition: AurynVector.h:154
IndexType size
Size of the vector.
Definition: AurynVector.h:151
Definition: auryn_definitions.h:265
AurynStateVector * find_state_vector(std::string key)
Returns existing state vector by name or NULL if it does not exist.
Definition: SpikingGroup.cpp:748
Logger * logger
Global pointer to instance of Logger which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:36
int auryn_AlignOffset(const int N, const void *vp, const int inc, const int align)
Determines memory alignment (adapted from ATLAS library)
Definition: auryn_definitions.cpp:34
void add_state_vector(std::string key, AurynStateVector *state_vector)
Adds a state vector passed as an argument to the dictinary.
Definition: SpikingGroup.cpp:729
NeuronID get_vector_size()
Rank size but rounded up to multiples of 4 (or potentially some other and larger number in future ver...
Definition: SpikingGroup.cpp:901
AurynVectorFloat AurynStateVector
Defines AurynStateVector type as synonymous to AurynVectorFloat.
Definition: auryn_definitions.h:329
Definition: auryn_definitions.h:289
void error(std::string text)
Definition: Logger.cpp:141
Default AurynVectorFloat class for performance computation.
Definition: AurynVector.h:796
Here is the call graph for this function:

◆ evolve()

virtual void auryn::SpikingGroup::evolve ( )
pure virtual

Virtual pure evolve function which needs to be implemented by derived classes.

The evolve function is called during simulations in every timestep by the System class. It updates the internal state of the spiking group and pushes spikes which are generated in this timestep to the axonal output delay (SpikeDelay).

Implemented in auryn::StimulusGroup, auryn::AdExGroup, auryn::MovingBumpGroup, auryn::ModSynIFGroup, auryn::IFGroup, auryn::NaudGroup, auryn::IafPscExpGroup, auryn::TIFGroup, auryn::IzhikevichGroup, auryn::CorrelatedPoissonGroup, auryn::SRM0Group, auryn::InputChannelGroup, auryn::AuditoryBeepGroup, auryn::CubaIFGroup, auryn::FileInputGroup, auryn::AIFGroup, auryn::ProfilePoissonGroup, auryn::PoissonGroup, auryn::StructuredPoissonGroup, auryn::IafPscDeltaGroup, auryn::SpikeTimingStimGroup, auryn::AIF2Group, auryn::FileModulatedPoissonGroup, auryn::ParrotGroup, and auryn::PoissonSpikeInjector.

◆ evolve_locally()

bool SpikingGroup::evolve_locally ( )

Returns true if the calling instance has units which are integrated on the current rank.

324 {
325  return evolve_locally_bool;
326 }

◆ evolve_traces()

void SpikingGroup::evolve_traces ( )
virtual

Evolves traces.

464 {
465 
466  // evolve pre synaptic traces
467  for ( NeuronID i = 0 ; i < pretraces.size() ; i++ ) { // loop over all traces
468  for (SpikeContainer::const_iterator spike = get_spikes()->begin() ; // spike = pre_spike
469  spike != get_spikes()->end() ;
470  ++spike ) {
471  // std::cout << " bar " << *spike << std::endl;
472  pretraces[i]->inc(*spike);
473  }
474  pretraces[i]->evolve();
475  }
476 
477  // evolve post synaptic traces
478  for ( NeuronID i = 0 ; i < posttraces.size() ; i++ ) {
479  for (SpikeContainer::const_iterator spike = get_spikes_immediate()->begin() ;
480  spike != get_spikes_immediate()->end() ;
481  ++spike ) {
482  NeuronID translated_spike = global2rank(*spike); // only to be used for post traces
483  // std::cout << " foo " << translated_spike << std::endl;
484  posttraces[i]->inc(translated_spike);
485  }
486  posttraces[i]->evolve();
487  }
488 
489  // evolve state traces
490  for ( NeuronID i = 0 ; i < post_state_traces.size() ; i++ ) {
491 
492  // spike triggered component
493  if ( post_state_traces_spike_biases[i] != 0 ) {
494  for (SpikeContainer::const_iterator spike = get_spikes_immediate()->begin() ;
495  spike != get_spikes_immediate()->end() ;
496  ++spike ) {
497  NeuronID translated_spike = global2rank(*spike); // only to be used for post traces
498  post_state_traces[i]->add_specific(translated_spike, post_state_traces_spike_biases[i]);
499  }
500  }
501 
502  // follow the target vector (instead of evolve)
503  post_state_traces[i]->follow();
504  }
505 }
std::vector< AurynFloat > post_state_traces_spike_biases
Definition: SpikingGroup.h:112
std::vector< Trace * > posttraces
Posttraces.
Definition: SpikingGroup.h:108
NeuronID global2rank(NeuronID i)
Converts global NeuronID within the SpikingGroup to the local NeuronID on this rank.
Definition: SpikingGroup.h:446
SpikeContainer * get_spikes()
Returns pointer to a spike container that contains spikes which arrive in this timestep from all neur...
Definition: SpikingGroup.cpp:245
std::vector< Trace * > pretraces
Pretraces.
Definition: SpikingGroup.h:105
SpikeContainer * get_spikes_immediate()
Returns pointer to SpikeContainer of spikes generated during the last evolve() step.
Definition: SpikingGroup.cpp:250
std::vector< Trace * > post_state_traces
Post state traces.
Definition: SpikingGroup.h:111
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:

◆ find_state_vector()

AurynStateVector * SpikingGroup::find_state_vector ( std::string  key)

Returns existing state vector by name or NULL if it does not exist.

Parameters
keyA string with the name of the state vector.
Returns
The state vector and NULL if the state_vector does not exist.
749 {
750  std::stringstream oss;
751  oss << "SpikingGroup:: Running find_state_vector for " << key;
752  auryn::logger->msg(oss.str(),VERBOSE);
753  if ( state_vectors.find(key) == state_vectors.end() ) {
754  return NULL;
755  } else {
756  return state_vectors.find(key)->second;
757  }
758 }
Logger * logger
Global pointer to instance of Logger which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:36
std::map< std::string, AurynStateVector * > state_vectors
Definition: SpikingGroup.h:153
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
Here is the call graph for this function:

◆ free()

void SpikingGroup::free ( )
protected

Frees potentially allocated memory.

183 {
184  std::stringstream oss;
185  oss << "SpikingGroup:: " <<
186  get_log_name()
187  << " freeing ...";
188  auryn::logger->msg(oss.str(),VERBOSE);
189 
190  auryn::logger->msg("SpikingGroup:: Deleting delay",VERBOSE);
191  delete delay;
192 
193  auryn::logger->msg("SpikingGroup:: Freeing pretraces",VERBOSE);
194  for ( NeuronID i = 0 ; i < pretraces.size() ; ++i )
195  delete pretraces[i];
196 
197  auryn::logger->msg("SpikingGroup:: Freeing posttraces",VERBOSE);
198  for ( NeuronID i = 0 ; i < posttraces.size() ; ++i )
199  delete posttraces[i];
200 
201  auryn::logger->msg("SpikingGroup:: Freeing state traces",VERBOSE);
202  for ( NeuronID i = 0 ; i < post_state_traces.size() ; ++i ) {
203  std::stringstream oss;
204  oss << get_log_name()
205  << ":: Freeing state trace "
207  << " at "
208  << i;
209  auryn::logger->msg(oss.str() ,VERBOSE);
210  delete post_state_traces[i];
211  }
212 
213  auryn::logger->msg("SpikingGroup:: Freeing state vectors",VERBOSE);
214  for ( std::map<std::string,AurynStateVector *>::const_iterator iter = state_vectors.begin() ;
215  iter != state_vectors.end() ;
216  ++iter ) {
217  std::stringstream oss;
218  oss << "Freeing " << get_name()
219  << ": " << iter->first;
220  auryn::logger->msg(oss.str(),VERBOSE);
221  if ( iter->first[0] == '_' ) continue; // do not process volatile state_vector
222  delete iter->second;
223  }
224  state_vectors.clear();
225 
226 }
std::vector< Trace * > posttraces
Posttraces.
Definition: SpikingGroup.h:108
std::vector< Trace * > pretraces
Pretraces.
Definition: SpikingGroup.h:105
std::vector< AurynStateVector * > post_state_traces_states
Definition: SpikingGroup.h:113
Logger * logger
Global pointer to instance of Logger which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:36
std::map< std::string, AurynStateVector * > state_vectors
Definition: SpikingGroup.h:153
std::string get_log_name()
Returns a string which is the combination of file and connection name for logging.
Definition: SpikingGroup.cpp:523
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
SpikeDelay * delay
Definition: SpikingGroup.h:144
std::vector< Trace * > post_state_traces
Post state traces.
Definition: SpikingGroup.h:111
std::string get_name()
Retrieves the groups name.
Definition: SpikingGroup.cpp:512
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:

◆ get_attributes()

AttributeContainer * SpikingGroup::get_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.

256 {
257  return delay->get_attributes();
258 }
SpikeDelay * delay
Definition: SpikingGroup.h:144
AttributeContainer * get_attributes(unsigned int pos=1)
Like get_spikes but returns the spike attributes.
Definition: SpikeDelay.cpp:95
Here is the call graph for this function:

◆ get_attributes_immediate()

AttributeContainer * SpikingGroup::get_attributes_immediate ( )

Returns pointer to Attributecontainer of spikes generated during the last evolve() step.

261 {
263 }
SpikeDelay * delay
Definition: SpikingGroup.h:144
AttributeContainer * get_attributes_immediate()
Like get_spikes_immediate but returns the spike attributes.
Definition: SpikeDelay.cpp:100
Here is the call graph for this function:

◆ get_existing_state_vector()

AurynStateVector * SpikingGroup::get_existing_state_vector ( std::string  key)

Returns an existing state with the supplied name.

Parameters
keyA string with the name of the state vector.
Returns
The state vector and NULL if the state_vector does not exist.
760  {
761  return find_state_vector(key);
762 }
AurynStateVector * find_state_vector(std::string key)
Returns existing state vector by name or NULL if it does not exist.
Definition: SpikingGroup.cpp:748
Here is the call graph for this function:

◆ get_file_name()

std::string SpikingGroup::get_file_name ( )

Extracts the class name of the connection from the file name.

518 {
519  std::string filename (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__);
520  return filename;
521 }
std::string string
Standard library string type which is imported into Auryn namespace.
Definition: auryn_definitions.h:156

◆ get_locked_range()

unsigned int SpikingGroup::get_locked_range ( )

Returns locked range of ranks for SpikingGroups which are not distributed across all ranks.

335 {
336  return locked_range;
337 }

◆ get_locked_rank()

unsigned int SpikingGroup::get_locked_rank ( )

Returns locked rank for SpikingGroups which are not distributed across all ranks.

330 {
331  return locked_rank;
332 }

◆ get_log_name()

std::string SpikingGroup::get_log_name ( )

Returns a string which is the combination of file and connection name for logging.

524 {
525  std::stringstream oss;
526  oss << get_name() << " ("
527  << get_file_name() << "): ";
528  return oss.str();
529 }
std::string get_file_name()
Extracts the class name of the connection from the file name.
Definition: SpikingGroup.cpp:517
std::string get_name()
Retrieves the groups name.
Definition: SpikingGroup.cpp:512
Here is the call graph for this function:

◆ get_name()

std::string SpikingGroup::get_name ( )

Retrieves the groups name.

513 {
514  return group_name;
515 }
std::string group_name
Identifying name for object.
Definition: SpikingGroup.h:116

◆ get_num_spike_attributes()

int SpikingGroup::get_num_spike_attributes ( )
916 {
917  return delay->get_num_attributes();
918 }
int get_num_attributes()
Returns the number of spike attributes per spike.
Definition: SpikeDelay.cpp:139
SpikeDelay * delay
Definition: SpikingGroup.h:144
Here is the call graph for this function:

◆ get_output_line()

std::string SpikingGroup::get_output_line ( NeuronID  i)
protectedvirtual
810 {
811  std::stringstream oss;
812 
813  for ( std::map<std::string,AurynStateVector *>::const_iterator iter = state_vectors.begin() ;
814  iter != state_vectors.end() ;
815  ++iter ) {
816  if ( iter->first[0] == '_' ) continue; // do not process volatile state_vector
817  oss << std::scientific << iter->second->get( i ) << " ";
818  }
819 
820  for ( NeuronID k = 0 ; k < pretraces.size() ; k++ ) {
821  // TODO this is actually a bug and only a part of the pretrace gets saved this way
822  for ( NeuronID l = 0 ; l < get_locked_range() ; ++l ) {
823  NeuronID t = get_locked_range()*(i)+l;
824  if ( t < get_size() )
825  oss << pretraces[k]->get(t) << " ";
826  else
827  oss << 0.0 << " ";
828  }
829  }
830 
831  for ( NeuronID k = 0 ; k < posttraces.size() ; k++ ) {
832  oss << posttraces[k]->get(i) << " ";
833  }
834 
835  oss << "\n";
836 
837  return oss.str();
838 }
std::vector< Trace * > posttraces
Posttraces.
Definition: SpikingGroup.h:108
std::vector< Trace * > pretraces
Pretraces.
Definition: SpikingGroup.h:105
std::map< std::string, AurynStateVector * > state_vectors
Definition: SpikingGroup.h:153
unsigned int get_locked_range()
Returns locked range of ranks for SpikingGroups which are not distributed across all ranks...
Definition: SpikingGroup.cpp:334
NeuronID get_size()
Returns the size of the group.
Definition: SpikingGroup.cpp:304
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:

◆ get_post_size()

NeuronID SpikingGroup::get_post_size ( )

Returns the size on this rank.

It's the size that should be used when a postsynaptic trace is defined on this group, hence the name.

315 {
316  return get_rank_size();
317 }
NeuronID get_rank_size()
Returns the size on this rank.
Definition: SpikingGroup.h:450
Here is the call graph for this function:

◆ get_post_state_trace() [1/2]

Trace * SpikingGroup::get_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.

This trace is an cotinuously integrated Trace which uses the follow function on the mem state vector.

Parameters
state_nameA string stating the neurons state name
tauThe time constant of the trace.
bThe optional parameter b allows to specify a spike triggered contribution which will be added instantaneously to the trace upon each postsynaptic spike.
458 {
459  AurynStateVector * state = find_state_vector( state_name );
460  return get_post_state_trace(state, tau, b);
461 }
Trace * get_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...
Definition: SpikingGroup.cpp:457
AurynStateVector * find_state_vector(std::string key)
Returns existing state vector by name or NULL if it does not exist.
Definition: SpikingGroup.cpp:748
Default AurynVectorFloat class for performance computation.
Definition: AurynVector.h:796
Here is the call graph for this function:

◆ get_post_state_trace() [2/2]

Trace * SpikingGroup::get_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.

This trace is an cotinuously integrated Trace which uses the follow function on the mem state vector.

Parameters
stateA pointer to the relevant state vector
tauThe time constant of the trace.
bThe optional parameter b allows to specify a spike triggered contribution which will be added instantaneously to the trace upon each postsynaptic spike.
423 {
424  // first let's check if a state with that name exists
425  if ( state == NULL ) {
426  auryn::logger->msg("A state vector was not found at this pointer reference.", ERROR);
428  } // good to go
429 
430  for ( NeuronID i = 0 ; i < post_state_traces.size() ; i++ ) {
431  if ( post_state_traces[i]->get_tau() == tau
433  && post_state_traces_states[i] == state ) {
434  std::stringstream oss;
435  oss << get_log_name()
436  << ":: Sharing post state trace for ptr reference "
437  << state // TODO replace by name reverse lookup
438  << " with "
439  << tau
440  << "s timeconstant." ;
441  auryn::logger->msg(oss.str(),VERBOSE);
442  return post_state_traces[i];
443  }
444  }
445 
446  // trace does not exist yet, so we are creating
447  // it and do the book keeping
448  auryn::logger->msg("Initializing post trace instance",VERBOSE);
449  Trace * tmp = new EulerTrace(get_post_size(),tau);
450  tmp->set_target(state);
451  post_state_traces.push_back(tmp);
452  post_state_traces_spike_biases.push_back(b);
453  post_state_traces_states.push_back(state);
454  return tmp;
455 }
Solves a set of identical linear differential equations with the Euler method. It is used to implemen...
Definition: EulerTrace.h:43
std::vector< AurynFloat > post_state_traces_spike_biases
Definition: SpikingGroup.h:112
std::vector< AurynStateVector * > post_state_traces_states
Definition: SpikingGroup.h:113
Abstract base class of synaptic traces.
Definition: Trace.h:36
Logger * logger
Global pointer to instance of Logger which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:36
std::string get_log_name()
Returns a string which is the combination of file and connection name for logging.
Definition: SpikingGroup.cpp:523
Definition: Logger.h:41
virtual void set_target(AurynStateVector *target)=0
Set the target vector for follow operation.
Definition: auryn_definitions.h:289
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
NeuronID get_post_size()
Returns the size on this rank.
Definition: SpikingGroup.cpp:314
std::vector< Trace * > post_state_traces
Post state traces.
Definition: SpikingGroup.h:111
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:

◆ get_post_trace()

Trace * SpikingGroup::get_post_trace ( AurynFloat  x)

Returns a post trace with time constant x.

Checks first if an instance of a trace exists and returns it otherwise creates a new instance first.

Parameters
xThe timeconstant for the postsynaptic trace.
Returns
a pointer to a postsynaptic trace instance.
391 {
392  for ( NeuronID i = 0 ; i < posttraces.size() ; i++ ) {
393  if ( posttraces[i]->get_tau() == x ) {
394  std::stringstream oss;
395  oss << get_log_name() << ":: Sharing post trace with " << x << "s timeconstant." ;
396  auryn::logger->msg(oss.str(),VERBOSE);
397  return posttraces[i];
398  }
399  }
400 
401 
402  auryn::logger->msg("Initializing post trace instance",VERBOSE);
403  Trace * tmp = new EulerTrace(get_post_size(),x);
404  add_post_trace(tmp);
405  return tmp;
406 }
Solves a set of identical linear differential equations with the Euler method. It is used to implemen...
Definition: EulerTrace.h:43
std::vector< Trace * > posttraces
Posttraces.
Definition: SpikingGroup.h:108
Abstract base class of synaptic traces.
Definition: Trace.h:36
Logger * logger
Global pointer to instance of Logger which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:36
std::string get_log_name()
Returns a string which is the combination of file and connection name for logging.
Definition: SpikingGroup.cpp:523
void add_post_trace(Trace *tr)
Adds trace to posttrace stack of a connection.
Definition: SpikingGroup.cpp:408
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
NeuronID get_post_size()
Returns the size on this rank.
Definition: SpikingGroup.cpp:314
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:

◆ get_pre_size()

NeuronID SpikingGroup::get_pre_size ( )

Returns the size of the group.

It's the size that should be used when a presynaptic trace is defined on this grou, hence the name.

310 {
311  return get_size();
312 }
NeuronID get_size()
Returns the size of the group.
Definition: SpikingGroup.cpp:304
Here is the call graph for this function:

◆ get_pre_trace()

Trace * SpikingGroup::get_pre_trace ( AurynFloat  x)

Returns a pre trace with time constant x.

Checks first if an instance of a trace exists and returns it otherwise creates a new instance first.

Parameters
xThe timeconstant for the presynaptic trace
Returns
a pointer to a pre trace instance
360 {
361  for ( NeuronID i = 0 ; i < pretraces.size() ; i++ ) {
362  if ( pretraces[i]->get_tau() == x ) {
363  std::stringstream oss;
364  oss << get_log_name() << ":: Sharing pre trace with " << x << "s timeconstant." ;
365  auryn::logger->msg(oss.str(),VERBOSE);
366  return pretraces[i];
367  }
368  }
369 
370  auryn::logger->msg("Initializing pre trace instance",VERBOSE);
371  Trace * tmp = new EulerTrace(get_pre_size(),x);
372  add_pre_trace(tmp);
373  return tmp;
374 }
Solves a set of identical linear differential equations with the Euler method. It is used to implemen...
Definition: EulerTrace.h:43
std::vector< Trace * > pretraces
Pretraces.
Definition: SpikingGroup.h:105
Abstract base class of synaptic traces.
Definition: Trace.h:36
Logger * logger
Global pointer to instance of Logger which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:36
std::string get_log_name()
Returns a string which is the combination of file and connection name for logging.
Definition: SpikingGroup.cpp:523
void add_pre_trace(Trace *tr)
Adds trace to pretrace stack of a connection.
Definition: SpikingGroup.cpp:376
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
NeuronID get_pre_size()
Returns the size of the group.
Definition: SpikingGroup.cpp:309
Here is the call graph for this function:

◆ get_rank_size()

NeuronID auryn::SpikingGroup::get_rank_size ( )
inline

Returns the size on this rank.

451 {
452  return rank_size;
453 }
NeuronID rank_size
Stores the size of the group on this rank.
Definition: SpikingGroup.h:121

◆ get_size()

NeuronID SpikingGroup::get_size ( )

Returns the size of the group.

305 {
306  return size;
307 }
NeuronID size
Stores the size of the group.
Definition: SpikingGroup.h:119

◆ get_spikes()

SpikeContainer * SpikingGroup::get_spikes ( )

Returns pointer to a spike container that contains spikes which arrive in this timestep from all neurons in this group.

In paralell simulations the SpikeContainer returned is at this point in time guaranteed to contain spikes from all ranks.

246 {
247  return delay->get_spikes();
248 }
SpikeContainer * get_spikes(unsigned int pos=1)
Returns the spikes at a given delay position.
Definition: SpikeDelay.cpp:85
SpikeDelay * delay
Definition: SpikingGroup.h:144
Here is the call graph for this function:

◆ get_spikes_immediate()

SpikeContainer * SpikingGroup::get_spikes_immediate ( )

Returns pointer to SpikeContainer of spikes generated during the last evolve() step.

251 {
252  return delay->get_spikes_immediate();
253 }
SpikeContainer * get_spikes_immediate()
Returns the spikes stored into the delay within this very same time step.
Definition: SpikeDelay.cpp:90
SpikeDelay * delay
Definition: SpikingGroup.h:144
Here is the call graph for this function:

◆ get_state_variable()

AurynState * SpikingGroup::get_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.

922 {
923  if ( state_variables.find(key) == state_variables.end() ) {
924  state_variables[key] = 0.0;
925  }
926  return &(state_variables.find(key)->second);
927 }
std::map< std::string, AurynState > state_variables
Definition: SpikingGroup.h:156

◆ get_state_vector()

AurynStateVector * SpikingGroup::get_state_vector ( std::string  key)

Creates a new or returns an existing state vector by name.

This function returns a state vector for the given key. If a vector with the key does not exist the function creates one. If it does exist it returns the existing one. The function returns NULL if the statevector would have zero length on that rank.

Parameters
keyThe key name of the state vector to be return
Returns
A StateVector matching the key provided.
782 {
783  AurynStateVector * vec = find_state_vector(key);
784  if ( vec ) {
785  return vec;
786  } else {
787  return create_state_vector(key);
788  }
789 }
AurynStateVector * create_state_vector(std::string key)
Creates a new state vector and throws an exception if a vector with the same name exists...
Definition: SpikingGroup.cpp:764
AurynStateVector * find_state_vector(std::string key)
Returns existing state vector by name or NULL if it does not exist.
Definition: SpikingGroup.cpp:748
Default AurynVectorFloat class for performance computation.
Definition: AurynVector.h:796
Here is the call graph for this function:

◆ get_uid()

NeuronID SpikingGroup::get_uid ( )

Get the unique ID of the class.

Returns
a unique numerical identifier of the present SpikingGroup instance.
266 {
267  return unique_id;
268 }

◆ get_vector_size()

NeuronID SpikingGroup::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.

902 {
904 }
NeuronID get_rank_size()
Returns the size on this rank.
Definition: SpikingGroup.h:450
NeuronID calculate_vector_size(NeuronID i)
Rounds vector size to multiple of four to allow using the SSE optimizations.
Definition: auryn_definitions.cpp:50
Here is the call graph for this function:

◆ global2rank()

NeuronID auryn::SpikingGroup::global2rank ( NeuronID  i)
inline

Converts global NeuronID within the SpikingGroup to the local NeuronID on this rank.

The return value of global2rank is only defined if the SpikingGroup has units on the present rank.

See also
evolve_locally
Parameters
iThe global NeuronID to convert
Returns
The NeuronID of the referenced neuron on the current rankDoes not
446  {
447  return i/locked_range;
448 }

◆ inc_num_spike_attributes()

void SpikingGroup::inc_num_spike_attributes ( int  x)

Instructs SpikingGroup to increase the number of spike attributes by x.

The reason we only increment the size is that multiple Connection objects such as STPConnection might want to add an attribute to a spike. These might be different to allow synaptic type dependent plasticity and hence will all have to be transmitted without knowledge about the other synapses which might want to submit a different value.

907 {
908  std::stringstream oss;
909  oss << get_log_name() << ":: Registering " << x << " spike attributes." ;
910  auryn::logger->msg(oss.str(),VERBOSE);
911 
913 }
Logger * logger
Global pointer to instance of Logger which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:36
void inc_num_attributes(int x)
Internally used by SyncBuffer to submit x attributes with spikes in this delay.
Definition: SpikeDelay.cpp:144
std::string get_log_name()
Returns a string which is the combination of file and connection name for logging.
Definition: SpikingGroup.cpp:523
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
SpikeDelay * delay
Definition: SpikingGroup.h:144
Here is the call graph for this function:

◆ load_from_file()

bool SpikingGroup::load_from_file ( const char *  filename)
virtual

Reads current states of SpikingGroup to human-readible textfile if implemented in derived class.

586 {
587  if ( !evolve_locally() ) return true;
588 
589  std::stringstream oss;
590  oss << "Loading SpikingGroup from " << filename;
591  auryn::logger->msg(oss.str(),NOTIFICATION);
592 
593  std::ifstream infile (filename);
594 
595  if (!infile) {
596  std::stringstream oes;
597  oes << "Can't open input file " << filename;
598  auryn::logger->msg(oes.str(),ERROR);
599  throw AurynOpenFileException();
600  }
601 
602  NeuronID count = 0;
603  char buffer[1024];
604 
605  infile.getline (buffer,1024); // skipping header TODO once could make this logic a bit smarter
606  infile.getline (buffer,1024); // skipping header
607 
608  boost::archive::text_iarchive ia(infile);
609  ia >> *delay;
610 
611  infile.getline (buffer,1024); // jumpting to next line
612 
613  while ( infile.getline (buffer,1024) )
614  {
615  load_input_line(count,buffer);
616  count++;
617  }
618 
619  if ( get_rank_size() != count ) {
620  // issue warning
621  std::stringstream oes;
622  oes << "SpikingGroup:: NeuronState file corrupted. Read "
623  << count << " entries, but "
624  << get_rank_size() << " expected in " << filename;
625  auryn::logger->msg(oes.str(),WARNING);
626  }
627 
628  infile.close();
629  return true;
630 }
NeuronID get_rank_size()
Returns the size on this rank.
Definition: SpikingGroup.h:450
Definition: Logger.h:41
Definition: Logger.h:41
virtual void load_input_line(NeuronID i, const char *buf)
Definition: SpikingGroup.cpp:840
Logger * logger
Global pointer to instance of Logger which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:36
Definition: auryn_definitions.h:208
bool evolve_locally()
Returns true if the calling instance has units which are integrated on the current rank...
Definition: SpikingGroup.cpp:323
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
SpikeDelay * delay
Definition: SpikingGroup.h:144
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:

◆ load_input_line()

void SpikingGroup::load_input_line ( NeuronID  i,
const char *  buf 
)
protectedvirtual
841 {
842  int nums_now, bytes_now;
843  int bytes_consumed = 0, nums_read = 0;
844  float temp;
845 
846  // read the state_vectors
847  for ( std::map<std::string,AurynStateVector *>::const_iterator iter = state_vectors.begin() ;
848  iter != state_vectors.end() ;
849  ++iter ) {
850  if ( iter->first[0] == '_' ) continue; // do not process volatile state_vector
851  if ( ( nums_now = sscanf( buf + bytes_consumed, "%f%n", & temp, & bytes_now ) ) <= 0 )
852  {
853  // error handling
854  auryn::logger->msg("Expected additional fields for single neuron parameters. Corrupted nstate file? Aborting.",ERROR);
855  return;
856  }
857  bytes_consumed += bytes_now;
858  nums_read += nums_now;
859  iter->second->set( i, temp );
860  }
861 
862  for ( int k = 0 ; k < pretraces.size() ; k++ ) {
863  for ( int l = 0 ; l < get_locked_range() ; ++l ) {
864  if ( ( nums_now = sscanf( buf + bytes_consumed, "%f%n", & temp, & bytes_now ) ) <= 0 )
865  {
866  // error handling
867  auryn::logger->msg("Expected additional fields for pretrace values. Corrupted nstate file? Aborting.",ERROR);
868  return;
869  }
870  bytes_consumed += bytes_now;
871  nums_read += nums_now;
872  NeuronID t = get_locked_range()*(i)+l;
873  if ( t<get_size() )
874  pretraces[k]->set(t,temp);
875 
876  // std::cout << temp << std::endl;
877  }
878  }
879 
880  for ( int k = 0 ; k < posttraces.size() ; k++ ) {
881  if ( ( nums_now = sscanf( buf + bytes_consumed, "%f%n", & temp, & bytes_now ) ) <= 0 )
882  {
883  // error handling
884  auryn::logger->msg("Expected additional fields for posttrace values. Corrupted nstate file? Aborting.",ERROR);
885  return;
886  }
887  bytes_consumed += bytes_now;
888  nums_read += nums_now;
889  posttraces[k]->set(i,temp);
890  }
891 
892 
893  // check if we read all the values on that line
894  if ( ( nums_now = sscanf( buf + bytes_consumed, "%f%n", & temp, & bytes_now ) ) > 0 )
895  {
896  // error handling
897  auryn::logger->msg("There were unprocessed values in nstatefile.",WARNING);
898  }
899 }
std::vector< Trace * > posttraces
Posttraces.
Definition: SpikingGroup.h:108
std::vector< Trace * > pretraces
Pretraces.
Definition: SpikingGroup.h:105
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
std::map< std::string, AurynStateVector * > state_vectors
Definition: SpikingGroup.h:153
Definition: Logger.h:41
unsigned int get_locked_range()
Returns locked range of ranks for SpikingGroups which are not distributed across all ranks...
Definition: SpikingGroup.cpp:334
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:

◆ localrank()

bool SpikingGroup::localrank ( NeuronID  i)

Checks if the global NeuronID i is integrated on this MPI rank.

Parameters
ithe NeuronID to check.
Returns
true if the neuron with global id i is integrated on the present rank.
531  {
532 
533 #ifdef DEBUG
534  std::cout << ( (i%locked_range+locked_rank)==mpi_rank ) << " "
535  << ( (int) mpi_rank >= locked_rank) << " "
536  << ( (int) mpi_rank >= locked_rank) << " "
537  << ( (int) mpi_rank < (locked_rank+locked_range) ) << " "
538  << ( i/locked_range < get_rank_size() ) << std::endl;
539 #endif //DEBUG
540 
541  bool t = ( (i%locked_range+locked_rank)==mpi_rank )
542  && (int) mpi_rank >= locked_rank
543  && (int) mpi_rank < (locked_rank+locked_range)
544  && i/locked_range < get_rank_size();
545  return t;
546 }
NeuronID get_rank_size()
Returns the size on this rank.
Definition: SpikingGroup.h:450
Here is the call graph for this function:

◆ push_attribute()

void SpikingGroup::push_attribute ( AurynFloat  attrib)

Pushes a spike attribute into the axonal SpikeDelay buffer.

This is for instance used to implement short-term plasticity in which each presynaptic spike is associated with a certain currently available amount of presynaptic neurotransmitter. Spike attributes are float values which can be attaced to a spike to convey this information.

276 {
277  attribs->push_back(attrib);
278 }
AttributeContainer * attribs
Definition: SpikingGroup.h:124

◆ push_spike()

void SpikingGroup::push_spike ( NeuronID  spike)

Pushes a local NeuronID as spike into the axonal SpikeDelay buffer.

This function expectes the local NeuronID and translates the argument to a global argument.

See also
rank2global, global2rank
Parameters
spikeThe NeuronID of the units which spiked in the current timestep
271 {
272  spikes->push_back(rank2global(spike));
273 }
SpikeContainer * spikes
SpikeContainers to store spikes produced during one step of evolve.
Definition: SpikingGroup.h:123
NeuronID rank2global(NeuronID i)
Converts local NeuronID from the local rank to a global NeuronID.
Definition: SpikingGroup.cpp:319
Here is the call graph for this function:

◆ randomize_state_vector_gauss()

void SpikingGroup::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.

793 {
794  boost::mt19937 ng_gen(seed+mpi_rank); // produces same series every time
795  boost::normal_distribution<> dist((double)mean, (double)sigma);
796  boost::variate_generator<boost::mt19937&, boost::normal_distribution<> > die(ng_gen, dist);
797  AurynState rv;
798 
799  AurynStateVector * vec = get_state_vector(state_vector_name);
800 
801 
802  for ( AurynLong i = 0 ; i<get_rank_size() ; ++i ) {
803  rv = die();
804  vec->set( i, rv );
805  }
806 
807 }
NeuronID get_rank_size()
Returns the size on this rank.
Definition: SpikingGroup.h:450
AurynStateVector * get_state_vector(std::string key)
Creates a new or returns an existing state vector by name.
Definition: SpikingGroup.cpp:781
void set(IndexType i, T value)
Sets element i in vector to value.
Definition: AurynVector.h:224
unsigned long AurynLong
An unsigned long type used to count synapses or similar.
Definition: auryn_definitions.h:154
AurynFloat AurynState
Type for Auryn state variables (default single precision since it needs to be compatible with auryn_v...
Definition: auryn_definitions.h:160
Default AurynVectorFloat class for performance computation.
Definition: AurynVector.h:796
Here is the call graph for this function:

◆ rank2global()

NeuronID SpikingGroup::rank2global ( NeuronID  i)

Converts local NeuronID from the local rank to a global NeuronID.

Parameters
iThe local neuron id.
Returns
The global neuron id.
See also
global2rank

This function performs id translation for parallel simulations from a local rank id to a global NeuronID.

319  {
320  return i*locked_range+(mpi_rank-locked_rank);
321 }

◆ ranksize()

NeuronID SpikingGroup::ranksize ( )

Returns size (num of neurons) on the current rank.

300  {
301  return get_rank_size();
302 }
NeuronID get_rank_size()
Returns the size on this rank.
Definition: SpikingGroup.h:450
Here is the call graph for this function:

◆ remove_state_vector()

void SpikingGroup::remove_state_vector ( std::string  key)

Removes a state vector passed as an argument to the dictinary.

The state vector is not freed automatically!

744 {
745  state_vectors.erase(key);
746 }
std::map< std::string, AurynStateVector * > state_vectors
Definition: SpikingGroup.h:153

◆ set_clock_ptr()

void SpikingGroup::set_clock_ptr ( AurynTime clock)
228  {
229  clock_ptr = clock;
230  delay->set_clock_ptr(clock);
231 }
SpikeDelay * delay
Definition: SpikingGroup.h:144
void set_clock_ptr(AurynTime *clock)
Internal function to set clock pointer.
Definition: SpikeDelay.cpp:105
static AurynTime * clock_ptr
Definition: SpikingGroup.h:127
Here is the call graph for this function:

◆ set_delay()

void SpikingGroup::set_delay ( int  d)

Sets axonal delay for this SpikingGroup.

Note the delay needs to be larger er equal to the MINDELAY defined in auryn_definitions.h

346 {
347  if ( d < MINDELAY ) {
349  }
350 
351  axonaldelay = d;
352 
353  delay->set_delay(d); // the plus one here takes care of the current timestep
354 
355  // spikes = delay->get_spikes_immediate();
356  // attribs = delay->get_attributes_immediate();
357 }
Definition: auryn_definitions.h:273
void set_delay(int delay)
Set delay in number of timesteps.
Definition: SpikeDelay.cpp:41
SpikeDelay * delay
Definition: SpikingGroup.h:144
#define MINDELAY
Switches collection of timing stats in some classes like SyncBuffer and system.
Definition: auryn_definitions.h:82
Here is the call graph for this function:

◆ set_name()

void SpikingGroup::set_name ( std::string  s)

Set connection name.

508 {
509  group_name = s;
510 }
std::string group_name
Identifying name for object.
Definition: SpikingGroup.h:116

◆ virtual_serialize() [1/2]

void SpikingGroup::virtual_serialize ( boost::archive::binary_oarchive &  ar,
const unsigned int  version 
)
protectedvirtual

Implementatinon of serialize function for writing.

633 {
634  std::stringstream oss;
635  oss << get_log_name() << " serializing delay";
636  auryn::logger->msg(oss.str(),VERBOSE);
637 
638  ar & size & axonaldelay;
639  ar & *delay;
640 
641  oss.str("");
642  oss << get_log_name() << " serializing " << state_vectors.size() << " state vectors";
643  auryn::logger->msg(oss.str(),VERBOSE);
644  for ( std::map<std::string,AurynStateVector *>::const_iterator iter = state_vectors.begin() ;
645  iter != state_vectors.end() ;
646  ++iter ) {
647  if ( iter->first[0] == '_' ) continue; // do not process volatile state_vector
648  ar & iter->first;
649  ar & *(iter->second);
650  }
651 
652  oss.str("");
653  oss << get_log_name() << " serializing " << state_variables.size() << " state variables";
654  ar & state_variables;
655 
656  oss.str("");
657  oss << get_log_name() << " serializing " << pretraces.size() << " pre traces";
658  auryn::logger->msg(oss.str(),VERBOSE);
659  for ( NeuronID i = 0 ; i < pretraces.size() ; ++i )
660  ar & *(pretraces[i]);
661 
662  oss.str("");
663  oss << get_log_name() << " serializing " << posttraces.size() << " post traces";
664  auryn::logger->msg(oss.str(),VERBOSE);
665  for ( NeuronID i = 0 ; i < posttraces.size() ; ++i )
666  ar & *(posttraces[i]);
667 
668  oss.str("");
669  oss << get_log_name() << " serializing " << post_state_traces.size() << " post_state traces";
670  auryn::logger->msg(oss.str(),VERBOSE);
671  for ( NeuronID i = 0 ; i < post_state_traces.size() ; ++i )
672  ar & *(post_state_traces[i]);
673 
674  oss.str("");
675  oss << get_log_name() << " serialize finished for group ";
676  auryn::logger->msg(oss.str(),VERBOSE);
677 }
std::vector< Trace * > posttraces
Posttraces.
Definition: SpikingGroup.h:108
std::vector< Trace * > pretraces
Pretraces.
Definition: SpikingGroup.h:105
Logger * logger
Global pointer to instance of Logger which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:36
std::map< std::string, AurynStateVector * > state_vectors
Definition: SpikingGroup.h:153
std::string get_log_name()
Returns a string which is the combination of file and connection name for logging.
Definition: SpikingGroup.cpp:523
NeuronID size
Stores the size of the group.
Definition: SpikingGroup.h:119
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
SpikeDelay * delay
Definition: SpikingGroup.h:144
std::map< std::string, AurynState > state_variables
Definition: SpikingGroup.h:156
std::vector< Trace * > post_state_traces
Post state traces.
Definition: SpikingGroup.h:111
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:

◆ virtual_serialize() [2/2]

void SpikingGroup::virtual_serialize ( boost::archive::binary_iarchive &  ar,
const unsigned int  version 
)
protectedvirtual

Implementatinon of serialize function for reading.

680 {
681  std::stringstream oss;
682  oss << get_log_name() << " reading delay";
683  auryn::logger->msg(oss.str(),VERBOSE);
684 
685  ar & size & axonaldelay ;
686  ar & *delay;
687 
688  oss.str("");
689  oss << get_log_name() << " reading " << state_vectors.size() << " state vectors";
690  auryn::logger->msg(oss.str(),VERBOSE);
691  for ( std::map<std::string,AurynStateVector *>::const_iterator iter = state_vectors.begin() ;
692  iter != state_vectors.end() ;
693  ++iter ) {
694  if ( iter->first[0] == '_' ) continue; // do not process volatile state_vector
695  std::string key;
696  ar & key;
697  AurynStateVector * vect = find_state_vector(key);
698  ar & *vect;
699  }
700 
701  oss.str("");
702  oss << get_log_name() << " reading " << state_variables.size() << " state variables";
703  ar & state_variables;
704 
705  oss.str("");
706  oss << get_log_name() << " reading " << pretraces.size() << " pre traces";
707  auryn::logger->msg(oss.str(),VERBOSE);
708  for ( NeuronID i = 0 ; i < pretraces.size() ; ++i )
709  ar & *(pretraces[i]);
710 
711  oss.str("");
712  oss << get_log_name() << " reading " << posttraces.size() << " post traces";
713  auryn::logger->msg(oss.str(),VERBOSE);
714  for ( NeuronID i = 0 ; i < posttraces.size() ; ++i )
715  ar & *(posttraces[i]);
716 
717  oss.str("");
718  oss << get_log_name() << " reading " << post_state_traces.size() << " post_state_traces";
719  auryn::logger->msg(oss.str(),VERBOSE);
720  for ( NeuronID i = 0 ; i < post_state_traces.size() ; ++i )
721  ar & *(post_state_traces[i]);
722 
723  oss.str("");
724  oss << get_log_name() << " serialize finished for group ";
725  auryn::logger->msg(oss.str(),VERBOSE);
726 }
std::vector< Trace * > posttraces
Posttraces.
Definition: SpikingGroup.h:108
std::vector< Trace * > pretraces
Pretraces.
Definition: SpikingGroup.h:105
AurynStateVector * find_state_vector(std::string key)
Returns existing state vector by name or NULL if it does not exist.
Definition: SpikingGroup.cpp:748
Logger * logger
Global pointer to instance of Logger which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:36
std::map< std::string, AurynStateVector * > state_vectors
Definition: SpikingGroup.h:153
std::string get_log_name()
Returns a string which is the combination of file and connection name for logging.
Definition: SpikingGroup.cpp:523
NeuronID size
Stores the size of the group.
Definition: SpikingGroup.h:119
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
SpikeDelay * delay
Definition: SpikingGroup.h:144
Default AurynVectorFloat class for performance computation.
Definition: AurynVector.h:796
std::map< std::string, AurynState > state_variables
Definition: SpikingGroup.h:156
std::vector< Trace * > post_state_traces
Post state traces.
Definition: SpikingGroup.h:111
std::string string
Standard library string type which is imported into Auryn namespace.
Definition: auryn_definitions.h:156
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:

◆ write_to_file()

bool SpikingGroup::write_to_file ( const char *  filename)
virtual

Writes current states of SpikingGroup to human-readible textfile if implemented in derived class.

550 {
551  if ( !evolve_locally() ) return true;
552 
553  std::ofstream outfile;
554  outfile.open(filename,std::ios::out);
555  if (!outfile) {
556  std::cerr << "Can't open output file " << filename << std::endl;
557  throw AurynOpenFileException();
558  }
559 
560  outfile << "# Auryn SpikingGroup state file for n="<< get_rank_size() <<" neurons" << std::endl;
561  outfile << "# Default field order (might be overwritten): ";
562  for ( std::map<std::string,AurynStateVector *>::const_iterator iter = state_vectors.begin() ;
563  iter != state_vectors.end() ;
564  ++iter ) {
565  if ( iter->first[0] == '_' ) continue; // do not process volatile state_vector
566  outfile << std::scientific << iter->first << " ";
567  }
568  outfile << "(plus traces)";
569  outfile << std::endl;
570 
571 
572  boost::archive::text_oarchive oa(outfile);
573  oa << *(delay);
574  outfile << std::endl;
575 
576  for ( NeuronID i = 0 ; i < get_rank_size() ; ++i )
577  {
578  outfile << get_output_line(i);
579  }
580 
581  outfile.close();
582  return true;
583 }
NeuronID get_rank_size()
Returns the size on this rank.
Definition: SpikingGroup.h:450
virtual std::string get_output_line(NeuronID i)
Definition: SpikingGroup.cpp:809
Definition: auryn_definitions.h:208
bool evolve_locally()
Returns true if the calling instance has units which are integrated on the current rank...
Definition: SpikingGroup.cpp:323
std::map< std::string, AurynStateVector * > state_vectors
Definition: SpikingGroup.h:153
SpikeDelay * delay
Definition: SpikingGroup.h:144
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:

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Member Data Documentation

◆ active

bool auryn::SpikingGroup::active

Toggles group active.

Groups do not necessarily obey this toggle though.

◆ attribs

AttributeContainer* auryn::SpikingGroup::attribs
protected

◆ clock_ptr

AurynTime * SpikingGroup::clock_ptr = NULL
staticprotected

Stores the length of output delay

◆ delay

SpikeDelay* auryn::SpikingGroup::delay

◆ group_name

std::string auryn::SpikingGroup::group_name
protected

Identifying name for object.

◆ post_state_traces

std::vector<Trace *> auryn::SpikingGroup::post_state_traces
protected

Post state traces.

◆ post_state_traces_spike_biases

std::vector<AurynFloat> auryn::SpikingGroup::post_state_traces_spike_biases
protected

◆ post_state_traces_states

std::vector<AurynStateVector *> auryn::SpikingGroup::post_state_traces_states
protected

◆ posttraces

std::vector<Trace *> auryn::SpikingGroup::posttraces
protected

Posttraces.

◆ pretraces

std::vector<Trace *> auryn::SpikingGroup::pretraces
protected

Pretraces.

◆ rank_size

NeuronID auryn::SpikingGroup::rank_size
protected

Stores the size of the group on this rank.

◆ size

NeuronID auryn::SpikingGroup::size
protected

Stores the size of the group.

◆ spikes

SpikeContainer* auryn::SpikingGroup::spikes
protected

SpikeContainers to store spikes produced during one step of evolve.

◆ state_variables

std::map<std::string,AurynState> auryn::SpikingGroup::state_variables

Holds group-wide state variables such as population target rates or global protein levels etc

◆ state_vectors

std::map<std::string,AurynStateVector *> auryn::SpikingGroup::state_vectors

Can hold single neuron vectors such as target rates or STP states etc


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