Potential Cost factors in Route Optimization API

Questions refering to the PTV Optiflow based API within PTV Developer (launched on 20.12.2023)
Post Reply
User avatar
Bernd Welter
Site Admin
Posts: 3025
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Potential Cost factors in Route Optimization API

Post by Bernd Welter »

As you know: Optiflow optimizes tour structures based on costs.
A question that appears often on my screen is
Which cost factors are supported by Optiflow?
:!: The potential factors in API will be extended!

As of today the Route Optimization Optiflow API offers many different cost factors such as
  • Per Vehicle: Defines the costs for using the vehicle to execute tasks.
    • fix costs (Specifies the fixed cost for assigning a route to the vehicle.)
    • per kilometer (Specifies the cost for every kilometer driven with the vehicle.)
    • per hour (Specifies the cost for every hour the vehicle is used.)
    • per stop (Specifies the cost for every stop on the route of the vehicle.)
    • per overtimes: A list of overtime costs that describe an increasing cost if the route duration exceeds a threshold. For each exceeded threshold, the extra fixed cost and the additional cost for the extra hours contribute to the total cost of the route.
      • threshold : The threshold for the route duration (seconds) above which the extra cost per hour applies.
      • extraFixed : Specifies the extra fixed cost when exceeding the threshold.
      • extraPerHour : Specifies the extra cost for every hour above the threshold.
    • overdistances: A list of overdistance costs that describe an increasing cost if the total distance of a route exceeds a threshold. For each exceeded threshold, the extra fixed cost and the additional cost for the extra kilometers contribute to the total cost of the route.
      • threshold : The threshold for the route's total distance (meters) above which the extra cost per kilometer applies.
      • extraFixed: Specifies the extra fixed cost when exceeding the threshold.
      • extraPerKilometer : Specifies the extra cost for every kilometer above the threshold.
    • overstops : A list of overstop costs that describe an increasing cost if the number of stops of a route exceeds a threshold. For each exceeded threshold, the extra fixed cost and the additional cost for the extra stops contribute to the total cost of the route.
      • threshold : The threshold for the route's number of stops above which the extra cost per stop applies.
      • extraFixed : Specifies the extra fixed cost when exceeding the threshold.
      • extraPerStop : Specifies the extra cost for every stop above the threshold.
    • overloads (1.26.0 / 07.10.2025): A list of overload costs that describe an extra cost for loading orders onto a vehicle when the vehicle's load exceeds a threshold. For each dimension and threshold, the extra cost contribute to the total cost of the route.
      • dimension : Indicates the dimension of the load, to which the threshold applies.
      • threshold : The threshold for the specified load dimension. When an order is loaded, only the part of that order which contributes to exceeding the threshold is considered for the extra cost.
      • extraPerUnit : Specifies the extra cost per unit when loading an order which exceeds the threshold.
    • repositioningEfforts: Specifies a list of repositioning effort costs that describe an increasing cost if the route's repositioning effort exceeds a threshold. When two orders are loaded into the same compartment and delivered in the same order, we refer to them as a non-last-in-first-out (non-LIFO) pair. Any non-LIFO pair of orders requires repositioning in the vehicle, as the last picked-up order obstructs the first order that needs to be delivered. The effort involved in this repositioning is the minimum effort required for the two orders. The total repositioning effort for the route is the sum of the repositioning efforts for all non-LIFO pairs of orders.
      • threshold : The threshold for the repositioning effort from which the cost per effort applies.
      • extraPerEffort : Specifies the extra cost for every unit of effort above the threshold. If the threshold of multiple repositioning effort costs is exceeded, the extra costs per effort are added.
    • unused (1.47 / 10.2.2026) : Specifies the fixed cost when the vehicle remains unused. A vehicle is unused if the optimization does not assign a route to the vehicle.
  • Per Location:
    • costPerAppointment : Describes the cost for assigning an appointment to this time slot.
    • per concurrent ramp...
      • vehicleSlots.cost : The cost incurred when assigning at least one stop to this vehicle slot.
      • violationCostPerExtraSlot : The additional cost incurred for using an extra vehicle slot beyond the available ones. This must be greater than or equal to the cost of each vehicle slot.
  • Per Order (Outsourcing cost and insourcing revenue)
    • Outsourcing costs: Defines the cost for not scheduling the order on a route. This cost is weighed against the cost of scheduling the order on a route. When omitted the optimization will try to schedule the order regardless of the added cost.
    • Insourcing Revenue (1.34 / 20.11.2025): Defines the revenue for scheduling the order on a route. The order will only be scheduled on a route when the sum of the outsourcingCost and insourcingRevenue is less than the added route cost. When both the outsourcingCost and insourcingRevenue are omitted, the optimization will try to schedule the order regardless of the added cost.
    • Bernd (12.01.2026): :!: If the optional outsourcing costs for an order are not specified, the engine calculates with a very high substitute value. However, this will not be included in the total cost of the result. This can lead to the overall cost of an optimization step appearing higher, but this can be explained by the fact that at least one such order could be scheduled compared to the previous result.
  • per violated Constraint:
    • combinations.orderVehicle.violationCost : The cost incurred when an order-vehicle combination does not meet this constraint. When omitted, all order-vehicle combinations must satisfy this constraint.
    :!: There are more constraints defined but not all of them offer a violation cost property. These constraints are hard constraints.
  • Per Resource (1.24.0 / 26.09.2025): Defines the costs for assigning the resource to vehicles.
    • fixed : A one-time fixed cost incurred when this resource is used, regardless of how many vehicles use it.
    • perVehicle : The cost charged for each vehicle that uses this resource.
    • overVehicles.threshold : The threshold for the number of vehicles assigned to the resource above which the extra costs apply.
    • overVehicles.extraFixed : Specifies the extra fixed cost when exceeding the threshold.
    • overVehicles.extraPerVehicle : Specifies the extra cost for every assigned vehicle above the threshold.
    • perLayover (v1.31 / 31.10.2025): The cost charged when a layover occurs between consecutive vehicles sharing this resource. This cost is weighed against the cost for these vehicles to end and start at their provided start and end locations.
This list covers a subset of a way bigger set of contributing factors and we will extend the API step by step.
If you spot a cost factor in the SaaS Excel definition you are interested in get back to us and we can check whether and when it is on our roadmap.

Bernd
Attachments
Decrease of total cost during a 1min planning (gathered every 5 seconds). This visualization shows the different contributions including the decrease of unscheduled orders (red).
Decrease of total cost during a 1min planning (gathered every 5 seconds). This visualization shows the different contributions including the decrease of unscheduled orders (red).
Bernd Welter
Technical Partner Manager Developer Components
PTV Logistics - Germany

Bernd at... The Forum,LinkedIn, Youtube, StackOverflow
I like the smell of PTV Developer in the morning... :twisted:
User avatar
Bernd Welter
Site Admin
Posts: 3025
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Re: Potential Cost factors in Route Optimization API

Post by Bernd Welter »

By the way:

check the section Cost+vs.+Objective in the official SaaS documentation!

Thanks to Tim for redirecting me!

Enjoy your christmas vacation and get well into 2025 ;-)
bernd nikolaus 2019.face only.jpg
bernd nikolaus 2019.face only.jpg (18.42 KiB) Viewed 9750 times
Bernd
Bernd Welter
Technical Partner Manager Developer Components
PTV Logistics - Germany

Bernd at... The Forum,LinkedIn, Youtube, StackOverflow
I like the smell of PTV Developer in the morning... :twisted:
User avatar
Bernd Welter
Site Admin
Posts: 3025
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Re: Potential Cost factors in Route Optimization API

Post by Bernd Welter »

added the resource costs ("resources" are available as of 25.09.2025 / 1.24.0) to the article
Bernd Welter
Technical Partner Manager Developer Components
PTV Logistics - Germany

Bernd at... The Forum,LinkedIn, Youtube, StackOverflow
I like the smell of PTV Developer in the morning... :twisted:
User avatar
Bernd Welter
Site Admin
Posts: 3025
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Re: Potential Cost factors in Route Optimization API

Post by Bernd Welter »

added Version 1.26.0 | 2025-10-07
  • Feature: Added overloads to define an extra cost for loading orders onto a vehicle when the vehicle's load exceeds a threshold.
Bernd Welter
Technical Partner Manager Developer Components
PTV Logistics - Germany

Bernd at... The Forum,LinkedIn, Youtube, StackOverflow
I like the smell of PTV Developer in the morning... :twisted:
User avatar
Bernd Welter
Site Admin
Posts: 3025
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Re: Potential Cost factors in Route Optimization API

Post by Bernd Welter »

ver 1.31:

Request.resource.costs.perLayover:
  • number <double> >= 0
  • Default: 0
  • The cost charged when a layover occurs between consecutive vehicles sharing this resource. This cost is weighed against the cost for these vehicles to end and start at their provided start and end locations.
Bernd Welter
Technical Partner Manager Developer Components
PTV Logistics - Germany

Bernd at... The Forum,LinkedIn, Youtube, StackOverflow
I like the smell of PTV Developer in the morning... :twisted:
User avatar
Bernd Welter
Site Admin
Posts: 3025
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Re: Potential Cost factors in Route Optimization API

Post by Bernd Welter »

Added order.properties.insourcingRevenue in 1.34 / 20.11.2025:
Defines the revenue for scheduling the order on a route. The order will only be scheduled on a route when the sum of the outsourcingCost and insourcingRevenue is less than the added route cost. When both the outsourcingCost and insourcingRevenue are omitted, the optimization will try to schedule the order regardless of the added cost.
Bernd Welter
Technical Partner Manager Developer Components
PTV Logistics - Germany

Bernd at... The Forum,LinkedIn, Youtube, StackOverflow
I like the smell of PTV Developer in the morning... :twisted:
User avatar
Bernd Welter
Site Admin
Posts: 3025
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Re: Potential Cost factors in Route Optimization API

Post by Bernd Welter »

With version 1.37 you can now get more detailed infos about the costs produced by a certain route from the Response:
  • total : The total cost of the route.
  • fixed :The fixed cost of a the route.
  • time : The time cost of a the route. This includes the cost per hour as well as overtime costs.
  • distance : The distance cost of a the route. This includes the cost per kilometer as well as overdistance costs.
  • stop : The stop cost of a the route. This includes the cost per stop as well as overstops costs.
  • appointment : The appointment cost of a the route. Defined as the sum of all used time slots their cost per appointment.
  • load : The load cost of the route, defined by overload costs.
  • repositioning : effort
  • orderVehicle: The order-vehicle violation cost of the route. Defined as the sum of all violation costs for order-vehicle combination constraints applicable to the route.
This enables you to create such charts and shows where exactly the money flows:
Metrics-Costs-Chart.png
Metrics-Costs-DGV.png
Check Result.Routes[..].Metrics.Costs:
Metrics-Costs-Api.png
PS: In the past did this on client side and
  • :idea: it took time to implement this!
  • :idea: it was time consuming to derive this valuable info from the input parameters and returned routes!
Furthermore we also return some more details about the optimization result: Optimization.Metrics.Costs:
  • grossTotal : The total gross cost of the optimization result.
  • netTotal : The total net cost of the optimization result expressed as the total gross cost subtracted by the insourcing revenue.
  • routes : The total route cost. Contributes to the total gross cost of the optimization result.
  • outsourcing : The total outsourcing cost. Contributes to the total gross cost of the optimization result.
  • insourcing : The total insourcing revenue of the optimization result.
  • vehicleSlots : The cost incurred by all vehicle slots used in the optimziation result, as defined by the locations' stop concurrency. Contributes to the total gross cost of the optimization result.
  • resources : The total resource cost. Contributes to the total gross cost of the optimization result.
So big thanks to team engine for this internal calculation!
Bernd Welter
Technical Partner Manager Developer Components
PTV Logistics - Germany

Bernd at... The Forum,LinkedIn, Youtube, StackOverflow
I like the smell of PTV Developer in the morning... :twisted:
User avatar
Bernd Welter
Site Admin
Posts: 3025
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Re: Potential Cost factors in Route Optimization API

Post by Bernd Welter »

and we return the route metrics durations:
Route.Metrics.Duration.png
Bernd Welter
Technical Partner Manager Developer Components
PTV Logistics - Germany

Bernd at... The Forum,LinkedIn, Youtube, StackOverflow
I like the smell of PTV Developer in the morning... :twisted:
User avatar
Bernd Welter
Site Admin
Posts: 3025
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Re: Potential Cost factors in Route Optimization API

Post by Bernd Welter »

Cheerio,

We added Vehicle.Costs.unused in v1.47 (10.2.2026)

Bernd
Bernd Welter
Technical Partner Manager Developer Components
PTV Logistics - Germany

Bernd at... The Forum,LinkedIn, Youtube, StackOverflow
I like the smell of PTV Developer in the morning... :twisted:
Post Reply