-
Notifications
You must be signed in to change notification settings - Fork 17
/
main.cpp
61 lines (50 loc) · 1.55 KB
/
main.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
//
// Created by yue on 18-3-16.
//
#include <vector>
#include "cstdio"
#include "iostream"
#include "ARIMAModel.h"
int main(){
freopen("data.txt","r",stdin);
double gets;
std::vector<double> dataArray;
while(std::cin>>gets){
dataArray.push_back(gets);
std::cout<<gets<<std::endl;
}
ARIMAModel* arima = new ARIMAModel(dataArray);
int period = 7;
int modelCnt=5;
int cnt=0;
std::vector<std::vector<int>> list;
std::vector<int> tmpPredict(modelCnt);
for (int k = 0; k < modelCnt; ++k) //控制通过多少组参数进行计算最终的结果
{
std::vector<int> bestModel = arima->getARIMAModel(period, list, (k == 0) ? false : true);
//std::cout<<bestModel.size()<<std::endl;
if (bestModel.size() == 0)
{
tmpPredict[k] = (int)dataArray[dataArray.size() - period];
cnt++;
break;
}
else
{
//std::cout<<bestModel[0]<<bestModel[1]<<std::endl;
int predictDiff = arima->predictValue(bestModel[0], bestModel[1], period);
//std::cout<<"fuck"<<std::endl;
tmpPredict[k] = arima->aftDeal(predictDiff, period);
cnt++;
}
std::cout<<bestModel[0]<<" "<<bestModel[1]<<std::endl;
list.push_back(bestModel);
}
double sumPredict = 0.0;
for (int k = 0; k < cnt; ++k)
{
sumPredict += ((double)tmpPredict[k])/(double)cnt;
}
int predict = (int)std::round(sumPredict);
std::cout<<"Predict value="<<predict<<std::endl;
}