Skip to content

Commit

Permalink
Fix if ISLs go out of range
Browse files Browse the repository at this point in the history
  • Loading branch information
snkas committed Oct 9, 2020
1 parent 92ca63b commit 41ef4cc
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions satgenpy/satgen/dynamic_state/generate_dynamic_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,30 +129,37 @@ def generate_dynamic_state_at(
print("\nISL INFORMATION")

# ISL edges
isls_valid = 0
isls_invalid = 0
total_num_isls = 0
num_isls_per_sat = [0] * len(satellites)
sat_neighbor_to_if = {}
for (a, b) in list_isls:

# Only ISLs which are close enough are considered
# ISLs are not permitted to exceed their maximum distance
# TODO: Technically, they can (could just be ignored by forwarding state calculation),
# TODO: but practically, defining a permanent ISL between two satellites which
# TODO: can go out of distance is generally unwanted
sat_distance_m = sat_distance(satellites[a], satellites[b], str(time))
if sat_distance_m <= max_isl_length_m:
sat_net_graph_only_satellites_with_isls.add_edge(
a, b, weight=sat_distance_m
if sat_distance_m > max_isl_length_m:
raise ValueError(
"The distance between two satellites (%d and %d) "
"with an ISL exceeded the maximum ISL length (%.2fm > %.2fm at t=%dns)"
% (a, b, sat_distance_m, max_isl_length_m, time_since_epoch_ns)
)
isls_valid += 1
sat_neighbor_to_if[(a, b)] = num_isls_per_sat[a]
sat_neighbor_to_if[(b, a)] = num_isls_per_sat[b]
num_isls_per_sat[a] += 1
num_isls_per_sat[b] += 1
else:
isls_invalid += 1

# Add to networkx graph
sat_net_graph_only_satellites_with_isls.add_edge(
a, b, weight=sat_distance_m
)

# Interface mapping of ISLs
sat_neighbor_to_if[(a, b)] = num_isls_per_sat[a]
sat_neighbor_to_if[(b, a)] = num_isls_per_sat[b]
num_isls_per_sat[a] += 1
num_isls_per_sat[b] += 1
total_num_isls += 1

if enable_verbose_logs:
print(" > Total ISLs............. " + str(len(list_isls)))
print(" >> Valid ISLs (used)... " + str(isls_valid))
print(" >> Invalid ISLs........ " + str(isls_invalid))
print(" > Min. ISLs/satellite.... " + str(np.min(num_isls_per_sat)))
print(" > Max. ISLs/satellite.... " + str(np.max(num_isls_per_sat)))

Expand Down

0 comments on commit 41ef4cc

Please sign in to comment.