Beispiel #1
0
def create_all_time_cloudlets(t_len: int,
                              x_len: int,
                              y_len: int,
                              r: int = 5) -> AllTimeCloudlets:
    """
    時間軸、横軸、縦軸の最大長を指定してCloudletの三次元リストを生成する。
    :param t_len: 時間軸の最大長
    :param x_len: 横軸の最大長
    :param y_len: 縦軸の最大長
    :param r: 各クラウドレットの所有リソース
    :return: 
    """
    all_time_cloudlets = [[[
        Cloudlet(r, Point3D(i, j, k)) for i in range(x_len)
    ] for j in range(y_len)] for k in range(t_len)]  # type: AllTimeCloudlets
    return all_time_cloudlets
for d in range(num):
    startup_time = float(devices[d].startup_time)
    if 500 <= startup_time:
        if new_devices is None:
            new_devices = [devices[d]]
        else:
            new_devices.append(devices[d])

num = len(new_devices)
for d in range(num):
    new_plan = None
    plan_num = len(new_devices[d].plan)
    for p in range(plan_num):
        pivot_time = float(new_devices[d].plan[p].time)
        if new_plan is None:
            new_plan = [Point3D(new_devices[d].plan[p].x, new_devices[d].plan[p].y, float(pivot_time - 500.00))]
        else:
            new_plan.append(Point3D(new_devices[d].plan[p].x, new_devices[d].plan[p].y, float(pivot_time - 500.00)))
    new_devices[d].plan = new_plan

for i in range(num):
    new_devices[i].startup_time = float(new_devices[i].plan[0].time) # 各デバイスの起動時間を設定する

new_devices = sorted(new_devices, key=lambda d: d.startup_time, reverse=False)

num = len(new_devices)
for d in range(num):
    print(d, new_devices[d].startup_time, new_devices[d].plan[0].time)

f = open('/home/tomokishiraga/PycharmProjects/simulation/CloudletSimulator/dataset/device.ns_start_binaryfile2', 'wb')
pickle.dump(new_devices, f)
Beispiel #3
0
    device[0].name = n
    if new_devices is None:
        new_devices = [copy.deepcopy(device[0])]
    else:
        new_devices.append(copy.deepcopy(device[0]))

plan_num = len(new_devices[0].plan)
num = len(new_devices)
for d in range(num):
    random_value = random.randint(1, 100)
    new_plan = None
    for p in range(plan_num):
        # こいつが悪さをしてる
        pivot_time = float(new_devices[d].plan[p].time)
        if new_plan is None:
            new_plan = [
                Point3D(new_devices[d].plan[p].x, new_devices[d].plan[p].y,
                        str(pivot_time + random_value))
            ]
        else:
            new_plan.append(
                Point3D(new_devices[d].plan[p].x, new_devices[d].plan[p].y,
                        str(pivot_time + random_value)))
    new_devices[d].plan = new_plan

#221秒間ある
f = open(
    '/Users/sugimurayuuki/Desktop/mecsimulator/CloudletSimulator/dataset/device.clone_binaryfile',
    'wb')
pickle.dump(new_devices, f)
    elif d < 500:
        random_value = random.randint(70, 100)
    elif d < 750:
        random_value = random.randint(300, 350)

    #random_value = random.randint(400, 500)

    new_plan = None
    plan_num = len(new_devices[d].plan)
    startup_time = float(new_devices[d].startup_time)

    for p in range(plan_num):
        pivot_time = float(new_devices[d].plan[p].time)
        if new_plan is None:
            new_plan = [
                Point3D(new_devices[d].plan[p].x, new_devices[d].plan[p].y,
                        float(pivot_time - startup_time + random_value))
            ]
        else:
            new_plan.append(
                Point3D(new_devices[d].plan[p].x, new_devices[d].plan[p].y,
                        float(pivot_time - startup_time + random_value)))
    new_devices[d].plan = new_plan

for i in range(num):
    new_devices[i].startup_time = float(
        new_devices[i].plan[0].time)  #各デバイスの起動時間を設定する

new_devices = sorted(new_devices, key=lambda d: d.startup_time, reverse=False)

num = len(new_devices)
for d in range(num):
Beispiel #5
0
#deviceの作成
with open('Kuruma3.csv', newline='') as csvfile:
	#csvの読み込み
	reader = csv.DictReader(csvfile)
	devices = [] # type:List[Device]
	dflag = 0
	num = 0
	for row in reader:
		d_name = row['vehicle_id']
		d_time = row['timestep_time']
		d_lon = row['vehicle_x']
		d_lat = row['vehicle_y']
		d_angle = Angle(d_time, row['vehicle_angle'])
		d_speed = Speed(d_time, row['vehicle_speed'])
		d_plan = Point3D(d_lon, d_lat, d_time)
		dflag = 0

		for d in devices:
				#情報の追加
			if d.name == d_name:
				d.append_speed(d_speed)
				d.append_plan(d_plan)
				d.append_angle(d_angle)
				dflag = 1
				break
		if dflag == 0:
			d = Device(name=d_name)
			d.startup_time = d_time
			d.append_plan(d_plan)
			d.append_speed(d_speed)
Beispiel #6
0
    if d < 250:
        random_value = random.randint(0, 25)
    elif d < 500:
        random_value = random.randint(70, 100)
    elif d < 750:
        random_value = random.randint(300, 350)

    #random_value = random.randint(0, 100)

    new_plan = None
    plan_num = len(new_devices[d].plan)
    startup_time = float(new_devices[d].startup_time)
    for p in range(plan_num):
        pivot_time = float(new_devices[d].plan[p].time)
        if new_plan is None:
            new_plan = [Point3D(new_devices[d].plan[p].x, new_devices[d].plan[p].y, float(pivot_time - startup_time + random_value))]
        else:
            new_plan.append(Point3D(new_devices[d].plan[p].x, new_devices[d].plan[p].y, float(pivot_time - startup_time + random_value)))
    new_devices[d].plan = new_plan

for i in range(num):
    new_devices[i].startup_time = float(new_devices[i].plan[0].time) # 各デバイスの起動時間を設定する


new_devices = sorted(new_devices, key=lambda d: d.startup_time, reverse=False)

num = len(new_devices)
for d in range(num):
    print(d, new_devices[d].startup_time, new_devices[d].plan[0].time)

#221秒間ある