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
| Parameter | Description | Default | Unit |
|---|---|---|---|
drivingCostPerHour | Cost of driver time while driving/traveling | 25.0 | EUR/hour |
distanceCostPerKm | Cost per kilometer (fuel, maintenance, wear) | 0.0 | EUR/km |
waitingCostPerHour | Cost of idle/waiting time | 0.0 | EUR/hour |
overtimeCostPerHour | Cost of overtime work | 50.0 | EUR/hour |
timeWindowViolationCostPerHour | Penalty for missing time windows | 20.0 | EUR/hour |
priorityCostPerPointPerHour | Cost per priority point per hour late | 5.0 | EUR |
preferredResourceViolationCost | Penalty for not using preferred resource | 20.0 | EUR |
rankingViolationCostPerRank | Cost per rank deviation | 5.0 | EUR |
resourceActivationCost | Fixed cost for using a resource | (from resource) | EUR |
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
Fixed costs incurred when a resource is used:Cost Calculation Examples
- Employee Model
- Contractor Model
- Rental Model
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: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: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:DayIndex Strategy
Set dayIndex
dayIndex: 0 = available immediately
dayIndex: 1 = available from day 2
dayIndex: 2 = available from day 3Optimization Strategies
Strategy 1: Cost Minimization
Focus on reducing operational costs:Strategy 2: Service Level Optimization
Prioritize customer satisfaction:Strategy 3: Balanced Optimization
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:Multi-Objective Optimization
Balance competing objectives:Performance Tips
Best Practices
Measure Impact
Track these metrics:
- Total operational cost
- Cost per delivery/service
- Resource utilization rates
- Customer satisfaction scores
Iterate and Refine
- Adjust weights based on business priorities
- Monitor unintended consequences
- Document weight configurations
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