Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- help = False
- conn_string = "host='localhost' dbname='slovakia' user='postgres' password='admin'"
- # print the connection string we will use to connect
- print("Connecting to database\n ->%s" % (conn_string))
- # get a connection, if a connect cannot be made an exception will be raised here
- conn = psycopg2.connect(conn_string)
- make_new_matrix_to_file("all_data_100_60_00.matrix", 100, 60, help)
- new_m = load_matrix_from_file('all_data_120_00.matrix')
- # use when you want to show new grid at map ... make one
- #put_matrix_coordinates_into_json_file("matrix_" + str(len(new_m)) + "_cells.json", new_m)
- matrix = []
- # delete cells which have less than 100 citizens in them
- for c in new_m:
- if c.population > 100:
- matrix.append(c)
- matrix = set_ranking(matrix)
- # load existing charging stations from json file
- existing_charging_stations = get_existing_stations_from_file("sk_stations.json")
- # make array of Stations_in_cell type, so we will know how many stations should belong to the cell
- stations_in_cells_arr = set_count_of_stations_in_cell(matrix, existing_charging_stations)
- # make new positions for stations
- # new_charging_stations = make_new_positions_of_stations_random(stations_in_cells_arr)
- new_charging_stations = make_new_positions_of_sations_parts(stations_in_cells_arr, 4)
- # new_charging_stations = make_new_positions_of_sations_distance(stations_in_cells_arr)
- # make json files to store results of algorithm
- if len(existing_charging_stations) != len(new_charging_stations):
- print("Count of new stations and existing stations is not equal")
- print(len(existing_charging_stations), len(new_charging_stations))
- else:
- make_files_with_positions(existing_charging_stations,
- new_charging_stations,
- "./results/existing_without_120_0_0_0_10_10_10_0_0_0_parts.json",
- "./results/new_without_120_0_0_0_10_10_10_0_0_0_parts.json")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement