hive icon indicating copy to clipboard operation
hive copied to clipboard

network speed updates

Open robfitzgerald opened this issue 3 years ago • 1 comments

in order to more realistically estimate travel times, HIVE should support reading tables describing speeds by time of day, of the form:

time_seconds link_id speed_kph
0 z235g 55
...
3600 z235g 53
...
  • to signal that there is a (CSV) file with speeds by time of day, we modify config.network to have a speeds_file: Optional[str] entry.
  • the file is assumed to be sorted by time
  • HIVE can use DictReaderStepper (stored as a new field on the OsmRoadNetwork class) to advance and update link attributes from a file pointer
    • see other examples of DictReaderStepper reading time of day-sorted inputs such as reading the requests.csv file
  • the time should be in the same SimTime system as the config.yaml describes (int or ISO datetime) so we can step through it as the example below
  • if a link id does not match the network, it should cause a failure
  • if a link id isn't represented in the file, we use the free flow travel time found on the network file (see OsmRoadNetwork.from_polygon)

where does this happen? turns out the update method stub already exists on the RoadNetwork class. the OsmRoadNetwork implementation of update would access the reader and, if there are entries that haven't been consumed where the column time >= the current sim time, then the rows are consumed and the network is updated.

for each consumed entry from the CSV, we compute the travel time from distance / speed and overwrite the entry for travel_time on that link. this will require interacting with the underlying networkx MultiDiGraph instance via get_edge_data.

the OsmRoadNetwork.update() method should be called from within a new SimulationUpdateFunction class called nrel.hive.state.simulation_state.update.network_update.py. this update function should be added to the default set of pre-step update functions in the Update.build method if env.network.speeds_file is not None.

robfitzgerald avatar Nov 15 '22 21:11 robfitzgerald

@nreinicke removing this from the issues, it balloons since we need to deal with #154 first.

robfitzgerald avatar Apr 18 '23 23:04 robfitzgerald