| Forum | GitHub | Maps | Blog

Non linear cost function


I try to build a cost functon of a vehicle with dynamic costs. Until now I use:

  • setFixedCost(double)
  • setCostPerDistance(double)
  • setCostPerTransportTime(double)

Problem: e.G. between 0-5 hours threre are costs of X, later after 5 additional costs of Y (extra charge by time).

Formula for a vehicle: fixCost + (TransportTime * dynCostPrice) + (additionalTime * extraChargePrice)

Is it possible to represent this? How?

Kind regards


Hi Volker,

one way is to create your own Vehicle Routing Cost matrix. Have a look at the VehicleRoutingTransportCostsMatrix you should be able to easily adapt for your needs.



Hi Chris,
thanks for your reply,
thats interesting, but I think that does not help.
The Question is how to calculate the tour cost (profit-function) of one vehicle with many stops and the first (cost) time window (e.g. 5 hours) are over and the timedependent costs after this are getting higher, but not the cost for one long distance beween two stops.