Skip to content
Snippets Groups Projects
Commit e2b8bd48 authored by David Radu's avatar David Radu
Browse files

major update commit before for OR paper.

parent fe4dba0b
No related branches found
No related tags found
No related merge requests found
......@@ -1060,7 +1060,7 @@ def get_partition_index(input_dict, deployment_vector, capacity_split='per_tech'
for region, tech in key_list:
index_dict[region][tech] = [i + 1 for i in index_dict[region][tech]]
print(index_dict)
# print(index_dict)
return index_dict
......
......@@ -101,23 +101,22 @@ elif parameters['solution_method']['RAND']['set']:
for i in range(it):
random_locations = []
random_locations_index = []
all_locations = []
for region in parameters['deployment_vector'].keys():
for tech in parameters['technologies']:
population = input_dict['coordinates_data'][region][tech]
k = parameters['deployment_vector'][region][tech]
all_locations.extend(population)
random_locations.extend(sample(population, k))
all_locations = []
for region in parameters['deployment_vector'].keys():
for tech in parameters['technologies']:
all_locations.extend(input_dict['coordinates_data'][region][tech])
random_locations_index = []
for loc in random_locations:
idx = all_locations.index(loc)
random_locations_index.append(idx)
random_locations_index.append(idx + 1)
random_locations_index = sorted(random_locations_index)
random_locations_index = [i-1 for i in sorted(random_locations_index)]
xs = zeros(shape=input_dict['criticality_data'].shape[1])
xs[random_locations_index] = 1
......@@ -128,6 +127,7 @@ elif parameters['solution_method']['RAND']['set']:
if objective > best_objective:
best_objective = objective
best_random_locations = random_locations
random_locations_dict = {parameters['technologies'][0]: best_random_locations}
retrieve_site_data(c, parameters, input_dict, output_folder, random_locations_dict, best_objective)
......
......@@ -870,22 +870,22 @@ def retrieve_index_dict(model_parameters, coordinate_dict):
d = model_parameters['deployment_vector']
if isinstance(d[list(d.keys())[0]], int):
dict_deployment = d
print(dict_deployment)
# print(dict_deployment)
n = sum(dict_deployment[item] for item in dict_deployment)
print(n)
# print(n)
partitions = [item for item in d]
print(partitions)
# print(partitions)
if model_parameters['deployment_constraint'] == 'country':
indices = get_partition_index(coordinate_dict, d, capacity_split='per_country')
elif model_parameters['deployment_constraint'] == 'tech':
indices = get_partition_index(coordinate_dict, d, capacity_split='per_tech')
else:
dict_deployment = concatenate_dict_keys(d)
print(dict_deployment)
# print(dict_deployment)
n = sum(dict_deployment[item] for item in dict_deployment)
print(n)
# print(n)
partitions = [item for item in dict_deployment]
print(partitions)
# print(partitions)
indices = concatenate_dict_keys(get_partition_index(coordinate_dict, d, capacity_split='per_country_and_tech'))
return n, dict_deployment, partitions, indices
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment