-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain_helper.py
183 lines (169 loc) · 6.94 KB
/
main_helper.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
import sys
from config import HYPATIA_DIR
sys.path.append(HYPATIA_DIR + "/satgenpy")
import satgen
import helper_dynamic_state
import os
import isls
class MainHelper:
def __init__(
self,
BASE_NAME,
NICE_NAME,
ECCENTRICITY,
ARG_OF_PERIGEE_DEGREE,
PHASE_DIFF,
MEAN_MOTION_REV_PER_DAY,
ALTITUDE_M,
MAX_GSL_LENGTH_M,
MAX_ISL_LENGTH_M,
NUM_ORBS,
NUM_SATS_PER_ORB,
INCLINATION_DEGREE,
):
self.BASE_NAME = BASE_NAME
self.NICE_NAME = NICE_NAME
self.ECCENTRICITY = ECCENTRICITY
self.ARG_OF_PERIGEE_DEGREE = ARG_OF_PERIGEE_DEGREE
self.PHASE_DIFF = PHASE_DIFF
self.MEAN_MOTION_REV_PER_DAY = MEAN_MOTION_REV_PER_DAY
self.ALTITUDE_M = ALTITUDE_M
self.MAX_GSL_LENGTH_M = MAX_GSL_LENGTH_M
self.MAX_ISL_LENGTH_M = MAX_ISL_LENGTH_M
self.NUM_ORBS = NUM_ORBS
self.NUM_SATS_PER_ORB = NUM_SATS_PER_ORB
self.INCLINATION_DEGREE = INCLINATION_DEGREE
def calculate(
self,
output_generated_data_dir, # Final directory in which the result will be placed
CLUSTER_CONFIG,
CLUSTER_DIR,
duration_s,
time_step_ms,
isl_selection, # isls_{none, plus_grid}
gs_selection, # ground_stations_{top_100, paris_moscow_grid}
dynamic_state_algorithm, # algorithm_{free_one_only_{gs_relays,_over_isls}, paired_many_only_over_isls}
num_threads,
is_reconfig,
):
# Add base name to setting
name = self.BASE_NAME + "_" + isl_selection + "_" + gs_selection + "_" + dynamic_state_algorithm
# Create output directories
if not os.path.isdir(output_generated_data_dir):
os.makedirs(output_generated_data_dir, exist_ok=True)
if not os.path.isdir(output_generated_data_dir + "/" + name):
os.makedirs(output_generated_data_dir + "/" + name, exist_ok=True)
TOPO_FILE = CLUSTER_DIR + "/" + CLUSTER_CONFIG["topo_file"]
# Ground stations
# TODO: may add more custom GS files. e.g. houston only
print("Generating ground stations...")
if gs_selection == "ground_stations_top_100":
satgen.extend_ground_stations(
HYPATIA_DIR + "/paper/satellite_networks_state/input_data/ground_stations_cities_sorted_by_estimated_2025_pop_top_100.basic.txt",
output_generated_data_dir + "/" + name + "/ground_stations.txt"
)
elif gs_selection == "ground_stations_paris_moscow_grid":
satgen.extend_ground_stations(
HYPATIA_DIR + "/paper/satellite_networks_state/input_data/ground_stations_paris_moscow_grid.basic.txt",
output_generated_data_dir + "/" + name + "/ground_stations.txt"
)
elif gs_selection == "ground_stations_paris_grid":
satgen.extend_ground_stations(
"input_data/ground_stations_paris_grid.basic.txt",
output_generated_data_dir + "/" + name + "/ground_stations.txt"
)
else:
raise ValueError("Unknown ground station selection: " + gs_selection)
# TLEs
print("Generating TLEs...")
satgen.generate_tles_from_scratch_manual(
output_generated_data_dir + "/" + name + "/tles.txt",
self.NICE_NAME,
self.NUM_ORBS,
self.NUM_SATS_PER_ORB,
self.PHASE_DIFF,
self.INCLINATION_DEGREE,
self.ECCENTRICITY,
self.ARG_OF_PERIGEE_DEGREE,
self.MEAN_MOTION_REV_PER_DAY
)
# ISLs
print("Generating ISLs...")
# if isl_selection == "isls_plus_grid":
# satgen.generate_plus_grid_isls(
# output_generated_data_dir + "/" + name + "/isls.txt",
# self.NUM_ORBS,
# self.NUM_SATS_PER_ORB,
# isl_shift=0,
# idx_offset=0
# )
if isl_selection == "isls_plus_grid":
isls.generate_plus_grid_isls(
output_generated_data_dir + "/" + name + "/isls.txt",
CLUSTER_DIR,
CLUSTER_CONFIG,
self.NUM_ORBS,
self.NUM_SATS_PER_ORB,
is_reconfig,
isl_shift=0,
idx_offset=0
)
# TODO: add support for motif and line
elif isl_selection == "isls_none":
satgen.generate_empty_isls(
output_generated_data_dir + "/" + name + "/isls.txt"
)
# Deprecated:
elif isl_selection == "isls_custom":
isls.generate_custom_isls(
output_generated_data_dir + "/" + name + "/isls.txt",
TOPO_FILE,
CLUSTER_CONFIG["num_masters"],
CLUSTER_CONFIG["num_workers"],
CLUSTER_CONFIG["num_gs"]
)
else:
raise ValueError("Unknown ISL selection: " + isl_selection)
# Description
print("Generating description...")
satgen.generate_description(
output_generated_data_dir + "/" + name + "/description.txt",
self.MAX_GSL_LENGTH_M,
self.MAX_ISL_LENGTH_M
)
# GSL interfaces
ground_stations = satgen.read_ground_stations_extended(
output_generated_data_dir + "/" + name + "/ground_stations.txt"
)
if dynamic_state_algorithm == "algorithm_free_one_only_gs_relays" \
or dynamic_state_algorithm == "algorithm_free_one_only_over_isls":
gsl_interfaces_per_satellite = 1
elif dynamic_state_algorithm == "algorithm_paired_many_only_over_isls":
gsl_interfaces_per_satellite = len(ground_stations)
else:
raise ValueError("Unknown dynamic state algorithm: " + dynamic_state_algorithm)
print("Generating GSL interfaces info..")
satgen.generate_simple_gsl_interfaces_info(
output_generated_data_dir + "/" + name + "/gsl_interfaces_info.txt",
self.NUM_ORBS * self.NUM_SATS_PER_ORB,
len(ground_stations),
gsl_interfaces_per_satellite, # GSL interfaces per satellite
1, # (GSL) Interfaces per ground station
1, # Aggregate max. bandwidth satellite (unit unspecified)
1 # Aggregate max. bandwidth ground station (same unspecified unit)
)
# Forwarding state
print("Generating forwarding state...")
helper_dynamic_state.help_dynamic_state(
output_generated_data_dir,
CLUSTER_CONFIG,
CLUSTER_DIR,
num_threads, # Number of threads
name,
time_step_ms,
duration_s,
self.MAX_GSL_LENGTH_M,
self.MAX_ISL_LENGTH_M,
dynamic_state_algorithm,
False
)