-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLDS (1).py
111 lines (93 loc) · 13.1 KB
/
LDS (1).py
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
# MIT License
# Copyright (c) 2023 Ericsson Research
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
##################################################################
# Author: Shilpa Budhkar
# Dated: 3 Feb 2023
# Module Name: Learning Data Set
# Copyright Ericsson 2023
##################################################################
import random
import csv
# initializing list
Throughput = [35102,16252,23826,9850,29430,198,2931,19843,34033,18306,36412,20787,25159,17292,28811,38560,18052,16254,31514,30454,8574,31102,29809,24393,26374,35737,27807,35303,20832,4069,37334,15100,23496,8568,6517,25327,19799,25792,8262,12299,31074,34733,13040,18025,23276,38268,7543,17981,6491,5210,6113,31207,39633,19833,36438,23094,19961,17650,28686,19215,27515,6360,34118,28061,923,9631,39471,12079,8115,1316,1278,2276,21332,37065,6929,17927,22785,36855,23657,18069,38410,22714,23199,24846,22132,12259,1375,23182,32057,5649,30676,4480,20784,14742,24922,14970,32708,12942,29265,17112,2574,4975,2234,3283,2957,640,2652,3009,591,3992,4754,1214,2979,1972,987,1340,631,2119,2249,4442,3873,2432,4193,4440,1097,2045,887,1934,2819,3467,1873,3808,2115,4125,4629,4289,1272,1988,1178,4542,1368,1265,1971,805,879,3870,2255,4327,222,149,4258,726,3635,4237,2463,4947,2789,4360,4477,738,2464,4234,3419,3764,1343,3024,4517,4649,1766,216,130,4895,152,4447,4850,522,665,4487,2269,4285,2046,4996,2585,300,2067,4253,2776,3271,3917,2909,1840,3350,2088,4815,906,995,2064,4349,135,1521]
Throughput_P = [4325,4147,1331,3836,251,2888,4658,4917,3552,466,1880,2500,533,437,3112,350,2776,1408,3684,2418,4774,352,3171,1910,4136,1908,4643,2112,1308,1618,2616,895,3084,4106,4288,4317,2985,3387,326,3262,1734,1573,3592,1559,4072,1940,4681,1541,551,163,3701,1612,859,4110,2515,3186,2049,1583,528,2232,1682,837,755,2275,982,1186,361,1770,4066,2924,2653,2573,2912,1678,2358,4413,1783,1986,3921,1873,960,4979,4059,3937,903,2564,2788,2524,1611,3408,1650,3668,384,3502,4620,3225,886,1127,4883,501,39046,15266,14851,18559,36773,32754,22011,5680,35703,25109,38852,10505,21072,39550,22137,13594,38139,37120,16251,16451,15971,17838,27074,33829,26181,27891,9735,12127,37841,15009,13692,5075,26118,29143,18848,34253,5727,20459,23521,14549,14769,35679,30678,23042,11149,33256,22309,37239,27628,5515,8485,10544,14686,33514,20766,37830,7847,21741,13701,9397,5038,32998,28167,12626,21279,28442,30458,22642,39228,11059,17954,30673,38473,35922,12024,13857,39205,39378,26046,9162,14187,17746,29398,7329,38955,11222,11623,17278,23378,26341,28810,33973,24422,15682,34753,32985,28195,18964,29577,17976]
Compute= [75,70,74,71,70,61,98,86,83,77,89,77,83,77,70,84,77,92,85,73,88,74,93,70,67,80,83,96,95,96,69,64,83,67,91,81,66,91,91,97,97,95,96,90,87,71,64,63,97,92,62,76,95,80,80,62,65,92,86,70,64,61,69,79,89,64,94,82,92,94,73,80,87,81,73,89,66,65,76,82,92,69,96,69,66,95,75,75,67,93,94,61,62,67,63,74,67,90,99,96,26,41,16,50,11,36,46,14,25,43,25,59,56,18,18,30,36,45,12,51,30,13,39,18,14,38,14,16,16,13,28,43,12,59,28,14,60,44,39,40,34,11,23,37,60,45,34,26,51,14,51,23,30,31,17,34,18,47,53,41,56,45,52,40,18,29,28,32,33,35,42,37,27,56,41,59,43,34,54,34,23,45,12,49,32,22,49,20,19,47,57,35,49,28,22,40,53,48,45,45]
Compute_P= [27,28,11,41,26,12,35,49,29,31,46,38,51,27,45,28,55,36,16,37,15,35,16,15,22,28,37,19,18,47,33,58,38,30,56,40,22,60,12,35,23,21,26,54,16,24,57,10,53,49,16,43,37,31,20,49,18,16,51,47,28,44,18,49,34,55,43,57,44,22,38,35,18,21,59,36,11,34,18,47,12,60,59,21,48,11,53,35,17,25,11,30,40,50,31,22,33,30,12,53,72,67,65,88,82,95,68,63,93,75,87,66,75,83,99,91,91,82,71,72,89,74,82,64,98,63,62,70,95,86,89,91,94,97,72,77,89,67,80,72,76,76,70,66,87,64,76,90,90,72,61,67,82,78,99,87,63,68,66,90,69,72,82,81,88,89,65,82,69,61,72,85,71,88,68,77,98,66,69,93,97,97,98,74,69,71,71,71,63,62,91,85,87,69,73,64,87,75,62,65]
Storage= [54,15,36,19,22,41,32,18,50,57,54,40,22,39,47,15,17,54,58,52,48,59,48,18,51,11,44,46,35,47,35,15,50,56,54,29,19,22,54,45,58,48,29,37,51,54,23,16,57,44,26,28,48,29,57,29,39,40,15,21,22,28,24,46,53,30,11,17,21,25,60,18,45,14,55,45,21,47,58,59,34,10,22,48,53,55,19,54,34,41,42,57,33,52,22,39,58,56,18,19,72,83,97,87,78,82,76,90,93,92,96,95,61,68,85,78,68,69,69,77,65,71,87,87,66,68,78,89,69,80,73,98,94,77,67,75,84,88,79,92,78,85,91,66,86,80,90,64,66,73,62,91,66,63,66,86,94,82,84,73,65,74,63,79,66,62,98,87,99,97,96,68,69,66,89,93,93,99,89,79,91,95,88,91,94,89,70,96,97,81,77,68,68,71,91,73,75,92,98,85]
Storage_P= [63,89,90,68,92,64,81,66,80,73,93,68,80,64,65,74,86,75,63,77,72,68,65,88,75,72,87,71,90,74,85,70,93,93,88,97,79,65,62,86,82,78,67,71,71,71,85,79,82,93,89,85,89,69,74,73,77,61,67,94,96,98,83,64,61,96,75,61,84,90,63,98,81,69,69,88,63,88,85,94,63,74,90,75,97,99,90,76,70,75,64,95,78,81,82,85,63,62,87,94,34,35,49,15,32,14,43,13,18,37,12,49,52,23,31,56,21,20,21,46,32,18,26,50,37,56,44,51,10,52,30,11,11,45,21,56,13,29,55,14,38,47,14,39,60,42,31,46,33,23,58,28,22,25,25,31,56,31,19,48,44,14,39,33,27,29,11,17,37,49,50,56,32,35,34,35,32,28,51,15,52,57,40,51,19,18,47,36,12,16,47,59,18,27,34,28,21,38,59,48]
Latency= [447,697,265,763,217,280,199,716,544,379,541,722,519,301,562,427,473,772,413,302,281,486,788,449,623,396,381,482,159,419,114,597,222,253,350,360,658,509,791,441,53,210,242,113,153,647,480,377,98,240,682,761,92,512,646,191,669,540,277,397,692,122,422,116,467,239,711,371,171,307,316,690,611,402,147,498,60,162,653,702,436,738,723,141,205,737,69,705,461,72,85,117,329,272,729,258,615,571,164,247,2976,3962,3429,4889,3894,3402,4215,2497,4972,1755,2181,1367,1829,4050,1355,1838,1038,1730,4892,2380,4222,4722,4884,1543,4731,1712,1056,1419,862,2030,1566,2765,4639,4159,1822,1965,1839,4794,2095,3397,3674,2337,3046,966,1248,1309,4230,1792,3271,1895,1876,4762,4267,4323,954,2152,1306,3573,811,4816,3544,4686,1548,2187,2242,3185,1672,3813,1324,3540,2298,1595,1634,2757,2782,2313,4823,4841,3506,2344,3912,1086,1795,2008,1685,934,1121,4730,2669,3961,2758,2084,2759,2674,1878,2928,4048,3394,4125,2874]
Latency_P= [2679,2832,4093,1489,2756,4511,2961,3965,4358,3604,1219,1994,2995,3030,1693,2594,1406,3071,2302,2240,3318,3051,1503,4734,4050,2928,3067,4315,2526,4038,3991,2041,4114,1539,3867,2672,1426,1966,3143,3750,4911,2337,1550,2469,1823,2108,4148,4831,4730,2704,4818,1315,3517,2519,3184,4414,4972,1808,3463,1568,1991,1822,1507,2208,4314,3124,1683,917,1460,4471,2118,2630,2876,1200,3537,4294,1590,2791,3551,1026,3175,2804,3516,2898,1257,3694,3888,1135,3448,4193,3497,1266,4580,3431,4721,4268,4700,2859,1091,3481,759,549,641,117,175,503,245,747,280,585,356,395,288,455,757,466,626,722,385,123,37,440,414,743,198,132,351,659,507,277,467,634,53,396,325,493,576,718,126,115,437,465,45,498,268,760,696,248,638,156,39,255,195,717,26,435,756,29,334,706,368,518,367,230,771,608,332,355,687,494,22,770,249,643,260,94,701,68,533,337,453,31,345,229,364,683,729,560,436,236,625,783,343,392,679,763,329,306,430,547]
StartD= [3.55,4.65,4.04,2.5,2.89,2.21,4.24,2.4,1.01,2.85,1.76,3.27,1.98,3.52,4.33,3.22,4.3,1.38,3.54,1.21,1.43,2.06,4.58,4.31,3.81,4.28,0.51,0.91,0.82,3.65,4.38,3.3,1.83,1.55,1,2.46,3.6,1.07,3.44,0.7,4.59,1.35,2.12,2.2,4.87,3.64,0.75,1.79,0.68,2.3,2.13,2.77,3.95,4.54,1.54,0.92,3.56,4.66,1.64,0.56,2.86,4.74,4.01,3.13,3.02,1.19,1.96,2.57,1.17,1.42,2.24,1.89,0.66,3.39,0.85,1.08,1.49,2.68,1.62,1.37,4.09,3.83,2.64,1.48,1.39,2.14,2.32,3.14,3.37,2.31,2.48,3.28,1.74,2.29,3.18,1.12,4.4,2.82,4.32,3.82,8.83,8.49,5.41,8.17,9.87,5.37,8.35,7.83,9.98,5.71,9.89,7.06,7.75,6.96,8.13,7.09,8.64,8.85,8.34,5.6,5.17,6.89,8.38,9.36,9.53,6.74,9.48,6.36,6.73,8.01,9.82,6.44,8.23,6.38,5.77,8.9,9.49,7.48,9.93,5.57,6.22,9.78,7.38,9.07,6.34,9.21,8.42,5.76,9.85,9.25,8.09,7.16,6.02,9.3,5.62,5.94,6.1,9.79,6.94,7.65,7.13,8.81,5.8,8.87,8.27,5.3,8.56,8.04,8.07,9.5,6.16,6.53,6.71,5.64,7.91,7.14,5.7,9.69,5.65,7.61,9.17,8.93,8.46,8.74,6.43,6.28,8.6,8.94,6.88,8.32,8.82,9.24,5.33,9.09,8.28,7.9,9.71,5.91,9.61,5.1]
LatencyExp= [4.7,3.02,4.22,4.48,4.4,3.6,4.18,3.88,4.53,4,3.56,3.86,2.18,3.47,4.69,4.57,2.84,2.02,3.01,3.19,2.97,3.09,3.82,2.71,3.04,4.96,2.69,2.76,3.84,3.27,4.79,4.88,3.23,2.46,2.2,3.16,3.52,3.39,3.93,3.35,3.64,2.89,4.37,3.65,3.91,3.11,4.46,3.24,2.83,2.95,2.28,4.78,2.85,3.21,2.56,3.31,2.64,4.75,2.06,3.77,2.63,3.25,3.41,2.22,4.43,5,3.76,2.3,3.69,3.67,4.04,3.54,3.44,4.45,4.55,3.08,4.11,3.28,4.01,3.66,4.51,2.74,3.1,2.79,4.29,3.43,4.72,3.97,3.45,4.41,3.8,4.68,4.3,3.79,2.6,2.4,2.39,4.61,3,2.1,8.87,13.68,6.07,6.41,9.95,5.15,8.64,7.54,6.94,10.39,10.12,12.25,10.89,7.52,14.61,5.19,12.03,6.33,8.91,11.34,14.28,11.18,12.44,12.56,10.86,10.53,12.43,10.97,14.49,5.86,10.5,8.53,13.6,8.11,12.82,12.66,9.62,7.34,13.65,5.37,7.99,13.78,13.64,5.97,8.62,7.59,11.39,12.34,6.74,13.98,12.72,5.49,8.7,11.74,11.84,13,14.24,9.48,9.96,12.86,11,14.75,10.9,10.66,10.31,14.93,13.28,13.67,10.8,5.46,6.56,8.15,10.15,9.2,6.34,8.41,14.07,6.83,9.7,10.37,12.55,13.96,8.19,6.42,11.89,7.09,12.74,8.16,8.57,8.03,11.81,8.08,10.2,13.59,11.98,5.23,7.69,7.51,5.67,5.89]
Bandwidth= [3057,7741,4094,7964,8413,2632,4260,229,536,3962,4624,7842,3585,1905,8734,1873,6335,7262,3865,7524,5620,3718,6238,2075,5288,9787,2567,5449,295,6243,5075,9333,6423,8350,8123,5364,5145,9986,7481,4201,8377,2788,8380,886,5797,5232,8721,585,1633,1838,1842,3283,9552,7637,1232,8241,6452,290,4898,7116,656,6370,2419,2357,937,6730,8819,3511,3437,1446,5218,7480,429,144,4919,2092,2507,7675,358,4384,3834,7955,7673,1140,525,7405,7457,8456,3831,510,4809,4465,8117,613,8787,9094,8817,3411,4526,6369,23977,10115,32203,37147,17072,32070,24257,11668,19570,24011,13388,32939,21612,15823,32523,32321,14793,31184,20953,26444,26139,18811,35418,19913,35209,18861,10048,12071,13390,22238,18721,28100,16267,15392,19302,19153,12311,38799,38772,21292,26285,34176,16573,38305,10680,37109,31671,19768,33836,34686,24100,31287,36706,25938,29819,22413,28597,38179,36182,35849,19615,39573,32005,38687,14827,24609,23265,21458,37297,39457,36597,13796,16295,15134,35410,37999,14317,14260,13991,14622,19168,19535,10382,22953,10011,25576,26550,21509,25115,23432,11969,26484,22537,33148,23611,36951,23236,28992,10374,18059]
# field names
fields = ['Throughput', 'Throughput_predicted', 'Compute', 'Compute_predicted', 'Storage', 'Storage_predicted', 'Latency', 'Latency_predicted', 'StartD', 'LatencyExp', 'Bandwidth','Decision']
# name of csv file
filename = "LearningSet.csv"
# writing to csv file
with open(filename, 'w') as csvfile:
# creating a csv dict writer object
writer = csv.DictWriter(csvfile, fieldnames = fields)
# writing headers (field names)
writer.writeheader()
result =0
# using random.choice() to
# get a random number
for x in range(200):
random_num1 = random.choice(Throughput)
if random_num1 in range(5000, 40001):
result= result+1
random_num2 = random.choice(Throughput_P)
if random_num2 in range(5000, 40001):
result= result+1
random_num3 = random.choice(Compute)
if random_num3 in range(10, 61):
result= result+1
random_num4 = random.choice(Compute_P)
if random_num4 in range(10, 61):
result= result+1
random_num5 = random.choice(Storage)
if random_num5 in range(10, 61):
result= result+1
random_num6 = random.choice(Storage_P)
if random_num6 in range(10, 61):
result= result+1
random_num7 = random.choice(Latency)
if random_num7 in range(20, 801):
result= result+1
random_num8 = random.choice(Latency_P)
if random_num8 in range(20, 801):
result= result+1
random_num9 = random.choice(StartD)
if ((random_num9>=0.5) and (random_num9<=5.0)):
result= result+1
random_num10 = random.choice(LatencyExp)
if ((random_num10>=2.0) and (random_num10<=5.0)):
result= result+1
random_num11 = random.choice(Bandwidth)
if random_num11 in range(10000, 40001):
result= result+1
if result >= 6:
result =1
else:
result =0
# my data rows as dictionary objects
rowdata =[{'Throughput': random_num1, 'Throughput_predicted': random_num2, 'Compute': random_num3, 'Compute_predicted': random_num4, 'Storage': random_num5, 'Storage_predicted': random_num6, 'Latency': random_num7, 'Latency_predicted': random_num8, 'StartD': random_num9, 'LatencyExp': random_num10, 'Bandwidth': random_num11, 'Decision':result }]
# writing data rows
writer.writerows(rowdata)
result =0