• Main Page
  • Classes
  • Files
  • File List

GenericPopulCodeSEMSynapse.h

00001 #ifndef GenericPopulCodeSEMSynapse_H_
00002 #define GenericPopulCodeSEMSynapse_H_
00003 
00004 #include "EvSimObject.h"
00005 #include "SpikeResponse.h"
00006 
00007 template<class Base>
00008 class GenericPopulCodeSEMSynapse : public Base {
00009 
00010 public:
00011         GenericPopulCodeSEMSynapse(float Winit,
00012                                         float eta,
00013                                         bool withHessian,
00014                                         bool activePlasticity,
00015                                         float maxW,
00016                                         float minW,
00017                                         SpikeResponse *response,
00018                                         SpikeResponse *bap_trace)
00019         {
00020                 this->Winit = Winit;
00021                 this->eta = eta;
00022                 this->withHessian = withHessian;
00023                 this->activePlasticity = activePlasticity;
00024                 this->maxW = maxW;
00025                 this->minW = minW;
00026 
00027                 this->Base::syn_resp = (response) ? dynamic_cast<SpikeResponse *>(response->copy()) : 0;
00028                 this->bap_response = (bap_trace) ? dynamic_cast<SpikeResponse *>(bap_trace->copy()) : 0;
00029         }
00030 
00031         virtual ~GenericPopulCodeSEMSynapse() {};
00032 
00033         float eta;
00034 
00035         float Winit;
00036 
00037         bool withHessian;
00038 
00039         bool activePlasticity;
00040 
00041         float C;
00042 
00043         float maxW;
00044 
00045         float minW;
00046 
00047         virtual void setBackpropAPResponse(SpikeResponse *response) {
00048                 bap_response = response;
00049         }
00050 
00051         virtual bool propagatesUpdate(update_id_t upd_id) const {
00052                 if (upd_id == 1)
00053                         return false;
00054                 return true;
00055         }
00056 
00057         virtual void reset(SimContext &sim_ctxt)
00058         {
00059                 Base::W = Winit;
00060                 Base::resetPSRs();
00061         };
00062 
00063         virtual SpikeResponse *createBackpropAPResponseObject() {return bap_response;};
00064 
00065         virtual void updateState(SimContext &sim_ctxt, Time time, update_id_t upd_id);
00066 
00067         virtual bool isPlastic() { return true; };
00068 
00069 protected:
00070         SpikeResponse *bap_response;
00071         Time timeOfLastChange;
00072 };
00073 
00074 
00075 template<class Base>
00076 void GenericPopulCodeSEMSynapse<Base>::updateState(SimContext& sim_ctxt, Time time, update_id_t upd_id) {
00077         double pre_trace, post_trace;
00078         if (upd_id == 0) {
00079                 pre_trace = Base::syn_resp->getOld();
00080                 post_trace = bap_response->get();
00081         }
00082         else {
00083                 pre_trace = Base::syn_resp->get();
00084                 post_trace = bap_response->getOld();
00085         }
00086         if (activePlasticity) {
00087                 double m = 1;
00088                 if (withHessian) {
00089                         m = exp(-Base::W);
00090                 }
00091                 double newW = Base::W + eta * m * post_trace * (pre_trace - exp(Base::W)) * (time - timeOfLastChange);
00092                 if (newW < maxW && newW > minW) Base::W = newW;
00093                 timeOfLastChange = time;
00094         }
00095         if (upd_id == 0)
00096                 Base::updateState(sim_ctxt, time, upd_id);
00097 }
00098 
00099 
00100 #endif /* GenericPopulCodeSEMSynapse_H_ */

Generated on Wed Sep 18 2013 11:25:40 for NEVESIM by  doxygen 1.7.1