Skip to main content

Cost Optimization

The VRP solver provides comprehensive cost modeling to optimize your routing operations based on real business constraints. This guide covers the recommended cost-based configuration, weight-based tuning, and optimization strategies. The simplest way to configure the solver is using the costs configuration. Instead of tuning abstract weights, you specify actual business costs in EUR (or your currency), and the solver derives optimal weights automatically.
Why use costs instead of weights?
  • Intuitive: Costs represent real business values (EUR/hour, EUR/km)
  • Comparable: Different constraint types can be directly compared
  • Transparent: Response includes a cost breakdown in your currency
  • Maintainable: Business changes are easier to translate to configuration

Available Cost Parameters

Cost Breakdown in Response

When using costs, the response includes a detailed financial breakdown:

Cost Types Overview

The solver considers multiple cost components when optimizing routes:
Total Cost = Fixed Costs + Variable Costs + Penalty Costs
  • Fixed Costs: Activation costs for using resources
  • Variable Costs: Time-based costs (hourly rates, overtime), distance costs
  • Penalty Costs: Violations of soft constraints

Resource Cost Configuration

Hourly Costs

Configure time-based costs for resources:
Hourly costs apply to the entire shift duration, not just driving time. Consider using activation costs if you only want to charge for actual usage.

Activation Costs

A fixed cost incurred whenever a resource is actually used. This is configured once for the whole request via costs.resourceActivationCost — there is no per-resource activationCost field on the resource itself:

Cost Calculation Examples

Because resourceActivationCost is a single request-wide value, it applies identically to every resource that ends up used — the only per-resource lever for cost differences is hourlyCost:
8-hour shift cost: 8 × 30=30 = 240 Used or not: Same cost (salaried, no activation cost)
resourceActivationCost lives under costs and applies request-wide — you cannot give individual resources different activation costs.

Travel Cost Optimization

The easiest way to optimize travel costs is using the costs configuration:
This example says:
  • Every hour of driving costs 25 EUR (driver wages, opportunity cost)
  • Every kilometer driven costs 0.35 EUR (fuel, maintenance, depreciation)
The solver will balance both time and distance to minimize total cost.
Typical cost values:
  • Driving cost: 20-40 EUR/hour (depending on driver wages)
  • Distance cost: 0.25-0.50 EUR/km (depending on vehicle type)
  • Small city car: ~0.25 EUR/km
  • Delivery van: ~0.35 EUR/km
  • Heavy truck: ~0.50 EUR/km

Using Weight-Based Configuration (Advanced)

For fine-grained control, use the weights configuration:
number
default:"1"
Multiplier for travel time in the objective function. Higher values prioritize shorter travel times.

Balancing Travel vs Other Objectives

Urgency-Based Optimization

Basic Urgency Scoring

Prioritize time-sensitive jobs:
integer
default:"0"
Priority score from 0-100. Higher values are scheduled earlier.

Urgency Calculation Formula

Urgency Impact = urgency × urgencyWeight × time_until_scheduledThis creates increasing pressure to schedule urgent jobs sooner.

ASAP Scheduling

Schedule jobs as soon as possible across multiple days:

ASAP Strategy

There is no dayIndex job field. The earliest day a job can be scheduled is determined entirely by its windows: flexible-task-1’s first window opens on day 1, while flexible-task-2 only becomes available on day 2 because that’s where its first window starts.
1

Express Earliest Availability via Windows

A job’s first windows entry sets its earliest possible day — omit early windows to push earliest availability out
2

Configure Weight

Higher asapWeight = stronger preference for using a job’s earliest available window over a later one
3

Combine with Urgency

Optimization Strategies

Strategy 1: Cost Minimization

Focus on reducing operational costs:
There is no per-resource activationCost field. A flat cost per activated resource is configured request-wide via costs.resourceActivationCost; the weight-based equivalent for reducing the number of vehicles used is weights.minimizeResourcesWeight.

Strategy 2: Service Level Optimization

Prioritize customer satisfaction:
There is no global windowWeight. Time-window preference strength is set per window via that window’s own hard/weight fields (hard: false makes it a soft preference, weight sets the penalty for missing it). The weight for keeping a job on its preferred/planned resource is preferredVehicleWeight, not preferredResourceWeight.

Strategy 3: Balanced Optimization

fairWorkloadPerResource and fairWorkloadPerTrip are booleans under options, not numeric weights. The single weight that controls how aggressively both are enforced is weights.workloadSpreadWeight.

Cost Analysis in Results

When using the costs configuration, the response includes a detailed estimatedCost breakdown:
The estimatedCost field is only included when you provide a costs configuration in the request.

Understanding Cost Components

  • Resource activation costs
  • Daily vehicle fees
  • Equipment rental charges
  • Base operating costs
  • Hourly labor costs
  • Fuel costs (via travel time)
  • Overtime premiums
  • Distance-based charges
  • Soft time window violations
  • Preference violations
  • Workload imbalance penalties
  • Capacity overages (if allowed)

Advanced Cost Scenarios

Peak Hour Pricing

Different costs for different times:

Performance Tips

Cost Calculation Performance:
  • Complex cost models increase computation time
  • Many soft constraints require more iterations
  • Large weight differences can cause instability
Recommendations:
  • Keep weights in reasonable ratios (1:100 max)
  • Use hard constraints where possible
  • Profile different weight combinations

Best Practices

1

Start with Defaults

Begin with default weights and adjust based on results
2

Measure Impact

Track these metrics:
  • Total operational cost
  • Cost per delivery/service
  • Resource utilization rates
  • Customer satisfaction scores
3

Iterate and Refine

  • Adjust weights based on business priorities
  • Monitor unintended consequences
  • Document weight configurations
4

Consider Trade-offs

  • Lower costs vs better service
  • Fewer vehicles vs more overtime
  • Urgency vs efficiency

Troubleshooting

Check:
  • Overtime penalties being triggered
  • Excessive activation of resources
  • Long travel times due to poor clustering
  • Soft constraint violations
Solutions:
  • Review shift definitions
  • Adjust activation costs
  • Modify territory assignments
  • Convert critical soft constraints to hard
Check:
  • Weight balance between objectives
  • Conflicting constraints
  • Insufficient resources
Solutions:
  • Reduce focus on cost minimization
  • Increase service-related weights
  • Add resources or extend shifts
Check:
  • urgencyWeight value
  • Competing objectives
  • Time window conflicts
Solutions:
  • Increase urgencyWeight significantly
  • Reduce other weight values
  • Review job time windows

Resource Management

Configure resource costs and constraints

Time Windows

Balance costs with time constraints

Workload Balancing

Fair distribution vs cost optimization

Scoring System

How costs affect solution scoring