Skip to content

Make creating CH profile more configurable #493

Closed

Description

@karussell

If one wants to create CH profile for foot and bike but disable for car due to turn costs support this is not possible. We should implement a list of weightings where the CH profile should be configured for like chWeightings instead of chWeighting.

Furthermore it should be possible to use different weightings for different vehicles e.g. curvature for motorcycle and priority for bike.

Partially implemented through #623

Activity

  1. easbar commented on Jan 22, 2020

    @easbar
    Member

    This issue seems quite important considering the changes for #1776, #1708 and also #1820. Currently CH profiles are configured like this:

    graph.flag_encoders=car,motorcycle|turn_costs=true,bike
    prepare.ch.weightings=fastest|u_turn_costs=30,shortest
    prepare.ch.edge_based=edge_and_node
    

    which means:

    • there are three flag encoders/vehicles one of which needs turn cost support so there will be a TurnCostStorage
    • there are two weightings for CH preparation so for each of the vehicles there will be at least two CH preparations (one for each weighting)
    • for every encoder with turn_costs=true there will be in fact two preparations for each weighting (one node- and one edge-based). if we set prepare.ch.edge_based=off we only get the node-based one and if we set prepare.ch.edge_based=edge_or_node only the edge-based one

    so in total we get the following preparations:

    • car|fastest|node
    • car|shortest|node
    • motorcycle|fastest|node
    • motorcycle|fastest|edge|u_turn_costs=30
    • motorcycle|shortest|node
    • motorcycle|shortest|edge
    • bike|fastest|node
    • bike|shortest|edge

    The drawbacks of the current method are:

    1. its not intuitive and rather hard to understand
    2. we cannot select the weighting for each vehicle individually, for example skip bike|shortest, but add car|short_fastest
    3. we cannot customize the weightings, for example set the time/distance factor on ShortFastestWeighting. this is also problematic, because if we did set this factor it would have to be included in the profile name, otherwise we would not be able to distinguish weightings with different choices of this factor
    4. we cannot use block area (I guess for the same reason)
    5. the custom weightings in Introduce configurable Weighting / CustomWeighting #1776 cannot be mapped to this current simplistic configuration scheme

    Bullets 1) and 2) are easy to fix: We could just use a list similar to the one I have written above. The only downside would be that it breaks backward compatibility (we could add a converter though).

    Bullets 3) and 4) are more problematic, because so far the 'identity' of a CH profile is fully based on its properties. This either gets more and more complex with additional properties that are included to build the identity or does not work at all (we cannot include all the information needed to specify a blocked area in the CH profile (name)). I think the best solution is giving a name to the CH profiles, #1708.

    Bullet 5) is yet more complex and I am wondering if we can find a format that allows specifying both the 'classic' and the 'custom' profiles .

    A first try to create a configuration scheme that fixes all these issues would be this:

    prepare.ch.profiles:
      - name: car_fastest
        vehicle: car
        weighting: fastest
        edge_based: false
    
     - name: motorbike_fastest
       vehicle: motorcycle 
       weighting: fastest
       edge_based: true
       u_turn_costs: 30
    
      - name: my_car
        vehicle: car
        weighting: custom
        edge_based: true
        u_turn_costs: 40
        custom_model:
          - base: car
            max_speed: 110
            average_speed:
            road_class: { motorway: 80 }

    It allows both specifying the 'classic' profiles as well as the new 'custom' ones. Instead of writing this list in config.yml we could also put each configuration into a separate file in a special directory (like the custom-model directory currently used in #1776). However, there are a few drawbacks here:

    1. Specifying the 'classic' profiles would be very verbose like this. Especially creating an extra file for each of them seems too cumbersome.
    2. We have to give a name to something as simple as car|fastest|node. And even more important does this mean we have to specify profile=car_fastest on each request (instead of specifying vehicle=car and weighting=fastest)? This once again raises the question whether the request parameters should be about what should be done vs. how it should be done?
    3. The custom model has a base field, but its really clear how this relates to the vehicle field of the configuration? Do they have to be the same? Could we just omit the vehicle field in case the weighting is set to custom? Or maybe the other way around and we omit the base in custom_model?

    Maybe we can solve 1) and 2) by allowing a special syntax like this?

    prepare.ch.profiles:
      - name: car_fastest_node
      - name: car_fastest_edge
        u_turn_costs: 40
    

    We could allow setting profiles here and additionally add the ones from the configuration directory? Or maybe as we do in #1776 just add the profiles from the profile directory to this list?

    Also would it make sense to allow the current selection of the profile for these profiles (specifying vehicle/weighting/turn_costs/u_turn_costs on the request)?

    After describing this whole issue, here is my current suggestion how to deal with the ch profile configuration in the future:

    # config.yml
    ...
    ch.profiles:
      # this is the new way of configuring the 'old' profiles
      # the profile names follow a naming convention that is used to select the profile when doing routing requests, just like we did in the past
      - name: car_fastest_node
      - name: car_fastest_edge
        # turn cost configuration: so far `u_turn_costs` is the only parameter, but likely there will be more, so put this into a separate yaml node already?
        turn_costs:
          - u_turn_costs: 40
    
     # we can also use the more verbose way of specifying such profiles.
     # selecting these (any other than the simple ones above) per request **requires** setting the `profile=profile_name` parameter
      - name: my_car
        vehicle: car
        weighting: short_fastest
        distance_factor: 0.15
        edge_based: true
        turn_costs:
          - u_turn_costs: 30
        # blocked areas could be included here (but probably add this functionality afterwards)
        blocked_areas:
          - polygon:
             - bounds...
    
    ---
    
    # my_custom_car.yaml in the graph.custom_models directory
    # configurations like this will simply be added to `ch.profiles` automatically assuming `vehicle=base`, and `weighting=custom`.
    
    # we could even omit this and use the filename instead ?
    - name: my_custom_car
    # weighting and vehicle must be omitted here, otherwise there will be an error
    # or should we allow/enforce `weighting: custom` and/or `vehicle: <same as base>`?
    - edge_based: true
    - turn_costs:
      - u_turn_costs: 50
    - custom_model:
      -  base: car
         max_speed: 110
         average_speed:
         road_class: { motorway: 80 }

    One thing that still bothers me is the naming convention for the 'classic' profiles:

    - name: car_fastest_node

    Can we use some kind of protected prefix to easily recognize these? Otherwise it could be problematic if a custom profile used a name like this. Unfortunately I could not come up with a convention I like yet. Maybe something like gh_car_fastest_node? With gh_ meaning that its a classic profile that can be selected without using profile=profile_name on the request (and does not allow any of the advanced configuration options like distance_factor, block_area etc.)?

  2. karussell commented on Jan 22, 2020

    @karussell
    MemberAuthor

    Interesting, I like it 👍

    We can definitely think about renaming base to vehicle for the custom models (or see my suggestion below to even deprecate vehicle).

    I've also thought about moving the "model" properties one level up, from:

    points: ...
    model:
       max_speed: 110
       vehicle: car # or base: car

    into

    points: ...
    max_speed: 110
    vehicle: car # or base: car

    Which has some advantages but also disadvantages like mixing "routing-only" parameters like algorithm and points with "profile" properties.

    But an advantage would be that a truck.yml could be directly usable for the request. And also in a CH profile my_custom_car we can refer to it like custom_model: profiles/truck.yml and it would be relative clear how it is merged. We could even easily overwrite properties of the custom_model in the CH profile section. And this will make usage easier as no thought is spend on additional indentation.

    btw1: if we do this "one level up shift" and add the routing-only parameters afterwards in the GH maps UI, then the line and column numbers would be correct for all parser exceptions.

    btw2: this would also make renaming CustomModel into CustomProfile more meaningful.

    btw3: the good thing about this linking to profiles/truck.yml is that we can easily define a complex truck profile and do CH preparations for slightly different things like "default truck" vs. "exclude ferries truck" both using the same file.

    this is the new way of configuring the 'old' profiles

    A small problem here is also that vehicle and weighting could both contain underscores.

    Also I would prefer having a single way to specify these profiles, even if that means writing more characters.

    Also would it make sense to allow the current selection of the profile for these profiles (specifying vehicle/weighting/turn_costs/u_turn_costs on the request)?

    Yes, I would find interesting if a profile name is implicit determined by some of its properties (like the car_fastest_node you proposed) and an explicit profile name is only necessary if there is some ambiguity e.g. when there are 2 profiles with vehicle=car. Would be also good for backward compatibility.

    Still the problem with a separate profile parameter is that users won't understand why they need to specify "vehicle=car" for car and "profile=truck" for truck or probably we should deprecate vehicle and prefer base?

    we could even omit this and use the filename instead ?

    Yes.

    turn_costs:

    Would we need a separate section for turn_costs if we currently only have one parameter? How could we specify "consider only turn restrictions" and use whatever default for u turns?

    ch.profiles:

    We will also need lm.profiles.

    or should we allow/enforce weighting: custom and/or vehicle: <same as base>?

    Yes, we should probably assume these values and if a different is specified raise an exception?

  3. easbar commented on Jan 23, 2020

    @easbar
    Member

    One more thing: The custom models on the server side are not necessarily the ones we want to prepare for CH (and LM), right? For this reason I suggest to distinguish between custom models and CH/LM profiles. I think this also solves a few more problems like using the same custom model for CH and LM. We could have a directory of custom models, each specifying a custom 'vehicle' (like truck.yml) and then use these within the CH/LM profile definition (vehicle: truck) (in config.yml). The vehicle can either be one of the 'classic' ones (car,bike,foot,...) or one of the custom ones in the custom model directory.

    I put my first draft here and updated it according to this discussion here. I am hoping this will eventually lead us to the final definition of the configuration format.

    I've also thought about moving the "model" properties one level up, from:

    Here you are talking about how the custom model is embedded in the request object? I have not thought about this yet. So far I am trying to find a good way to define the CH/LM profiles.

    like mixing "routing-only" parameters like algorithm and points with "profile" properties.

    Ok in terms of (yaml key) naming collisions I would assume this should not be so much of a problem.

    But an advantage would be that a truck.yml could be directly usable for the request.

    You mean the contents of truck.yml can be pasted into the browser textbox or used via curl? This I do not understand, why does the custom model have to be top level to do this?

    And also in a CH profile my_custom_car we can refer to it like custom_model: profiles/truck.yml and it would be relative clear how it is merged.

    This is what I have written above: We can use vehicle: truck in the CH profile definition. What do you think has to be merged here? One thing that comes to my mind is something like setting u_turn_costs to 40,60 and 80 each time using vehcicle: truck instead of creating truck_40.yml, truck_60.yml and truck_80.yml.

    We could even easily overwrite properties of the custom_model in the CH profile section.

    Yes maybe this should be possible as well, but we should be careful to keep things simple as well, so not entirely convinced this is really necessary yet.

    And this will make usage easier as no thought is spend on additional indentation.

    This I do not understand. Where do we need to take care of additional indentation?

    if we do this "one level up shift" and add the routing-only parameters afterwards in the GH maps UI, then the line and column numbers would be correct for all parser exceptions.

    Ok but I think this should not be our concern at the moment. There are many ways to fix the line/column numbers and improve the error messages and this should not affect how we choose to design the configuration format now (there are more crucial things at play imo).

    this would also make renaming CustomModel into CustomProfile more meaningful.

    I have no preference here yet, first we should finalize the configuration format and then I am sure we find pretty names for everything :)

    the good thing about this linking to profiles/truck.yml is that we can easily define a complex truck profile and do CH preparations for slightly different things like "default truck" vs. "exclude ferries truck" both using the same file.

    Yeah, I am definitely sold on putting the custom models in separate files and referencing thim from ch/lm profile definitions as written above.

    A small problem here is also that vehicle and weighting could both contain underscores.

    Yes this is an issue. I thought about using |, but this needs to be escaped for url encoding. Then I thought about using -, but this is a special character in YAML. But we will find a solution for separator symbols once we have decided on our desired configuration format I am sure.

    Also I would prefer having a single way to specify these profiles, even if that means writing more characters.

    Ok! I agree. Its actually not that much more verbose and I suggest using a convention of creating the profile name (see my v2.md draft).

    Yes, I would find interesting if a profile name is implicit determined by some of its properties (like the car_fastest_node you proposed) and an explicit profile name is only necessary if there is some ambiguity e.g. when there are 2 profiles with vehicle=car. Would be also good for backward compatibility.

    This is a great idea! I think we can first use some standard parameters to derive a (standard) CH/LM profile name and try to find a matching profile. If this fails we can return an error message stating the names of the available profiles. Only for more advanced stuff it will be necessary to explicitly use the profile name.

    Still the problem with a separate profile parameter is that users won't understand why they need to specify "vehicle=car" for car and "profile=truck" for truck

    No I think they can specify "vehicle=truck" as well which will then be used to derive a standard CH profile name (as I mentioned above, see v2.md for more details). Of course this only works as long the profile names follow the naming convention, but I think that's ok. For example even if we had three different customized truck profiles we could name them truck1/2/3 and be able to use the vehicle parameter to select them.

    Would we need a separate section for turn_costs if we currently only have one parameter?

    Sure we could, but honestly I do not see a reason why not to use a separate section. In the mid/long run I think it should be possible to pick a single node of another custom model for your model. We have the concept of inheriting from a 'base' vehicle, but what if we want to share a (complex) turn cost configuration or blocked areas between five vehicles? It'd be ugly to repeat them five times and just as ugly to pick all the turn cost options. So I think using nested sections like turn_costs for related things is a good thing.

    How could we specify "consider only turn restrictions" and use whatever default for u turns?

    So far I am not sure where to put the turn cost configuration. Currently you can put the turn_costs=true parameter on the request or set edge_based: true in the CH profile. We will need similar options in the custom model I guess:

    turn_costs:
       turn_restrictions: true
       u_turn_costs: 60

    We will also need lm.profiles.

    Yes, this is easy in case we put the custom models in a separate directory and simply reference them in the ch/lm.profiles.

  4. karussell commented on Jan 23, 2020

    @karussell
    MemberAuthor

    The custom models on the server side are not necessarily the ones we want to prepare for CH (and LM), right? For this reason I suggest to distinguish between custom models and CH/LM profiles.

    Yes, it makes sense to use them as base in CustomModel or vehicle in the CH/LM profile.

    I have no preference here yet, first we should finalize the configuration format and then I am sure we find pretty names for everything :)

    There are surely more critical things at the moment but I think it is important :) ... I mean, when we talk about "CH/LM profiles" then these yml files are some kind of a "flex/custom profile"? (with regards to the flexible mode). (Or we would need to call it CH/LM model?)

    This I do not understand, why does the custom model have to be top level to do this?
    ...
    This I do not understand. Where do we need to take care of additional indentation?

    Sorry, I meant this needs to be top level for the request and partially I mixed it up. But as you say: it is not important in this discussion here.

    Yeah, I am definitely sold on putting the custom models in separate files and referencing thim from ch/lm profile definitions as written above.

    👍

    But we will find a solution for separator symbols once we have decided on our desired configuration format I am sure.

    👍

    What do you think has to be merged here?

    E.g. you can define u_turn_cost: 40 in the CustomModel and in the CH profile you say u_turn_cost: 80 to overwrite it ("merge it"). We could even allow other parameters like speed_factor etc later.

    but what if we want to share a (complex) turn cost configuration or blocked areas between five vehicles? It'd be ugly to repeat them five times and just as ugly to pick all the turn cost options.

    Reusage in code is fine but in configurations I think I would just repeat myself. The block_area case is indeed a bit lengthy and we already have these spatial rules (geojson files) and so we could reference them fully from a CustomModel.

    I am hoping this will eventually lead us to the final definition of the configuration format.

    Nice - thanks! This looks good!

    Some comments:

    Custom profiles do not necessarily have to be the same as lm/ch profiles, but the latter can use the custom profiles as 'vehicle'.

    Should we call this base or rename base to vehicle in the CustomModel?

    your_car.yml
    base: your_car # we can reference another custom model here,

    I think this is a typo? The base should be probably my_car if I understand the example properly?

    blocked areas could be included here (but probably add this functionality afterwards)

    Yes, this should be done later. We could even think about allowing all parameters of a CustomModel here too.

    Or we go the opposite way of moving all stuff into the CustomModel, even the turn_costs definition.

  5. easbar commented on Jan 23, 2020

    @easbar
    Member

    There are surely more critical things at the moment but I think it is important :)

    Yes its important, or at least we should know what we are talking about (and make sure others are talking about the same) :)

    I mean, when we talk about "CH/LM profiles" then these yml files are some kind of a "flex/custom profile"? (with regards to the flexible mode). (Or we would need to call it CH/LM model?)

    So far I am thinking there are files in the custom model directory, like truck.yml. These are the ones we are using in #1776 to configure CustomWeighting, so currently I would call them CustomModel. They are strictly coupled to CustomWeighting and basically enclose everything that is customizable in CustomWeighting.
    And then there are the LM/CH profiles which only specify which weighting shall be used for preparation (+ the choice of edge/node-based for CH + currently the u_turn_costs, but see below for turn cost stuff). So far I assume they will live in config.yml as prepare.ch/lm.profiles (instead of the current prepare.ch/lm.weightings + prepare.ch.edge_based. For CH they are represented as CHProfiles in java currently.
    Now you would like to rename CustomModel -> CustomProfile, but it should still be the same thing?

    E.g. you can define u_turn_cost: 40 in the CustomModel and in the CH profile you say u_turn_cost: 80 to overwrite it ("merge it"). We could even allow other parameters like speed_factor etc later.

    Yes, my assumption was that we can use vehicle: my_vehicle, weighting: custom in the CH/LM profile definition and if we do we can specify all properties of CustomModel right there as well, so it will overwrite (or extend) what is defined by the custom model in my_vehicle.yml. This is just a matter of convenience and would be equivalent to creating my_vehicle2.yml and setting vehicle: my_vehicle2.yml. This way seems useful if we want to use my_vehicle with slightly different options. Is this not what you suggested? Initially I did not plan to include this convenience way (and keep things simple instead), but now I think its useful.

    Now, u_turn_costs seems a bit special, because we probably want it in CustomModel, but at the same time it can be configured for the normal FastestWeighting as well (as we currently do). But this does not seem to be a real problem with the above design, because in CustomModel we can just include it, and when its added in the CH profile definition it will work for both cases (no matter whether weighting: fastest or weighting: custom). This should be true for the entire turn cost definition (so far only turn_restrictions true/false and u_turn_costs, but hopefully more advanced in the future).

    Reusage in code is fine but in configurations I think I would just repeat myself. The block_area case is indeed a bit lengthy and we already have these spatial rules (geojson files) and so we could reference them fully from a CustomModel.

    Ok, I just wanted to say that we have this concept of inheriting from one 'base' vehicle, but this way we cannot inherit different things from different models. I totally agree we should keep this simple here and if the blocked areas can be put into separate files I think the most important use-case for the mechanism I suggested is out of the way -> Lets not support this for now.

    Should we call this base or rename base to vehicle in the CustomModel?

    Good question. I would not call it base, because its not very expressive and makes no sense when using fastest instead of custom weighting: weighting: fastest, base: car? At the same time calling the base in CustomModel, vehicle does not really tell us that we are building upon something else, so I like base better there (or base_vehicle) ;) Hm, not sure at the moment and I do not see a real reason to use the same name for both, maybe this makes it just more confusing.

    I think this is a typo? The base should be probably my_car if I understand the example properly?

    Yes this was a typo -> fixed.

    We could even think about allowing all parameters of a CustomModel here too.

    Yes and no. I mean yes I think we should allow all parameters of custom model here (as I explained above), but no not really here because in the example I gave with blocked areas the weighting is short_fastest. It'd only make sense if weighting was "custom" (but thats probably what you meant).

    Or we go the opposite way of moving all stuff into the CustomModel, even the turn_costs definition.

    I probably repeat myself here, but I mean it like everything belonging to custom weighting goes into custom model, including turn cost options. But in the CH profile we can extend/overwrite the custom model we select via the vehicle. Turn costs are special, because they can be used with any weighting (not just custom).

  6. karussell commented on Jan 23, 2020

    @karussell
    MemberAuthor

    Now you would like to rename CustomModel -> CustomProfile, but it should still be the same thing?

    Yes. The reasoning is that properties of a CH profile control the weight of an edge, which is also what CustomModel currently does. But I'm not 100% sure - it just looks now so similar :)

    This way seems useful if we want to use my_vehicle with slightly different options. Is this not what you suggested?

    Yes :)

    but no not really here because in the example I gave with blocked areas the weighting is short_fastest ... It'd only make sense if weighting was "custom" (but thats probably what you meant).

    Yes

    Turn costs are special, because they can be used with any weighting (not just custom).

    👍

    (or base_vehicle) ;)

    That is not that bad and gives a hint that it could collide with vehicle of a CH profile (?)

  7. easbar commented on Jan 23, 2020

    @easbar
    Member

    Yes. The reasoning is that properties of a CH profile control the weight of an edge, which is also what CustomModel currently does. But I'm not 100% sure - it just looks now so similar :)

    Hmm the CH profile really only controls the vehicle,weighting&edge_based, but it allows adding some custom model keys as well (for convenience). I wouldn't say this makes it so similar to CustomModel. I think the CH profile could even include stuff like CH preparation tuning parameters (but lets not make things more complicated now). Maybe rename CustomModel to CustomWeightingConfig (thats what I think it is: a collection of configuration parameters that are specific to CustomWeighting). Its a bit like FlexModelWeighting and FlexModel except that it tells us that the model is made for the weighting instead of the weighting is made for the model...
    Then again I like model, because config is used in so many other contexts. And I also like profile, because this is what we used most frequently when speaking about doing shortest path calculations for different types of vehicles.

    That is not that bad and gives a hint that it could collide with vehicle of a CH profile (?)

    Yes and they really must not collide, because they are different after all. How are we going to de-serialize the custom model fields that we write on the top-level in the CH profile (for convenience)? If we just deserialize it into a CustomModel object the vehicle will be mistakenly used as the base (ok we could somehow exclude the CH profile vehicle before we do the deserialization).

    Btw do you know how to actually do this merging/overwriting stuff? Have you done it yet for the use-case where a request has a CustomModel and is then merged with the one from the custom.model.directory?

  8. karussell commented on Jan 23, 2020

    @karussell
    MemberAuthor

    I wouldn't say this makes it so similar to CustomModel

    Yes, this makes sense. And I now understand that they are different but ...

    And I also like profile, because this is what we used most frequently when speaking about doing shortest path calculations for different types of vehicles.

    Yes, that is what I think. But this sounds like we should not call the "CH config" a "CH profile"? And rename CustomModel to CustomProfile :) ?

    Have you done it yet for the use-case where a request has a CustomModel and is then merged with the one from the

    No. This is missing. I guess we could use reflection (I do not like it :) !) or just manually iterating over all properties.

  9. easbar commented on Jan 23, 2020

    @easbar
    Member

    Yes, that is what I think. But this sounds like we should not call the "CH config" a "CH profile"? And rename CustomModel to CustomProfile :) ?

    You mean renaming CHProfile to CHConfig? That sounds fine to me (although we often called the preparations 'profiles' as well (outdoor etc.)).

    CustomModel->CustomProfile also works for me (maybe I would go for CustomWeightingProfile still). Thinking of the pure Java class I'd prefer CustomWeightingConfig. But for the user-facing part I think speaking of 'custom profiles' (or even 'custom vehicles') would be better. We could at least call the directory they are in the "custom vehicle directory"? Most users will not ever see the corresponding Java classes anyway?

    I guess we could use reflection (I do not like it :) !) or just manually iterating over all properties.

    Jackson also seems to have some support for such things: https://stackoverflow.com/a/9912406

  10. easbar commented on Jan 23, 2020

    @easbar
    Member

    One more problem that came to my mind is this: Lets say we specify a CH profile like this:

    ch.profiles:
      - name: my_ch_profile
        vehicle: my_car
        weighting: custom
        max_speed: 80

    i.e. we use my_car.yaml and change the max speed. If we do a request with vehicle=my_car&weighting=custom we want to select this CH profile (even without using the profile url parameter). But if we put ch.disable=true we will get my_car (without max_speed: 80) instead. Not sure if this is so much of an issue, but it could be confusing.

    The same problem arises when we use the above profile for LM and CH (maybe with different max_speeds): The selected profile will depend on the algorithm. This can happen even when we set the profile parameter unless we make sure that no LM and CH profile names coincide (which we probably should).

  11. karussell commented on Jan 23, 2020

    @karussell
    MemberAuthor

    You mean renaming CHProfile to CHConfig? That sounds fine to me (although we often called the preparations 'profiles' as well (outdoor etc.)).
    CustomModel->CustomProfile also works for me

    Ok, let's decide this in a few days :)

    Thinking of the pure Java class I'd prefer CustomWeightingConfig. But for the user-facing part I think speaking of 'custom profiles'

    Ok, I understand this too.

    We could at least call the directory they are in the "custom vehicle directory"?

    "profile" would be slightly better than "vehicle" in this context as sometimes it is not a "vehicle" ("foot" or "multi modal"). And so it comes I often use "vehicle profile" when speaking about this from higher level, because also "(travel) mode" is confusing (could mean shortest vs. fastest etc)

    If we do a request with vehicle=my_car&weighting=custom we want to select this CH profile

    Hmmh, this is ugly. It would not happen if we move all config stuff into a separate named CustomModel. But then it would be more complicated. Hmmh.

    Jackson also seems to have some support for such things: https://stackoverflow.com/a/9912406

    Perfect. Really nice!!

  12. easbar commented on Jan 27, 2020

    @easbar
    Member

    "profile" would be slightly better than "vehicle" in this context as sometimes it is not a "vehicle" ("foot" or "multi modal"). And so it comes I often use "vehicle profile" when speaking about this from higher level, because also "(travel) mode" is confusing (could mean shortest vs. fastest etc)

    So far we use also "vehicle=foot" as url parameter... custom_vehicle_profile_directory is a bit long? Anyway we can go with custom_profile_directory as far as I am concerned.

    Hmmh, this is ugly. It would not happen if we move all config stuff into a separate named CustomModel. But then it would be more complicated. Hmmh.

    What do you think would be more complicated? Having to create another file instead of just adding some properties in ch.profiles? This is a bit of work yes. But for example if its just about changing (not adding) another profile it would only mean having to edit something like my_car.yml instead of config.yml. On the other hand the whole rules/mechanism would be less complicated (fewer ways to do things). Right now I cannot think of a perfect way to do this, but maybe we can start with the simple/obvious way to do this: Simply referencing a custom vehicle in a CH profile (without adding/overwriting properties). Once we have this we can still think about the overwrite mechanism and decide if we need it?

  13. karussell commented on Jan 27, 2020

    @karussell
    MemberAuthor

    Anyway we can go with custom_profile_directory as far as I am concerned.

    Ok, have changed it accordingly (graph.custom_profiles.directory)

    Simply referencing a custom vehicle in a CH profile (without adding/overwriting properties). Once we have this we can still think about the overwrite mechanism and decide if we need it?

    👍

  14. easbar commented on Feb 3, 2020

    @easbar
    Member

    After some discussion I think we decided to:

    • specify a name for every profile
    • specify all profiles upfront (via config.yml)
    • use a profile request parameter to select a profile

    This allows us to keep the CH/LM stuff out of the profiles, which means all we have to think about is how to define the profiles and then we simply add two lists which define for which of of these profiles we want a preparation. Something like this:

    profiles:
      - name: profile1
        # not showing properties here (to be discussed, see below...)
      - name: profile2
    
    ch.profiles:
      - profile1|node
      - profile2|edge
      - profile2|node
    
    lm.profiles:
      - profile2

    Ok, in theory we could just as well add a prepare_ch: node/edge/no and/or prepare_lm: true/false in each profile, but this is rather a detail and I think it helps to think of a profile not really being related to CH/LM here. The takeaway here is that a CH/LM profile definition simply means we want a preparation for an (otherwise also) existing profile and we are not changing this profile. This way we do not run into a situation where the profile details depend on whether ch/lm is used or not. Does that make sense? If yes I think the next question is what goes into a profile (and no need to think about CH/LM any longer).

    A profile should contain all the information needed to assign edge- and turn weights to the routing graph, basically what Weighting does on the Java side currently. More specifically, currently these are the following:

    • the FlagEncoder
    • the type of Weighting, e.g. "fastest","short_fastest" or "shortest", but also "custom" (Introduce configurable Weighting / CustomWeighting #1776)
    • parameters of the Weighting, e.g. distance_factor for "short_fastest" and the custom model for "custom"
    • the type of TurnCostProvider, e.g. no turn costs or the DefaultTurnCostProvider, which currently is parameterized by the uTurnCosts parameter
    • blocked areas

    This could be specified using the following yaml:

    # each profile has the following fields:
    # - name (required): a unique identifier string
    # - vehicle (required): one of the default GH vehicles (foot,bike,mtb,car,...) or 
    #   one of the custom profiles in the custom profiles directory
    # - weighting (required): fastest,short_fastest,shortest or custom.
    #    must be custom when using a custom profile.
    # - hints (defaults to empty map): key-value pairs passed to the chosen
    #   weighting and turn cost provider. It is possible to overwrite these hints per request 
    #   (unless CH (or LM?) is used).
    # - blocked areas (defaults to an empty list): references geojson files specifying blocked
    #    areas?
    # - turn costs (defaults to false): whether or not this profile should pay attention
    #   to turn restrictions. doing so means slower routing (if turn_costs=true we will choose
    #   an edge-based algorithm whenever a request uses this profile). In case of CH this even
    #   requires a special preparation.
    
    profiles: 
      - name: my_profile
        vehicle: car
        weighting: fastest
        turn_costs: false
    
      - name: my_other_profile
        vehicle: bike
        weighting: short_fastest
        turn_costs: true
        hints:
          - distance_factor: 0.2
          - u_turn_costs: 60
        # blocked areas?
    
      - name: my_truck
        vehicle: my_custom_truck
        weighting: custom

    Open questions:

    • Shall we automatically derive whether or not a CH profile should be edge/node based? We could use profile.turn_costs to decide this -> yes do it automatically

    • Shall we include some kind of overwriting mechanism for custom model? Now that we have profile names this is no longer a problem, but maybe its still better to leave it out for now to keep things simple? If we want to include it could we use a custom model object within hints? Or use an extra custom model node in profile which only can be used if weighting=custom? -> maybe later

    • Will we be able to replace fastest/shortest/short_fastest weighting with custom weighting (soon)? If yes this would make profile.weighting obsolete and it would make sense to add a custom model node (since we are only using custom weighting anyway) so we would probably adjust the format for profiles accordingly. Do we care much about changing the format again then? Shall we try to anticipate this change already now or keep it simple and focus on making it work for the current state? -> postponed

    • How to include more complex turn cost configurations? Currently these do not exist, but what if? They could either be treated similar to what we do with custom weighting/model or there would have to be different implementations of TurnCostProvider which can be referenced by a name and expose some parameters we simply pass via the hints field (just like we do with short_fastest&distance_factor). Maybe by the time we implement this we have replaced fastest/short_fastest/shortest with custom anyway? -> postponed / maybe extend profile options later

    • The hints (like distance_factor) can be overwritten per request. This does not work for CH, should there be an error then or should we ignore request hints in this case? This question is even more complicated for LM: In some cases its ok to change the parameters, but in others its not, how should this be handled? We have the same problem for the custom model parameters of course. -> Make error/ignore configurable

    • Is it ok (or even better?) to require an explicit name for each profile or shall we use something like vehicle+weighting by default (in case this leads to multiple profiles there would of course be an error and one has to give an explicit name). -> require explicit name

    • What is the exact format we should use for block_area? And shall we already include it or leave it for later? -> later

  15. karussell commented on Feb 3, 2020

    @karussell
    MemberAuthor

    Nice, this reads clear :) !

    Shall we automatically derive whether or not a CH profile should be edge/node based? We could use profile.turn_costs to decide this.

    I do not know. E.g. CH preparation is still rather heavy for edge-based and for LM it is no difference.

    maybe its still better to leave it out for now to keep things simple?

    Yes, IMO we should keep it simple and try this after #1776 is merged. And also yes, I think probably an extra custom model node in profile that can be used if weighting=custom.

    Will we be able to replace fastest/shortest/short_fastest weighting with custom weighting (soon)?

    Good question. Would be good, but for now I would concentrate to introduce a separate Weighting and hopefully it turns out as generic enough in maybe a year so that we can remove the other Weightings.

    Do we care much about changing the format again then?

    I would avoid it but not at all costs :)

    How to include more complex turn cost configurations? Currently these do not exist, but what if?

    As we cannot prepare for any problem in the future I would keep this problem out of this issue here. But even if there are other configuration options I do not see an issue when introducing them via hints or extra nodes?

    This does not work for CH, should there be an error then or should we ignore request hints in this case?

    I would prefer an error but also can imagine that users want it backward compatible and so this should be maybe even configurable?

    The hints (like distance_factor)

    Is the extra sublevel inside the hints necessary? Or is it to indicate required weighting and vehicle parameters and optional hints?

    Is it ok (or even better?) to require an explicit name for each profile or shall we use something like vehicle+weighting by default (in case this leads to multiple profiles there would of course be an error and one has to give an explicit name)

    Do you mean in the config or in the request? In the configuration I would be explicit and in the web API I would try to keep backward compatibility.

    blocked areas

    Let us keep this for a different issue, which is more #1280.

  16. easbar commented on Feb 3, 2020

    @easbar
    Member

    I do not know. E.g. CH preparation is still rather heavy for edge-based and for LM it is no difference.

    Yes for LM there is no such thing as node/edge. For CH yes edge-based is heavy, but also required if one wants to use turn costs. My question was just whether its ok one has to first set turn_costs: true in the profile and then not forget to use edge when setting the CH profile or if we should use edge automatically if the profile has turn_costs: true.

    Yes, IMO we should keep it simple and try this after #1776 is merged. And also yes, I think probably an extra custom model node in profile that can be used if weighting=custom.

    👍

    Good question. Would be good, but for now I would concentrate to introduce a separate Weighting and hopefully it turns out as generic enough in maybe a year so that we can remove the other Weightings.

    👍

    I would avoid it but not at all costs :)

    If we keep the other weightings we need the weighting node

    As we cannot prepare for any problem in the future I would keep this problem out of this issue here. But even if there are other configuration options I do not see an issue when introducing them via hints or extra nodes?

    Ok I agree. If we had more complex turn cost options and an associated node, maybe the turn_costs: true/false node won't make much sense anymore, but then again its nice to be able to see whether or not we need edge-based routing or not.

    I would prefer an error but also can imagine that users want it backward compatible and so this should be maybe even configurable?

    👍

    Is the extra sublevel inside the hints necessary? Or is it to indicate required weighting and vehicle parameters and optional hints?

    Its not necessary, but it makes validating the profile easier, because there are only a few allowed nodes on the top level while hints might contain all kinds of parameters (depending on the weighting).

    Do you mean in the config or in the request? In the configuration I would be explicit and in the web API I would try to keep backward compatibility.

    I meant in the config. Ok so lets keep profile.name a required field. For the web api we'll use vehicle+weighting (etc.) to map to the right profile name.

    Let us keep this for a different issue, which is more #1280.

    👍

  17. karussell commented on Feb 3, 2020

    @karussell
    MemberAuthor

    My question was just whether its ok one has to first set turn_costs: true in the profile and then not forget to use edge when setting the CH profile or if we should use edge automatically if the profile has turn_costs: true.

    Ah, ok. So you mean it is still possible to specify in the CH profile. Then, I would probably set it automatically to edge based if turn_costs==true, but no strong opinion.

    Its not necessary, but it makes validating the profile easier, because there are only a few allowed nodes on the top level while hints might contain all kinds of parameters (depending on the weighting).

    I would do this only differently if the top level properties have a different meaning like "required" otherwise it could be ugly to decide where to put which property when more "top level properties" will be added. Or also it might be harder to understand why vehicle etc is not allowed under hints?

  18. easbar commented on Feb 3, 2020

    @easbar
    Member

    Ah, ok. So you mean it is still possible to specify in the CH profile. Then, I would probably set it automatically to edge based if turn_costs==true, but no strong opinion.

    Yes this is the question: Set it explicitly in the CH profile or derive this information from turn_costs=true/false? I have a slight bias towards setting it automatically as well, so I guess its decided :)

    I would do this only differently if the top level properties have a different meaning like "required" otherwise it could be ugly to decide where to put which property when more "top level properties" will be added. Or also it might be harder to understand why vehicle etc is not allowed under hints?

    Some of the top level properties are required, others are not and yet others are forbidden (like custom model with weighting=fastest). Ok, I'll try putting everything (currently there are only two hints that I know of: distance_factor and uTurnCosts) on the top level then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions