-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathelements.h
174 lines (161 loc) · 3.82 KB
/
elements.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
167
168
169
170
171
172
173
174
#ifndef elements_H
#define elements_H
#include <vector>
#include "parameter.h"
#include "frandom.h"
using namespace std;
// to describe the Edge for routing
#ifdef _edge_with_bandwidth
struct Edge
{
// int Source; // First vertex in edge is implicit
int Dest; // Second vertex in edge
float Cost;
float Bandwidth;
int Addr;
Edge(const Edge & Rhs){
Dest=Rhs.Dest;Addr=Rhs.Addr;Cost=Rhs.Cost;Bandwidth=Rhs.Bandwidth;
}
Edge(){}
Edge(const int &dest,const float& cost,const float &bandw,const int &addr):
Dest(dest),Cost(cost),Bandwidth(bandw),Addr(addr){}
void Assign( const int &dest, const float& cost,const float &bandw,const int &addr){
Dest=dest;Cost=cost;Bandwidth=bandw;Addr=addr;
}
};
#else
struct Edge
{
// int Source; // First vertex in edge is implicit
int Dest; // Second vertex in edge
float Cost;
int Addr;
Edge(const Edge & Rhs){
Dest=Rhs.Dest;Addr=Rhs.Addr;Cost=Rhs.Cost;
}
Edge(){}
Edge(const int &dest,const float& cost,const int &addr):
Dest(dest),Cost(cost),Addr(addr){}
void Assign( const int &dest, const float& cost,const int &addr){
Dest=dest;Cost=cost;Addr=addr;
}
};
#endif
struct Node
{
//int Name; // Real name
bool Type; // 0: server, 1:switch
int Slot; // number of VM slots
//routing variables:
int Degree;
float Dist; // Cost (after running algorithm)
int Prev; // Previous vertex on shortest link
bool Visited; // Extra variable for use in algorithm
Edge* Adj; // Adjacent vertices
Node(){}
Node(const int &node_name);
};
/* tree node */
struct tNode
{
//int Name; // Real name
bool Type; // 0: server, 1:switch
int Slot; // number of VM slots
int Degree;
int Parent;
Edge* Adj; // Adjacent vertices
tNode(){}
tNode(const int &node_name);
};
// a pair of source and destination
struct Pair
{
int s;
int d;
Pair(int s1,int d1):s(s1),d(d1){}
Pair(){}
};
// a comparable object used in heap
class Comparable
{
public:
int index; // W
float value; // D(W)
Comparable(){index=0;value=0;}
Comparable(const int &idx, const float& va) : index( idx ), value( va ) { }
bool operator<( const Comparable & Rhs ) const
{ return value< Rhs.value; }
const Comparable& operator=( const Comparable & Rhs )
{
index=Rhs.index;
value=Rhs.value;
return *this;
}
};
// to define the Virutal data center
struct Cluster
{
int N;
vector<float>B;
float Arrivaltime;
float Holdtime;
Cluster(){}
Cluster(const Cluster& Rhs);//deep copy
void random();
void random(float load);
void random(int nVM,float minBw,float maxBw);
void random(int nVM1,int nVM2,float minBw,float maxBw);
};
//created bt luchukun
//to define the ouversubscript
struct OversubscriptionCluster
{
int numberofGroup;
int numberofVms;
float oversubscriptionFactor;
float bandwithLowLink;
float arrivalTime;
float holdTime;
OversubscriptionCluster(){}
OversubscriptionCluster(const OversubscriptionCluster& rhs);//deep copy
void random();
//void randow(float load);
void random(int nGroup,float o,float minN,float maxN,float minBw,float maxBw);
};
// to store the embedding solution
class Solution
{
public:
float Departtime;
int Slot[nServer];
float Bandwidth[Ne];
Solution();
void Clear();
Solution(const Solution &Rhs);
bool operator<( const Solution & Rhs ) const
{ return Departtime< Rhs.Departtime; }
const Solution& operator=( const Solution & Rhs );
};
struct Performance
{
float sucess_rate;
float max_utilization;
float RC;
Performance(){}
void clear();
};
struct allocateRange
{
//int ARs[maxN][maxSlot][maxSlot][nServer];
//int ARx[maxN][maxN][maxN][Nv-nServer];
bool ***p;
//int **split;
int n;
int a;
allocateRange(){}
void resize(int nVM,int nSlot);
bool& operator () (int x, int y, int i);
void release();
~allocateRange();
};
#endif