diff options
Diffstat (limited to 'code/core/global.cpp')
-rw-r--r-- | code/core/global.cpp | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/code/core/global.cpp b/code/core/global.cpp new file mode 100644 index 0000000..83ec666 --- /dev/null +++ b/code/core/global.cpp @@ -0,0 +1,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"); + } +} |