Skip to content

Commit

Permalink
Merge pull request #74 from edwardoughton/update_supply
Browse files Browse the repository at this point in the history
Update supply
  • Loading branch information
edwardoughton committed Aug 6, 2021
2 parents acca842 + 03778dc commit 417ddc7
Show file tree
Hide file tree
Showing 11 changed files with 850 additions and 237 deletions.
4 changes: 2 additions & 2 deletions scripts/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def generate_business_model_options():
scenarios = ['S1_25_10_2', 'S2_200_50_5', 'S3_400_100_10']
generation_core_types = ['4G_epc','5G_nsa', '5G_sa']
backhaul_types = ['microwave', 'fiber']
sharing_types = ['baseline', 'passive', 'active', 'shared']
sharing_types = ['baseline', 'passive', 'active', 'srn']
networks_types = ['baseline']
spectrum_types = ['baseline']
tax_types = ['baseline']
Expand Down Expand Up @@ -179,7 +179,7 @@ def generate_mixed_options():
scenarios = ['S1_25_10_2', 'S2_200_50_5', 'S3_400_100_10']
generation_core_types = ['4G_epc','5G_nsa', '5G_sa']
backhaul_types = ['microwave', 'fiber']
sharing_types = ['shared']
sharing_types = ['srn']
networks_types = ['baseline']
spectrum_types = ['low']
tax_types = ['low']
Expand Down
47 changes: 36 additions & 11 deletions src/pytal/costs.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,13 @@ def greenfield_4g(region, strategy, costs, global_parameters,
if not key in shared_assets:
cost_structure[key] = value
else:
value = value / networks
cost_structure[key] = value
if sharing == 'srn':
if geotype == 'urban' or geotype == 'suburban':
cost_structure[key] = value
else:
cost_structure[key] = value / networks
else:
cost_structure[key] = value / networks

return cost_structure

Expand Down Expand Up @@ -319,8 +324,13 @@ def upgrade_to_4g(region, strategy, costs, global_parameters,
if not key in shared_assets:
cost_structure[key] = value
else:
value = value / networks
cost_structure[key] = value
if sharing == 'srn':
if geotype == 'urban' or geotype == 'suburban':
cost_structure[key] = value
else:
cost_structure[key] = value / networks
else:
cost_structure[key] = value / networks

return cost_structure

Expand Down Expand Up @@ -395,8 +405,13 @@ def greenfield_5g_nsa(region, strategy, costs,
if not key in shared_assets:
cost_structure[key] = value
else:
value = value / networks
cost_structure[key] = value
if sharing == 'srn':
if geotype == 'urban' or geotype == 'suburban':
cost_structure[key] = value
else:
cost_structure[key] = value / networks
else:
cost_structure[key] = value / networks

return cost_structure

Expand Down Expand Up @@ -468,8 +483,13 @@ def upgrade_to_5g_nsa(region, strategy, costs,
if not key in shared_assets:
cost_structure[key] = value
else:
value = value / networks
cost_structure[key] = value
if sharing == 'srn':
if geotype == 'urban' or geotype == 'suburban':
cost_structure[key] = value
else:
cost_structure[key] = value / networks
else:
cost_structure[key] = value / networks

return cost_structure

Expand Down Expand Up @@ -545,8 +565,13 @@ def greenfield_5g_sa(region, strategy, costs,
if not key in shared_assets:
cost_structure[key] = value
else:
value = value / networks
cost_structure[key] = value
if sharing == 'srn':
if geotype == 'urban' or geotype == 'suburban':
cost_structure[key] = value
else:
cost_structure[key] = value / networks
else:
cost_structure[key] = value / networks

return cost_structure

Expand Down Expand Up @@ -1209,7 +1234,7 @@ def calc_costs(region, cost_structure, backhaul, backhaul_quantity,
'backhaul',
'cloud_backhaul',
],
'shared': [
'srn': [
'single_sector_antenna',
'single_remote_radio_unit',
'io_fronthaul',
Expand Down
8 changes: 4 additions & 4 deletions src/pytal/supply.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,11 +366,11 @@ def estimate_backhaul_upgrades(region, strategy, country_parameters):
backhaul = strategy.split('_')[2]
geotype = region['geotype'].split(' ')[0]
networks = country_parameters['networks']['baseline' + '_' + geotype]
all_sites = (region['new_mno_sites'] + region['upgraded_mno_sites']) / networks
all_sites = (region['new_mno_sites'] + region['upgraded_mno_sites']) #/ networks

if backhaul == 'fiber':

existing_fiber = region['backhaul_fiber'] / networks
existing_fiber = math.floor(region['backhaul_fiber'] / networks)

if existing_fiber < all_sites:
region['backhaul_new'] = math.ceil(all_sites - existing_fiber)
Expand All @@ -379,8 +379,8 @@ def estimate_backhaul_upgrades(region, strategy, country_parameters):

elif backhaul == 'microwave':

existing_backhaul = (region['backhaul_microwave'] +
region['backhaul_fiber']) / networks
existing_backhaul = math.floor((region['backhaul_microwave'] +
region['backhaul_fiber']) / networks)

if existing_backhaul < all_sites:
region['backhaul_new'] = math.ceil(all_sites - existing_backhaul)
Expand Down
97 changes: 79 additions & 18 deletions tests/test_costs.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,20 +254,34 @@ def test_greenfield_4g(setup_region, setup_option, setup_costs,
setup_region[0]['sites_3G'] = 3
setup_region[0]['network_site_density'] = 2

#test shared wholesale core network
#test srn wholesale core network
cost_structure = greenfield_4g(setup_region[0],
'4G_epc_microwave_shared_baseline_baseline_baseline',
'4G_epc_microwave_srn_baseline_baseline_baseline',
setup_costs, setup_global_parameters,
setup_core_lut, setup_country_parameters)

assert cost_structure['core_node'] == (
(setup_costs['core_node_epc'] * 2) /
(setup_region[0]['new_mno_sites'] + setup_region[0]['upgraded_mno_sites']))
assert cost_structure['regional_node'] == (
(setup_costs['regional_node_epc'] * 2) /
(setup_region[0]['new_mno_sites'] + setup_region[0]['upgraded_mno_sites']))

#test srn wholesale core network
setup_region[0]['geotype'] = 'rural'
cost_structure = greenfield_4g(setup_region[0],
'4G_epc_microwave_srn_baseline_baseline_baseline',
setup_costs, setup_global_parameters,
setup_core_lut, setup_country_parameters)

assert cost_structure['core_node'] == (
(setup_costs['core_node_epc'] * 2) /
(setup_region[0]['new_mno_sites'] + setup_region[0]['upgraded_mno_sites']) /
(setup_country_parameters['networks']['baseline_urban']))
(setup_country_parameters['networks']['baseline_rural']))
assert cost_structure['regional_node'] == (
(setup_costs['regional_node_epc'] * 2) /
(setup_region[0]['new_mno_sites'] + setup_region[0]['upgraded_mno_sites']) /
(setup_country_parameters['networks']['baseline_urban']))
(setup_country_parameters['networks']['baseline_rural']))


def test_upgrade_to_4g(setup_region, setup_option, setup_costs,
Expand Down Expand Up @@ -314,9 +328,20 @@ def test_upgrade_to_4g(setup_region, setup_option, setup_costs,
setup_region[0]['sites_3G'] = 3
setup_region[0]['network_site_density'] = 2

#test shared wholesale core network
#test srn wholesale core network
cost_structure = upgrade_to_4g(setup_region[0],
'4G_epc_microwave_shared_baseline_baseline_baseline',
'4G_epc_microwave_srn_baseline_baseline_baseline',
setup_costs, setup_global_parameters,
setup_core_lut, setup_country_parameters)

assert cost_structure['regional_node'] == int(
(setup_costs['regional_node_epc'] * 2) /
(setup_region[0]['new_mno_sites'] + setup_region[0]['upgraded_mno_sites']))

#test srn wholesale core network
setup_region[0]['geotype'] = 'rural'
cost_structure = upgrade_to_4g(setup_region[0],
'4G_epc_microwave_srn_baseline_baseline_baseline',
setup_costs, setup_global_parameters,
setup_core_lut, setup_country_parameters)

Expand Down Expand Up @@ -376,19 +401,32 @@ def test_greenfield_5g_nsa(setup_region, setup_option, setup_costs,
setup_region[0]['sites_3G'] = 3
setup_region[0]['network_site_density'] = 2

#test shared wholesale core network
#test srn wholesale core network
cost_structure = greenfield_5g_nsa(setup_region[0],
'5G_nsa_microwave_shared_baseline_baseline_baseline',
'5G_nsa_microwave_srn_baseline_baseline_baseline',
setup_costs, setup_global_parameters,
setup_core_lut, setup_country_parameters)

assert cost_structure['core_node'] == (
(setup_costs['core_node_nsa'] * 2) /
(setup_region[0]['new_mno_sites'] + setup_region[0]['upgraded_mno_sites']))
assert cost_structure['regional_node'] == (
(setup_costs['regional_node_nsa'] * 2) /
(setup_region[0]['new_mno_sites'] + setup_region[0]['upgraded_mno_sites']))

#test srn wholesale core network
setup_region[0]['geotype'] = 'rural'
cost_structure = greenfield_5g_nsa(setup_region[0],
'5G_nsa_microwave_srn_baseline_baseline_baseline',
setup_costs, setup_global_parameters,
setup_core_lut, setup_country_parameters)

assert cost_structure['core_node'] == ((setup_costs['core_node_nsa'] * 2) /
(setup_region[0]['new_mno_sites'] + setup_region[0]['upgraded_mno_sites']) /
(setup_country_parameters['networks']['baseline_urban']))
assert cost_structure['regional_node'] == (
(setup_costs['regional_node_nsa'] * 2) /
(setup_region[0]['new_mno_sites'] + setup_region[0]['upgraded_mno_sites']) /
(setup_region[0]['new_mno_sites'] + setup_region[0]['upgraded_mno_sites']) /
(setup_country_parameters['networks']['baseline_urban']))


Expand Down Expand Up @@ -436,16 +474,28 @@ def test_upgrade_to_5g_nsa(setup_region, setup_option, setup_costs,
setup_region[0]['sites_3G'] = 3
setup_region[0]['network_site_density'] = 2

#test shared wholesale core network
#test srn wholesale core network
cost_structure = upgrade_to_5g_nsa(setup_region[0],
'5G_nsa_microwave_shared_baseline_baseline_baseline',
'5G_nsa_microwave_srn_baseline_baseline_baseline',
setup_costs, setup_global_parameters,
setup_core_lut, setup_country_parameters)

assert cost_structure['core_node'] == ((setup_costs['core_node_nsa'] * 2) /
(setup_region[0]['new_mno_sites'] + setup_region[0]['upgraded_mno_sites']))
assert cost_structure['regional_node'] == (
(setup_costs['regional_node_nsa'] * 2) /
(setup_region[0]['new_mno_sites'] + setup_region[0]['upgraded_mno_sites']))

#test srn wholesale core network
setup_region[0]['geotype'] = 'rural'
cost_structure = upgrade_to_5g_nsa(setup_region[0],
'5G_nsa_microwave_srn_baseline_baseline_baseline',
setup_costs, setup_global_parameters,
setup_core_lut, setup_country_parameters)

assert cost_structure['core_node'] == ((setup_costs['core_node_nsa'] * 2) /
(setup_region[0]['new_mno_sites'] + setup_region[0]['upgraded_mno_sites']) /
(setup_country_parameters['networks']['baseline_urban']))

assert cost_structure['regional_node'] == (
(setup_costs['regional_node_nsa'] * 2) /
(setup_region[0]['new_mno_sites'] + setup_region[0]['upgraded_mno_sites']) /
Expand Down Expand Up @@ -503,20 +553,31 @@ def test_greenfield_5g_sa(setup_region, setup_option, setup_costs,
setup_region[0]['sites_3G'] = 3
setup_region[0]['network_site_density'] = 2

#test shared wholesale core network
#test srn wholesale core network
cost_structure = greenfield_5g_sa(setup_region[0],
'5G_sa_microwave_shared_baseline_baseline_baseline',
'5G_sa_microwave_srn_baseline_baseline_baseline',
setup_costs, setup_global_parameters,
setup_core_lut, setup_country_parameters)
assert cost_structure['core_node'] == (
(setup_costs['core_node_sa'] * 2) /
(setup_region[0]['new_mno_sites'] + setup_region[0]['upgraded_mno_sites']))
assert cost_structure['regional_node'] == (
(setup_costs['regional_node_sa'] * 2) /
(setup_region[0]['new_mno_sites'] + setup_region[0]['upgraded_mno_sites']))

setup_region[0]['geotype'] = 'rural'
cost_structure = greenfield_5g_sa(setup_region[0],
'5G_sa_microwave_srn_baseline_baseline_baseline',
setup_costs, setup_global_parameters,
setup_core_lut, setup_country_parameters)
assert cost_structure['core_node'] == (
(setup_costs['core_node_sa'] * 2) /
(setup_region[0]['new_mno_sites'] + setup_region[0]['upgraded_mno_sites']) /
(setup_country_parameters['networks']['baseline_urban']))
(setup_country_parameters['networks']['baseline_rural']))
assert cost_structure['regional_node'] == (
(setup_costs['regional_node_sa'] * 2) /
(setup_region[0]['new_mno_sites'] + setup_region[0]['upgraded_mno_sites']) /
(setup_country_parameters['networks']['baseline_urban']))
(setup_country_parameters['networks']['baseline_rural']))


def test_upgrade_to_5g_sa(setup_region, setup_option, setup_costs,
Expand Down Expand Up @@ -566,9 +627,9 @@ def test_upgrade_to_5g_sa(setup_region, setup_option, setup_costs,
setup_region[0]['sites_3G'] = 3
setup_region[0]['network_site_density'] = 2

#test shared wholesale core network
#test srn wholesale core network
cost_structure = upgrade_to_5g_sa(setup_region[0],
'5G_sa_microwave_shared_baseline_baseline_baseline',
'5G_sa_microwave_srn_baseline_baseline_baseline',
setup_costs, setup_global_parameters,
setup_core_lut, setup_country_parameters)

Expand Down
23 changes: 19 additions & 4 deletions tests/test_supply.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,21 @@ def test_find_site_density(

assert answer == 2

answer = find_site_density(
{'demand_mbps_km2': 0.005, #OBF is high on this test, hence large demand.
'geotype': 'urban'},
{ #generation_core_backhaul_sharing_networks_spectrum_tax
'scenario': 'S1_50_5_1',
'strategy': '5G_epc_microwave_baseline_baseline_high_high_high'
},
setup_global_parameters,
setup_country_parameters,
setup_lookup,
setup_ci
)

assert answer == 0.01


def test_estimate_site_upgrades(
setup_region,
Expand Down Expand Up @@ -242,15 +257,15 @@ def test_estimate_backhaul_upgrades(
setup_country_parameters
)

assert answer['backhaul_new'] == 27
assert answer['backhaul_new'] == 87

answer = estimate_backhaul_upgrades(
setup_region[0],
'4G_epc_microwave_baseline_baseline_baseline_baseline',
setup_country_parameters
)

assert answer['backhaul_new'] == 10
assert answer['backhaul_new'] == 70

setup_region[0]['backhaul_fiber'] = 100

Expand All @@ -260,7 +275,7 @@ def test_estimate_backhaul_upgrades(
setup_country_parameters
)

assert answer['backhaul_new'] == 0
assert answer['backhaul_new'] == 57

setup_region[0]['backhaul_fiber'] = 0
setup_region[0]['backhaul_microwave'] = 100
Expand All @@ -271,7 +286,7 @@ def test_estimate_backhaul_upgrades(
setup_country_parameters
)

assert answer['backhaul_new'] == 0
assert answer['backhaul_new'] == 57


def test_lookup_capacity():
Expand Down
Loading

0 comments on commit 417ddc7

Please sign in to comment.