Skip to content

Commit

Permalink
Correct fronthaul to average dist
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardoughton committed May 31, 2020
1 parent d3f196d commit 35050f1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
7 changes: 3 additions & 4 deletions src/pytal/costs.py
Expand Up @@ -140,7 +140,6 @@ def find_single_network_cost(region, option, costs, global_parameters,
regional_cost.append(total_cost)
regional_asset_cost.append(cost_by_asset)


counter = collections.Counter()
for d in regional_asset_cost:
counter.update(d)
Expand Down Expand Up @@ -640,8 +639,7 @@ def get_fronthaul_costs(region, costs):
Fiber fronthaul cost.
"""
average_cell_spacing_km = math.sqrt(1/region['network_site_density'])
average_cell_spacing_m = average_cell_spacing_km * 1000 #convert km to m
average_cell_spacing_m = (math.sqrt(1/region['network_site_density']) / 2) * 1000

tech = 'fiber_{}_m'.format(region['geotype'].split(' ')[0])
cost_per_meter = costs[tech]
Expand Down Expand Up @@ -680,6 +678,7 @@ def get_backhaul_costs(region, backhaul, costs, core_lut):
combined_key = '{}_{}'.format(region['GID_id'], age)
nodes += core_lut[asset_type][combined_key]
node_density_km2 = nodes / region['area_km2']

if node_density_km2 > 0:
ave_distance_to_a_node_m = (math.sqrt(1/node_density_km2) / 2) * 1000
else:
Expand Down Expand Up @@ -1127,6 +1126,7 @@ def calc_costs(region, cost_structure, backhaul, backhaul_quantity,
backhaul_fronthaul = [
'fronthaul',
'backhaul',
'cloud_backhaul',
]

civils = [
Expand All @@ -1139,7 +1139,6 @@ def calc_costs(region, cost_structure, backhaul, backhaul_quantity,
]

core = [
'cloud_backhaul',
'regional_node',
'regional_edge',
'core_node',
Expand Down
35 changes: 23 additions & 12 deletions tests/test_costs.py
Expand Up @@ -378,23 +378,29 @@ def test_upgrade_to_5g_sa(setup_region, setup_option, setup_costs,

def test_get_fronthaul_costs(setup_region, setup_costs):

setup_region[0]['network_site_density'] = 1

assert get_fronthaul_costs(setup_region[0], setup_costs) == int(
setup_costs['fiber_urban_m'] *
(math.sqrt(1/setup_region[0]['network_site_density']) / 2) * 1000)

setup_region[0]['network_site_density'] = 4

assert get_fronthaul_costs(setup_region[0], setup_costs) == int(
setup_costs['fiber_urban_m'] *
math.sqrt(1/setup_region[0]['network_site_density']) * 1000)
(math.sqrt(1/setup_region[0]['network_site_density']) / 2) * 1000)

setup_region[0]['network_site_density'] = 0.5

assert get_fronthaul_costs(setup_region[0], setup_costs) == int(
setup_costs['fiber_urban_m'] *
math.sqrt(1/setup_region[0]['network_site_density']) * 1000)
(math.sqrt(1/setup_region[0]['network_site_density']) / 2) * 1000)

setup_region[0]['network_site_density'] = 0.00001

assert get_fronthaul_costs(setup_region[0], setup_costs) == int(
setup_costs['fiber_urban_m'] *
math.sqrt(1/setup_region[0]['network_site_density']) * 1000)
(math.sqrt(1/setup_region[0]['network_site_density']) / 2) * 1000)


def test_get_backhaul_costs(setup_region, setup_costs, setup_core_lut):
Expand All @@ -417,6 +423,11 @@ def test_get_backhaul_costs(setup_region, setup_costs, setup_core_lut):
assert get_backhaul_costs(setup_region[0], 'fiber',
setup_costs, setup_core_lut) == (setup_costs['fiber_urban_m'] * 250)

setup_region[0]['area_km2'] = 8

assert get_backhaul_costs(setup_region[0], 'fiber',
setup_costs, setup_core_lut) == (setup_costs['fiber_urban_m'] * 500)

assert get_backhaul_costs(setup_region[0], 'incorrect_backhaul_tech_name',
setup_costs, setup_core_lut) == 0

Expand Down Expand Up @@ -575,9 +586,9 @@ def test_calc_costs(setup_region, setup_global_parameters, setup_country_paramet

answer, structure = calc_costs(setup_region[0],
{'single_sector_antenna': 1500,
'single_baseband_unit': 4000,
'tower': 10000,
'site_rental': 9600},
'single_baseband_unit': 4000,
'tower': 10000,
'site_rental': 9600},
'fiber',
6,
setup_global_parameters,
Expand Down Expand Up @@ -699,7 +710,7 @@ def test_find_single_network_cost(setup_region, setup_costs,
setup_core_lut
)

assert answer['network_cost'] == 734594.3#(110322 + 11952 + 11952 + 1027906)
assert answer['network_cost'] == 715999.9000000001#(110322 + 11952 + 11952 + 1027906)

setup_region[0]['new_sites'] = 0
setup_region[0]['upgraded_sites'] = 1
Expand All @@ -715,7 +726,7 @@ def test_find_single_network_cost(setup_region, setup_costs,
setup_core_lut
)

assert answer['network_cost'] == 1158837.9#63357.0 + 1027906
assert answer['network_cost'] == 1149540.7#63357.0 + 1027906

setup_region[0]['new_sites'] = 0
setup_region[0]['upgraded_sites'] = 1
Expand All @@ -731,7 +742,7 @@ def test_find_single_network_cost(setup_region, setup_costs,
setup_core_lut
)

assert answer['network_cost'] == 1158837.9#63357 + 1027906
assert answer['network_cost'] == 1149540.7#63357 + 1027906

setup_region[0]['new_sites'] = 1
setup_region[0]['upgraded_sites'] = 1
Expand All @@ -747,7 +758,7 @@ def test_find_single_network_cost(setup_region, setup_costs,
setup_core_lut
)

assert answer['network_cost'] == 1250638.4000000001#152690 + 1027906
assert answer['network_cost'] == 1232044.0000000002#152690 + 1027906

setup_region[0]['new_sites'] = 1
setup_region[0]['upgraded_sites'] = 0
Expand All @@ -763,7 +774,7 @@ def test_find_single_network_cost(setup_region, setup_costs,
setup_core_lut
)

assert answer['network_cost'] == 1583508.3#450398.0 + 1027906
assert answer['network_cost'] == 1375624.7999999998#450398.0 + 1027906

setup_region[0]['new_sites'] = 10
setup_region[0]['upgraded_sites'] = 10
Expand All @@ -779,4 +790,4 @@ def test_find_single_network_cost(setup_region, setup_costs,
setup_core_lut
)

assert answer['network_cost'] == 2750488.4000000004#1451800.0 + 1027906
assert answer['network_cost'] == 2619016.4000000004#1451800.0 + 1027906

0 comments on commit 35050f1

Please sign in to comment.