コード例 #1
0
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
コード例 #2
0
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
コード例 #3
0
 road_num = road[0]
 left_side = road[1]
 right_side = road[2]
 for i in range(x_len):
     n = random.randint(min_road_device_num, max_road_device_num)
     for j in range(n):
         d_name = "d{0}{1:05}".format(road_num, d_num)
         d = Device(name=d_name)
         d.use_resource = random.randint(min_use_resource, max_use_resource)
         d.startup_time = 0
         if random.randint(0, 3) == 0:
             roads = list(filter(lambda r: r != road, setup_roads))
             r = roads[random.randint(0, len(roads) - 1)]
             if random.randint(0, 1) == 0:
                 if road[0] < 30:
                     d.plan = route(Point(i, left_side.y), r[1])
                 else:
                     d.plan = route(Point(left_side.x, i), r[1])
             else:
                 if road[0] < 30:
                     d.plan = route(Point(x_len - 1 - i, left_side.y), r[1])
                 else:
                     d.plan = route(Point(left_side.y, y_len - 1- i), r[1])
         else:
             if random.randint(0, 1) == 0:
                 if road[0] < 30:
                     d.plan = route(Point(i, left_side.y), right_side)
                 else:
                     d.plan = route(Point(left_side.x, i), right_side)
             else:
                 if road[0] < 30:
コード例 #4
0
            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")
コード例 #5
0
                da_num[1] += 1
            elif n1 == c_sur[2]:
                d.append_app(app3)
                da_num[2] += 1
            """


            if random.randint(0, 3) == 0:
                # 別サイドをゴールにする
                roads = list(filter(lambda r: r[0] / 30 != road[0] / 30, setup_roads))
                r = roads[random.randint(0, len(roads) - 1)]
                goal = random.randint(1, 2)
                if random.randint(0, 1) == 0:
                    if road[0] < 30:
                        # 左右のルート
                        d.plan = route(Point(i, side_a.y), r[goal])
                    else:
                        # 上下のルート
                        d.plan = route(Point(side_a.x, i), r[goal])
                else:
                    if road[0] < 30:
                        # 左右のルート
                        d.plan = route(Point(x_len - 1 - i, side_a.y), r[goal])
                    else:
                        # 上下のルート
                        d.plan = route(Point(side_a.y, y_len - 1 - i), r[goal])
            else:
                if random.randint(0, 1) == 0:
                    # aからbへ
                    if road[0] < 30:
                        d.plan = route(Point(i, side_a.y), side_b)
コード例 #6
0
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)
        d.startup_time = 0
        d.plan = route(r_pos, Point(x_len - 1, r_pos.y))
        d_num += 1

# device name is