Auryn simulator  v0.8.1-206-gb56e451
Plastic Spiking Neural Network Simulator
SpikeDelay.h
Go to the documentation of this file.
1 /*
2 * Copyright 2014-2018 Friedemann Zenke
3 *
4 * This file is part of Auryn, a simulation package for plastic
5 * spiking neural networks.
6 *
7 * Auryn is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * Auryn is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with Auryn. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * If you are using Auryn or parts of it for your work please cite:
21 * Zenke, F. and Gerstner, W., 2014. Limits to high-speed simulations
22 * of spiking neural networks using general-purpose computers.
23 * Front Neuroinform 8, 76. doi: 10.3389/fninf.2014.00076
24 */
25 
26 #ifndef SPIKEDELAY_H_
27 #define SPIKEDELAY_H_
28 
29 #include "auryn_definitions.h"
30 #include "AurynVector.h"
31 #include <vector>
32 
33 #include <boost/serialization/utility.hpp>
34 #include <boost/serialization/split_member.hpp>
35 
36 namespace auryn {
37 
38 
48 {
49  private:
51  template<class Archive>
52  void serialize(Archive & ar, const unsigned int version)
53  {
54  for (unsigned int i = 0 ; i < ndelay ; ++i ) {
55  SpikeContainer * sc = get_spikes(i);
56  ar & *sc;
57  }
58 
59  for (unsigned int i = 0 ; i < ndelay ; ++i ) {
61  ar & *ac;
62  }
63  }
64 
65  SpikeContainer ** delaybuf;
66  AttributeContainer ** attribbuf;
67 
68  int numSpikeAttributes;
69 
70  static AurynTime * clock_ptr;
71 
78  unsigned int ndelay;
79  void free();
80 
81  public:
82 
83 
85  SpikeDelay( int delaysteps=MINDELAY );
86 
88  virtual ~SpikeDelay();
89 
94  void set_delay( int delay );
95 
99  int get_delay( );
100 
105  void set_clock_ptr(AurynTime * clock);
106 
111  void insert_spike(NeuronID i, AurynTime ahead);
112 
119 
123  void push_back(NeuronID i);
124 
128  void push_back(NeuronID i, AurynState attr);
129 
133  void push_back( SpikeContainer * sc );
134 
138  int get_num_attributes();
139 
141  void inc_num_attributes(int x);
142 
148  SpikeContainer * get_spikes(unsigned int pos = 1);
149 
152 
154  AttributeContainer * get_attributes(unsigned int pos = 1);
155 
158 
160  void print();
161 
163  void clear();
164 };
165 
166 }
167 
168 
169 #endif /*SPIKEDELAY_H_*/
void push_back(NeuronID i)
Allows to use SpikeDelay like a queue.
Definition: SpikeDelay.cpp:121
friend class boost::serialization::access
Definition: SpikeDelay.h:50
int get_num_attributes()
Returns the number of spike attributes per spike.
Definition: SpikeDelay.cpp:139
void clear()
Definition: SpikeDelay.cpp:72
std::vector< NeuronID > SpikeContainer
Spike container type. Used for storing spikes.
Definition: auryn_definitions.h:161
void insert_spike_and_attrib(NeuronID i, AurynState attr, AurynTime ahead)
Allows to insert spikes with a single attribute so many time steps ahead with less than max delay...
Definition: SpikeDelay.cpp:115
std::vector< float > AttributeContainer
Attribute container type. Used for storing spike attributes that are needed for efficient STP impleme...
Definition: auryn_definitions.h:162
void print()
Print delay contents for debugging .
Definition: SpikeDelay.cpp:150
Delay object for spikes which is synchronized between nodes using the SyncBuffer formalism implemente...
Definition: SpikeDelay.h:47
virtual ~SpikeDelay()
The default destructor.
Definition: SpikeDelay.cpp:80
void inc_num_attributes(int x)
Internally used by SyncBuffer to submit x attributes with spikes in this delay.
Definition: SpikeDelay.cpp:144
Definition: ABSConnection.h:38
AurynFloat AurynState
Type for Auryn state variables (default single precision since it needs to be compatible with auryn_v...
Definition: auryn_definitions.h:160
void set_delay(int delay)
Set delay in number of timesteps.
Definition: SpikeDelay.cpp:41
SpikeContainer * get_spikes_immediate()
Returns the spikes stored into the delay within this very same time step.
Definition: SpikeDelay.cpp:90
void insert_spike(NeuronID i, AurynTime ahead)
Allows to insert spikes so many time steps ahead with less than max delay.
Definition: SpikeDelay.cpp:110
SpikeDelay(int delaysteps=MINDELAY)
The default constructor.
Definition: SpikeDelay.cpp:32
SpikeContainer * get_spikes(unsigned int pos=1)
Returns the spikes at a given delay position.
Definition: SpikeDelay.cpp:85
void set_clock_ptr(AurynTime *clock)
Internal function to set clock pointer.
Definition: SpikeDelay.cpp:105
int get_delay()
Get delay time in AurynTime.
Definition: SpikeDelay.cpp:57
#define MINDELAY
Switches collection of timing stats in some classes like SyncBuffer and system.
Definition: auryn_definitions.h:82
AttributeContainer * get_attributes_immediate()
Like get_spikes_immediate but returns the spike attributes.
Definition: SpikeDelay.cpp:100
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
AttributeContainer * get_attributes(unsigned int pos=1)
Like get_spikes but returns the spike attributes.
Definition: SpikeDelay.cpp:95
unsigned int NeuronID
NeuronID is an unsigned integeger type used to index neurons in Auryn.
Definition: auryn_definitions.h:151