-
Notifications
You must be signed in to change notification settings - Fork 0
/
TimmeParameterInferenceEngineNoLoops.h
166 lines (166 loc) · 4.67 KB
/
TimmeParameterInferenceEngineNoLoops.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
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
///*
// * TimmeParameterInferenceEngineNoLoops.h
// *
// * Created on: 2 May 2014
// * Author: rusty
// */
//
//#ifndef TIMMEPARAMETERINFERENCEENGINENOLOOPS_H_
//#define TIMMEPARAMETERINFERENCEENGINENOLOOPS_H_
//
////CURRENTLY ONLY WORKS WITH READING FROM UNITS..
//
//#include "IInferenceEngine.h"
//#include "ReaderFileToArray.h"
//// from simulationResources
//#include "IDynamicalUnit.h"
//#include "UnitHistory.h"
//
//class TimmeParameterInferenceEngineNoLoops : public IInferenceEngine
//{
//
//private:
// int ID;
//
// int unitCount;
// int unitDimension;
// int nTimesteps;
// int parametersPerUnit;
//
// double **fullTimeseries;
//
// double **jHat; // following Timme notation: jHat is the inferred adjacency matrix.
// mat X;
// mat G;
//
// const char* timeseriesFileName;
// // for reading directly from units:
// double timestepSize;
// IDynamicalUnit** units;
//
// void readTimseriesToArray() {
// int columnCount = unitCount * unitDimension + 1;
//
// ReaderFileToArray reader(nTimesteps, columnCount, timeseriesFileName);
//
// reader.readFile();
// cout << "Timseries File Read." << endl;
// double** tempStore = reader.getArray();
//
// for (int i = 0; i < nTimesteps; i++) {
// fullTimeseries[i] = new double[columnCount];
// for (int j = 0; j < columnCount; j++) {
// fullTimeseries[i][j] = tempStore[i][j];
// //cout << i << endl;
// }
// }
// //reader.~ReaderFileToArray(); // why does it not like this??
// cout << "Timeseries stored in local array" << endl;
// }
//
// void readUnitHistoriesToArray(){
// int columnCount = unitCount * unitDimension + 1;
//
// for (int i = 0; i < nTimesteps; i++) {
// //fullTimeseries[i] = new double[columnCount];
// fullTimeseries[i][0] = timestepSize*i;
// for (int j = 1; j < columnCount; j++) {
// fullTimeseries[i][j] = units[j-1]->getHistory()->getHistoryTi(i);
// //cout << i << endl;
// }
// }
//
//// cout << "Timeseries stored in local array" << endl;
//
// }
//
// bool saveResult();
//
//public:
// ~TimmeParameterInferenceEngineNoLoops(){
// for (int i = 0; i < nTimesteps; i++) {
// delete[] fullTimeseries[i];
// }
// delete[] fullTimeseries;
// for (int i=0; i < this->unitCount; i++){
// delete[] jHat[i];
// }
// delete[] jHat;
// }
//
// // this constructor reads time series from units that are still active (instead of from file):
// TimmeParameterInferenceEngineNoLoops(int ID, int unitCount, int nTimesteps, int unitDimension, int parametersPerUnit, IDynamicalUnit** units , double timestepSize);
//
// //TimmeParameterInferenceEngine(int unitCount, int nTimesteps, int unitDimension, int parametersPerUnit, const char* timeseriesFileName, double *parameters, IDynamicalUnit** dummyUnits);
//
// bool runInference(int sampleStepLength);
//
// bool fillJhat(int sampleStepLength);
//
// void printJhat();
//
// // updated from:
// //double qualityOfReconstruction(double accuracy, INetwork *net);
// // to:
// bool qualityOfReconstruction(double accuracy, double& quality, vector<double > IMelements);
//
// bool percentageQualityOfReconstruction(double accuracy, double& quality, vector<double > IMelements);
//
// bool originalQualityOfReconstruction(double accuracy, double& quality, vector<double > IMelements);
//
// bool unweightedQualityOfReconstruction(double threshold, double& quality, vector< vector<double > > adjacency);
//
// double getSampleRate(int sampleStepLength);
//
//private:
// // helper functions, not accessible by base class pointer:
// void runInferenceNoLoops(int sampleStepLength);
//
// bool timmeJhatI(int unitID, int sampleStepLength, mat &JHatI);
//
// double **getJhat();
//
// double heaviside(double x);
//
// bool movingWindow(int windowLength, int unitID, double **result){
// if (windowLength<(this->unitCount+1)){return 1;}
//
// int M = (nTimesteps) - windowLength;
// mat X = zeros<mat>(1,windowLength);
// mat G = zeros<mat>(unitCount+1,windowLength);
// double xtau[unitCount];
//
// double xdotTau;
//
// mat jHat;
//
// // iterate over all windows:
// for (int i=0;i<M;i++){
// cout << "window " << i << endl;
// // iterate of entries in window:
// for (int w=0; w<windowLength; w++){
// xdotTau = (fullTimeseries[i+1+w][1+unitID] - fullTimeseries[i+w][1+unitID])/((fullTimeseries[i+1+w][0] - fullTimeseries[i+w][0]));
// X(0,w) = xdotTau;
//
// for(int j=0;j<unitCount;j++){
// xtau[j] = (fullTimeseries[i+1+w][1+j] + fullTimeseries[i+w][1+j])/2;
//
// G(j,w) = xtau[j] * xtau[unitID];
// }
// G(unitCount,w) = xtau[unitID];
// }
// jHat = X*trans(G)*inv(G*trans(G));
//
// for (int j=0;j<unitCount+1;j++){
// result[i][j] = jHat[j];
// }
// }
//
//
// return true;
// }
//};
//
//
//
//#endif /* TIMMEPARAMETERINFERENCEENGINENOLOOPS_H_ */