-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEdgeComputingModel.py
More file actions
51 lines (37 loc) · 1.4 KB
/
Copy pathEdgeComputingModel.py
File metadata and controls
51 lines (37 loc) · 1.4 KB
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
'''
边缘服务器的class 和 边缘计算业务的class
'''
import random
'''
边缘计算服务器
'''
class Server:
def __init__(self, name):
self.name = name
self.load = random.uniform(200, 1300)
self.cyclePerSec = 500
def randomLoad(self):
self.load = random.uniform(200, 1300)
def display(self):
print('[node:' + str(self.name) + ', load:' + str(self.load) + ', cyclePerSec:' + str(self.cyclePerSec) + ']')
def computingServerState(self):
return float(self.load)/float(self.cyclePerSec)
'''
边缘计算任务
'''
class ComputingTask:
def __init__(self, accessNode):
self.cycles = 50 #random.randint(10, 80) # 需要的计算量(cycles)
self.bitNum = 40 #random.randint(80, 180) # 传输数据量(bit)
self.maxTime = 2.5 #random.uniform(1.5, 2.5) # 可接受的最大时延(s)
self.accessNode = int(accessNode) # 接入节点
self.delayTime = 0 # 保存存储时间
def taskDataNormalization(self):
return [float(self.cycles)/55.0, float(self.bitNum)/60.0, self.maxTime/6.0]
def display(self):
print("computingTask:"
+ '[cycles:' + str(self.cycles)
+ ', bitNum:' + str(self.bitNum)
+ ', maxTime:' + str(self.maxTime)
+ ', accessNode:' + str(self.accessNode)
+ ', delayTime:' + str(self.delayTime) + ']')