PetaVision  Alpha
LIF.hpp
1 /*
2  * LIF.hpp
3  *
4  * Created on: Dec 21, 2010
5  * Author: Craig Rasmussen
6  *
7  */
8 
9 #ifndef LIF_HPP_
10 #define LIF_HPP_
11 
12 #include "../columns/Random.hpp"
13 #include "HyPerLayer.hpp"
14 //#include "../kernels/LIF_params.h"
15 
16 #define NUM_LIF_EVENTS 4
17 //#define EV_LIF_GSYN_E 0
18 //#define EV_LIF_GSYN_I 1
19 #define EV_LIF_GSYN_IB 2
20 //#define EV_LIF_ACTIVITY 3
21 #define pvconductance_t float
22 
23 struct LIF_params {
24  float Vrest;
25  float Vexc;
26  float Vinh;
27  float VinhB;
28 
29  float tau;
30  float tauE;
31  float tauI;
32  float tauIB;
33 
34  float VthRest;
35  float tauVth;
36  float deltaVth;
37  float deltaGIB;
38 
39  float noiseFreqE;
40  float noiseAmpE;
41  float noiseFreqI;
42  float noiseAmpI;
43  float noiseFreqIB;
44  float noiseAmpIB;
45 };
46 
47 namespace PV {
48 
49 class LIF : public PV::HyPerLayer {
50  public:
51  friend int test_kernels(int argc, char *argv[]);
52  friend int test_LIF(int argc, char *argv[]);
53 
54  LIF(const char *name, HyPerCol *hc);
55  LIF(const char *name, HyPerCol *hc, int num_channels);
56  virtual ~LIF();
57 
58  virtual Response::Status
59  communicateInitInfo(std::shared_ptr<CommunicateInitInfoMessage const> message) override;
60  virtual Response::Status allocateDataStructures() override;
61  virtual Response::Status registerData(Checkpointer *checkpointer) override;
62 
63  virtual Response::Status updateState(double time, double dt) override;
64  virtual int setActivity() override;
65 
66  float *getVth() { return Vth; }
67  virtual pvconductance_t *getConductance(ChannelType ch) {
68  return ch < this->numChannels ? G_E + ch * getNumNeurons() : NULL;
69  }
70 
71  virtual float getChannelTimeConst(enum ChannelType channel_type) override;
72 
73  virtual LIF_params *getLIFParams() { return &lParams; };
74 
75  virtual bool activityIsSpiking() override { return true; }
76 
77  protected:
78  LIF_params lParams;
79  Random *randState;
80  float *Vth; // threshold potential
81  pvconductance_t *G_E; // excitatory conductance
82  pvconductance_t *G_I; // inhibitory conductance
83  pvconductance_t *G_IB;
84 
85  char *methodString; // 'arma', 'before', or 'original'
86  char method; // 'a', 'b', or 'o', the first character of methodString
87 
88  protected:
89  LIF();
90  int initialize(const char *name, HyPerCol *hc, const char *kernel_name);
91  virtual int ioParamsFillGroup(enum ParamsIOFlag ioFlag) override;
92  virtual void ioParam_Vrest(enum ParamsIOFlag ioFlag);
93  virtual void ioParam_Vexc(enum ParamsIOFlag ioFlag);
94  virtual void ioParam_Vinh(enum ParamsIOFlag ioFlag);
95  virtual void ioParam_VinhB(enum ParamsIOFlag ioFlag);
96  virtual void ioParam_VthRest(enum ParamsIOFlag ioFlag);
97  virtual void ioParam_tau(enum ParamsIOFlag ioFlag);
98  virtual void ioParam_tauE(enum ParamsIOFlag ioFlag);
99  virtual void ioParam_tauI(enum ParamsIOFlag ioFlag);
100  virtual void ioParam_tauIB(enum ParamsIOFlag ioFlag);
101  virtual void ioParam_tauVth(enum ParamsIOFlag ioFlag);
102  virtual void ioParam_deltaVth(enum ParamsIOFlag ioFlag);
103  virtual void ioParam_deltaGIB(enum ParamsIOFlag ioFlag);
104  virtual void ioParam_noiseAmpE(enum ParamsIOFlag ioFlag);
105  virtual void ioParam_noiseAmpI(enum ParamsIOFlag ioFlag);
106  virtual void ioParam_noiseAmpIB(enum ParamsIOFlag ioFlag);
107  virtual void ioParam_noiseFreqE(enum ParamsIOFlag ioFlag);
108  virtual void ioParam_noiseFreqI(enum ParamsIOFlag ioFlag);
109  virtual void ioParam_noiseFreqIB(enum ParamsIOFlag ioFlag);
110  virtual void ioParam_method(enum ParamsIOFlag ioFlag);
111  virtual void allocateBuffers() override;
112  virtual void allocateConductances(int num_channels);
113  virtual Response::Status readStateFromCheckpoint(Checkpointer *checkpointer) override;
114  virtual void readVthFromCheckpoint(Checkpointer *checkpointer);
115  virtual void readG_EFromCheckpoint(Checkpointer *checkpointer);
116  virtual void readG_IFromCheckpoint(Checkpointer *checkpointer);
117  virtual void readG_IBFromCheckpoint(Checkpointer *checkpointer);
118  virtual void readRandStateFromCheckpoint(Checkpointer *checkpointer);
119 
120  private:
121  int initialize_base();
122  int findPostSynaptic(
123  int dim,
124  int maxSize,
125  int col,
126  // input: which layer, which neuron
127  HyPerLayer *lSource,
128  float pos[],
129 
130  // output: how many of our neurons are connected.
131  // an array with their indices.
132  // an array with their feature vectors.
133  int *nNeurons,
134  int nConnectedNeurons[],
135  float *vPos);
136 }; // class LIF
137 
138 } // namespace PV
139 
140 #endif /* LIF_HPP_ */
Definition: LIF.hpp:49