Skip to content

Commit

Permalink
Merge pull request #142 from NREL/rjf/no-stations-charger-search
Browse files Browse the repository at this point in the history
skip charge instructions with no valid stations
  • Loading branch information
nreinicke authored Mar 16, 2023
2 parents 75b0985 + 10352ed commit 273859c
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,12 @@ def instruct_vehicles_to_dispatch_to_station(
if len(instructions) >= n:
break

valid_stations = simulation_state.get_stations(
filter_function=lambda s: s.membership.grant_access_to_membership(veh.membership)
)
if len(valid_stations) == 0:
break

if charging_search_type == ChargingSearchType.NEAREST_SHORTEST_QUEUE:
# use the simple weighted euclidean distance ranking

Expand All @@ -203,7 +209,7 @@ def instruct_vehicles_to_dispatch_to_station(

nearest_station = H3Ops.nearest_entity(
geoid=veh.geoid,
entities=simulation_state.stations.values(),
entities=valid_stations,
entity_search=simulation_state.s_search,
sim_h3_search_resolution=simulation_state.sim_h3_search_resolution,
max_search_distance_km=max_search_radius_km,
Expand Down Expand Up @@ -284,6 +290,12 @@ def get_nearest_valid_station_distance(
:return: the distance in km to the nearest valid station
"""

valid_stations = simulation_state.get_stations(
filter_function=lambda s: s.membership.grant_access_to_membership(vehicle.membership)
)
if len(valid_stations) == 0:
return 99999999999999

if charging_search_type == ChargingSearchType.NEAREST_SHORTEST_QUEUE:
# use the simple weighted euclidean distance ranking

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
base_id,lat,lon,station_id,stall_count
b1,39.754695,-104.988116,,300
101 changes: 101 additions & 0 deletions nrel/hive/resources/scenarios/denver_downtown/denver_no_stations.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
sim:
# (required) any name you want to give your simulation (go ahead, be creative);
sim_name: denver_demo

# (required) the start time of the simulation;
start_time: "1970-01-01T00:00:00"

# (required) the end time of the simulation;
end_time: "1970-01-02T00:00:00"

# (optional) how many seconds does a single hive time step represent;
# must be an integer; generally, 60 seconds is the recommended value based on internal testing and validation;
timestep_duration_seconds: 60

# (optional) represents how long a request will be active in the simulation;
# after this timeout the request is destroyed;
request_cancel_time_seconds: 600

# (optional) what is the atomic unit of the simulation;
# 15 is equivalent to approximately 1 meter;
sim_h3_resolution: 15

# (optional) which h3 resolution should we search for entities?
sim_h3_search_resolution: 7

# (optional) if using human drivers, what type of schedule should we use?
schedule_type: "time_range"

network:
# (required) what type of network to use; options: osm_network | euclidean
network_type: osm_network

# (optional) if no speed exists in the road network data input, we fill it in with this value;
default_speed_kmph: 40.0

input:
# (required)
vehicles_file: denver_demo_vehicles_no_stations.csv

# (required)
requests_file: denver_demo_requests.csv

# (required)
bases_file: denver_demo_no_stations.csv

# (required)
stations_file: denver_demo_no_stations.csv

# (optional) only used with `network_type: osm_network`
road_network_file: downtown_denver_network.json

# (optional) outline a geofence for control purposes
geofence_file: downtown_denver.geojson

# (optional) defaults to zero cost if not specified
rate_structure_file: rate_structure.csv

# (optional) defaults to zero cost if not specified
charging_price_file: denver_charging_prices_by_geoid.csv

# (optional) default is no demand forecasting
demand_forecast_file: denver_demand.csv

dispatcher:
# (optional) how often should we issue dispatching instructions?
default_update_interval_seconds: 600

# (optional) ingnore searching for any entity beyond this threshold
max_search_radius_km: 100.0

## Parameters for the default matching dispatcher

# (optional) don't match requests to vehicles beyond this range
matching_range_km_threshold: 20

# (optional) which states will the default matching dispatcher consider valid?
valid_dispatch_states:
- Idle
- Repositioning

## Parameters for the default charging dispatcher

# (optional) how to search for stations? nearest_shortest_queue | shortest_time_to_charge
charging_search_type: nearest_shortest_queue

# (optional) ignore charging at stations when remaining range is greater than this plus the nearest station distance
charging_range_km_threshold: 20

# (optional) ignore charging at stations when remaining range is greater than this
charging_range_km_soft_threshold: 50

# (optional) ignore base charging at bases more than this threshold
base_charging_range_km_threshold: 100

## Parameters for the driver control

# (optional) SOC target for fast charging at a station
ideal_fastcharge_soc_limit: 0.8

# (optional) how long do drivers idle before returning to a base?
idle_time_out_seconds: 1800
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
station_id,lat,lon,charger_count,charger_id,on_shift_access
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
vehicle_id,lat,lon,mechatronics_id,initial_soc,schedule_id,home_base_id
v1,39.754695,-104.988116,leaf_50,0.3
v2,39.754695,-104.988116,leaf_50,0.3
v3,39.754695,-104.988116,leaf_50,0.3
v4,39.754695,-104.988116,leaf_50,0.3
v5,39.754695,-104.988116,leaf_50,0.3
v6,39.754695,-104.988116,leaf_50,0.3
v7,39.754695,-104.988116,leaf_50,0.3
v8,39.754695,-104.988116,leaf_50,0.3
v9,39.754695,-104.988116,leaf_50,0.3
v10,39.754695,-104.988116,leaf_50,0.3
v11,39.754695,-104.988116,leaf_50,0.3
v12,39.754695,-104.988116,leaf_50,0.3
v13,39.754695,-104.988116,leaf_50,0.3
v14,39.754695,-104.988116,toyota_corolla,0.3
v15,39.754695,-104.988116,toyota_corolla,0.3
v16,39.754695,-104.988116,toyota_corolla,0.3
v17,39.754695,-104.988116,toyota_corolla,0.3
v18,39.754695,-104.988116,toyota_corolla,0.3
v19,39.754695,-104.988116,toyota_corolla,0.3
v20,39.754695,-104.988116,toyota_corolla,0.3

0 comments on commit 273859c

Please sign in to comment.