Skip to content

Commit 273859c

Browse files
authored
Merge pull request #142 from NREL/rjf/no-stations-charger-search
skip charge instructions with no valid stations
2 parents 75b0985 + 10352ed commit 273859c

File tree

5 files changed

+138
-1
lines changed

5 files changed

+138
-1
lines changed

nrel/hive/dispatcher/instruction_generator/instruction_generator_ops.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,12 @@ def instruct_vehicles_to_dispatch_to_station(
186186
if len(instructions) >= n:
187187
break
188188

189+
valid_stations = simulation_state.get_stations(
190+
filter_function=lambda s: s.membership.grant_access_to_membership(veh.membership)
191+
)
192+
if len(valid_stations) == 0:
193+
break
194+
189195
if charging_search_type == ChargingSearchType.NEAREST_SHORTEST_QUEUE:
190196
# use the simple weighted euclidean distance ranking
191197

@@ -203,7 +209,7 @@ def instruct_vehicles_to_dispatch_to_station(
203209

204210
nearest_station = H3Ops.nearest_entity(
205211
geoid=veh.geoid,
206-
entities=simulation_state.stations.values(),
212+
entities=valid_stations,
207213
entity_search=simulation_state.s_search,
208214
sim_h3_search_resolution=simulation_state.sim_h3_search_resolution,
209215
max_search_distance_km=max_search_radius_km,
@@ -284,6 +290,12 @@ def get_nearest_valid_station_distance(
284290
:return: the distance in km to the nearest valid station
285291
"""
286292

293+
valid_stations = simulation_state.get_stations(
294+
filter_function=lambda s: s.membership.grant_access_to_membership(vehicle.membership)
295+
)
296+
if len(valid_stations) == 0:
297+
return 99999999999999
298+
287299
if charging_search_type == ChargingSearchType.NEAREST_SHORTEST_QUEUE:
288300
# use the simple weighted euclidean distance ranking
289301

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
base_id,lat,lon,station_id,stall_count
2+
b1,39.754695,-104.988116,,300
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
sim:
2+
# (required) any name you want to give your simulation (go ahead, be creative);
3+
sim_name: denver_demo
4+
5+
# (required) the start time of the simulation;
6+
start_time: "1970-01-01T00:00:00"
7+
8+
# (required) the end time of the simulation;
9+
end_time: "1970-01-02T00:00:00"
10+
11+
# (optional) how many seconds does a single hive time step represent;
12+
# must be an integer; generally, 60 seconds is the recommended value based on internal testing and validation;
13+
timestep_duration_seconds: 60
14+
15+
# (optional) represents how long a request will be active in the simulation;
16+
# after this timeout the request is destroyed;
17+
request_cancel_time_seconds: 600
18+
19+
# (optional) what is the atomic unit of the simulation;
20+
# 15 is equivalent to approximately 1 meter;
21+
sim_h3_resolution: 15
22+
23+
# (optional) which h3 resolution should we search for entities?
24+
sim_h3_search_resolution: 7
25+
26+
# (optional) if using human drivers, what type of schedule should we use?
27+
schedule_type: "time_range"
28+
29+
network:
30+
# (required) what type of network to use; options: osm_network | euclidean
31+
network_type: osm_network
32+
33+
# (optional) if no speed exists in the road network data input, we fill it in with this value;
34+
default_speed_kmph: 40.0
35+
36+
input:
37+
# (required)
38+
vehicles_file: denver_demo_vehicles_no_stations.csv
39+
40+
# (required)
41+
requests_file: denver_demo_requests.csv
42+
43+
# (required)
44+
bases_file: denver_demo_no_stations.csv
45+
46+
# (required)
47+
stations_file: denver_demo_no_stations.csv
48+
49+
# (optional) only used with `network_type: osm_network`
50+
road_network_file: downtown_denver_network.json
51+
52+
# (optional) outline a geofence for control purposes
53+
geofence_file: downtown_denver.geojson
54+
55+
# (optional) defaults to zero cost if not specified
56+
rate_structure_file: rate_structure.csv
57+
58+
# (optional) defaults to zero cost if not specified
59+
charging_price_file: denver_charging_prices_by_geoid.csv
60+
61+
# (optional) default is no demand forecasting
62+
demand_forecast_file: denver_demand.csv
63+
64+
dispatcher:
65+
# (optional) how often should we issue dispatching instructions?
66+
default_update_interval_seconds: 600
67+
68+
# (optional) ingnore searching for any entity beyond this threshold
69+
max_search_radius_km: 100.0
70+
71+
## Parameters for the default matching dispatcher
72+
73+
# (optional) don't match requests to vehicles beyond this range
74+
matching_range_km_threshold: 20
75+
76+
# (optional) which states will the default matching dispatcher consider valid?
77+
valid_dispatch_states:
78+
- Idle
79+
- Repositioning
80+
81+
## Parameters for the default charging dispatcher
82+
83+
# (optional) how to search for stations? nearest_shortest_queue | shortest_time_to_charge
84+
charging_search_type: nearest_shortest_queue
85+
86+
# (optional) ignore charging at stations when remaining range is greater than this plus the nearest station distance
87+
charging_range_km_threshold: 20
88+
89+
# (optional) ignore charging at stations when remaining range is greater than this
90+
charging_range_km_soft_threshold: 50
91+
92+
# (optional) ignore base charging at bases more than this threshold
93+
base_charging_range_km_threshold: 100
94+
95+
## Parameters for the driver control
96+
97+
# (optional) SOC target for fast charging at a station
98+
ideal_fastcharge_soc_limit: 0.8
99+
100+
# (optional) how long do drivers idle before returning to a base?
101+
idle_time_out_seconds: 1800
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
station_id,lat,lon,charger_count,charger_id,on_shift_access
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
vehicle_id,lat,lon,mechatronics_id,initial_soc,schedule_id,home_base_id
2+
v1,39.754695,-104.988116,leaf_50,0.3
3+
v2,39.754695,-104.988116,leaf_50,0.3
4+
v3,39.754695,-104.988116,leaf_50,0.3
5+
v4,39.754695,-104.988116,leaf_50,0.3
6+
v5,39.754695,-104.988116,leaf_50,0.3
7+
v6,39.754695,-104.988116,leaf_50,0.3
8+
v7,39.754695,-104.988116,leaf_50,0.3
9+
v8,39.754695,-104.988116,leaf_50,0.3
10+
v9,39.754695,-104.988116,leaf_50,0.3
11+
v10,39.754695,-104.988116,leaf_50,0.3
12+
v11,39.754695,-104.988116,leaf_50,0.3
13+
v12,39.754695,-104.988116,leaf_50,0.3
14+
v13,39.754695,-104.988116,leaf_50,0.3
15+
v14,39.754695,-104.988116,toyota_corolla,0.3
16+
v15,39.754695,-104.988116,toyota_corolla,0.3
17+
v16,39.754695,-104.988116,toyota_corolla,0.3
18+
v17,39.754695,-104.988116,toyota_corolla,0.3
19+
v18,39.754695,-104.988116,toyota_corolla,0.3
20+
v19,39.754695,-104.988116,toyota_corolla,0.3
21+
v20,39.754695,-104.988116,toyota_corolla,0.3

0 commit comments

Comments
 (0)