hive icon indicating copy to clipboard operation
hive copied to clipboard

Validate dispatcher valid_dispatch_states on input

Open nreinicke opened this issue 3 years ago • 1 comments

I recently added this to the manhattan.yaml scenario file:

dispatcher:
  valid_dispatch_states:
    - idle
    - repositioning
    - reserve_base 

The model ran without complaint but the true value for reserve_base should have been reservebase.

We should validate these inputs and compare them to our list of vehicle state names, only accepting valid names.

nreinicke avatar Oct 27 '22 17:10 nreinicke

Here is where the strings get loaded from the input configurations and a good candidate for validating them: https://github.com/NREL/hive/blob/2220709fc90df31919bd10f313e5b89be9372d95/nrel/hive/config/dispatcher_config.py#L46

These strings should be converted into a VehicleStateType. It probably makes sense to add a from_string classmethod to that enum while we're at it (similar to this).

Then, we'll need to update the dispatcher at this following location to use the vehicle.vehicle_state.vehicle_state_type when looking in the environment.config.dispatcher.valid_dispatch_states:

https://github.com/NREL/hive/blob/2220709fc90df31919bd10f313e5b89be9372d95/nrel/hive/dispatcher/instruction_generator/dispatcher.py#L55

nreinicke avatar Apr 23 '23 15:04 nreinicke