CH with CustomProfile

I’m building an offline satnav app for my car’s android 7.0 head unit with 4gb ram.

for map rendering i use mapsforge vtm - works well.

for routing i want to use graphhopper 1.0 (last offline version).

i’m building my own graph with config.yml as:

graphhopper:
datareader.file: my-europe-gh.osm.pbf
graph.location: gh-fast-tolls-ch
graph.dataaccess.default_type: DISK_STORE
graph.dataaccess: mmap_byte_buffer
graph.flag_encoders: car|turn_costs=true
profiles:
  - name: car
    vehicle: car
    turn_costs: true
    weighting: fastest
graph.encoded_values: toll,max_speed
profiles_ch:
  - profile: car

…….

then, in the app the init code goes as:

val profile = CustomProfile(“car”)
.setCustomModel(customModel)
.setVehicle(“car”)
.setTurnCosts(true)
.setWeighting(“fastest”)
ghConfig.setProfiles(listOf(profile))
ghConfig.setCHProfiles(listOf(CHProfile(“car”)))
ghConfig.putObject(“graph.dataaccess”, “mmap_byte_buffer”)
ghConfig.putObject(“graph.flag_encoders”, “car|turn_costs=true”)
ghConfig.putObject(“graph.encoded_values”, “toll,max_speed,road_class”)
localHopper.setGraphHopperLocation(ghGraphDataPath.absolutePath)
localHopper.init(ghConfig)
localHopper.load(ghGraphDataPath.absolutePath)

the code runs ok and uses CH

this calculates default route.

but when i want an option to avoid tolls,

i create another graph with .yml as:

graphhopper:
  datareader.file: my-europe-gh.osm.pbf
  graph.location: gh-fast-no-tolls-ch
  graph.dataaccess: mmap_byte_buffer

  profiles:
    - name: carnt
      vehicle: car
      turn_costs: true
      weighting: custom
      custom_model_file: profile-fast-no-tolls.yml

  graph.encoded_values: toll,max_speed,road_class
  graph.flag_encoders: car|turn_costs=true

  profiles_ch:
    - profile: carnt

and with profile-fast-no-tolls.yml as:

priority:
  road_class: { motorway: 1.0 }
  road_class: { trunk: 1.0 }
  road_class: { primary: 0.8 }
  road_class: { secondary: 0.5 }
  road_class: { tertiary: 0.1 }
  road_class: { unclassified: 0.1 }
  road_class: { residential: 0.1 }
  road_class: { living_street: 0.1 }
  road_class: { pedestrian: 0.0 }
  toll: { all: 0.0 }

max_speed:
  road_class: { motorway: 89 }
  road_class: { trunk: 87 }
  road_class: { primary: 78 }
  road_class: { secondary: 60 }
  road_class: { tertiary: 50 }
  road_class: { residential: 40 }
  road_class: { living_street: 20 }
  road_class: { unclassified: 40 }

max_speed_fallback: 50

distance_influence: 100

and
later in the code
i use custom model as:

val customModel: CustomModel
try {
      Log.w(TAG, "using profile: ${ghProf}")
      context.assets.open(ghProf).use { inputStream ->
      val yamlMapper = ObjectMapper(YAMLFactory())
      customModel = yamlMapper.readValue(inputStream, CustomModel::class.java)
      }
    } catch (e: Exception) {
      throw RuntimeException("Could not load custom_model_file from assets", e)
    }

val profile = CustomProfile("carnt")
    .setCustomModel(customModel)
    .setVehicle("car")
    .setTurnCosts(true)
    .setWeighting("custom")


ghConfig.setProfiles(listOf(profile))
ghConfig.setCHProfiles(listOf(CHProfile("carnt")))

ghConfig.putObject("graph.dataaccess", "mmap_byte_buffer")
ghConfig.putObject("graph.flag_encoders", "car|turn_costs=true")
ghConfig.putObject("graph.encoded_values", "toll,max_speed,road_class")

localHopper.setGraphHopperLocation(ghGraphDataPath.absolutePath)
localHopper.init(ghConfig)
localHopper.load(ghGraphDataPath.absolutePath)

but during init graphhopper throws exception that:

GraphHopper initialization FAILED: CH preparation of carnt already exists in storage and doesn't match configuration
    java.lang.IllegalArgumentException: CH preparation of carnt already exists in storage and doesn't match configuration
    	at com.graphhopper.GraphHopper.postProcessing(GraphHopper.java:985)

interesting that if i only comment

//  ghConfig.setCHProfiles(listOf(CHProfile("carnt")))

graphhopper does not complain, inits and calculates the route with avoiding tolls
BUT using flexible, not CH algorithm

does anyone know the cause of the problem and how to sort it out

thank you.