-
Notifications
You must be signed in to change notification settings - Fork 2
/
Controller.h
55 lines (44 loc) · 1.27 KB
/
Controller.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
#ifndef __Controller_H__
#define __Controller_H__
#include "ThreadableBase.h"
#include <fstream>
#include <iomanip>
using namespace std;
typedef struct { double data[2]; } Double2;
struct SNode { Int8 center; double lWeight; double rWeight; double activity; };
#define INPUT_COUNT 8
#define NODE_COUNT 100
#define TRAINING_CYCLES 100
#define NODE_ACTIVITY_DECAY_FACTOR 0.9
#define TOTAL_ACTIVATION_LIMIT 0.5
#define MAX_DIMENSION_DISTANCE 25
class CController : public CThreadableBase
{
public:
CController(CKheperaUtility* pUtil);
void LoadNodesFromFile(std::string path);
void SaveNodesToFile(std::string path);
void ListNodes();
std::fstream file;
std::string line;
Int8 temp_read_int;
Double2 temp_read_double;
protected:
virtual void DoCycle();
private:
SIOSet Evaluate(Int8 sensors);
void Adapt(SIOSet ideal);
// rbf network functions
double NodeMaxDimensionalDistance(SNode nodeA, SNode nodeB);
double RbfBase(Int8 sensors, Int8 nodeCenter);
void CreateTrainingData();
void Train();
void AddNode(Int8, double left, double right);
void Forget();
private:
std::vector<SNode> m_NetworkNodes;
double m_Sigma;
double m_LearnWeight;
std::vector<SIOSet> m_TrainingData;
};
#endif