def simple_use_plan(kwargs) -> AllocationPlan: atcs = kwargs["atcs"] devices = kwargs["ds"] max_hop = kwargs["max_hop"] congestion_scope = kwargs["congestion_scope"] t_len = len(atcs) y_len = len(atcs[0]) x_len = len(atcs[0][0]) allocation_plan = create_blank_allocation_plan(atcs, devices) for time, cloudlets in enumerate(tqdm(atcs)): ds = list(filter(lambda d: d.is_poweron(time), devices)) tempallocation = create_tempallocation(time, ds, max_hop) congestion_map = create_congestion_map(time, x_len, y_len, ds, congestion_scope, tempallocation) print_congestion(congestion_map, x_len, y_len) ds = sorted(ds, key=lambda d: congestion_map[tempallocation[d.name].y][tempallocation[d.name].x], reverse=True) for d in ds: pos = tempallocation[d.name] for hop in range(0, 30): nps = near_points(pos, hop, Point(x_len - 1, y_len - 1), Point(0, 0)) nps = sorted(nps, key=lambda p: distance(p, d.get_pos(time))) tp, index = search(nps, True, key=lambda p: cloudlets[p.y][p.x].can_append_device(d)) if index == -1: continue allocate(d, time, tp, allocation_plan, cloudlets) break else: # どこにも割当られなかった場合 allocation = Allocation(pos.x, pos.y, -1) allocation_plan[d.name][time] = allocation d.set_allocation_point(time, allocation) print("allocation failed", d.name, time) return allocation_plan
def set_device_set_pri2(atcs: AllTimeCloudlets, cong_map: List[List[int]], t: int, devices: Devices, x_len: int, y_len: int, scope: int): ds = list(filter(lambda d: d.is_poweron(t), devices)) d_num = 0 i=0 for d in ds: app_name = d.app_name() app_num = [0,0,0] pos = d.get_pos(t) pts = near_points(pos, scope, Point(x_len - 1, y_len - 1), Point(0, 0)) for p in pts: cloud = atcs[p.y][p.x][0] if cloud.is_operatable_application("1"): app_num[0] += 1 i += 1 if cloud.is_operatable_application("2"): app_num[1] += 1 i += 1 if cloud.is_operatable_application("3"): app_num[2] += 1 i += 1 max_len = [0,0,0] for i in range(0,3): max_len[i] = str(np.argmax(app_num) + 1) app_num[int(max_len[i]) - 1] = 0 if app_name == max_len[2]: pri_num = int(cong_map[pos.y][pos.x] + 2) elif app_name == max_len[1]: pri_num = int(cong_map[pos.y][pos.x] + 1) else: pri_num = int(cong_map[pos.y][pos.x]) #pri_num = app_num d.set_ds_pri(value=pri_num)
def single_cross(p_min: Point, p_max: Point, t_max: int, ur_min: int = 0, ur_max: int = 3) -> Devices: ds = [] for t in range(t_max + 1): num = t + 1 if t > ur_max: num = ur_max for n in range(num): d1 = Device() p1_start = Point(int((p_max.x + p_min.x) / 2), 0) p1_goal = Point(int((p_max.x + p_min.x) / 2), p_max.y) d1.plan = route(p1_start, p1_goal) d1.use_resource = random.randint(ur_min, ur_max) d1.startup_time = t d2 = Device() p2_start = Point(0, int((p_min.y + p_max.y) / 2)) p2_goal = Point(p_max.y, int((p_min.y + p_max.y) / 2)) d2.plan = route(p2_start, p2_goal) d2.use_resource = random.randint(ur_min, ur_max) d2.startup_time = t ds.append(d1) ds.append(d2) return ds
def setUp(self): self.devices = [ Device("d1", plan=[Point(0, 0)]), Device("d2", plan=[Point(2, 1)]) ] self.devices[0].use_resource = 2 self.devices[1].use_resource = 3 pass
def simple_use_plan_03(kwargs) -> AllocationPlan: atcs = kwargs["atcs"] devices = kwargs["ds"] max_hop = kwargs["max_hop"] congestion_scope = kwargs["congestion_scope"] reqapp=["1", "2", "3"] t_len = len(atcs) y_len = len(atcs[0]) x_len = len(atcs[0][0]) # cloudlets の空計画の作成 allocation_plan = create_blank_allocation_plan(atcs, devices) for time, cloudlets in enumerate(tqdm(atcs)): # ds 終了していないデバイスを集める ds = list(filter(lambda d: d.is_poweron(time), devices)) congestion_map = simple_create_congestion_map(time, x_len, y_len, ds, congestion_scope) cong_app_ds = [] congestion_map1 = [[1,3,4,5,6,7,10],[2,4,5,12,5,3,11],[2,1,3,1,6,7,8]] dsa1 = list(filter(lambda d: d.appret(reqapp[0]), max_congest_ds)) dsa2 = list(filter(lambda d: d.appret(reqapp[1]), max_congest_ds)) dsa3 = list(filter(lambda d: d.appret(reqapp[2]), max_congest_ds)) dsa = dsa2 + dsa1 + dsa3 #cong_app_ds.extend(dsa) #print ("a") for d in ds: # step1 前回と同じ場所に置くことが適切かどうか判定し、適切なら配置を試行する now_pos = d.get_pos(time) if d.startup_time != time: prev_pos = d.get_allocation_point(time - 1) if distance(prev_pos, now_pos) <= max_hop: # 前回と同じ場所に置くことを試行する if cloudlets[prev_pos.y][prev_pos.x].can_append_device(d, True): allocate(d, time, prev_pos, allocation_plan, cloudlets) continue # step2 if d.is_poweron(time + max_hop): next_pos = d.get_pos(time + max_hop) else: next_pos = d.get_pos(d.shutdown_time - 1) for hop in range(max_hop, 30): nps = near_points(now_pos, hop, Point(x_len - 1, y_len - 1), Point(0, 0)) nps = sorted(nps, key=lambda p: distance(p, next_pos)) tp, index = search(nps, True, key=lambda p: cloudlets[p.y][p.x].can_append_device(d, True)) if index == -1: continue allocate(d, time, tp, allocation_plan, cloudlets) break else: # どこにも割当られなかった場合 allocation = Allocation(now_pos.x, now_pos.y, -1) allocation_plan[d.name][time] = allocation d.set_allocation_point(time, allocation) print("allocation failed", d.name, time) return allocation_plan
def cross(p_min: Point, p_max: Point, t_max: int, ur_min: int = 0, ur_max: int = 3, r_num: int = 6, density: int = 1, upr: int = 3) -> Devices: """ :param p_min: :param p_max: :param t_max: :param ur_min: :param ur_max: max of use resource :param r_num: number of road :param density: 集密度? :param upr: unit par roads :return: """ ds = [] for t in range(t_max + 1): for i in range(int(r_num / 2)): offset = density div = int(r_num / 2) - 1 + (2 * density) for j in range(upr): d1 = Device() p1_start = Point(0, int((p_min.y + p_max.y) / div) * (offset + i)) p1_goal = Point(p_max.x, int((p_min.y + p_max.y) / div) * (offset + i)) d1.plan = route(p1_start, p1_goal) d1.use_resource = random.randint(ur_min, ur_max) d1.startup_time = t ds.append(d1) for j in range(upr): d2 = Device() p2_start = Point( int((p_min.x + p_max.x) / div) * (offset + i), 0) p2_goal = Point( int((p_min.x + p_max.x) / div) * (offset + i), p_max.y) d2.plan = route(p2_start, p2_goal) d2.use_resource = random.randint(ur_min, ur_max) d2.startup_time = t ds.append(d2) Device.num = 0 random.shuffle(ds) return ds
def set_device_set_pri(atcs: AllTimeCloudlets, cong_map: List[List[int]], t: int, devices: Devices, x_len: int, y_len: int, scope: int): ds = list(filter(lambda d: d.is_poweron(t), devices)) d_num = 0 for d in ds: app_name = d.app_name() app_num = 0 pos = d.get_pos(t) pts = near_points(pos, scope, Point(x_len - 1, y_len - 1), Point(0, 0)) for p in pts: cloud = atcs[p.y][p.x][0] if cloud.is_operatable_application(app_name): app_num += 1 pri_num = int(cong_map[pos.y][pos.x]) #/ app_num) #+ cong_map[pos.y][pos.x]) #pri_num = app_num d.set_ds_pri(value=pri_num)
def allocate(device: Device, time, allocate_pos: Point, allocation_plan, cloudlets: List[List[Cloudlet]]) -> None: cloudlets[allocate_pos.y][allocate_pos.x].append_device(device) d_pos = device.get_pos(time) #ある時刻のデバイスの座標を取得 #distanceは2点間の座標の距離を返す関数, Allocation()で割り当て計画の定義 allocation = Allocation(allocate_pos.x, allocate_pos.y, distance(d_pos, allocate_pos)) allocation_plan[device.name][time] = allocation #デバイス名と時間からなる2次元リストに割り当て計画を代入 device.set_allocation_point(time, Point(allocation.x, allocation.y)) #割り当て
def simple_use_plan_07(kwargs) -> AllocationPlan: atcs = kwargs["atcs"] devices = kwargs["ds"] max_hop = kwargs["max_hop"] congestion_scope = kwargs["congestion_scope"] t_len = len(atcs) y_len = len(atcs[0]) x_len = len(atcs[0][0]) allocation_plan = create_blank_allocation_plan(atcs, devices) for time, cloudlets in enumerate(tqdm(atcs)): ds = list(filter(lambda d: d.is_poweron(time), devices)) congestion_map = simple_create_congestion_map(time, x_len, y_len, ds, congestion_scope) # print_congestion(congestion_map, x_len, y_len) ds = sorted(ds, key=lambda d: congestion_map[d.get_pos(time).y][d.get_pos(time).x], reverse=True) for d in ds: # step1 前回と同じ場所に置くことが適切かどうか判定し、適切なら配置を試行する now_pos = d.get_pos(time) if d.startup_time != time: prev_pos = d.get_allocation_point(time - 1) if distance(prev_pos, now_pos) <= max_hop: # 前回と同じ場所に置くことを試行する if cloudlets[prev_pos.y][prev_pos.x].can_append_device(d, True): allocate(d, time, prev_pos, allocation_plan, cloudlets) continue # step2 if d.is_poweron(time + max_hop): next_pos = d.get_pos(time + max_hop) else: next_pos = d.get_pos(d.shutdown_time - 1) for hop in range(max_hop, 30): nps = near_points(now_pos, hop, Point(x_len - 1, y_len - 1), Point(0, 0)) nps = sorted(nps, key=lambda p: distance(p, next_pos)) tp, index = search(nps, True, key=lambda p: cloudlets[p.y][p.x].can_append_device(d, True)) if index == -1: continue allocate(d, time, tp, allocation_plan, cloudlets) break else: # どこにも割当られなかった場合 allocation = Allocation(now_pos.x, now_pos.y, -1) allocation_plan[d.name][time] = allocation d.set_allocation_point(time, allocation) print("allocation failed", d.name, time) return allocation_plan
def simple_create_congestion_map(t: int, x_len: int, y_len: int, devices: Devices, scope: int) -> List[List[int]]: """ 仮割り当てを用いて混雑度マップを生成する :param t: 混雑度マップを生成する時間 :param x_len: xの長さ? :param y_len: yの長さ? :param devices: デバイス集合 :param scope: 端末位置からどの程度はなれた範囲まで混雑度を加算するかを示す値 :return: """ ret = [[0 for x in range(x_len)] for y in range(y_len)] ds = list(filter(lambda d: d.is_poweron(t), devices)) for d in ds: pos = d.get_pos(t) pts = near_points(pos, scope, Point(x_len - 1, y_len - 1), Point(0, 0)) for p in pts: ret[p.y][p.x] += d.use_resource return ret
def congestion_priority(kwards) -> AllocationPlan: """ 混雑Cloudletの直轄地にあるデバイスを優先して割り当てる方式 :param atcs: すべての時間のCloudlet集合 :param devices: すべてのデバイス集合 :return: """ atcs = kwards["atcs"] devices = kwards["ds"] t_len = len(atcs) y_len = len(atcs[0]) x_len = len(atcs[0][0]) allocation_plan = create_blank_allocation_plan(atcs, devices) for time, cloudlets in enumerate(tqdm(atcs)): ds = list(filter(lambda d: d.is_poweron(time), devices)) requests = create_congestion_map(time, len(cloudlets[0]), len(cloudlets), ds, 3) ds = sorted( ds, key=lambda d: requests[d.get_pos(time).y][d.get_pos(time).x], reverse=True) for d in ds: pos = d.get_pos(time) for hop in range(0, 30): nps = near_points(pos, hop, Point(x_len - 1, y_len - 1), Point(0, 0)) tp, index = search( nps, True, key=lambda p: cloudlets[p.y][p.x].can_append_device(d)) if index == -1: continue cloudlets[tp.y][tp.x].append_device(d) allocation = Allocation(tp.x, tp.y, distance(pos, tp)) allocation_plan[d.name][time] = allocation d.set_allocation_point(time, Point(allocation.x, allocation.y)) break else: # どこにも割当られなかった場合 allocation = Allocation(pos.x, pos.y, -1) allocation_plan[d.name][time] = allocation d.set_allocation_point(time, Point(allocation.x, allocation.y)) return allocation_plan
def create_app_cong_map(t: int, x_len: int, y_len: int, devices: Devices, scope: int, tempallocation: Dict[str, Point]) -> List[List[int]]: """ 仮割り当てを用いてアプリ用混雑度マップを生成する :param t: アプリ用混雑度マップを生成する時間 :param x_len: xの長さ? :param y_len: yの長さ? :param devices: デバイス集合 :param scope: 端末位置からどの程度はなれた範囲まで混雑度を加算するかを示す値 :return: """ ret = [[0 for x in range(x_len)] for y in range(y_len)] ds = list(filter(lambda d: d.is_poweron(t), devices)) for d in ds: pos = tempallocation[d.name] pts = near_points(pos, scope, Point(x_len - 1, y_len - 1), Point(0, 0)) for p in pts: ret[p.y][p.x] += d.use_resource return ret
def simple_use_plan_06(kwargs) -> AllocationPlan: atcs = kwargs["atcs"] devices = kwargs["ds"] max_hop = kwargs["max_hop"] congestion_scope = kwargs["congestion_scope"] t_len = len(atcs) y_len = len(atcs[0]) x_len = len(atcs[0][0]) allocation_plan = create_blank_allocation_plan(atcs, devices) for time, cloudlets in enumerate(tqdm(atcs)): ds = list(filter(lambda d: d.is_poweron(time), devices)) reqapp = ["1","2","3"] # reqapp ごとにデバイスを分ける dsa1 = list(filter(lambda d: d.appret(reqapp[0]), ds)) dsa2 = list(filter(lambda d: d.appret(reqapp[1]), ds)) dsa3 = list(filter(lambda d: d.appret(reqapp[2]), ds)) # 要求数が多い順番を特定 ds_app_len = [ len(dsa1), len(dsa2), len(dsa3) ] max_len = [0,0,0] for i in range(0,3): max_len[i] = str(np.argmax(ds_app_len)) ds_app_len[int(max_len[i])] = 0 # app ごとの混雑度を計測 congestion_mapa1 = simple_create_congestion_map(time, x_len, y_len, dsa1, congestion_scope) congestion_mapa2 = simple_create_congestion_map(time, x_len, y_len, dsa2, congestion_scope) congestion_mapa3 = simple_create_congestion_map(time, x_len, y_len, dsa3, congestion_scope) # app ごとの混雑度と近傍の利用可能cloudletの set_app_pri(atcs, congestion_mapa1, time, dsa1, x_len, y_len, max_len, congestion_scope) set_app_pri(atcs, congestion_mapa2, time, dsa2, x_len, y_len, max_len, congestion_scope) set_app_pri(atcs, congestion_mapa3, time, dsa3, x_len, y_len, max_len, congestion_scope) ds = sorted(ds, key=lambda d: d.ds_pri, reverse=False) for d in ds: # step1 前回と同じ場所に置くことが適切かどうか判定し、適切なら配置を試行する now_pos = d.get_pos(time) if d.startup_time != time: prev_pos = d.get_allocation_point(time - 1) if distance(prev_pos, now_pos) <= max_hop: # 前回と同じ場所に置くことを試行する if cloudlets[prev_pos.y][prev_pos.x].can_append_device(d, True): allocate(d, time, prev_pos, allocation_plan, cloudlets) continue # step2 if d.is_poweron(time + max_hop): next_pos = d.get_pos(time + max_hop) else: next_pos = d.get_pos(d.shutdown_time - 1) for hop in range(max_hop, 30): nps = near_points(now_pos, hop, Point(x_len - 1, y_len - 1), Point(0, 0)) nps = sorted(nps, key=lambda p: distance(p, next_pos)) tp, index = search(nps, True, key=lambda p: cloudlets[p.y][p.x].can_append_device(d, True)) if index == -1: continue allocate(d, time, tp, allocation_plan, cloudlets) break else: # どこにも割当られなかった場合 allocation = Allocation(now_pos.x, now_pos.y, -1) allocation_plan[d.name][time] = allocation d.set_allocation_point(time, allocation) print("allocation failed", d.name, time) return allocation_plan
#(10, Point(0, 10), Point(x_len - 1, 10)), (14, Point(0, 14), Point(x_len - 1, 14)), (15, Point(0, 15), Point(x_len - 1, 15)), (16, Point(0, 16), Point(x_len - 1, 16)), # #(20, Point(0, 20), Point(x_len - 1, 20)), # #(40, Point(10, 0), Point(10, y_len - 1)), (44, Point(14, 0), Point(14, y_len - 1)), (45, Point(15, 0), Point(15, y_len - 1)), (46, Point(16, 0), Point(16, y_len - 1)), #(50, Point(20, 0), Point(20, y_len - 1)), ] """ #分散 setup_roads = [ # # 混雑道路 (13, Point(0, 0), Point(x_len - 1, y_len - 1)), (15, Point(x_len - 1, y_len - 1), Point(0, 0)), (43, Point(0, y_len - 1), Point(x_len - 1, 0)), (45, Point(y_len - 1, 0), Point(0, x_len - 1)), ] min_road_device_num = 3 max_road_device_num = 9 min_use_resource = 1 max_use_resource = 3 app1 = Application( name="1", use_resource=3) #random.randint(min_use_resource, max_use_resource)) app2 = Application( name="2", use_resource=3) #random.randint(min_use_resource, max_use_resource)) app3 = Application(
elif i % 3 + 1 == c_sur[2]: # else : atcs[x][y][t].apps_append(app2) atcs[x][y][t].apps_append(app3) ca_num[2] += 1 i += 1 """ devices = [] # type:List[Device] d_num = 0 da_num = [0, 0, 0, 0, 0] #p1 setup_roads = [ # # 混雑道路 #(10, Point(0, 10), Point(x_len - 1, 10)), (13, Point(0, 13), Point(x_len - 1, 13)), (15, Point(0, 17), Point(x_len - 1, 15)), (17, Point(0, 19), Point(x_len - 1, 17)), # # #(20, Point(0, 20), Point(x_len - 1, 20)), # # #(40, Point(10, 0), Point(10, y_len - 1)), (43, Point(13, 0), Point(13, y_len - 1)), (45, Point(15, 0), Point(15, y_len - 1)), (47, Point(17, 0), Point(17, y_len - 1)), #(50, Point(20, 0), Point(20, y_len - 1)), ] """ #分散 setup_roads = [ # # 混雑道路 (13, Point(0, 0), Point(x_len - 1, y_len -1)),
def simple_use_plan_02(kwargs) -> AllocationPlan: atcs = kwargs["atcs"] devices = kwargs["ds"] max_hop = kwargs["max_hop"] congestion_scope = kwargs["congestion_scope"] reqapp=["1", "2", "3"] t_len = len(atcs) y_len = len(atcs[0]) x_len = len(atcs[0][0]) # cloudlets の空計画の作成 allocation_plan = create_blank_allocation_plan(atcs, devices) for time, cloudlets in enumerate(tqdm(atcs)): # ds 終了していないデバイスを集める ds = list(filter(lambda d: d.is_poweron(time), devices)) #ds = sorted(ds,lambda d: d.app_name,reversed=True) dsa1 = list(filter(lambda d: d.appret(reqapp[0]), ds)) dsa2 = list(filter(lambda d: d.appret(reqapp[1]), ds)) dsa3 = list(filter(lambda d: d.appret(reqapp[2]), ds)) a1_len = len(dsa1) a2_len = len(dsa2) a3_len = len(dsa3) # # 混雑度マップの作成 congestion_mapa1 = simple_create_congestion_map(time, x_len, y_len, dsa1, congestion_scope) congestion_mapa2 = simple_create_congestion_map(time, x_len, y_len, dsa2, congestion_scope) congestion_mapa3 = simple_create_congestion_map(time, x_len, y_len, dsa3, congestion_scope) # # # # print_congestion(congestion_map, x_len, y_len) dsa1 = sorted(dsa1, key=lambda d: congestion_mapa1[d.get_pos(time).y][d.get_pos(time).x], reverse=True) dsa2 = sorted(dsa2, key=lambda d: congestion_mapa2[d.get_pos(time).y][d.get_pos(time).x], reverse=True) dsa3 = sorted(dsa3, key=lambda d: congestion_mapa3[d.get_pos(time).y][d.get_pos(time).x], reverse=True) # if(a1_len > a2_len): # if(a1_len > a3_len): # if(a2_len > a3_len): # ds = dsa2 + dsa1 + dsa3 # else: # ds = dsa3 + dsa1 + dsa2 # else: # ds = dsa1 + dsa3 + dsa2 # else: # if(a1_len > a3_len): # ds = dsa1 + dsa2 + dsa3 # else: # if(a2_len > a3_len): # ds = dsa2 + dsa3 + dsa1 # else: # ds = dsa3 + dsa2 + dsa1 #ds = dsa2 + dsa1 + dsa3 ds = dsa1 + dsa3 + dsa2 # congestion_map = simple_create_congestion_map(time, x_len, y_len, ds, congestion_scope) # ds_high = list(filter(lambda d: congestion_map[d.get_pos(time).y][d.get_pos(time).x] > 3), ds) # ds_low = list(filter(lambda d: congestion_map[d.get_pos(time).y][d.get_pos(time).x] < 3), ds) # ds = ds_high + ds_low for d in ds: # step1 前回と同じ場所に置くことが適切かどうか判定し、適切なら配置を試行する now_pos = d.get_pos(time) if d.startup_time != time: prev_pos = d.get_allocation_point(time - 1) if distance(prev_pos, now_pos) <= max_hop: # 前回と同じ場所に置くことを試行する if cloudlets[prev_pos.y][prev_pos.x].can_append_device(d, True): allocate(d, time, prev_pos, allocation_plan, cloudlets) continue # step2 if d.is_poweron(time + max_hop): next_pos = d.get_pos(time + max_hop) else: next_pos = d.get_pos(d.shutdown_time - 1) for hop in range(max_hop, 30): nps = near_points(now_pos, hop, Point(x_len - 1, y_len - 1), Point(0, 0)) nps = sorted(nps, key=lambda p: distance(p, next_pos)) tp, index = search(nps, True, key=lambda p: cloudlets[p.y][p.x].can_append_device(d, True)) if index == -1: continue allocate(d, time, tp, allocation_plan, cloudlets) break else: # どこにも割当られなかった場合 allocation = Allocation(now_pos.x, now_pos.y, -1) allocation_plan[d.name][time] = allocation d.set_allocation_point(time, allocation) print("allocation failed", d.name, time) return allocation_plan
if n == 0: #app = Application(name="a1") elif n == 1: #app = Application(name="a2") else: #app = Application(name="a3") #atcs[x][y][t].apps_append(app) """ devices = [] # type:List[Device] d_num = 100 for i in range(d_num): d = Device(name="d{}".format(i)) d.startup_time = 0 n = random.randint(0, 3) if n == 0: d.plan = route(Point(0, 0), Point(x_len, y_len)) if n == 1: d.plan = route(Point(x_len, y_len), Point(0, 0)) if n == 2: d.plan = route(Point(0, y_len), Point(x_len, 0)) if n == 3: d.plan = route(Point(y_len, 0), Point(0, x_len)) n = random.randint(0, 2) if n == 0: #app = Application(name="a1") d.use_resource = 1 elif n == 1: #app = Application(name="a2") d.use_resource = 1 else: #app = Application(name="a3")
atcs[x][y][t].apps_append(app3) ca_num[2] += 1 i = 0 else: i += 1 # print(1) devices = [] # type:List[Device] d_num = 0 #deviceの数 da_num = [0, 0, 0] #deviceの数のリスト #道路作成 setup_roads = [ # 混雑道路 #横線を引くための (13, Point(0, 13), Point(x_len - 1, 13)), (15, Point(0, 15), Point(x_len - 1, 15)), #真ん中(30の半分) (17, Point(0, 19), Point(x_len - 1, 17)), (43, Point(13, 0), Point(13, y_len - 1)), (45, Point(15, 0), Point(15, y_len - 1)), (47, Point(17, 0), Point(17, y_len - 1)), ] """ #分散 setup_roads = [ # 混雑道路 # (13, Point(0, 0), Point(x_len - 1, y_len -1)), # (15, Point(x_len-1, y_len-1), Point(0, 0)), # (43, Point(0, y_len-1), Point(x_len-1, 0)), # (45, Point(x_len-1, 0), Point(0, y_len-1)), ]
import random cloudlets_type = "plane" t_len = 30 x_len = 30 y_len = 30 atcs = create_all_time_cloudlets(t_len, x_len, y_len) devices = [] # type:List[Device] d_num = 0 setup_roads = [ # 混雑道路 (10, Point(0, 10), Point(x_len - 1, 10)), (13, Point(0, 13), Point(x_len - 1, 13)), (15, Point(0, 15), Point(x_len - 1, 15)), (17, Point(0, 17), Point(x_len - 1, 17)), (20, Point(0, 20), Point(x_len - 1, 20)), (40, Point(10, 0), Point(10, y_len - 1)), (43, Point(13, 0), Point(13, y_len - 1)), (45, Point(15, 0), Point(15, y_len - 1)), (47, Point(17, 0), Point(17, y_len - 1)), (50, Point(20, 0), Point(20, y_len - 1)), ] min_road_device_num = 1 max_road_device_num = 1 min_use_resource = 1 max_use_resource = 1
from simulator.utility.point import route from typing import List import random cloudlets_type = "plane" t_len = 10 x_len = 30 y_len = 30 atcs = create_all_time_cloudlets(t_len, x_len, y_len) devices = [] # type:List[Device] # device name is 10000 - 10999[ r_num = 10 r_pos = Point(10, 0) d_num = 0 for i in range(x_len): n = random.randint(5) for j in range(n): d = Device(name="d10{0:03}".format(d_num)) d.use_resource = random.randint(3) d.startup_time = 0 d.plan = route(Point(r_pos.x + i, r_pos.y), Point(x_len - 1, r_pos.y)) devices.append(d) d_num += 1 for t in range(t_len): n = random.randint(5) for i in range(n): d = Device(name="d10{0:03}".format(d_num)) d.use_resource = random.randint(3)