diff options
author | Jan Huwald <jh@sotun.de> | 2012-05-07 19:53:27 (GMT) |
---|---|---|
committer | Jan Huwald <jh@sotun.de> | 2012-05-07 19:53:27 (GMT) |
commit | 00b209240138660db1ded3ef3870023964ce6e4e (patch) | |
tree | 8ffaec780b060bdc478929aa714b8af2ee760671 /code/trainer/mem1.h |
Diffstat (limited to 'code/trainer/mem1.h')
-rw-r--r-- | code/trainer/mem1.h | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/code/trainer/mem1.h b/code/trainer/mem1.h new file mode 100644 index 0000000..31fc2b0 --- /dev/null +++ b/code/trainer/mem1.h @@ -0,0 +1,72 @@ +#ifndef TRAINER_H +#define TRAINER_H + +#include <stdio.h> +#include <pthread.h> +#include <map> +#include <queue> +#include "boost/tuple/tuple.hpp" + + +using namespace std; + +class Trainer { + public: + FILE *fd_spike_in, + *fd_spike_out, + *fd_global_out, + *fd_global_in, + *fd_trace_out, + *fd_performance_out; + + // init stuff + Trainer(int argc, char** argv); + void initConfig(); + void initState(); + void initGroups(); + void initFiles(); + void initThreads(); + + // main routine + void run(); + + // state vars + long currentTrial; + vector<int> groupFreq; // spikes fired during epoch for each symbol (=group of neurons) + vector< set<int>* > ioNeurons; // a set of neurons for each symbol to which the symbol is written and from wich it is read later + //queue< int > symbolHist; // stores the symbols displayed; written by thread_write, read by main thread + int currentSymbol; + double dopamin_level; + int state; + MS_Global msg; + + // synchronisation vars + typedef boost::tuple<double, int, double> SpikeEvent; // <what time, wich neuron, current> + queue<SpikeEvent> incomingSpikes; + // TODO: outgoingSpikes; + pthread_mutex_t incomingSpikeLock, writerLock; + // TODO: , outgoingSpikeLock; (including a condition for the writer to wakeup upon if a previously empyt queue has been filled) + pthread_t thread_read, thread_write; + + // configuration + // network + long neurons; // total number of neurons + long neuronsPerSymbol; + double noiseFreq; // of poisson noise (per neuron) + double noiseVoltage; // per noise spike + double reward; // per succesful trial + + // learning task + double epochDuration; // a trial consists of several epochs + long numTrials; + int numSymbols; // number of different things to remember + //int readoutDelay; // number of epochs between symbol-write and symbol-read-epoch + int refractoryPeriods; // how many epochs to wait after a trial finished until we start with a new trial +}; + +// seperate thread to read all spikes neccessary because reading and +// writing to these descriptors could block and thus cause a deadlock +void *read_spikes(Trainer *t); +void *write_spikes(Trainer *t); + +#endif // TRAINER_H |