NREL / routee-compass

An energy-aware routing engine
https://nrel.github.io/routee-compass/
BSD 3-Clause "New" or "Revised" License
10 stars 5 forks source link

Add state keys to path result #240

Closed nreinicke closed 3 weeks ago

nreinicke commented 3 months ago

Looking at an example path returned from compass:

{'features': [{'geometry': {'coordinates': [[-104.96916961669922,
      39.77902603149414],
     [-104.96910095214844, 39.77896499633789],
     [-104.96887969970703, 39.77878189086914],
     [-104.96884155273438, 39.778751373291016]],
    'type': 'LineString'},
   'id': 11305,
   'properties': {'access_cost': 0.0,
    'edge_id': 11305,
    'result_state': [0.00137196828747872,
     0.055087682159255455,
     0.025957737726286807],
    'traversal_cost': 0.0181789351125543},
   'type': 'Feature'},
 ...
}

~It's not immediately clear what value is what in result_state. While we can cross reference this information from result.route.state_model,~

It's impossible to tell which value is which in result_state since the indices are not captured directly in the result.

it might be more ergonomic to have them in the path directly, maybe something like result_state_{state_feature}_{state_feature_unit}.

robfitzgerald commented 2 months ago

right. this was supposed to be solved by the "state" section of the "route" object:

            "state_model": {
                "battery_state": {
                    "format": {
                        "floating_point": {
                            "initial": 100.0
                        }
                    },
                    "type": "soc",
                    "unit": "percent"
                },
                "distance": {
                    "distance_unit": "miles",
                    "initial": 0.0
                },
                "energy_electric": {
                    "energy_unit": "kilowatt_hours",
                    "initial": 0.0
                },
                "time": {
                    "initial": 0.0,
                    "time_unit": "minutes"
                }
            }

but i'm realizing the index is missing from each object. or, since it's a map, we can't guarantee ordering. so, i think that means this task is either to add the index (explicitly):

                "battery_state": {
                    "index": 0,
                    "format": {
                        "floating_point": {
                            "initial": 100.0
                        }
                    },
                    "type": "soc",
                    "unit": "percent"
                }

or make these an array (index implicit):

            "state_model": [
                {
                    "name": "battery_state",
                    "format": {
                        "floating_point": {
                            "initial": 100.0
                        }
                    },
                    "type": "soc",
                    "unit": "percent"
                }
            ]

thoughts?

nreinicke commented 2 months ago

Yeah those are both good solutions. I think I would favor adding the index into the entry explicitly since it makes it obvious what it means.

robfitzgerald commented 3 weeks ago

Addressed via #251.