MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
SeqSynHandler Class Reference

#include <SeqSynHandler.h>

+ Inheritance diagram for SeqSynHandler:
+ Collaboration diagram for SeqSynHandler:

Public Member Functions

void addSpike (unsigned int index, double time, double weight)
 
unsigned int addSynapse ()
 Adds a new synapse, returns its index. More...
 
void dropSynapse (unsigned int droppedSynNumber)
 
void fixSynapseOrder ()
 
double getBaseScale () const
 
vector< double > getHistory () const
 
double getHistoryTime () const
 
vector< double > getKernel () const
 
string getKernelEquation () const
 
unsigned int getKernelWidth () const
 
double getPlasticityScale () const
 
double getSeqActivation () const
 
double getSeqDt () const
 
double getSequencePower () const
 
double getSequenceScale () const
 
vector< unsigned int > getSynapseOrder () const
 
int getSynapseOrderOption () const
 
double getTopSpike (unsigned int index) const
 
vector< double > getWeightScaleVec () const
 
int numHistory () const
 
SeqSynHandleroperator= (const SeqSynHandler &other)
 
void refillSynapseOrder (unsigned int newSize)
 
 SeqSynHandler ()
 
void setBaseScale (double v)
 
void setHistoryTime (double v)
 
void setKernelEquation (string eq)
 
void setKernelWidth (unsigned int v)
 
void setPlasticityScale (double v)
 
void setSeqDt (double v)
 
void setSequencePower (double v)
 
void setSequenceScale (double v)
 
void setSynapseOrder (vector< unsigned int > v)
 
void setSynapseOrderOption (int v)
 
unsigned int vGetNumSynapses () const
 
SynapsevGetSynapse (unsigned int i)
 
void vProcess (const Eref &e, ProcPtr p)
 
void vReinit (const Eref &e, ProcPtr p)
 
void vSetNumSynapses (unsigned int num)
 
 ~SeqSynHandler ()
 
- Public Member Functions inherited from SynHandlerBase
unsigned int getNumSynapses () const
 
SynapsegetSynapse (unsigned int i)
 
void process (const Eref &e, ProcPtr p)
 
bool rangeWarning (const string &field, double value)
 
void reinit (const Eref &e, ProcPtr p)
 
void setNumSynapses (unsigned int num)
 
 SynHandlerBase ()
 
virtual ~SynHandlerBase ()
 

Static Public Member Functions

static const CinfoinitCinfo ()
 
- Static Public Member Functions inherited from SynHandlerBase
static SrcFinfo1< double > * activationOut ()
 
static const CinfoinitCinfo ()
 

Private Member Functions

void updateKernel ()
 

Private Attributes

double baseScale_
 Scaling factor for baseline synaptic responses. More...
 
priority_queue< PreSynEvent,
vector< PreSynEvent >
, CompareSynEvent
events_
 
RollingMatrix history_
 Kernel for seq selectivity. More...
 
double historyTime_
 Time to store history. KernelDt defines num of rows. More...
 
vector< vector< double > > kernel_
 
string kernelEquation_
 
unsigned int kernelWidth_
 
vector< double > latestSpikes_
 
double plasticityScale_
 
double seqActivation_
 
double seqDt_
 
double sequencePower_
 
double sequenceScale_
 Scaling factor for sequence recognition responses. More...
 
vector< unsigned int > synapseOrder_
 Rows = time; cols = synInputs. More...
 
int synapseOrderOption_
 
vector< Synapsesynapses_
 
vector< double > weightScaleVec_
 

Detailed Description

This handles synapses organized sequentially. The parent class SimpleSynHandler deals with the mechanics of data arrival. Here the algorithm is 0. Assume all synaptic input comes on a linear dendrite.

  1. Maintain a history of depth D for synaptic activity. May be simplest to do as event list (sparse matrix) rather than full matrix.
  2. Maintain a kernel of how to weight time and space
  3. Here we have various options 3.1 At each spike event, decide how to weight it based on history. 3.2 At each timestep, compute an effective Gk and send to activation. This will be moderately nasty to compute

Definition at line 26 of file SeqSynHandler.h.

Constructor & Destructor Documentation

SeqSynHandler::SeqSynHandler ( )

Definition at line 209 of file SeqSynHandler.cpp.

References history_, numHistory(), and RollingMatrix::resize().

210  :
211  kernelEquation_( "" ),
212  kernelWidth_( 5 ),
213  historyTime_( 2.0 ),
214  seqDt_ ( 1.0 ),
215  baseScale_( 0.0 ),
216  sequenceScale_( 1.0 ),
217  plasticityScale_( 0.0 ),
218  sequencePower_( 1.0 ),
219  seqActivation_( 0.0 ),
220  synapseOrderOption_( -1 ) // sequential ordering
221 {
222  history_.resize( numHistory(), 0 );
223 }
double seqActivation_
void resize(unsigned int numRows, unsigned int numColumns)
double plasticityScale_
double historyTime_
Time to store history. KernelDt defines num of rows.
double baseScale_
Scaling factor for baseline synaptic responses.
int numHistory() const
RollingMatrix history_
Kernel for seq selectivity.
string kernelEquation_
Definition: SeqSynHandler.h:98
unsigned int kernelWidth_
Definition: SeqSynHandler.h:99
double sequencePower_
double sequenceScale_
Scaling factor for sequence recognition responses.

+ Here is the call graph for this function:

SeqSynHandler::~SeqSynHandler ( )

Definition at line 225 of file SeqSynHandler.cpp.

226 { ; }

Member Function Documentation

void SeqSynHandler::addSpike ( unsigned int  index,
double  time,
double  weight 
)
virtual

Record arrival of a new spike event. The 'time' is time for eventual arrival of the spike, and is typically well in the future. The index specifies which synapse the spike came to.

Implements SynHandlerBase.

Definition at line 502 of file SeqSynHandler.cpp.

References events_, latestSpikes_, synapseOrder_, and synapses_.

503 {
504  assert( index < synapses_.size() );
505  events_.push( PreSynEvent( index, time, weight ) );
506  // Strictly speaking this isn't right. If we have a long time lag
507  // then the correct placement of the spike may be in another time
508  // slice. For now, to get it going for LIF neurons, this will do.
509  // Even in the general case we will probably have a very wide window
510  // for the latestSpikes slice.
511  //
512  // Here we reorder the entries in latestSpikes by the synapse order.
513  latestSpikes_[ synapseOrder_[index] ] += weight;
514 }
vector< Synapse > synapses_
priority_queue< PreSynEvent, vector< PreSynEvent >, CompareSynEvent > events_
vector< double > latestSpikes_
vector< unsigned int > synapseOrder_
Rows = time; cols = synInputs.
unsigned int SeqSynHandler::addSynapse ( )
virtual

Adds a new synapse, returns its index.

Implements SynHandlerBase.

Definition at line 523 of file SeqSynHandler.cpp.

References synapses_.

524 {
525  unsigned int newSynIndex = synapses_.size();
526  synapses_.resize( newSynIndex + 1 );
527  synapses_[newSynIndex].setHandler( this );
528  return newSynIndex;
529 }
vector< Synapse > synapses_
void SeqSynHandler::dropSynapse ( unsigned int  droppedSynNumber)
virtual

Drops an existing synapse, triggered by deleteMsg of an input to the child synapse. This is a little messy because we can't change the indices of the other synapses. The Handler has to figure out how to handle the 'holes' in its array of synapses.

Implements SynHandlerBase.

Definition at line 531 of file SeqSynHandler.cpp.

References synapses_.

532 {
533  assert( msgLookup < synapses_.size() );
534  synapses_[msgLookup].setWeight( -1.0 );
535 }
vector< Synapse > synapses_
void SeqSynHandler::fixSynapseOrder ( )

Definition at line 276 of file SeqSynHandler.cpp.

References synapseOrder_.

Referenced by refillSynapseOrder(), and setSynapseOrder().

277 {
278  unsigned int sz = synapseOrder_.size();
279  vector< unsigned int > availableEntries( sz );
280  iota( availableEntries.begin(), availableEntries.end(), 0 );
281  for( unsigned int i = 0; i < sz; ++i ) {
282  if ( synapseOrder_[i] < sz )
283  availableEntries[ synapseOrder_[i] ] = sz;
284  }
285  vector< unsigned int > ae;
286  for( unsigned int i = 0; i < sz; ++i )
287  if ( availableEntries[i] < sz )
288  ae.push_back( availableEntries[i] );
289 
290  auto jj = ae.begin();
291  for( unsigned int i = 0; i < sz; ++i ) {
292  if ( synapseOrder_[i] >= sz )
293  synapseOrder_[i] = *jj++;
294  }
295 }
vector< unsigned int > synapseOrder_
Rows = time; cols = synInputs.

+ Here is the caller graph for this function:

double SeqSynHandler::getBaseScale ( ) const

Definition at line 409 of file SeqSynHandler.cpp.

References baseScale_.

Referenced by initCinfo().

410 {
411  return baseScale_;
412 }
double baseScale_
Scaling factor for baseline synaptic responses.

+ Here is the caller graph for this function:

vector< double > SeqSynHandler::getHistory ( ) const

Definition at line 464 of file SeqSynHandler.cpp.

References RollingMatrix::get(), history_, numHistory(), and vGetNumSynapses().

Referenced by initCinfo().

465 {
466  int nh = numHistory();
467  int numX = vGetNumSynapses();
468  vector< double > ret( numX * nh, 0.0 );
469  vector< double >::iterator k = ret.begin();
470  for ( int i = 0; i < nh; ++i ) {
471  for ( int j = 0; j < numX; ++j )
472  *k++ = history_.get( i, j );
473  }
474  return ret;
475 }
int numHistory() const
RollingMatrix history_
Kernel for seq selectivity.
unsigned int vGetNumSynapses() const
double get(unsigned int row, unsigned int column) const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

double SeqSynHandler::getHistoryTime ( ) const

Definition at line 399 of file SeqSynHandler.cpp.

References historyTime_.

Referenced by initCinfo().

400 {
401  return historyTime_;
402 }
double historyTime_
Time to store history. KernelDt defines num of rows.

+ Here is the caller graph for this function:

vector< double > SeqSynHandler::getKernel ( ) const

Definition at line 454 of file SeqSynHandler.cpp.

References kernel_, and numHistory().

Referenced by initCinfo().

455 {
456  int nh = numHistory();
457  vector< double > ret;
458  for ( int i = 0; i < nh; ++i ) {
459  ret.insert( ret.end(), kernel_[i].begin(), kernel_[i].end() );
460  }
461  return ret;
462 }
int numHistory() const
vector< vector< double > > kernel_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

string SeqSynHandler::getKernelEquation ( ) const

Definition at line 364 of file SeqSynHandler.cpp.

References kernelEquation_.

Referenced by initCinfo().

365 {
366  return kernelEquation_;
367 }
string kernelEquation_
Definition: SeqSynHandler.h:98

+ Here is the caller graph for this function:

unsigned int SeqSynHandler::getKernelWidth ( ) const

Definition at line 375 of file SeqSynHandler.cpp.

References kernelWidth_.

Referenced by initCinfo().

376 {
377  return kernelWidth_;
378 }
unsigned int kernelWidth_
Definition: SeqSynHandler.h:99

+ Here is the caller graph for this function:

double SeqSynHandler::getPlasticityScale ( ) const

Definition at line 429 of file SeqSynHandler.cpp.

References plasticityScale_.

Referenced by initCinfo().

430 {
431  return plasticityScale_;
432 }
double plasticityScale_

+ Here is the caller graph for this function:

double SeqSynHandler::getSeqActivation ( ) const

Definition at line 424 of file SeqSynHandler.cpp.

References seqActivation_.

Referenced by initCinfo().

425 {
426  return seqActivation_;
427 }
double seqActivation_

+ Here is the caller graph for this function:

double SeqSynHandler::getSeqDt ( ) const

Definition at line 387 of file SeqSynHandler.cpp.

References seqDt_.

Referenced by initCinfo().

388 {
389  return seqDt_;
390 }

+ Here is the caller graph for this function:

double SeqSynHandler::getSequencePower ( ) const

Definition at line 439 of file SeqSynHandler.cpp.

References sequencePower_.

Referenced by initCinfo().

440 {
441  return sequencePower_;
442 }
double sequencePower_

+ Here is the caller graph for this function:

double SeqSynHandler::getSequenceScale ( ) const

Definition at line 419 of file SeqSynHandler.cpp.

References sequenceScale_.

Referenced by initCinfo().

420 {
421  return sequenceScale_;
422 }
double sequenceScale_
Scaling factor for sequence recognition responses.

+ Here is the caller graph for this function:

vector< unsigned int > SeqSynHandler::getSynapseOrder ( ) const

Definition at line 484 of file SeqSynHandler.cpp.

References synapseOrder_.

Referenced by initCinfo().

485 {
486  return synapseOrder_;
487 }
vector< unsigned int > synapseOrder_
Rows = time; cols = synInputs.

+ Here is the caller graph for this function:

int SeqSynHandler::getSynapseOrderOption ( ) const

Definition at line 495 of file SeqSynHandler.cpp.

References synapseOrderOption_.

Referenced by initCinfo().

496 {
497  return synapseOrderOption_;
498 }

+ Here is the caller graph for this function:

double SeqSynHandler::getTopSpike ( unsigned int  index) const
virtual

Implements SynHandlerBase.

Definition at line 516 of file SeqSynHandler.cpp.

References events_.

517 {
518  if ( events_.empty() )
519  return 0.0;
520  return events_.top().time;
521 }
priority_queue< PreSynEvent, vector< PreSynEvent >, CompareSynEvent > events_
vector< double > SeqSynHandler::getWeightScaleVec ( ) const

Definition at line 449 of file SeqSynHandler.cpp.

References weightScaleVec_.

Referenced by initCinfo().

450 {
451  return weightScaleVec_;
452 }
vector< double > weightScaleVec_

+ Here is the caller graph for this function:

const Cinfo * SeqSynHandler::initCinfo ( )
static

Definition at line 20 of file SeqSynHandler.cpp.

References getBaseScale(), getHistory(), getHistoryTime(), getKernel(), getKernelEquation(), getKernelWidth(), SynHandlerBase::getNumSynapses(), getPlasticityScale(), getSeqActivation(), getSeqDt(), getSequencePower(), getSequenceScale(), SynHandlerBase::getSynapse(), getSynapseOrder(), getSynapseOrderOption(), getWeightScaleVec(), Synapse::initCinfo(), SynHandlerBase::initCinfo(), seqSynHandlerCinfo, setBaseScale(), setHistoryTime(), setKernelEquation(), setKernelWidth(), SynHandlerBase::setNumSynapses(), setPlasticityScale(), setSeqDt(), setSequencePower(), setSequenceScale(), setSynapseOrder(), and setSynapseOrderOption().

21 {
22  static string doc[] =
23  {
24  "Name", "SeqSynHandler",
25  "Author", "Upi Bhalla",
26  "Description",
27  "The SeqSynHandler handles synapses that recognize sequentially "
28  "ordered input, where the ordering is both in space and time. "
29  "It assumes that the N input synapses are ordered and "
30  "equally spaced along a single linear vector.\n "
31  "To do this it maintains a record of recent synaptic input, "
32  "for a duration of *historyTime*, at a time interval *seqDt*. "
33  "*SeqDt* is typically longer than the simulation "
34  "timestep *dt* for the synapse, and cannot be shorter. "
35  "*SeqDt* should represent the characteristic time of advance "
36  "of the sequence. \n"
37  "The SeqSynHandler uses a 2-D kernel to define how to recognize"
38  " a sequence, with dependence both on space and history. "
39  "This kernel is defined by the *kernelEquation* as a "
40  "mathematical expression in x (synapse number) and t (time)."
41  "It computes a vector with the local *response* term for each "
42  "point along all inputs, by taking a 2-d convolution of the "
43  "kernel with the history[time][synapse#] matrix."
44  "\nThe local response can affect the synapse in three ways: "
45  "1. It can sum the entire response vector, scale by the "
46  "*sequenceScale* term, and send to the synapse as a steady "
47  "activation. Consider this a cell-wide immediate response to "
48  "a sequence that it likes.\n"
49  "2. It do an instantaneous scaling of the weight of each "
50  "individual synapse by the corresponding entry in the response "
51  "vector. It uses the *plasticityScale* term to do this. "
52  "Consider "
53  "this a short-term plasticity effect on specific synapses. \n"
54  "3. It can do long-term plasticity of each individual synapse "
55  "using the matched local entries in the response vector and "
56  "individual synapse history as inputs to the learning rule. "
57  "This is not yet implemented.\n"
58  "In addition to all these, the SeqSynHandler can act just like "
59  "a regular synapse, where it responds to individual synaptic "
60  "input according to the weight of the synapse. The size of "
61  "this component of the output is scaled by *baseScale*\n"
62  };
63 
65  "synapse",
66  "Sets up field Elements for synapse",
71  );
72 
73  static ValueFinfo< SeqSynHandler, string > kernelEquation(
74  "kernelEquation",
75  "Equation in x and t to define kernel for sequence recognition",
78  );
80  "kernelWidth",
81  "Width of kernel, i.e., number of synapses taking part in seq.",
84  );
86  "seqDt",
87  "Characteristic time for advancing the sequence.",
90  );
91  static ValueFinfo< SeqSynHandler, double > historyTime(
92  "historyTime",
93  "Duration to keep track of history of inputs to all synapses.",
96  );
97  static ValueFinfo< SeqSynHandler, double > baseScale(
98  "baseScale",
99  "Basal scaling factor for regular synaptic activation.",
102  );
103  static ValueFinfo< SeqSynHandler, double > sequenceScale(
104  "sequenceScale",
105  "Scaling factor for sustained activation of synapse by seq",
108  );
110  "synapseOrder",
111  "Mapping of synapse input order to spatial order on syn array."
112  "Entries in this vector are indices which must remain smaller "
113  "than numSynapses. The system will fix up if you mess up. "
114  "It does not insist on unique mappings, but these are "
115  "desirable as outcome is undefined for repeated entries.",
118  );
119  static ValueFinfo< SeqSynHandler, int > synapseOrderOption(
120  "synapseOrderOption",
121  "How to do the synapse order remapping. This rule stays in "
122  "place and guarantees safe mappings even if the number of "
123  "synapses is altered. Options:\n"
124  "-2: User ordering.\n"
125  "-1: Sequential ordering, 0 to numSynapses-1.\n"
126  "0: Random ordering using existing system seed.\n"
127  ">0: Random ordering using seed specified by this number\n"
128  "Default is -1, sequential ordering.",
131  );
132  static ReadOnlyValueFinfo< SeqSynHandler, double > seqActivation(
133  "seqActivation",
134  "Reports summed activation of synaptic channel by sequence",
136  );
137  static ValueFinfo< SeqSynHandler, double > plasticityScale(
138  "plasticityScale",
139  "Scaling factor for doing plasticity by scaling each synapse by response vector",
142  );
143 
144  static ValueFinfo< SeqSynHandler, double > sequencePower(
145  "sequencePower",
146  "Exponent for the outcome of the sequential calculations. "
147  "This is needed because linear summation of terms in the kernel"
148  "means that a brief stong sequence match is no better than lots"
149  "of successive low matches. In other words, 12345 is no better"
150  "than 11111. Using an exponent lets us select the former."
151  "Defaults to 1.0.",
154  );
155 
157  weightScaleVec(
158  "weightScaleVec",
159  "Vector of weight scaling for each synapse",
161  );
163  "kernel",
164  "All entries of kernel, as a linear vector",
166  );
168  "history",
169  "All entries of history, as a linear vector",
171  );
172 
173  static Finfo* seqSynHandlerFinfos[] = {
174  &synFinfo, // FieldElement
175  &kernelEquation, // Field
176  &kernelWidth, // Field
177  &seqDt, // Field
178  &historyTime, // Field
179  &sequenceScale, // Field
180  &baseScale, // Field
181  &synapseOrder, // Field
182  &synapseOrderOption, // Field
183  &seqActivation, // ReadOnlyField
184  &plasticityScale, // Field
185  &sequencePower, // Field
186  &weightScaleVec, // ReadOnlyField
187  &kernel, // ReadOnlyField
188  &history // ReadOnlyField
189  };
190 
191  static Dinfo< SeqSynHandler > dinfo;
192  static Cinfo seqSynHandlerCinfo (
193  "SeqSynHandler",
195  seqSynHandlerFinfos,
196  sizeof( seqSynHandlerFinfos ) / sizeof ( Finfo* ),
197  &dinfo,
198  doc,
199  sizeof( doc ) / sizeof( string )
200  );
201 
202  return &seqSynHandlerCinfo;
203 }
vector< double > getKernel() const
double getBaseScale() const
void setNumSynapses(unsigned int num)
vector< double > getWeightScaleVec() const
Definition: Dinfo.h:60
double getSequenceScale() const
void setPlasticityScale(double v)
double getSequencePower() const
vector< unsigned int > getSynapseOrder() const
unsigned int getNumSynapses() const
void setKernelEquation(string eq)
string getKernelEquation() const
double getPlasticityScale() const
static const Cinfo * initCinfo()
Synapse * getSynapse(unsigned int i)
double getSeqDt() const
void setKernelWidth(unsigned int v)
void setSeqDt(double v)
static const Cinfo * initCinfo()
Definition: Synapse.cpp:15
int getSynapseOrderOption() const
double getSeqActivation() const
static const Cinfo * seqSynHandlerCinfo
void setSynapseOrderOption(int v)
vector< double > getHistory() const
void setSequencePower(double v)
void setSynapseOrder(vector< unsigned int > v)
unsigned int getKernelWidth() const
void setBaseScale(double v)
void setHistoryTime(double v)
double getHistoryTime() const
Definition: Cinfo.h:18
void setSequenceScale(double v)
Definition: Finfo.h:12

+ Here is the call graph for this function:

int SeqSynHandler::numHistory ( ) const

Definition at line 601 of file SeqSynHandler.cpp.

References historyTime_, and seqDt_.

Referenced by getHistory(), getKernel(), SeqSynHandler(), setHistoryTime(), setSeqDt(), updateKernel(), vProcess(), and vSetNumSynapses().

602 {
603  return static_cast< int >( 1.0 + floor( historyTime_ * (1.0 - 1e-6 ) / seqDt_ ) );
604 }
double historyTime_
Time to store history. KernelDt defines num of rows.

+ Here is the caller graph for this function:

SeqSynHandler & SeqSynHandler::operator= ( const SeqSynHandler other)

Definition at line 229 of file SeqSynHandler.cpp.

References events_, and synapses_.

230 {
231  synapses_ = ssh.synapses_;
232  for ( vector< Synapse >::iterator
233  i = synapses_.begin(); i != synapses_.end(); ++i )
234  i->setHandler( this );
235 
236  // For no apparent reason, priority queues don't have a clear operation.
237  while( !events_.empty() )
238  events_.pop();
239 
240  return *this;
241 }
vector< Synapse > synapses_
priority_queue< PreSynEvent, vector< PreSynEvent >, CompareSynEvent > events_
void SeqSynHandler::refillSynapseOrder ( unsigned int  newSize)

Definition at line 309 of file SeqSynHandler.cpp.

References fixSynapseOrder(), moose::mtrand(), moose::mtseed(), synapseOrder_, and synapseOrderOption_.

Referenced by setSynapseOrderOption(), and vSetNumSynapses().

310 {
311  if ( synapseOrderOption_ <= -2 ) { // User order
312  synapseOrder_.resize( newSize, newSize );
313  fixSynapseOrder();
314  } else if ( synapseOrderOption_ == -1 ) { // Ordered
315  synapseOrder_.resize( newSize );
316  for ( unsigned int i = 0 ; i < newSize; ++i )
317  synapseOrder_[i] = i;
318  } else {
319  synapseOrder_.resize( newSize );
320  if ( synapseOrderOption_ > 0 ) { // Specify seed explicitly
322  }
323  vector< double > x;
324  for ( unsigned int i = 0; i < newSize; ++i )
325  x.push_back( moose::mtrand() );
326  auto idx = sort_indexes< double >( x );
327  for ( unsigned int i = 0; i < newSize; ++i )
328  synapseOrder_[i] = idx[i];
329  }
330 }
void mtseed(unsigned int x)
Set the global seed or all rngs.
Definition: global.cpp:89
void fixSynapseOrder()
double mtrand(void)
Generate a random double between 0 and 1.
Definition: global.cpp:97
vector< unsigned int > synapseOrder_
Rows = time; cols = synInputs.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void SeqSynHandler::setBaseScale ( double  v)

Definition at line 404 of file SeqSynHandler.cpp.

References baseScale_.

Referenced by initCinfo().

405 {
406  baseScale_ = v;
407 }
double baseScale_
Scaling factor for baseline synaptic responses.

+ Here is the caller graph for this function:

void SeqSynHandler::setHistoryTime ( double  v)

Definition at line 392 of file SeqSynHandler.cpp.

References history_, historyTime_, numHistory(), RollingMatrix::resize(), updateKernel(), and vGetNumSynapses().

Referenced by initCinfo().

393 {
394  historyTime_ = v;
396  updateKernel();
397 }
void resize(unsigned int numRows, unsigned int numColumns)
double historyTime_
Time to store history. KernelDt defines num of rows.
int numHistory() const
RollingMatrix history_
Kernel for seq selectivity.
unsigned int vGetNumSynapses() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void SeqSynHandler::setKernelEquation ( string  eq)

Definition at line 358 of file SeqSynHandler.cpp.

References kernelEquation_, and updateKernel().

Referenced by initCinfo().

359 {
360  kernelEquation_ = eq;
361  updateKernel();
362 }
string kernelEquation_
Definition: SeqSynHandler.h:98

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void SeqSynHandler::setKernelWidth ( unsigned int  v)

Definition at line 369 of file SeqSynHandler.cpp.

References kernelWidth_, and updateKernel().

Referenced by initCinfo().

370 {
371  kernelWidth_ = v;
372  updateKernel();
373 }
unsigned int kernelWidth_
Definition: SeqSynHandler.h:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void SeqSynHandler::setPlasticityScale ( double  v)

Definition at line 434 of file SeqSynHandler.cpp.

References plasticityScale_.

Referenced by initCinfo().

435 {
436  plasticityScale_ = v;
437 }
double plasticityScale_

+ Here is the caller graph for this function:

void SeqSynHandler::setSeqDt ( double  v)

Definition at line 380 of file SeqSynHandler.cpp.

References history_, numHistory(), RollingMatrix::resize(), seqDt_, updateKernel(), and vGetNumSynapses().

Referenced by initCinfo().

381 {
382  seqDt_ = v;
383  updateKernel();
385 }
void resize(unsigned int numRows, unsigned int numColumns)
int numHistory() const
RollingMatrix history_
Kernel for seq selectivity.
unsigned int vGetNumSynapses() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void SeqSynHandler::setSequencePower ( double  v)

Definition at line 444 of file SeqSynHandler.cpp.

References sequencePower_.

Referenced by initCinfo().

445 {
446  sequencePower_ = v;
447 }
double sequencePower_

+ Here is the caller graph for this function:

void SeqSynHandler::setSequenceScale ( double  v)

Definition at line 414 of file SeqSynHandler.cpp.

References sequenceScale_.

Referenced by initCinfo().

415 {
416  sequenceScale_ = v;
417 }
double sequenceScale_
Scaling factor for sequence recognition responses.

+ Here is the caller graph for this function:

void SeqSynHandler::setSynapseOrder ( vector< unsigned int >  v)

Definition at line 477 of file SeqSynHandler.cpp.

References fixSynapseOrder(), synapseOrder_, and synapseOrderOption_.

Referenced by initCinfo().

478 {
479  synapseOrder_ = v;
480  fixSynapseOrder();
481  synapseOrderOption_ = -2; // Set the flag to say it is User defined.
482 }
void fixSynapseOrder()
vector< unsigned int > synapseOrder_
Rows = time; cols = synInputs.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void SeqSynHandler::setSynapseOrderOption ( int  v)

Definition at line 489 of file SeqSynHandler.cpp.

References refillSynapseOrder(), synapseOrder_, and synapseOrderOption_.

Referenced by initCinfo().

490 {
493 }
void refillSynapseOrder(unsigned int newSize)
vector< unsigned int > synapseOrder_
Rows = time; cols = synInputs.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void SeqSynHandler::updateKernel ( )
private

Definition at line 332 of file SeqSynHandler.cpp.

References historyTime_, kernel_, kernelEquation_, kernelWidth_, M_E, M_PI, numHistory(), and seqDt_.

Referenced by setHistoryTime(), setKernelEquation(), setKernelWidth(), setSeqDt(), and vSetNumSynapses().

333 {
334  if ( kernelEquation_ == "" || seqDt_ < 1e-9 || historyTime_ < 1e-9 )
335  return;
336  double x = 0;
337  double t = 0;
338  mu::Parser p;
339  p.DefineVar("x", &x);
340  p.DefineVar("t", &t);
341  p.DefineConst(_T("pi"), (mu::value_type)M_PI);
342  p.DefineConst(_T("e"), (mu::value_type)M_E);
343  p.SetExpr( kernelEquation_ );
344  kernel_.clear();
345  int nh = numHistory();
346  kernel_.resize( nh );
347  for ( int i = 0; i < nh; ++i ) {
348  kernel_[i].resize( kernelWidth_ );
349  t = i * seqDt_;
350  for ( unsigned int j = 0; j < kernelWidth_; ++j ) {
351  x = j;
352  kernel_[i][j] = p.Eval();
353  }
354  }
355 }
double value_type
#define M_PI
Definition: numutil.h:34
double historyTime_
Time to store history. KernelDt defines num of rows.
int numHistory() const
vector< vector< double > > kernel_
string kernelEquation_
Definition: SeqSynHandler.h:98
unsigned int kernelWidth_
Definition: SeqSynHandler.h:99
#define M_E
Definition: numutil.h:38

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

unsigned int SeqSynHandler::vGetNumSynapses ( ) const
virtual

Implements SynHandlerBase.

Definition at line 257 of file SeqSynHandler.cpp.

References synapses_.

Referenced by getHistory(), setHistoryTime(), setSeqDt(), and vProcess().

258 {
259  return synapses_.size();
260 }
vector< Synapse > synapses_

+ Here is the caller graph for this function:

Synapse * SeqSynHandler::vGetSynapse ( unsigned int  i)
virtual

Implements SynHandlerBase.

Definition at line 262 of file SeqSynHandler.cpp.

References dummy, and synapses_.

263 {
264  static Synapse dummy;
265  if ( i < synapses_.size() )
266  return &synapses_[i];
267  cout << "Warning: SeqSynHandler::getSynapse: index: " << i <<
268  " is out of range: " << synapses_.size() << endl;
269  return &dummy;
270 }
vector< Synapse > synapses_
static DestFinfo dummy("dummy","This Finfo is a dummy. If you are reading this you have used an invalid index", 0)
void SeqSynHandler::vProcess ( const Eref e,
ProcPtr  p 
)
virtual

Implements SynHandlerBase.

Definition at line 538 of file SeqSynHandler.cpp.

References SynHandlerBase::activationOut(), baseScale_, RollingMatrix::correl(), ProcInfo::currTime, ProcInfo::dt, events_, history_, kernel_, latestSpikes_, numHistory(), plasticityScale_, RollingMatrix::rollToNextRow(), seqActivation_, seqDt_, sequencePower_, sequenceScale_, RollingMatrix::sumIntoRow(), vGetNumSynapses(), and weightScaleVec_.

539 {
540  // Here we look at the correlations and do something with them.
541  int nh = numHistory();
542 
543  // Check if we need to do correlations at all.
544  if ( nh > 0 && kernel_.size() > 0 ) {
545  // Check if timestep rolls over a seqDt boundary
546  if ( static_cast< int >( p->currTime / seqDt_ ) >
547  static_cast< int >( (p->currTime - p->dt) / seqDt_ ) ) {
550  latestSpikes_.assign( vGetNumSynapses(), 0.0 );
551 
552  // Build up the sum of correlations over time
553  vector< double > correlVec( vGetNumSynapses(), 0.0 );
554  for ( int i = 0; i < nh; ++i )
555  history_.correl( correlVec, kernel_[i], i );
556  if ( sequenceScale_ > 0.0 ) { // Sum all responses, send to chan
557  seqActivation_ = 0.0;
558  for ( vector< double >::iterator y = correlVec.begin();
559  y != correlVec.end(); ++y )
560  seqActivation_ += pow( *y, sequencePower_ );
561 
562  // We'll use the seqActivation_ to send a special msg.
564  }
565  if ( plasticityScale_ > 0.0 ) { // Short term changes in individual wts
566  weightScaleVec_ = correlVec;
567  for ( vector< double >::iterator y=weightScaleVec_.begin();
568  y != weightScaleVec_.end(); ++y )
569  *y *= plasticityScale_;
570  }
571  }
572  }
573 
574  // Here we go through the regular synapse activation calculations.
575  // We can't leave it to the base class vProcess, because we need
576  // to scale the weights individually in some cases.
577  double activation = seqActivation_; // Start with seq activation
578  if ( plasticityScale_ > 0.0 ) {
579  while( !events_.empty() && events_.top().time <= p->currTime ) {
580  activation += events_.top().weight * baseScale_ *
581  weightScaleVec_[ events_.top().synIndex ] / p->dt;
582  events_.pop();
583  }
584  } else {
585  while( !events_.empty() && events_.top().time <= p->currTime ) {
586  activation += baseScale_ * events_.top().weight / p->dt;
587  events_.pop();
588  }
589  }
590  if ( activation != 0.0 )
591  SynHandlerBase::activationOut()->send( e, activation );
592 }
double seqActivation_
void sumIntoRow(const vector< double > &input, unsigned int row)
double currTime
Definition: ProcInfo.h:19
priority_queue< PreSynEvent, vector< PreSynEvent >, CompareSynEvent > events_
double plasticityScale_
vector< double > weightScaleVec_
double baseScale_
Scaling factor for baseline synaptic responses.
double dt
Definition: ProcInfo.h:18
int numHistory() const
void correl(vector< double > &ret, const vector< double > &input, unsigned int row) const
vector< vector< double > > kernel_
RollingMatrix history_
Kernel for seq selectivity.
unsigned int vGetNumSynapses() const
static SrcFinfo1< double > * activationOut()
vector< double > latestSpikes_
double sequencePower_
double sequenceScale_
Scaling factor for sequence recognition responses.

+ Here is the call graph for this function:

void SeqSynHandler::vReinit ( const Eref e,
ProcPtr  p 
)
virtual

Implements SynHandlerBase.

Definition at line 594 of file SeqSynHandler.cpp.

References events_.

595 {
596  // For no apparent reason, priority queues don't have a clear operation.
597  while( !events_.empty() )
598  events_.pop();
599 }
priority_queue< PreSynEvent, vector< PreSynEvent >, CompareSynEvent > events_
void SeqSynHandler::vSetNumSynapses ( unsigned int  num)
virtual

Implements SynHandlerBase.

Definition at line 243 of file SeqSynHandler.cpp.

References history_, latestSpikes_, numHistory(), refillSynapseOrder(), RollingMatrix::resize(), synapses_, updateKernel(), and weightScaleVec_.

244 {
245  unsigned int prevSize = synapses_.size();
246  synapses_.resize( v );
247  for ( unsigned int i = prevSize; i < v; ++i )
248  synapses_[i].setHandler( this );
249 
250  history_.resize( numHistory(), v );
251  latestSpikes_.resize( v, 0.0 );
252  weightScaleVec_.resize( v, 0.0 );
253  refillSynapseOrder( v );
254  updateKernel();
255 }
void resize(unsigned int numRows, unsigned int numColumns)
vector< Synapse > synapses_
void refillSynapseOrder(unsigned int newSize)
vector< double > weightScaleVec_
int numHistory() const
RollingMatrix history_
Kernel for seq selectivity.
vector< double > latestSpikes_

+ Here is the call graph for this function:

Member Data Documentation

double SeqSynHandler::baseScale_
private

Scaling factor for baseline synaptic responses.

Definition at line 105 of file SeqSynHandler.h.

Referenced by getBaseScale(), setBaseScale(), and vProcess().

priority_queue< PreSynEvent, vector< PreSynEvent >, CompareSynEvent > SeqSynHandler::events_
private

Definition at line 156 of file SeqSynHandler.h.

Referenced by addSpike(), getTopSpike(), operator=(), vProcess(), and vReinit().

RollingMatrix SeqSynHandler::history_
private

Kernel for seq selectivity.

Definition at line 138 of file SeqSynHandler.h.

Referenced by getHistory(), SeqSynHandler(), setHistoryTime(), setSeqDt(), vProcess(), and vSetNumSynapses().

double SeqSynHandler::historyTime_
private

Time to store history. KernelDt defines num of rows.

Definition at line 102 of file SeqSynHandler.h.

Referenced by getHistoryTime(), numHistory(), setHistoryTime(), and updateKernel().

vector< vector< double > > SeqSynHandler::kernel_
private

Definition at line 137 of file SeqSynHandler.h.

Referenced by getKernel(), updateKernel(), and vProcess().

string SeqSynHandler::kernelEquation_
private

Definition at line 98 of file SeqSynHandler.h.

Referenced by getKernelEquation(), setKernelEquation(), and updateKernel().

unsigned int SeqSynHandler::kernelWidth_
private

Definition at line 99 of file SeqSynHandler.h.

Referenced by getKernelWidth(), setKernelWidth(), and updateKernel().

vector< double > SeqSynHandler::latestSpikes_
private

Definition at line 134 of file SeqSynHandler.h.

Referenced by addSpike(), vProcess(), and vSetNumSynapses().

double SeqSynHandler::plasticityScale_
private

Scaling factor for short-term plastic weight changes in each synapse arising from sequential input.

Definition at line 113 of file SeqSynHandler.h.

Referenced by getPlasticityScale(), setPlasticityScale(), and vProcess().

double SeqSynHandler::seqActivation_
private

Definition at line 126 of file SeqSynHandler.h.

Referenced by getSeqActivation(), and vProcess().

double SeqSynHandler::seqDt_
private

Definition at line 103 of file SeqSynHandler.h.

Referenced by getSeqDt(), numHistory(), setSeqDt(), updateKernel(), and vProcess().

double SeqSynHandler::sequencePower_
private

Exponent to use for the outcome of the sequential calculations. This is needed because linear summation of terms in the kernel means that a brief stong sequence match is no better than lots of successive low matches. In other words, 12345 is no better than 11111.

Definition at line 122 of file SeqSynHandler.h.

Referenced by getSequencePower(), setSequencePower(), and vProcess().

double SeqSynHandler::sequenceScale_
private

Scaling factor for sequence recognition responses.

Definition at line 107 of file SeqSynHandler.h.

Referenced by getSequenceScale(), setSequenceScale(), and vProcess().

vector< unsigned int > SeqSynHandler::synapseOrder_
private

Rows = time; cols = synInputs.

Remaps synapse order to avoid correlations based on presynaptic object Id order, or on connection building order. This undesirable ordering occurs even when random synaptic projections are used. User can alter as preferred. This is simply a look up table so that the incoming synapse index is remapped: index_on_Handler = synapseOrder_[original_syn_index] This must only have numbers from zero to numSynapses, and should normally have all the numbers.

Definition at line 149 of file SeqSynHandler.h.

Referenced by addSpike(), fixSynapseOrder(), getSynapseOrder(), refillSynapseOrder(), setSynapseOrder(), and setSynapseOrderOption().

int SeqSynHandler::synapseOrderOption_
private

Options: -2: User. -1: ordered. 0: random by system seed.

0: Random by seed specified by this number

Definition at line 153 of file SeqSynHandler.h.

Referenced by getSynapseOrderOption(), refillSynapseOrder(), setSynapseOrder(), and setSynapseOrderOption().

vector< Synapse > SeqSynHandler::synapses_
private
vector< double > SeqSynHandler::weightScaleVec_
private

Definition at line 129 of file SeqSynHandler.h.

Referenced by getWeightScaleVec(), vProcess(), and vSetNumSynapses().


The documentation for this class was generated from the following files: