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

STDP Connection class to simulate arbitrary nearest-neighbor STDP windows. More...

#include <PairInteractionConnection.h>

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

Public Member Functions

 PairInteractionConnection (SpikingGroup *source, NeuronGroup *destination, const char *filename, AurynWeight maxweight=1., TransmitterType transmitter=GLUT)
 
 PairInteractionConnection (SpikingGroup *source, NeuronGroup *destination, AurynWeight weight, AurynFloat sparseness=0.05, AurynWeight maxweight=1., TransmitterType transmitter=GLUT, string name="PairInteractionConnection")
 Default random sparse constructor. More...
 
virtual ~PairInteractionConnection ()
 Default destructor. More...
 
void load_window_from_file (const char *filename, double scale=1.)
 Loads STDP windows for pre-post and post-pre from ASCII file. More...
 
void set_exponential_window (double Aplus=1e-3, double tau_plus=20e-3, double Aminus=-1e-3, double tau_minus=20e-3)
 Sets STDP window to be bi-exponential. More...
 
void set_floor_terms (double pre_post=0.0, double post_pre=0.0)
 Sets "floor" terms for STDP rule. More...
 
virtual void propagate ()
 Internally used propagate method. More...
 
- Public Member Functions inherited from auryn::DuplexConnection
 DuplexConnection (const char *filename)
 
 DuplexConnection (NeuronID rows, NeuronID cols)
 
 DuplexConnection (SpikingGroup *source, NeuronGroup *destination, TransmitterType transmitter=GLUT)
 
 DuplexConnection (SpikingGroup *source, NeuronGroup *destination, const char *filename, TransmitterType transmitter=GLUT)
 
 DuplexConnection (SpikingGroup *source, NeuronGroup *destination, AurynWeight weight, AurynFloat sparseness=0.05, TransmitterType transmitter=GLUT, std::string name="DuplexConnection")
 
virtual ~DuplexConnection ()
 
virtual void finalize ()
 Finalizes connection after random or manual initialization of the weights. More...
 
void prune ()
 Prune weight matrices. More...
 
- Public Member Functions inherited from auryn::SparseConnection
 SparseConnection ()
 Empty constructor which should not be used – TODO should be deprecated at some point. More...
 
 SparseConnection (const char *filename)
 Load from wmat file constructor which should not be used – TODO should be deprecated at some point. More...
 
 SparseConnection (NeuronID rows, NeuronID cols)
 Deprecated constructor for manual filling. More...
 
 SparseConnection (SpikingGroup *source, NeuronGroup *destination, const char *filename, TransmitterType transmitter=GLUT)
 Deprecated constructor for loading from file. More...
 
 SparseConnection (SpikingGroup *source, NeuronGroup *destination, TransmitterType transmitter=GLUT, string name="SparseConnection")
 Constructor for manual filling. More...
 
 SparseConnection (SpikingGroup *source, NeuronGroup *destination, AurynWeight weight, AurynDouble sparseness=0.05, TransmitterType transmitter=GLUT, string name="SparseConnection")
 Default constructor which sets up a random sparse matrix with fixed weight between the source and destination group. More...
 
 SparseConnection (SpikingGroup *source, NeuronGroup *destination, SparseConnection *con, string name="SparseConnection")
 This constructor tries to clone a connection by guessing all parameters except source and destination from another connection instance. More...
 
 SparseConnection (SpikingGroup *source, NeuronGroup *destination, AurynWeight weight, AurynDouble sparseness, NeuronID lo_row, NeuronID hi_row, NeuronID lo_col, NeuronID hi_col, TransmitterType transmitter=GLUT)
 Sparse block constructor. More...
 
virtual ~SparseConnection ()
 The default destructor. More...
 
void allocate_manually (AurynLong expected_size)
 Is used whenever memory has to be allocated manually. Automatically adjusts for number of ranks and for security margin. More...
 
AurynLong estimate_required_nonzero_entires (AurynLong nonzero, double sigma=5.)
 This function estimates the required size of the nonzero entry buffer. More...
 
void seed (NeuronID randomseed)
 This function seeds the pseudo random number generator for all random fill operatios. More...
 
virtual AurynWeight get (NeuronID i, NeuronID j)
 Returns weight value of a given element if it exists. More...
 
virtual AurynWeightget_ptr (NeuronID i, NeuronID j)
 Returns pointer to given weight element if it exists. Returns NULL if element does not exist. More...
 
virtual AurynWeight get_data (NeuronID i)
 Returns weight value of a given element referenced by index in the data array. More...
 
virtual void set_data (NeuronID i, AurynWeight value)
 Sets weight value of a given element referenced by its index in the data array. More...
 
virtual void set (NeuronID i, NeuronID j, AurynWeight value)
 Sets a single connection to value if it exists. More...
 
virtual void set (std::vector< neuron_pair > element_list, AurynWeight value)
 Sets a list of connection to value if they exists. More...
 
void random_data (AurynWeight mean, AurynWeight sigma)
 Synonym for random_data. More...
 
void random_data_normal (AurynWeight mean, AurynWeight sigma)
 Set weights of all existing connections randomly using a normal distrubtion. More...
 
void random_data_lognormal (AurynWeight m, AurynWeight s)
 Set weights of all existing connections randomly using a lognormal distribution. More...
 
void init_random_binary (AurynFloat prob=0.5, AurynWeight wlo=0.0, AurynWeight whi=1.0)
 Initialize with random binary at wlo and whi. More...
 
void random_col_data (AurynWeight mean, AurynWeight sigma)
 Sets weights in cols to the same value drewn from a Gaussian distribution. More...
 
void set_block (NeuronID lo_row, NeuronID hi_row, NeuronID lo_col, NeuronID hi_col, AurynWeight weight)
 Sets all weights of existing connections in a block spanned by the first 4 parameters to the value given. More...
 
void scale_block (NeuronID lo_row, NeuronID hi_row, NeuronID lo_col, NeuronID hi_col, AurynWeight alpha)
 Scale all weights of existing connections in a block spanned by the first 4 parameters to the value given. More...
 
virtual void set_all (AurynWeight weight)
 Sets all weights of existing connections to the given value. More...
 
virtual void scale_all (AurynFloat value)
 Scales all weights in the weight matrix with the given value. More...
 
virtual void clip (AurynWeight lo, AurynWeight hi)
 Clip weights. More...
 
void set_upper_triangular (AurynWeight weight)
 Sets weights in a upper triangular matrix. More...
 
virtual void sparse_set_data (AurynDouble sparseness, AurynWeight value)
 Sets a sparse random subset of connection elements wight the given value. More...
 
void connect_random (AurynWeight weight=1.0, AurynDouble sparseness=0.05, bool skip_diag=false)
 Connect src and dst SpikingGroup and NeuronGroup randomly with given sparseness. More...
 
void connect_block_random (AurynWeight weight, AurynDouble sparseness, NeuronID lo_row, NeuronID hi_row, NeuronID lo_col, NeuronID hi_col, bool skip_diag=false)
 Underlying sparse fill method. More...
 
bool push_back (NeuronID i, NeuronID j, AurynWeight weight)
 Pushes a single element to the ComplexMatrix. More...
 
AurynLong get_nonzero ()
 Returns number of nonzero elements in this SparseConnection. More...
 
void put_pattern (type_pattern *pattern, AurynWeight strength, bool overwrite)
 Puts cell assembly to existing sparse weights. More...
 
void put_pattern (type_pattern *pattern1, type_pattern *pattern2, AurynWeight strength, bool overwrite)
 Puts cell assembly or synfire pattern to existing sparse weights. More...
 
void load_patterns (string filename, AurynWeight strength, int nb_max_patterns=10000, bool overwrite=false, bool chainmode=false)
 Reads first n patterns from a .pat file and adds them as Hebbian assemblies onto an existing weight matrix. More...
 
void load_pre_post_patterns (std::string pre_file, std::string post_file, AurynWeight strength, int nb_max_patterns=10000, bool overwrite=false)
 Reads patterns from two files and connects them. More...
 
void sanity_check ()
 Quick an dirty function that checks if all units on the local rank are connected. More...
 
virtual AurynDouble sum ()
 Computes sum of all weight elements in the Connection. More...
 
virtual void stats (AurynDouble &mean, AurynDouble &std)
 Computes mean and variance of weights in default weight matrix. More...
 
virtual void stats (AurynDouble &mean, AurynDouble &std, NeuronID zid)
 Computes mean and variance of weights for matrix state zid. More...
 
bool write_to_file (ForwardMatrix *m, string filename)
 Writes rank specific weight matrix on the same rank to a file. More...
 
virtual bool write_to_file (string filename)
 Writes rank specific default weight matrix on the same rank to a file. More...
 
virtual bool load_from_complete_file (string filename)
 Loads weight matrix from a single file. More...
 
virtual bool load_from_file (string filename)
 Loads weight matrix from Matrix Market (wmat) file. More...
 
bool load_from_file (ForwardMatrix *m, string filename, AurynLong data_size=0)
 Loads weight matrix from Matrix Market (wmat) file to specified weight matrix. More...
 
virtual void set_min_weight (AurynWeight minimum_weight)
 Sets minimum weight (for plastic connections). More...
 
AurynWeight get_min_weight ()
 Gets minimum weight (for plastic connections). More...
 
virtual void set_max_weight (AurynWeight maximum_weight)
 Sets maximum weight (for plastic connections). More...
 
AurynWeight get_max_weight ()
 Gets maximum weight (for plastic connections). More...
 
std::vector< neuron_pairget_block (NeuronID lo_row, NeuronID hi_row, NeuronID lo_col, NeuronID hi_col)
 Returns a vector of ConnectionsID of a block specified by the arguments. More...
 
std::vector< neuron_pairget_post_partners (NeuronID i)
 Returns a vector of ConnectionsID of postsynaptic parterns of neuron i. More...
 
std::vector< neuron_pairget_pre_partners (NeuronID j)
 Returns a vector of ConnectionsID of presynaptic parterns of neuron i. More...
 
- Public Member Functions inherited from auryn::Connection
 Connection ()
 
 Connection (NeuronID rows, NeuronID cols)
 
 Connection (SpikingGroup *source, NeuronGroup *destination, TransmitterType transmitter=GLUT, std::string name="Connection")
 
virtual ~Connection ()
 
void set_size (NeuronID i, NeuronID j)
 
void set_name (std::string name)
 Set name of connection. More...
 
std::string get_name ()
 Returns name of connection. 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...
 
AurynStateVectorget_target_vector ()
 Returns target state vector if one is defined. More...
 
NeuronID get_m_rows ()
 Get number of rows (presynaptic) in connection. More...
 
NeuronID get_n_cols ()
 Get number of columns (postsynaptic) in connection. More...
 
TransmitterType get_transmitter ()
 Returns transmitter type. More...
 
void set_target (AurynWeight *ptr)
 Sets target state of this connection directly via a pointer. More...
 
void set_target (AurynStateVector *ptr)
 Sets target state of this connection directly via a StateVector. More...
 
void set_receptor (AurynStateVector *ptr)
 Same as set_target. More...
 
void set_transmitter (AurynStateVector *ptr)
 Same as set_target. More...
 
void set_transmitter (TransmitterType transmitter)
 Sets target state of this connection for a given receptor as one of Auryn's default transmitter types. More...
 
void set_receptor (string state_name)
 Sets target state of this connection directly the name of a state vector. More...
 
void set_target (string state_name)
 Same as set_receptor. More...
 
void set_transmitter (string state_name)
 Same as set_receptor, but DEPRECATED. More...
 
void set_source (SpikingGroup *source)
 Sets source SpikingGroup of this connection. More...
 
SpikingGroupget_source ()
 Returns pointer to the presynaptic group. More...
 
void set_destination (NeuronGroup *source)
 Sets destination SpikingGroup of this connection. More...
 
NeuronGroupget_destination ()
 Returns pointer to the postsynaptic group. More...
 
virtual void evolve ()
 Evolve method to update internal connection state. Called by System run method. More...
 
void conditional_propagate ()
 DEPRECATED. (Such connections should not be registered in the first place) Calls propagate only if the postsynaptic NeuronGroup exists on the local rank. More...
 
Traceget_pre_trace (const AurynDouble tau)
 Returns a pointer to a presynaptic trace object. More...
 
Traceget_post_trace (const AurynDouble tau)
 Returns a pointer to a postsynaptic trace object. More...
 
Traceget_post_state_trace (const string state_name, const AurynDouble tau, const AurynDouble jump_size=0.0)
 Returns a pointer to a postsynaptic state trace object. More...
 
void transmit (const NeuronID id, const AurynWeight amount)
 Default way to transmit a spike to a postsynaptic partner. More...
 
void targeted_transmit (SpikingGroup *target_group, AurynStateVector *target_state, const NeuronID id, const AurynWeight amount)
 Transmits a spike to a given target group and state. More...
 
void safe_transmit (NeuronID id, AurynWeight amount)
 Same as transmit but first checks if the target neuron exists and avoids segfaults that way (but it's also slower). More...
 
SpikeContainerget_pre_spikes ()
 Supplies pointer to SpikeContainer of all presynaptic spikes. More...
 
SpikeContainerget_post_spikes ()
 Returns pointer to SpikeContainer for postsynaptic spikes on this node. More...
 
void add_number_of_spike_attributes (int x)
 Set up spike delay to accomodate x additional spike attributes. More...
 
AurynFloat get_spike_attribute (const NeuronID i, const int attribute_id=0)
 Returns spike attribute belonging to the spike at position i in the get_spikes() SpikeContainer. More...
 

Public Attributes

AurynFloatwindow_pre_post
 
AurynFloatwindow_post_pre
 
bool stdp_active
 Switches stdp on or off. More...
 
- Public Attributes inherited from auryn::DuplexConnection
ForwardMatrixfwd
 
BackwardMatrixbkw
 
- Public Attributes inherited from auryn::SparseConnection
bool patterns_ignore_gamma
 Switch that toggles for the load_patterns function whether or not to use the intensity (gamma) value. Default is false. More...
 
NeuronID patterns_every_pre
 The every_pre parameter allows to skip presynaptically over pattern IDs when loading patterns. Default is 1. This can be useful to when loading patterns into the exc->inh connections and there significantly less inhibitory cells than exc ones. More...
 
NeuronID patterns_every_post
 The every_post parameter allows to skip postsynaptically over pattern IDs when loading patterns. Default is 1. This can be useful to when loading patterns into the exc->inh connections and there significantly less inhibitory cells than exc ones. More...
 
bool wrap_patterns
 Switch that toggles the behavior when loading a pattern to wrap neuron IDs back onto existing cells via the modulo function. More...
 
ForwardMatrixw
 A pointer that points per default to the ComplexMatrix that stores the connectinos. More...
 
- Public Attributes inherited from auryn::Connection
SpikingGroupsrc
 Pointer to the source group of this connection. More...
 
NeuronGroupdst
 Pointer to the destination group of this connection. More...
 

Protected Member Functions

AurynWeight dw_fwd (NeuronID post)
 
AurynWeight dw_bkw (NeuronID pre)
 
void propagate_forward ()
 
void propagate_backward ()
 
- Protected Member Functions inherited from auryn::DuplexConnection
void compute_reverse_matrix (int z=0)
 
- Protected Member Functions inherited from auryn::SparseConnection
void virtual_serialize (boost::archive::binary_oarchive &ar, const unsigned int version)
 
void virtual_serialize (boost::archive::binary_iarchive &ar, const unsigned int version)
 
void free ()
 
void allocate (AurynLong bufsize)
 
std::vector< type_patternload_pattern_file (string filename, int nb_max_patterns)
 Reads patterns from a .pat file and returns a vector with the patterns. More...
 
- Protected Member Functions inherited from auryn::Connection
void init (TransmitterType transmitter=GLUT)
 

Protected Attributes

AurynWeight w_max
 
AurynTimelast_spike_pre
 
AurynTimelast_spike_post
 
- Protected Attributes inherited from auryn::SparseConnection
AurynWeight wmin
 
AurynWeight wmax
 
bool skip_diagonal
 
- Protected Attributes inherited from auryn::Connection
TransmitterType trans
 
AurynStateVectortarget_state_vector
 
AurynFloattarget
 A more direct reference on the first element of the target_state_vector. More...
 
NeuronID number_of_spike_attributes
 Number of spike attributes to expect with each spike transmitted through this connection. More...
 
NeuronID spike_attribute_offset
 Stores spike attribute offset in attribute array. More...
 

Additional Inherited Members

- Static Protected Attributes inherited from auryn::SparseConnection
static boost::mt19937 sparse_connection_gen = boost::mt19937()
 

Detailed Description

STDP Connection class to simulate arbitrary nearest-neighbor STDP windows.

This class implements event-based STDP as nearest-neighbor spike interactions. Arbitrary STDP windows can be loaded from an external file or can be set by directly acessing the arrays window_pre_post and window_post_pre.

Todo:
Add usage example and unit tests

Constructor & Destructor Documentation

◆ PairInteractionConnection() [1/2]

PairInteractionConnection::PairInteractionConnection ( SpikingGroup source,
NeuronGroup destination,
const char *  filename,
AurynWeight  maxweight = 1.,
TransmitterType  transmitter = GLUT 
)
75 : DuplexConnection(source, destination, filename, transmitter)
76 {
77  init(maxweight);
78 }
DuplexConnection(const char *filename)
Definition: DuplexConnection.cpp:53

◆ PairInteractionConnection() [2/2]

PairInteractionConnection::PairInteractionConnection ( SpikingGroup source,
NeuronGroup destination,
AurynWeight  weight,
AurynFloat  sparseness = 0.05,
AurynWeight  maxweight = 1.,
TransmitterType  transmitter = GLUT,
std::string  name = "PairInteractionConnection" 
)

Default random sparse constructor.

83 : DuplexConnection(source, destination, weight, sparseness, transmitter, name)
84 {
85  init(maxweight);
86 }
DuplexConnection(const char *filename)
Definition: DuplexConnection.cpp:53

◆ ~PairInteractionConnection()

PairInteractionConnection::~PairInteractionConnection ( )
virtual

Default destructor.

89 {
90  free();
91 }

Member Function Documentation

◆ dw_bkw()

AurynWeight PairInteractionConnection::dw_bkw ( NeuronID  pre)
inlineprotected
102 {
105  double dw = window_pre_post[diff];
106  return dw;
107 }
AurynFloat * window_pre_post
Definition: PairInteractionConnection.h:63
AurynTime * last_spike_pre
Definition: PairInteractionConnection.h:52
System * sys
Global pointer to instance of System which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:37
AurynTime get_clock()
Gets the current clock value in AurynTime.
Definition: System.cpp:231
NeuronID AurynTime
Defines Auryns discrete time unit of the System clock. Change to AurynLong if 120h of simtime are not...
Definition: auryn_definitions.h:155
#define PAIRINTERACTIONCON_WINDOW_MAX_SIZE
Definition: PairInteractionConnection.h:24
Here is the call graph for this function:

◆ dw_fwd()

AurynWeight PairInteractionConnection::dw_fwd ( NeuronID  post)
inlineprotected
94 {
97  double dw = window_post_pre[diff];
98  return dw;
99 }
AurynFloat * window_post_pre
Definition: PairInteractionConnection.h:64
System * sys
Global pointer to instance of System which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:37
AurynTime get_clock()
Gets the current clock value in AurynTime.
Definition: System.cpp:231
NeuronID AurynTime
Defines Auryns discrete time unit of the System clock. Change to AurynLong if 120h of simtime are not...
Definition: auryn_definitions.h:155
#define PAIRINTERACTIONCON_WINDOW_MAX_SIZE
Definition: PairInteractionConnection.h:24
AurynTime * last_spike_post
Definition: PairInteractionConnection.h:53
Here is the call graph for this function:

◆ load_window_from_file()

void PairInteractionConnection::load_window_from_file ( const char *  filename,
double  scale = 1. 
)

Loads STDP windows for pre-post and post-pre from ASCII file.

Parameters
filenameString pointing to the file containing the STDP window
scaleScales read in values by this number
Todo:
Add file format description
173 {
174  std::stringstream oss;
175  oss << "PairInteractionConnection:: Loading STDP window from " << filename;
176  auryn::logger->msg(oss.str(),NOTIFICATION);
177 
178  // default window all zeros
179  for ( int i = 0 ; i < PAIRINTERACTIONCON_WINDOW_MAX_SIZE ; ++i ) {
180  window_pre_post[i] = 0;
181  window_post_pre[i] = 0;
182  }
183 
184  std::ifstream infile (filename);
185  if (!infile) {
186  std::stringstream oes;
187  oes << "Can't open input file " << filename;
188  auryn::logger->msg(oes.str(),ERROR);
189  return;
190  }
191 
192  unsigned int size;
193  float timebinsize;
194  float value;
195  float time;
196  unsigned int count = 0;
197 
198  char buffer[256];
199  infile.getline (buffer,256);
200  sscanf (buffer,"# %u %f",&size,&timebinsize);
201 
202  if ( size > 2*PAIRINTERACTIONCON_WINDOW_MAX_SIZE )
203  auryn::logger->msg("PairInteractionConnection:: STDP window too large ... truncating!",WARNING);
204 
205  if ( auryn_timestep < timebinsize )
206  auryn::logger->msg("PairInteractionConnection:: Timebinning of loaded STDP window is different from simulator timestep.",WARNING);
207 
208  double sum_pre_post = 0 ;
209  double sum_post_pre = 0 ;
210 
211  // read window file line-by-line
212  while ( infile.getline (buffer,256) )
213  {
214  sscanf (buffer,"%f %f",&time,&value);
215  if ( abs(time) < PAIRINTERACTIONCON_WINDOW_MAX_SIZE*auryn_timestep ) {
216  NeuronID start;
217  if ( time < 0 ) {
218  start = -(time+auryn_timestep/2)/auryn_timestep; // plus element is for correct rounding
219  window_post_pre[start] = scale*value;
220  sum_post_pre += scale*value;
221  } else {
222  start = (time+auryn_timestep/2)/auryn_timestep;
223  window_pre_post[start] = scale*value;
224  sum_pre_post += scale*value;
225  }
226  }
227  count++;
228  }
229 
230  // for ( int i = 0 ; i < PAIRINTERACTIONCON_WINDOW_MAX_SIZE ; ++i ) {
231  // std::cout << std::ifstream << window_pre_post[i] << std::endl;
232  // }
233  // for ( int i = 0 ; i < PAIRINTERACTIONCON_WINDOW_MAX_SIZE ; ++i ) {
234  // std::cout << std::ifstream << window_post_pre[i] << std::endl;
235  // }
236 
237 
238  oss.str("");
239  oss << "PairInteractionConnection:: sum_pre_post="
240  << std::scientific
241  << sum_pre_post
242  << " sum_post_pre="
243  << sum_post_pre;
244  auryn::logger->msg(oss.str(),NOTIFICATION);
245 
246  infile.close();
247 
248 }
AurynFloat * window_pre_post
Definition: PairInteractionConnection.h:63
Definition: Logger.h:41
AurynFloat * window_post_pre
Definition: PairInteractionConnection.h:64
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
double auryn_timestep
Simulation timestep in seconds.
Definition: auryn_definitions.cpp:31
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
#define PAIRINTERACTIONCON_WINDOW_MAX_SIZE
Definition: PairInteractionConnection.h:24
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:

◆ propagate()

void PairInteractionConnection::propagate ( )
virtual

Internally used propagate method.

This method propagates spikes in the main simulation loop. Should usually not be called directly by the user.

Reimplemented from auryn::SparseConnection.

166 {
167  // propagate
170 }
void propagate_forward()
Definition: PairInteractionConnection.cpp:109
void propagate_backward()
Definition: PairInteractionConnection.cpp:140
Here is the call graph for this function:

◆ propagate_backward()

void PairInteractionConnection::propagate_backward ( )
inlineprotected
141 {
142  if (stdp_active) {
143  SpikeContainer::const_iterator spikes_end = dst->get_spikes_immediate()->end();
144  // loop over all post spikes
145  for (SpikeContainer::const_iterator spike = dst->get_spikes_immediate()->begin() ; // spike = post_spike
146  spike != spikes_end ;
147  ++spike ) {
148  NeuronID translated_spike = dst->global2rank(*spike);
149 
150  // loop over all presynaptic partners
151  for (const NeuronID * c = bkw->get_row_begin(*spike) ; c != bkw->get_row_end(*spike) ; ++c ) {
152  // computes plasticity update
153  AurynWeight * weight = bkw->get_data(c);
154  *weight += dw_bkw(*c);
155 
156  // clips too large weights
157  if (*weight>get_max_weight()) *weight=get_max_weight();
158  }
159  // update post "trace"
160  last_spike_post[translated_spike] = auryn::sys->get_clock();
161  }
162  }
163 }
AurynWeight get_max_weight()
Gets maximum weight (for plastic connections).
Definition: SparseConnection.h:420
NeuronID global2rank(NeuronID i)
Converts global NeuronID within the SpikingGroup to the local NeuronID on this rank.
Definition: SpikingGroup.h:446
AurynFloat AurynWeight
Unit of synaptic weights.
Definition: auryn_definitions.h:159
BackwardMatrix * bkw
Definition: DuplexConnection.h:64
NeuronID * get_row_end(NeuronID i)
Definition: SimpleMatrix.h:598
NeuronGroup * dst
Pointer to the destination group of this connection.
Definition: Connection.h:111
AurynWeight dw_bkw(NeuronID pre)
Definition: PairInteractionConnection.cpp:101
T get_data(const AurynLong i)
Definition: SimpleMatrix.h:214
System * sys
Global pointer to instance of System which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:37
bool stdp_active
Switches stdp on or off.
Definition: PairInteractionConnection.h:67
SpikeContainer * get_spikes_immediate()
Returns pointer to SpikeContainer of spikes generated during the last evolve() step.
Definition: SpikingGroup.cpp:250
AurynTime get_clock()
Gets the current clock value in AurynTime.
Definition: System.cpp:231
AurynTime * last_spike_post
Definition: PairInteractionConnection.h:53
NeuronID * get_row_begin(NeuronID i)
Definition: SimpleMatrix.h:586
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:

◆ propagate_forward()

void PairInteractionConnection::propagate_forward ( )
inlineprotected
110 {
111  // Loop over all pre spikes
112  for (SpikeContainer::const_iterator spike = src->get_spikes()->begin() ; // spike = pre_spike
113  spike != src->get_spikes()->end() ; ++spike ) {
114  // Loop over all postsynaptic partners
115  for (const NeuronID * c = w->get_row_begin(*spike) ;
116  c != w->get_row_end(*spike) ;
117  ++c ) { // c = post index
118 
119  // determines the weight of connection
120  AurynWeight * weight = w->get_data_ptr(c);
121 
122  // handle plasticity
123  if ( stdp_active ) {
124  // performs weight update upon presynaptic spike
125  *weight += dw_fwd(*c);
126  // clips too small weights
127  if ( *weight < get_min_weight() ) *weight = get_min_weight();
128  else if ( *weight > get_max_weight() ) *weight = get_max_weight();
129  }
130 
131  // evokes the postsynaptic response
132  transmit( *c , *weight );
133 
134  // update pre "trace"
135  last_spike_pre[*spike] = auryn::sys->get_clock();
136  }
137  }
138 }
AurynWeight get_max_weight()
Gets maximum weight (for plastic connections).
Definition: SparseConnection.h:420
AurynWeight dw_fwd(NeuronID post)
Definition: PairInteractionConnection.cpp:93
void transmit(const NeuronID id, const AurynWeight amount)
Default way to transmit a spike to a postsynaptic partner.
Definition: Connection.h:294
NeuronID * get_row_end(NeuronID i)
Definition: ComplexMatrix.h:952
ForwardMatrix * w
A pointer that points per default to the ComplexMatrix that stores the connectinos.
Definition: SparseConnection.h:147
SpikeContainer * get_spikes()
Returns pointer to a spike container that contains spikes which arrive in this timestep from all neur...
Definition: SpikingGroup.cpp:245
AurynFloat AurynWeight
Unit of synaptic weights.
Definition: auryn_definitions.h:159
SpikingGroup * src
Pointer to the source group of this connection.
Definition: Connection.h:108
NeuronID * get_row_begin(NeuronID i)
Definition: ComplexMatrix.h:940
AurynTime * last_spike_pre
Definition: PairInteractionConnection.h:52
AurynWeight get_min_weight()
Gets minimum weight (for plastic connections).
Definition: SparseConnection.h:412
System * sys
Global pointer to instance of System which needs to be initialized in every simulation main program...
Definition: auryn_global.cpp:37
bool stdp_active
Switches stdp on or off.
Definition: PairInteractionConnection.h:67
AurynTime get_clock()
Gets the current clock value in AurynTime.
Definition: System.cpp:231
T * get_data_ptr(const AurynLong data_index, const StateID z=0)
Gets the matching data ptr for a given index i and state z.
Definition: ComplexMatrix.h:402
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_exponential_window()

void PairInteractionConnection::set_exponential_window ( double  Aplus = 1e-3,
double  tau_plus = 20e-3,
double  Aminus = -1e-3,
double  tau_minus = 20e-3 
)

Sets STDP window to be bi-exponential.

Parameters
Apluspre-post amplitude of window
tau_pluspre-post time constant of window
Aminuspost-pre amplitude of window
tau_minuspost-pre time constant of window
251 {
252  for ( int i = 0 ; i < PAIRINTERACTIONCON_WINDOW_MAX_SIZE ; ++i ) {
253  window_pre_post[i] = Aplus/tau_plus*exp(-i*auryn_timestep/tau_plus);
254  }
255 
256  for ( int i = 0 ; i < PAIRINTERACTIONCON_WINDOW_MAX_SIZE ; ++i ) {
257  window_post_pre[i] = Aminus/tau_minus*exp(-i*auryn_timestep/tau_minus);
258  }
259 
260  // zero floor terms
261  set_floor_terms(0.0, 0.0);
262 }
AurynFloat * window_pre_post
Definition: PairInteractionConnection.h:63
AurynFloat * window_post_pre
Definition: PairInteractionConnection.h:64
double auryn_timestep
Simulation timestep in seconds.
Definition: auryn_definitions.cpp:31
void set_floor_terms(double pre_post=0.0, double post_pre=0.0)
Sets "floor" terms for STDP rule.
Definition: PairInteractionConnection.cpp:264
#define PAIRINTERACTIONCON_WINDOW_MAX_SIZE
Definition: PairInteractionConnection.h:24
Here is the call graph for this function:

◆ set_floor_terms()

void PairInteractionConnection::set_floor_terms ( double  pre_post = 0.0,
double  post_pre = 0.0 
)

Sets "floor" terms for STDP rule.

These terms are used as update size when a time difference falls out of the window size.

Parameters
pre_postFloor for pre post pairs
post_preFloor for post pre pairs
265 {
268 }
AurynFloat * window_pre_post
Definition: PairInteractionConnection.h:63
AurynFloat * window_post_pre
Definition: PairInteractionConnection.h:64
#define PAIRINTERACTIONCON_WINDOW_MAX_SIZE
Definition: PairInteractionConnection.h:24

Member Data Documentation

◆ last_spike_post

AurynTime* auryn::PairInteractionConnection::last_spike_post
protected

◆ last_spike_pre

AurynTime* auryn::PairInteractionConnection::last_spike_pre
protected

◆ stdp_active

bool auryn::PairInteractionConnection::stdp_active

Switches stdp on or off.

◆ w_max

AurynWeight auryn::PairInteractionConnection::w_max
protected

◆ window_post_pre

AurynFloat* auryn::PairInteractionConnection::window_post_pre

◆ window_pre_post

AurynFloat* auryn::PairInteractionConnection::window_pre_post

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