-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCTimeNone.cpp
99 lines (83 loc) · 1.69 KB
/
CTimeNone.cpp
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
#include "CTimeNone.h"
using namespace std;
CTimeNone::CTimeNone(int idd)
{
id=idd;
measurements = 0;
numElements = 0;
type = TT_NONE;
}
void CTimeNone::init(int iMaxPeriod,int elements,int numClasses)
{
maxPeriod = iMaxPeriod;
numElements = 1;
estimation = 1.0/numClasses;
}
CTimeNone::~CTimeNone()
{
}
// adds new state observations at given times
int CTimeNone::add(uint32_t time,float state)
{
measurements++;
return 0;
}
void CTimeNone::update(int modelOrder,unsigned int* times,float* signal,int length)
{
}
/*text representation of the fremen model*/
void CTimeNone::print(bool verbose)
{
std::cout << "Model " << id << " Size: " << measurements << " ";
if (verbose) std::cout << "Value: "<< estimation << std::endl;
}
float CTimeNone::estimate(uint32_t time)
{
return 0;//estimation;
}
float CTimeNone::predict(uint32_t time)
{
return 0;//estimation;
return estimation;
}
int CTimeNone::save(const char* name,bool lossy)
{
FILE* file = fopen(name,"w");
save(file);
fclose(file);
return 0;
}
int CTimeNone::load(const char* name)
{
FILE* file = fopen(name,"r");
load(file);
fclose(file);
return 0;
}
int CTimeNone::save(FILE* file,bool lossy)
{
return -1;
}
int CTimeNone::load(FILE* file)
{
return -1;
}
int CTimeNone::exportToArray(double* array,int maxLen)
{
int pos = 0;
array[pos++] = type;
array[pos++] = estimation;
array[pos++] = id;
array[pos++] = measurements;
return pos;
}
int CTimeNone::importFromArray(double* array,int len)
{
int pos = 0;
type = (ETemporalType)array[pos++];
if (type != TT_NONE) std::cerr << "Error loading the model, type mismatch." << std::endl;
estimation = array[pos++];
id = array[pos++];
measurements = array[pos++];
return pos;
}