summaryrefslogtreecommitdiff
path: root/code/core/global.cpp
blob: 83ec6666c0e2d96f392e53a582b5fe7237f9cc02 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#include <math.h>

#include "interface.h"

#include "global.h"

Global::Global() :
    // neuron related
  voltage_tau(0.05),  // [s]
  voltage_base(-0.065), // [V] rest potential 
  threshold(-0.05),    // [V] above which a spike is emitted

  Wmax(0.004), // [V] 
  Wmin(0.0),   // [V]
  sumWeight(0.16),    // [V]
  absoluteRefractoryTime(0.001), // [V]

  // dopamin
  dopamin_level(0.0), // [?]
  dopamin_tau(0.005),   // [s]

  // STDP
  stdp_tau_plus(0.014),     // [s]
  stdp_tau_minus(0.034),    // [s]
  stdp_lambda_plus(0.066),  // [1]
  stdp_lambda_minus(0.066), // [1]
  stdp_et_tau(0.1),       // [s] eligibility trace tau

  // IP
  ip_sliding_avg_tau(), // TODO
  ip_lambda_R(),
  ip_lambda_C(),
  ip_dst_mom1(),
  ip_dst_mom2(),

  // external noise
  en_current(0.1) // [V]
  en_freq(1.0) // [Hz/Neuron]

  // trainer
  trainer_eval_delay(0.001), // [s]
  trainer_numSymbols(2),            // [1]
  trainer_refractoryTime(0.2),     // [s]
  trainer_rewardAmount(0.1),       // [?]
  trainer_rd_c1(0.05), // readout delay with
  trainer_rd_c2(0.0001), //   delay = c1 + t*c2 + r*c3 + t*r'*c4
  trainer_rd_c3(0.0), // where
  trainer_rd_c4(0.0001); //   r and r' are two distinct random numbers (equ. dist in [0,1))
{}

void Global::evolve(double td) {
  dopamin_level = decay_dopamin(dopamin_level, td);
}

double decay_dopamin(double level, double td) {
  return level * exp( - td / dopamin_tau );
}

template<class Action>
bool Global::reflect<Action>(Action &a) {
return
  // neuron related
  reflect(voltage_tau, "voltage_tau")
  && reflect(voltage_base, "voltage_base")
  && reflect(threshold, "threshold")

  && reflect(Wmin, "Wmin")
  && reflect(Wmax, "Wmax")
  && reflect(sumWeight, "sumWeight")
  && reflect(absoluteRefractoryTime, "absoluteRefractoryTime")

  // dopamin
  && reflect(dopamin_level, "dopamin_level")
  && reflect(dopamin_tau, "dopamin_tau")

  // STDP
  && reflect(stdp_tau_plus, "stdp_tau_plus")
  && reflect(stdp_tau_minus, "stdp_tau_minus")
  && reflect(stdp_lambda_plus, "stdp_lambda_plus")
  && reflect(stdp_lambda_minus, "stdp_lambda_minus")
  && reflect(stdp_et_tau, "stdp_et_tau")

  // IP
  && reflect(ip_sliding_avg_tau, "ip_sliding_avg_tau")
  && reflect(ip_lambda_R, "ip_lambda_R")
  && reflect(ip_lambda_C, "ip_lambda_C")
  && reflect(ip_dst_mom1, "ip_dst_mom1")
  && reflect(ip_dst_mom2, "ip_dst_mom2")

  // external noise
  && reflect(en_current, "en_current")
  && reflect(en_freq, "en_freq")

  // trainer
  && reflect(trainer_eval_delay, "trainer_eval_delay")
  && reflect(trainer_numSymbols, "trainer_numSymbols")
  && reflect(trainer_refractoryTime, "trainer_refractoryTime")
  && reflect(trainer_rewardAmount, "trainer_rewardAmount")
  && reflect(trainer_rd_c1, "trainer_rd_c1")
  && reflect(trainer_rd_c1, "trainer_rd_c2")
  && reflect(trainer_rd_c1, "trainer_rd_c3")
  && reflect(trainer_rd_c1, "trainer_rd_c4");
}

static id_type Global::numElements() {
  return 1;
}

static Global * singleton(int num) {
  if (num==0) {
    return &global;
  }else{
    DIE("requested global object with id != 0");
  }
}
contact: Jan Huwald // Impressum