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.Quick Start: Cost-Based Optimization (Recommended)
The simplest way to configure the solver is using thecosts 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 usingcosts, 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:Activation Costs
A fixed cost incurred whenever a resource is actually used. This is configured once for the whole request viacosts.resourceActivationCost — there is no per-resource activationCost field on the resource itself:
Cost Calculation Examples
BecauseresourceActivationCost 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:
- Employee Model
- Contractor Model
- Rental Model
resourceActivationCost lives under costs and applies request-wide — you cannot give individual resources different activation costs.Travel Cost Optimization
Using Cost-Based Configuration (Recommended)
The easiest way to optimize travel costs is using thecosts configuration:
- Every hour of driving costs 25 EUR (driver wages, opportunity cost)
- Every kilometer driven costs 0.35 EUR (fuel, maintenance, depreciation)
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 nodayIndex 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 out2
Configure Weight
Higher
asapWeight = stronger preference for using a job’s earliest available window over a later one3
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 thecosts 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
Fixed Costs
Fixed Costs
- Resource activation costs
- Daily vehicle fees
- Equipment rental charges
- Base operating costs
Variable Costs
Variable Costs
- Hourly labor costs
- Fuel costs (via travel time)
- Overtime premiums
- Distance-based charges
Penalty Costs
Penalty Costs
- 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
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
Unexpected High Costs
Unexpected High Costs
Check:
- Overtime penalties being triggered
- Excessive activation of resources
- Long travel times due to poor clustering
- Soft constraint violations
- Review shift definitions
- Adjust activation costs
- Modify territory assignments
- Convert critical soft constraints to hard
Poor Route Quality
Poor Route Quality
Check:
- Weight balance between objectives
- Conflicting constraints
- Insufficient resources
- Reduce focus on cost minimization
- Increase service-related weights
- Add resources or extend shifts
Urgency Not Respected
Urgency Not Respected
Check:
- urgencyWeight value
- Competing objectives
- Time window conflicts
- Increase urgencyWeight significantly
- Reduce other weight values
- Review job time windows
Related Features
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