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

# Clustering

Clustering is a route optimization feature that minimizes overlaps between trips from different vehicles. While this approach reduces route overlap, it may result in generally less optimized routes compared to non-clustered solutions.

## What is Clustering?

Clustering groups visits into distinct clusters and assigns each cluster to a specific vehicle. This prevents vehicles from crossing into each other's service areas, creating clear territorial boundaries for each route.

**Key Characteristics:**

* Reduces overlap between vehicle routes
* Creates distinct service territories per vehicle
* May result in longer total distances compared to fully optimized routes
* Useful when you prioritize clear route separation over absolute optimization

## Activate Clustering

To activate Clustering, follow these steps:

1. Go to the Routing/Configuration menu.
2. Check the "Clustering" checkbox.
3. Select one of two overlap prevention options:
   * Minimum overlap
   * No overlap

<div align="center">
  <img src="https://mintcdn.com/mileapp-c1584fbc/jvVKvpPwiK1qABos/images/clustering-configuration.png?fit=max&auto=format&n=jvVKvpPwiK1qABos&q=85&s=c83d0a62785c25494167f0ba19195cf8" alt="Clustering Configuration" width="600" data-path="images/clustering-configuration.png" />

  <p><i>Clustering configuration showing overlap options</i></p>
</div>

## Clustering Options

After enabling clustering, you can choose between two overlap prevention strategies:

### 1. Minimum Overlap

Use this option to minimize overlap between routes of different vehicles. Some overlap may still occur, but it will be kept to a minimum.

**When to use:**

* When complete separation is not critical
* When you want better overall route optimization while still reducing overlap
* For service areas with complex geography where some overlap is acceptable

**Trade-offs:**

* Better route efficiency compared to no overlap
* Slightly more flexible routing
* Some vehicles may still cross into nearby territories

### 2. No Overlap

Use this option to prevent any overlap between routes of different vehicles. Routes will be completely separated with no crossing service areas.

**When to use:**

* When strict territorial separation is required
* For compliance or operational policies requiring distinct service zones

**Trade-offs:**

* Strictest territorial boundaries
* May result in longer total distances
* Less routing flexibility

## How Clustering Works

### Without Clustering

Vehicles may visit locations across the entire service area, potentially crossing paths and overlapping routes for optimal efficiency.

### With Clustering

1. Visits are grouped into clusters based on proximity
2. Each cluster is assigned to a specific vehicle
3. Vehicles operate within their assigned cluster territory
4. Overlap is minimized or prevented based on selected option

## Use Cases

### Use Case 1: Regional Sales Teams

**Scenario:** Sales representatives with assigned territories

**Configuration:**

* Clustering: Enabled
* Clustering Option: No Overlap

**Result:** Each sales rep stays within their designated territory, no overlap with other reps.

### Use Case 2: Delivery Fleet with Territory Preference

**Scenario:** Drivers prefer consistent territories but can occasionally cross boundaries

**Configuration:**

* Clustering: Enabled
* Clustering Option: Minimum Overlap

**Result:** Drivers primarily stay in their territories but can cross for efficiency.

### Use Case 3: Mixed Urban and Rural Areas

**Scenario:** Some vehicles serve dense urban areas while others handle rural regions

**Configuration:**

* Clustering: Enabled
* Clustering Option: Minimum Overlap

**Result:** Natural clustering based on geography with minimal cross-territory visits.

## Best Practices

### When to Use Clustering

**✓ Use clustering when:**

* You need clear territorial boundaries between vehicles
* Drivers have assigned regions or service areas
* Reducing route overlap is more important than absolute optimization
* You want to prevent confusion from overlapping routes
* You have geographically distinct service areas

**✗ Avoid clustering when:**

* You prioritize minimum total distance over territorial boundaries
* Your service area is small and overlap is not an issue
* You need maximum route optimization efficiency
* Visits are densely packed in a small area
* You have very few vehicles serving a large area

### Choosing Between Minimum and No Overlap

| Aspect                 | Minimum Overlap  | No Overlap                   |
| ---------------------- | ---------------- | ---------------------------- |
| Overlap Allowed        | Some overlap     | Zero overlap                 |
| Route Efficiency       | Better           | May be less efficient        |
| Territorial Strictness | Flexible         | Strict                       |
| Total Distance         | Shorter          | Longer                       |
| Use When               | Some crossing OK | Complete separation required |

## Frequently Asked Questions

**Q: Will clustering always result in longer routes?**

A: Generally yes, because clustering prioritizes territorial separation over total distance optimization. The difference depends on visit distribution and service area geography. No Overlap typically results in longer routes than Minimum Overlap.

**Q: Can I use clustering with other route optimization features?**

A: Yes, clustering works with features like Auto Split, Auto Merge, Multi Trip, and capacity constraints. Clustering is applied during the optimization process.

**Q: What's the difference between "Minimum Overlap" and "No Overlap"?**

A: Minimum Overlap allows some vehicles to cross into nearby territories if it improves efficiency, while No Overlap creates strictly separated zones with no crossing allowed.

**Q: Does clustering work with tags?**

A: Yes, clustering respects tag constraints. Visits will only be assigned to vehicles with matching tags, even with clustering enabled.

**Q: Which clustering option should I choose?**

A: Use **Minimum Overlap** when you want territorial preference but value efficiency. Use **No Overlap** when strict territorial separation is mandatory.

**Q: Can clustering handle uneven visit distribution?**

A: Yes, but be aware that some vehicles may have smaller territories with more visits, while others have larger territories with fewer visits, depending on geographic distribution.

## Related Documentation

* [Route Optimization Configuration Introduction](/pages/route-optimization/configuration/introduction)
* [Auto Split](/pages/route-optimization/configuration/auto-split)
* [Auto Merge](/pages/route-optimization/configuration/auto-merge)
* [Multi Trip](/pages/route-optimization/configuration/multi-trip)
