-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
34 lines (23 loc) · 1.19 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import logging
from ev_station_solver.constants import CONSTANTS
from ev_station_solver.loading import load_locations
from ev_station_solver.logging import get_logger
from ev_station_solver.solving.solver import Solver
from ev_station_solver.solving.validator import Validator
# TODO: update paper pdf or fully remove it
logger = get_logger(__name__)
# use given starting solutions
locations = load_locations("medium").values
n_clusters = int(len(locations) * CONSTANTS["mu_charging"] / (2 * CONSTANTS["station_ub"]))
service_level = 0.95
s = Solver(vehicle_locations=locations, loglevel=logging.INFO, service_level=service_level)
# compute number of initial locations
s.add_samples(num=2)
s.add_initial_locations(n_stations=None, mode="clique")
s.add_initial_locations(n_stations=n_clusters, mode="k-means", seed=0)
s.add_initial_locations(n_stations=n_clusters, mode="random")
location_solutions = s.solve()
best_sol = location_solutions[-1] # take last solution (the one with optimal locations without filtering)
v = Validator(coordinates_cl=s.coordinates_potential_cl, vehicle_locations=locations, sol=best_sol)
validation_solutions = v.validate(desired_service_level=service_level)
logger.info("Finished")