Skip to main content

Scoring System

The VRP solver uses a three-level scoring system: Hard, Medium, and Soft constraints.

Score Levels

LevelPurposeFeasibility
HardMust be satisfiedhardScore = 0 required for feasible solution
MediumImportant but not mandatoryMinimized after hard constraints
SoftQuality optimizationsMinimized for best solution
{
  "score": {
    "hardScore": 0,
    "mediumScore": -500,
    "softScore": -12450,
    "feasible": true
  }
}

Constraint Reference

Hard Constraints

ConstraintDescription
TIME_WINDOW_CONFLICTJob scheduled outside hard time window
TRIP_CAPACITYVehicle capacity exceeded
TAG_HARDMissing required skill/tag
SHIFT_END_CONFLICTWork extends past shift end
MAX_DRIVE_TIMEDriving limit exceeded
DISALLOWED_RESOURCESJob assigned to blacklisted resource

Medium Constraints

ConstraintDescription
OVERTIME_END_CONFLICTWork extends into overtime
DATE_TIME_WINDOW_CONFLICT_SOFTSoft time window violated
SAME_TRIPRelated jobs on different trips

Soft Constraints

ConstraintDescription
TRAVEL_TIMETotal travel time
WAIT_TIMEIdle time at locations
RESOURCE_ACTIVATIONNumber of vehicles used
RANKING_SOFTResource preference score
FAIR_WORKWorkload balance across resources

Weight Configuration

Control optimization priorities using weights:
{
  "options": {
    "weights": {
      "travelTimeWeight": 1,
      "waitTimeWeight": 10,
      "urgencyWeight": 100,
      "priorityWeight": 50,
      "workloadSpreadWeight": 20,
      "minimizeResourcesWeight": 3600
    }
  }
}

Unassigned Jobs

When jobs cannot be assigned, the response includes reasons:
{
  "unserved": ["job-15"],
  "unservedReasons": {
    "job-15": ["TIME_WINDOW_CONFLICT", "TRIP_CAPACITY"]
  }
}