-
Notifications
You must be signed in to change notification settings - Fork 8
/
Helper.cpp
120 lines (94 loc) · 2.14 KB
/
Helper.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#include "Helper.h"
Helper::Helper() {
}
Helper::~Helper() {
}
bool Helper::init(int Al, int Kmin, int Gmax, int P, int F, int W) {
this->Al = Al;
this->P = P;
if (P % Al != 0) {
return false;
}
this->Kmin = Kmin;
this->Kmax = 8192;
this->Gmax = Gmax;
this->F = F;
this->W = W;
this->G = min((min((int)ceil((double)P * Kmin /F), (int)P/Al)), Gmax);
this->T = (int)floor((double)P/(Al*G)) * Al;
this->Kt = (int)ceil((double)F/T);
this->Z = (int)ceil((double)Kt/Kmax);
this->N = min((int)ceil(ceil((double)Kt/Z)*T/W),(int)T/Al);
if (ceil(ceil((double)F/T)/Z) > Kmax) {
return false;
}
this->KtZ = partition(Kt, Z);
this->TAlN = partition(T/Al, N);
return true;
};
const PartitionS Helper::partition(int I, int J) {
PartitionS result;
result.IL = (int)ceil((double)I/J);
result.IS = (int)floor((double)I/J);
result.JL = I - result.IS * J;
result.JS = J - result.JL;
return result;
}
const int Helper::getKmax() {
return Kmax;
}
const int Helper::getP() {
return P;
}
const int Helper::getF() {
return F;
}
const int Helper::getW() {
return W;
}
const int Helper::getAl() {
return Al;
}
const int Helper::getKmin() {
return Kmin;
}
const int Helper::getGmax() {
return Gmax;
}
const int Helper::getG() {
return G;
}
const int Helper::getT() {
return T;
}
const int Helper::getKt() {
return Kt;
}
const int Helper::getZ() {
return Z;
}
const int Helper::getN() {
return N;
}
const PartitionS Helper::getKtZ() {
return KtZ;
}
const PartitionS Helper::getTAlN() {
return TAlN;
}
void Helper::toString() {
std::cout<<"Kmax="<<Kmax<<std::endl
<<"P="<<P<<std::endl
<<"F="<<F<<std::endl
<<"W="<<W<<std::endl
<<"Al="<<Al<<std::endl
<<"Kmin="<<Kmin<<std::endl
<<"Gmax="<<Gmax<<std::endl
<<"G="<<G<<std::endl
<<"T="<<T<<std::endl
<<"Kt="<<Kt<<std::endl
<<"Z="<<Z<<std::endl
<<"N="<<N<<std::endl;
std::cout<<"KL,KS,ZL,ZS"<<std::endl<<KtZ.IL<<","<<KtZ.IS<<","<<KtZ.JL<<","<<KtZ.JS<<std::endl;
std::cout<<"TL,TS,NL,NS"<<std::endl<<TAlN.IL<<","<<TAlN.IS<<","<<TAlN.JL<<","<<TAlN.JS<<std::endl;
}