NEST  2.6.0,not_revisioned_source_dir@0
stdp_connection_facetshw_hom_impl.h
Go to the documentation of this file.
1 /*
2  * stdp_connection_facetshw_hom_impl.h
3  *
4  * This file is part of NEST.
5  *
6  * Copyright (C) 2004 The NEST Initiative
7  *
8  * NEST is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * NEST is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with NEST. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #include "network.h"
24 #include "dictdatum.h"
25 #include "connector_model.h"
28 #include "event.h"
29 
30 namespace nest
31 {
32  //
33  // Implementation of class STDPFACETSHWHomCommonProperties.
34  //
35 
36  template<typename targetidentifierT>
39 
40  tau_plus_(20.0),
41  tau_minus_(20.0),
42 
43  Wmax_(100.0),
44 
45  no_synapses_(0),
46  synapses_per_driver_(50), //hardware efficiency of 50/256=20%,
47  //which is comparable to Fieres et al. (2008)
48  driver_readout_time_(15.0) //in ms; measured on hardware
49 
50  {
51  lookuptable_0_.resize(16);
52  lookuptable_1_.resize(16);
53  lookuptable_2_.resize(16);
54 
55  //intermediate Guetig (mu=0.4)
56  //with r=4 bits and n=36 SSPs, see [3]
57  lookuptable_0_.at(0) = 2;
58  lookuptable_0_.at(1) = 3;
59  lookuptable_0_.at(2) = 4;
60  lookuptable_0_.at(3) = 4;
61  lookuptable_0_.at(4) = 5;
62  lookuptable_0_.at(5) = 6;
63  lookuptable_0_.at(6) = 7;
64  lookuptable_0_.at(7) = 8;
65  lookuptable_0_.at(8) = 9;
66  lookuptable_0_.at(9) = 10;
67  lookuptable_0_.at(10) = 11;
68  lookuptable_0_.at(11) = 12;
69  lookuptable_0_.at(12) = 13;
70  lookuptable_0_.at(13) = 14;
71  lookuptable_0_.at(14) = 14;
72  lookuptable_0_.at(15) = 15;
73 
74  lookuptable_1_.at(0) = 0;
75  lookuptable_1_.at(1) = 0;
76  lookuptable_1_.at(2) = 1;
77  lookuptable_1_.at(3) = 2;
78  lookuptable_1_.at(4) = 3;
79  lookuptable_1_.at(5) = 4;
80  lookuptable_1_.at(6) = 5;
81  lookuptable_1_.at(7) = 6;
82  lookuptable_1_.at(8) = 7;
83  lookuptable_1_.at(9) = 8;
84  lookuptable_1_.at(10) = 9;
85  lookuptable_1_.at(11) = 10;
86  lookuptable_1_.at(12) = 10;
87  lookuptable_1_.at(13) = 11;
88  lookuptable_1_.at(14) = 12;
89  lookuptable_1_.at(15) = 13;
90 
91  for(size_t i = 0; i < lookuptable_0_.size(); ++i){
92  lookuptable_2_.at(i) = i;
93  }
94 
95  configbit_0_.resize(4);
96  configbit_1_.resize(4);
97 
98  //see [4]
99  configbit_0_.at(0) = 0;
100  configbit_0_.at(1) = 0;
101  configbit_0_.at(2) = 1;
102  configbit_0_.at(3) = 0;
103  configbit_1_.at(0) = 0;
104  configbit_1_.at(1) = 1;
105  configbit_1_.at(2) = 0;
106  configbit_1_.at(3) = 0;
107 
108  reset_pattern_.resize(6);
109  for(size_t i = 0; i < reset_pattern_.size(); ++i){
110  reset_pattern_.at(i) = true;
111  }
112 
113  weight_per_lut_entry_ = Wmax_ / (lookuptable_0_.size() - 1);
115  }
116 
117  template<typename targetidentifierT>
119  {
120  readout_cycle_duration_ = int((no_synapses_ - 1.0) / synapses_per_driver_ + 1.0) * driver_readout_time_;
121  //std::cout << "stdp_connection_facetshw_hom::debug: readout cycle duration changed to " << readout_cycle_duration_ << std::endl;
122  }
123 
124  template<typename targetidentifierT>
126  {
128 
129  def<double_t>(d, "tau_plus", tau_plus_);
130  def<double_t>(d, "tau_minus_stdp", tau_minus_);
131  def<double_t>(d, "Wmax", Wmax_);
132  def<double_t>(d, "weight_per_lut_entry", weight_per_lut_entry_);
133 
134  def<long_t>(d, "no_synapses", no_synapses_);
135  def<long_t>(d, "synapses_per_driver", synapses_per_driver_);
136  def<double_t>(d, "driver_readout_time", driver_readout_time_);
137  def<double_t>(d, "readout_cycle_duration", readout_cycle_duration_);
138 
139  (*d)["lookuptable_0"] = IntVectorDatum(new std::vector<long_t>(lookuptable_0_));
140  (*d)["lookuptable_1"] = IntVectorDatum(new std::vector<long_t>(lookuptable_1_));
141  (*d)["lookuptable_2"] = IntVectorDatum(new std::vector<long_t>(lookuptable_2_));
142  (*d)["configbit_0"] = IntVectorDatum(new std::vector<long_t>(configbit_0_));
143  (*d)["configbit_1"] = IntVectorDatum(new std::vector<long_t>(configbit_1_));
144  (*d)["reset_pattern"] = IntVectorDatum(new std::vector<long_t>(reset_pattern_));
145  }
146 
147  template<typename targetidentifierT>
149  {
151 
152  updateValue<double_t>(d, "tau_plus", tau_plus_);
153  updateValue<double_t>(d, "tau_minus_stdp", tau_minus_);
154  if(updateValue<double_t>(d, "Wmax", Wmax_)){
155  weight_per_lut_entry_ = Wmax_ / (lookuptable_0_.size() - 1);
156  }
157 
158  //TP: they should not be allowed to be changed! But needed for CopyModel ...
159  updateValue<double_t>(d, "weight_per_lut_entry", weight_per_lut_entry_);
160  updateValue<double_t>(d, "readout_cycle_duration", readout_cycle_duration_);
161  if(updateValue<long_t>(d, "no_synapses", no_synapses_)){
162  calc_readout_cycle_duration_();
163  }
164 
165  if(updateValue<long_t>(d, "synapses_per_driver", synapses_per_driver_)){
166  calc_readout_cycle_duration_();
167  }
168  if(updateValue<double_t>(d, "driver_readout_time", driver_readout_time_)){
169  calc_readout_cycle_duration_();
170  }
171 
172  if(d->known("lookuptable_0")){
173  updateValue<std::vector<long_t> >(d, "lookuptable_0", lookuptable_0_);
174 
175  //right size?
176  if(lookuptable_0_.size() != lookuptable_1_.size()){
177  throw BadProperty("Look-up table has not 2^4 entries!");
178  }
179 
180  //are look-up table entries out of bounds?
181  for(size_t i = 0; i < size_t(lookuptable_0_.size()); ++i){
182  if((lookuptable_0_[i] < 0) || (lookuptable_0_[i] > 15)){
183  throw BadProperty("Look-up table entries must be integers in [0,15]");
184  }
185  }
186  }
187  if(d->known("lookuptable_1")){
188  updateValue<std::vector<long_t> >(d, "lookuptable_1", lookuptable_1_);
189 
190  //right size?
191  if(lookuptable_1_.size() != lookuptable_0_.size()){
192  throw BadProperty("Look-up table has not 2^4 entries!");
193  }
194 
195  //are look-up table entries out of bounds?
196  for(size_t i = 0; i < size_t(lookuptable_1_.size()); ++i){
197  if((lookuptable_1_[i] < 0) || (lookuptable_1_[i] > 15)){
198  throw BadProperty("Look-up table entries must be integers in [0,15]");
199  }
200  }
201  }
202  if(d->known("lookuptable_2")){
203  updateValue<std::vector<long_t> >(d, "lookuptable_2", lookuptable_2_);
204 
205  //right size?
206  if(lookuptable_2_.size() != lookuptable_0_.size()){
207  throw BadProperty("Look-up table has not 2^4 entries!");
208  }
209 
210  //are look-up table entries out of bounds?
211  for(size_t i = 0; i < size_t(lookuptable_2_.size()); ++i){
212  if((lookuptable_2_[i] < 0) || (lookuptable_2_[i] > 15)){
213  throw BadProperty("Look-up table entries must be integers in [0,15]");
214  }
215  }
216  }
217 
218  if(d->known("configbit_0")){
219  updateValue<std::vector<long_t> >(d, "configbit_0", configbit_0_);
220 
221  //right size?
222  if(configbit_0_.size() != 4){
223  throw BadProperty("Wrong number of configuration bits (!=4).");
224  }
225  }
226  if(d->known("configbit_1")){
227  updateValue<std::vector<long_t> >(d, "configbit_1", configbit_1_);
228 
229  //right size?
230  if(configbit_1_.size() != 4){
231  throw BadProperty("Wrong number of configuration bits (!=4).");
232  }
233  }
234  if(d->known("reset_pattern")){
235  updateValue<std::vector<long_t> >(d, "reset_pattern", reset_pattern_);
236 
237  //right size?
238  if(reset_pattern_.size() != 6){
239  throw BadProperty("Wrong number of reset bits (!=6).");
240  }
241  }
242  }
243 
244 
245  //
246  // Implementation of class STDPFACETSHWConnectionHom.
247  //
248  template<typename targetidentifierT>
250  weight_(1.0),
251  a_causal_(0.0),
252  a_acausal_(0.0),
253  a_thresh_th_(21.835), //exp(-10ms/20ms) * 36SSPs
254  a_thresh_tl_(21.835),
255 
256  init_flag_(false),
257  synapse_id_(0),
258  next_readout_time_(0.0),
259  discrete_weight_(0)
260  { }
261 
262  template<typename targetidentifierT>
264  ConnectionBase(rhs),
265  weight_(rhs.weight_),
266  a_causal_(rhs.a_causal_),
267  a_acausal_(rhs.a_acausal_),
268  a_thresh_th_(rhs.a_thresh_th_),
269  a_thresh_tl_(rhs.a_thresh_tl_),
270  init_flag_(rhs.init_flag_),
271  synapse_id_(rhs.synapse_id_),
272  next_readout_time_(rhs.next_readout_time_),
273  discrete_weight_(rhs.discrete_weight_)
274  { }
275 
276  template<typename targetidentifierT>
278  {
279  // base class properties, different for individual synapse
280  ConnectionBase::get_status(d);
281  def<double_t>(d, names::weight, weight_);
282 
283  // own properties, different for individual synapse
284  def<double_t>(d, "a_causal", a_causal_);
285  def<double_t>(d, "a_acausal", a_acausal_);
286  def<double_t>(d, "a_thresh_th", a_thresh_th_);
287  def<double_t>(d, "a_thresh_tl", a_thresh_tl_);
288 
289  def<bool>(d, "init_flag", init_flag_);
290  def<long_t>(d, "synapse_id", synapse_id_);
291  def<double_t>(d, "next_readout_time", next_readout_time_);
292  //useful to get conversion before activity, but weight_per_lut_entry_ not known here
293  //def<uint_t>(d, "discrete_weight", entry_to_weight_(weight_to_entry_(weight_, weight_per_lut_entry_), weight_per_lut_entry_));
294  }
295 
296  template<typename targetidentifierT>
298  {
299  // base class properties
300  ConnectionBase::set_status(d, cm);
301  updateValue<double_t>(d, names::weight, weight_);
302 
303  updateValue<double_t>(d, "a_causal", a_causal_);
304  updateValue<double_t>(d, "a_acausal", a_acausal_);
305  updateValue<double_t>(d, "a_thresh_th", a_thresh_th_);
306  updateValue<double_t>(d, "a_thresh_tl", a_thresh_tl_);
307 
308  updateValue<long_t>(d, "synapse_id", synapse_id_);
309 
310  //TP: they should not be allowed to be changed! But needed for CopyModel ...
311  updateValue<bool>(d, "init_flag", init_flag_);
312  updateValue<double_t>(d, "next_readout_time", next_readout_time_);
313 
314  //setting discrete_weight_ does not make sense, is temporary variable
315  }
316 
317 } // of namespace nest
void get_status(DictionaryDatum &d) const
Get all properties and put them into a dictionary.
Definition: stdp_connection_facetshw_hom_impl.h:125
void set_status(const DictionaryDatum &d, ConnectorModel &cm)
Set properties from the values given in dictionary.
Definition: common_synapse_properties.cpp:42
const Name d("d")
Specific to Izhikevich 2003.
Definition: nest_names.h:83
double_t weight_per_lut_entry_
Definition: stdp_connection_facetshw_hom.h:155
Class representing an STDP connection with homogeneous parameters, i.e.
Definition: stdp_connection_facetshw_hom.h:113
const Name weight("weight")
Connection parameters.
Definition: nest_names.h:344
std::vector< long_t > lookuptable_1_
Definition: stdp_connection_facetshw_hom.h:163
std::vector< long_t > configbit_1_
Definition: stdp_connection_facetshw_hom.h:166
std::vector< long_t > reset_pattern_
Definition: stdp_connection_facetshw_hom.h:167
void set_status(const DictionaryDatum &d, ConnectorModel &cm)
Set properties of this connection from the values given in dictionary.
Definition: stdp_connection_facetshw_hom_impl.h:297
void get_status(DictionaryDatum &d) const
Get all properties of this connection and put them into a dictionary.
Definition: stdp_connection_facetshw_hom_impl.h:277
void set_status(const DictionaryDatum &d, ConnectorModel &cm)
Set properties from the values given in dictionary.
Definition: stdp_connection_facetshw_hom_impl.h:148
double_t Wmax_
Definition: stdp_connection_facetshw_hom.h:154
Declarations for class Network.
Exception to be thrown if a status parameter is incomplete or inconsistent.
Definition: exceptions.h:420
std::vector< long_t > lookuptable_0_
Definition: stdp_connection_facetshw_hom.h:162
Class containing the common properties for all connections of a certain type.
Definition: common_synapse_properties.h:44
void get_status(DictionaryDatum &d) const
Get all properties and put them into a dictionary.
Definition: common_synapse_properties.cpp:40
std::vector< long_t > lookuptable_2_
Definition: stdp_connection_facetshw_hom.h:164
Base class for representing connections.
Definition: connection.h:85
STDPFACETSHWHomCommonProperties()
Default constructor.
Definition: stdp_connection_facetshw_hom_impl.h:37
STDPFACETSHWConnectionHom()
Default Constructor.
Definition: stdp_connection_facetshw_hom_impl.h:249
std::vector< long_t > configbit_0_
Definition: stdp_connection_facetshw_hom.h:165
Definition: connector_model.h:38
lockPTRDatum< std::vector< long >,&SLIInterpreter::IntVectortype > IntVectorDatum
Definition: arraydatum.h:82
void calc_readout_cycle_duration_()
Calculate the readout cycle duration.
Definition: stdp_connection_facetshw_hom_impl.h:118