> ## Documentation Index
> Fetch the complete documentation index at: https://docs.solvice.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Scoring System

> How the VRP solver evaluates and optimizes solutions

# Scoring System

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

## Score Levels

| Level      | Purpose                     | Feasibility                                  |
| ---------- | --------------------------- | -------------------------------------------- |
| **Hard**   | Must be satisfied           | hardScore = 0 required for feasible solution |
| **Medium** | Important but not mandatory | Minimized after hard constraints             |
| **Soft**   | Quality optimizations       | Minimized for best solution                  |

```json Feasible Solution theme={null}
{
  "score": {
    "hardScore": 0,
    "mediumScore": -500,
    "softScore": -12450,
    "feasible": true
  }
}
```

```json Infeasible Solution theme={null}
{
  "score": {
    "hardScore": -2000,
    "mediumScore": -800,
    "softScore": -15000,
    "feasible": false
  }
}
```

## Constraint Reference

### Hard Constraints

| Constraint             | Description                            |
| ---------------------- | -------------------------------------- |
| `TIME_WINDOW_CONFLICT` | Job scheduled outside hard time window |
| `TRIP_CAPACITY`        | Vehicle capacity exceeded              |
| `TAG_HARD`             | Missing required skill/tag             |
| `SHIFT_END_CONFLICT`   | Work extends past shift end            |
| `MAX_DRIVE_TIME`       | Driving limit exceeded                 |
| `DISALLOWED_RESOURCES` | Job assigned to blacklisted resource   |

### Medium Constraints

| Constraint                       | Description                     |
| -------------------------------- | ------------------------------- |
| `OVERTIME_END_CONFLICT`          | Work extends into overtime      |
| `DATE_TIME_WINDOW_CONFLICT_SOFT` | Soft time window violated       |
| `SAME_TRIP`                      | Related jobs on different trips |

### Soft Constraints

| Constraint            | Description                       |
| --------------------- | --------------------------------- |
| `TRAVEL_TIME`         | Total travel time                 |
| `WAIT_TIME`           | Idle time at locations            |
| `RESOURCE_ACTIVATION` | Number of vehicles used           |
| `RANKING_SOFT`        | Resource preference score         |
| `FAIR_WORK`           | Workload balance across resources |

## Weight Configuration

Control optimization priorities using weights:

```json theme={null}
{
  "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:

```json theme={null}
{
  "unserved": ["job-15"],
  "unservedReasons": {
    "job-15": ["TIME_WINDOW_CONFLICT", "TRIP_CAPACITY"]
  }
}
```
