1 /*
2  *  clopath_archiving_node.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 #ifndef CLOPATH_ARCHIVING_NODE_H
24 #define CLOPATH_ARCHIVING_NODE_H
25 
26 // C++ includes:
27 #include <deque>
28 
29 // Includes from nestkernel:
30 #include "histentry.h"
31 #include "nest_time.h"
32 #include "nest_types.h"
33 #include "archiving_node.h"
34 #include "synaptic_element.h"
35 
36 // Includes from sli:
37 #include "dictdatum.h"
38 
39 namespace nest
40 {
41 
42 /**
43  * \class ClopathArchivingNode
44  * a archiving node which additionally archives parameters
45  * and buffers needed for the Clopath plasticity rule
46  */
47 class ClopathArchivingNode : public ArchivingNode
48 {
49 
50 public:
51   /**
52    * \fn ClopathArchivingNode()
53    * Constructor.
54    */
55   ClopathArchivingNode();
56 
57   /**
58    * \fn ClopathArchivingNode()
59    * Copy Constructor.
60    */
61   ClopathArchivingNode( const ClopathArchivingNode& );
62 
63   /**
64    * \fn double get_LTD_value(long t)
65    * Returns value in LTD history at time t
66    */
67   double get_LTD_value( double t );
68 
69   /**
70    * \fn void get_LTP_history(long t1, long t2,
71    * std::deque<Archiver::histentry>::iterator* start,
72    * std::deque<Archiver::histentry>::iterator* finish)
73    * Sets pointer start (finish) to the first (last) entry in LTP_history
74    * whose time argument is between t1 and t2
75    */
76   void get_LTP_history( double t1,
77     double t2,
78     std::deque< histentry_extended >::iterator* start,
79     std::deque< histentry_extended >::iterator* finish );
80 
81   /**
82    * \fn double get_theta_plus()
83    * Returns threshold theta_plus_
84    */
85   double get_theta_plus() const;
86 
87   /**
88    * \fn double get_theta_minus()
89    * Returns threshold theta_minus_
90    */
91   double get_theta_minus() const;
92 
93 protected:
94   /**
95    * \fn void write_LTD_history( Time const& t_sp,
96    * double u_bar_minus, double u_bar_bar )
97    * Creates a new entry in the LTD history and deletes old entries that
98    * are not needed any more.
99    */
100   void write_LTD_history( const double t_ltd_ms, double u_bar_minus, double u_bar_bar );
101 
102   /**
103    * \fn void write_LTP_history( const double t_ltp_ms, double u,
104    * double u_bar_plus )
105    * Creates a new entry in the LTP history and delets old entries that
106    * are not needed any more.
107    */
108   void write_LTP_history( const double t_ltp_ms, double u, double u_bar_plus );
109 
110   /**
111    * \fn void write_clopath_history( Time const& t_sp,
112    * double u, double u_bar_plus, double u_bar_minus, double u_bar_bar )
113    * Writes and reads the delayed_u_bar_[plus/minus] buffers and
114    * calls write_LTD_history and write_LTP_history if
115    * the corresponding Heaviside functions yield 1.
116    */
117   void write_clopath_history( Time const& t_sp, double u, double u_bar_plus, double u_bar_minus, double u_bar_bar );
118 
119   void init_clopath_buffers();
120   void get_status( DictionaryDatum& d ) const;
121   void set_status( const DictionaryDatum& d );
122 
123 private:
124   std::vector< histentry_extended > ltd_history_;
125   std::deque< histentry_extended > ltp_history_;
126 
127   double A_LTD_;
128 
129   double A_LTP_;
130 
131   double u_ref_squared_;
132 
133   double theta_plus_;
134 
135   double theta_minus_;
136 
137   bool A_LTD_const_;
138 
139   double delay_u_bars_;
140   size_t delay_u_bars_steps_;
141   std::vector< double > delayed_u_bar_plus_;
142   std::vector< double > delayed_u_bar_minus_;
143   size_t delayed_u_bars_idx_;
144 
145   size_t ltd_hist_len_;
146 
147   size_t ltd_hist_current_;
148 };
149 
150 inline double
get_theta_plus()151 ClopathArchivingNode::get_theta_plus() const
152 {
153   return theta_plus_;
154 }
155 
156 inline double
get_theta_minus()157 ClopathArchivingNode::get_theta_minus() const
158 {
159   return theta_minus_;
160 }
161 
162 } // of namespace
163 #endif
164