forked from JakobHeller/NatureInspiredComputing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Node.h
59 lines (46 loc) · 1.09 KB
/
Node.h
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
#ifndef __Node_H__
#define __Node_H__
#include "SensorData.h"
#include "Speed.h"
#include <vector>
struct SIOSet
{
CSensorData sensors;
CSpeed speed;
};
class CNode
{
public:
static double Sigma;
static double LearningWeight;
public:
CNode();
CNode(CSensorData c, CSpeed w);
double Activate(CSensorData input, CSpeed& output);
double Calculate(CSensorData input, CSpeed& output);
void Adapt(CSensorData input, CSpeed difference);
void Adapt(CSensorData input, CSpeed old, CSpeed better, double totalActivity);
CSensorData Center();
CSpeed Weight();
void Dump();
static bool CompareActivity(CNode a, CNode b);
private:
double BaseFunction(CSensorData sensors);
void Decay();
void AddActivation(double act = 1);
private:
static const double DecayRate;
CSensorData m_Center;
CSpeed m_Weight;
double m_Activity;
};
class CNeuralNetwork : public std::vector<CNode>
{
public:
void AddNode(CSensorData, CSpeed speed);
void Forget(int maxCount);
int Count();
SIOSet Evaluate(CSensorData sensors);
void Adapt(SIOSet ideal);
};
#endif