def create_dyn_small_map(sharing_model, bs_dist=100, dist_to_border=10): """Small env with 2 BS and dynamic distance in between""" map = Map(width=2 * dist_to_border + bs_dist, height=2 * dist_to_border) bs1 = Basestation('A', Point(dist_to_border, dist_to_border), sharing_model) bs2 = Basestation('B', Point(dist_to_border + bs_dist, dist_to_border), sharing_model) return map, [bs1, bs2]
def create_small_map(sharing_model): """ Create small map and 2 BS :returns: tuple (map, bs_list) """ map = Map(width=150, height=100) bs1 = Basestation('A', Point(50, 50), get_sharing_for_bs(sharing_model, 0)) bs2 = Basestation('B', Point(100, 50), get_sharing_for_bs(sharing_model, 1)) bs_list = [bs1, bs2] return map, bs_list
def create_medium_map(sharing_model): """ Deprecated: Use dynamic medium env instead. Kept this to reproduce earlier results. Same as large env, but with map restricted to areas with coverage. Thus, optimal episode reward should be close to num_ues * eps_length * 10 (ie, all UEs are always connected) """ map = Map(width=205, height=85) bs1 = Basestation('A', Point(45, 35), sharing_model) bs2 = Basestation('B', Point(160, 35), sharing_model) bs3 = Basestation('C', Point(100, 85), sharing_model) bs_list = [bs1, bs2, bs3] return map, bs_list
def create_dyn_large_map(sharing_model, num_bs, dist_to_border=10): assert 1 <= num_bs <= 7, "Only support 1-7 BS in large env" _, bs_list = create_large_map(sharing_model) # take only selected BS bs_list = bs_list[:num_bs] # create map with size according to BS positions max_x, max_y = None, None for bs in bs_list: if max_x is None or bs.pos.x > max_x: max_x = bs.pos.x if max_y is None or bs.pos.y > max_y: max_y = bs.pos.y map = Map(width=max_x + dist_to_border, height=max_y + dist_to_border) return map, bs_list
def create_dyn_medium_map(sharing_model, bs_dist=100, dist_to_border=10): """ Create map with 3 BS at equal distance. Distance can be varied dynamically. Map is sized automatically. Keep the same layout as old medium env here: A, B on same horizontal axis. C above in the middle """ # calculate vertical distance from A, B to C using Pythagoras y_dist = np.sqrt(bs_dist ** 2 - (bs_dist / 2) ** 2) # derive map size from BS distance and distance to border map_width = 2 * dist_to_border + bs_dist map_height = 2 * dist_to_border + y_dist map = Map(width=map_width, height=map_height) # BS A is located at bottom left corner with specified distance to border bs1 = Basestation('A', Point(dist_to_border, dist_to_border), get_sharing_for_bs(sharing_model, 0)) # other BS positions are derived accordingly bs2 = Basestation('B', Point(dist_to_border + bs_dist, dist_to_border), get_sharing_for_bs(sharing_model, 1)) bs3 = Basestation('C', Point(dist_to_border + (bs_dist / 2), dist_to_border + y_dist), get_sharing_for_bs(sharing_model, 2)) return map, [bs1, bs2, bs3]
def create_custom_env(sharing_model): """Hand-created custom env. For demos or specific experiments.""" # map with 4 BS at distance of 100; distance 10 to border of map map = Map(width=194, height=120) bs_list = [ # left Basestation('A', Point(10, 60), get_sharing_for_bs(sharing_model, 0)), # counter-clockwise Basestation('B', Point(97, 10), get_sharing_for_bs(sharing_model, 1)), Basestation('C', Point(184, 60), get_sharing_for_bs(sharing_model, 2)), Basestation('D', Point(97, 110), get_sharing_for_bs(sharing_model, 3)), ] # UEs are now created dynamically according to CLI # ue_list = [ # User(str(1), map, pos_x=70, pos_y=40, movement=UniformMovement(map)), # User(str(2), map, pos_x=80, pos_y=60, movement=UniformMovement(map)) # ] return map, bs_list
def create_large_map(sharing_model): """ Create larger map with 7 BS that are arranged in a typical hexagonal structure. :returns: Tuple(map, bs_list) """ map = Map(width=230, height=260) bs_list = [ # center Basestation('A', Point(115, 130), get_sharing_for_bs(sharing_model, 0)), # top left, counter-clockwise Basestation('B', Point(30, 80), get_sharing_for_bs(sharing_model, 1)), Basestation('C', Point(115, 30), get_sharing_for_bs(sharing_model, 2)), Basestation('D', Point(200, 80), get_sharing_for_bs(sharing_model, 3)), Basestation('E', Point(200, 180), get_sharing_for_bs(sharing_model, 4)), Basestation('F', Point(115, 230), get_sharing_for_bs(sharing_model, 5)), Basestation('G', Point(30, 180), get_sharing_for_bs(sharing_model, 6)), ] return map, bs_list