blob: 46b00838275c639e4a573a75770d4d901534de59 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#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);
// main routine
void run();
// state vars
long currentEpoch;
map<int, int> *neuronFreq[2]; // stores if a surveilled neuron fired during the current or last epoch
double dopamin_level;
// synchronisation vars
typedef boost::tuple<double, int, double> SpikeEvent; // <what time, wich neuron, current>
queue<SpikeEvent> incomingSpikes;
// TODO: outgoingSpikes;
pthread_mutex_t incomingSpikeLock;
// 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
double epochDuration;
double entireDuration;
double freq; // of outgoing noise per neuron
double voltage; // per outgoing (random) spike
long neurons;
double da_single_reward;
};
// 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
|