Priority and CustomWeighting


I’m new to GH code and probably I am missing something, however checking on the GH source code I found something that I cannot explain.

I’m moving GH from the 6.2 version to the 8 version checking the new custom models to ensure backward compatibility to what I had before.

Analyzing the code I found that despite being included in the calcEdgeWeight in CustomWeighting calculation the priority seems to be always getting the value of 1 as you can see here and here .

My suspect are reinforced by the fact that in the last class there is a getRawPriority method that would expose the priority_enc fields seems not to be used by any reference.

Doesn’t this mean that despite the priority set in a custom model or given to an edge by a VehicleParser the priority will be always be equal to 1? Am I missing some other relevant pieces of code?

Thanks for your help

The CustomWeightingHelper is not directly used, only a subclass of it. The magic involves using Janino which creates this subclass at runtime. Have a look into CustomModelParser.createGetPriorityStatements where the code is created to overwrite CustomWeightingHelper.getPriority to run the statement list in customModel.getPriority.

I have a blog post that explains this in more detail but need to polish it a bit further :slight_smile:

1 Like

Thanks for the explanation! Will have a look at that, also waiting for your blog post keep strong :mechanical_arm:.

Also a question, if I’m not setting anything as a custom model, does the distance influence defaults to 0?

Yes, it will be 0. For compatibility with the fastest weighting I think for car you can use 70.0

Hey @karussell !

Tried to make a test with the following configuration and compared with the old version and I found out there’s a significant difference with the car and motorbike estimation.

As I said I was starting with a very similar profile with the fastest_weight enabled for all profiles, so in having 0 distance influence should be in principle the same.

Also about the motorbike, is it good to reuse the car profile? Should I go with a more custom profile like the one shown here?

graph.encoded_values: osm_way_id
        - name: car
          vehicle: car
          custom_model_files: [ ]
        - name: motorbike
          vehicle: car
          custom_model_files: [ ]
        - name: bicycle
          vehicle: bike
          custom_model_files: [ ]
        - name: walker
          vehicle: foot
          custom_model_files: [ ]

        - profile: car
        - profile: motorbike
        - profile: bicycle
        - profile: walker

      profiles_lm: [ ]
      prepare.min_network_size: 200
      prepare.subnetworks.threads: 1
      routing.non_ch.max_waypoint_distance: 1000000
      routing.instructions: false
      graph.dataaccess.default_type: RAM_STORE

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.