This repository has been archived by the owner on Jan 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
stdp_longterm_node.h
160 lines (128 loc) · 3.81 KB
/
stdp_longterm_node.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
//
// stdp_longterm_node.h
// NEST
//
//
#ifndef STDP_LONG_NEURON_H
#define STDP_LONG_NEURON_H
#include "nest.h"
#include "event.h"
#include "archiving_node.h"
#include "ring_buffer.h"
#include "namedatum.h"
#include "universal_data_logger.h"
namespace stdpmodule {
using namespace nest;
class Network;
class STDPLongNeuron : public Archiving_Node {
public:
STDPLongNeuron();
STDPLongNeuron(const STDPLongNeuron &);
using Node::handle;
using Node::handles_test_event;
port send_test_event(Node &, rport, synindex, bool);
port handles_test_event(SpikeEvent &, rport);
port handles_test_event(DataLoggingRequest &, rport);
void get_status(DictionaryDatum &) const;
void set_status(const DictionaryDatum &);
void handle(SpikeEvent &);
void handle(DataLoggingRequest &);
private:
void init_state_(const Node &proto) {}
void init_buffers_();
void calibrate();
void update(Time const &, const long_t, const long_t);
friend class RecordablesMap<STDPLongNeuron>;
friend class UniversalDataLogger<STDPLongNeuron>;
struct Parameters_ {
double_t tau_plus_;
double_t tau_slow_;
double_t tau_minus_;
double_t tau_ht_;
double_t tau_hom_;
double_t tau_const_;
double_t A_;
double_t P_;
double_t WP_;
double_t beta_;
double_t delta_;
bool nearest_spike_;
Parameters_();
void get(DictionaryDatum &) const;
void set(const DictionaryDatum &);
};
struct State_ {
double_t weight_;
double_t weight_ref_;
double_t B_;
double_t C_;
double_t Zplus_;
double_t Zslow_;
double_t Zminus_;
double_t Zht_;
State_();
void get(DictionaryDatum &) const;
void set(const DictionaryDatum &);
};
struct Buffers_ {
RingBuffer n_pre_spikes_;
RingBuffer n_post_spikes_;
UniversalDataLogger<STDPLongNeuron> logger_;
Buffers_(STDPLongNeuron &);
Buffers_(const Buffers_ &, STDPLongNeuron &);
};
struct Variables_ {
double_t Zplus_decay_;
double_t Zslow_decay_;
double_t Zminus_decay_;
double_t Zht_decay_;
};
// Access functions for UniversalDataLogger
double_t get_weight_() const { return S_.weight_; }
double_t get_weight_ref_() const { return S_.weight_ref_; }
double_t get_B_() const { return S_.B_; }
double_t get_C_() const { return S_.C_; }
double_t get_Zplus_() const { return S_.Zplus_; }
double_t get_Zslow_() const { return S_.Zslow_; }
double_t get_Zminus_() const { return S_.Zminus_; }
double_t get_Zht_() const { return S_.Zht_; }
Parameters_ P_;
State_ S_;
Variables_ V_;
Buffers_ B_;
static RecordablesMap<STDPLongNeuron> recordablesMap_;
};
inline port STDPLongNeuron::send_test_event(Node &target, rport receptor_type,
synindex, bool) {
SpikeEvent e;
e.set_sender(*this);
return target.handles_test_event(e, receptor_type);
}
inline port STDPLongNeuron::handles_test_event(SpikeEvent &,
rport receptor_type) {
// Allow connections to port 0 (pre-synaptic) and port 1 (post-synaptic)
if (receptor_type != 0 and receptor_type != 1) {
throw UnknownReceptorType(receptor_type, get_name());
}
return receptor_type;
}
inline port STDPLongNeuron::handles_test_event(DataLoggingRequest &dlr,
rport receptor_type) {
if (receptor_type != 0) {
throw UnknownReceptorType(receptor_type, get_name());
}
return B_.logger_.connect_logging_device(dlr, recordablesMap_);
}
inline void STDPLongNeuron::get_status(DictionaryDatum &d) const {
P_.get(d);
S_.get(d);
Archiving_Node::get_status(d);
(*d)[names::recordables] = recordablesMap_.get_list();
}
inline void STDPLongNeuron::set_status(const DictionaryDatum &d) {
P_.set(d);
S_.set(d);
Archiving_Node::set_status(d);
}
}
#endif /* STDP_LONG_NEURON_H */