Skip to main content

Vehicle Labels and Order Labels

One way to manage these relationships between vehicles and orders is through the use of vehicle labels and order labels. These labels act as tags or identifiers that provide additional information about the vehicles and orders, enabling more sophisticated and nuanced route optimization.

The SWAT model uses vehicle and order labels to match bookings with appropriate vehicles. These labels guide the assignment algorithm, restricting it to consider only orders and vehicles with matching labels. Furthermore, the API allows configuring label interpretation rules using 'OR' and 'AND' logic. Labels can be used to achieve zoning with the vehicles without applying geofence boundaries for the operations where geofences are hard to manage or do not provide enough flexibility.

Please refer to filtering to learn how to apply the filtering rules or refer to API.

Vehicle Labels:

Vehicle labels are attributes or classifications assigned to vehicles to represent specific characteristics, capabilities, or restrictions. These labels can be based on various factors, such as:

  • Vehicle Type: Labels like "van," "truck," "refrigerated truck," or "motorcycle" can categorize vehicles based on their size, capacity, and functionality.
  • Skills or Certifications: Labels can indicate if a vehicle has a driver with specific skills or certifications, such as "hazardous material handling" or "heavy machinery operation."
  • Equipment: Labels can signify the presence of specialized equipment, like "tail lift," "refrigeration," or "navigation system."
  • Availability: Labels can denote time windows or other availability constraints, such as "morning shift" or "weekend availability."
  • Zones or Regions: Labels can specify the operational zones or regions of a vehicle, such as "downtown delivery" or "regional transport."

Order Labels:

Order labels are similar identifiers assigned to orders to represent specific requirements, priorities, or restrictions. These labels can be based on factors like:

  • Order Type: Labels like "fragile," "urgent," "high-value," or "perishable" can categorize orders based on their handling needs.
  • Customer Type: Labels can indicate the type of customer, such as "VIP customer," "regular customer," or "new customer."
  • Delivery Time Windows: Labels can specify preferred or required delivery time windows, such as "morning delivery" or "afternoon delivery."
  • Location: Labels can denote the location or zone of the delivery, such as "city center" or "suburban area."
  • Special Instructions: Labels can convey specific instructions for handling the order, such as "handle with care" or "deliver to the back entrance.

Relationship Between Vehicle Labels and Order Labels:

Vehicle labels and order labels are interconnected. The labels assigned to an order determine the types of vehicles that are suitable to fulfill it. Matching vehicle labels with order labels is crucial for efficient and feasible route planning.

Here's how they relate:

  • Order labels guide vehicle selection: The labels on an order specify the characteristics required of the vehicle that will serve it.
  • Vehicle labels restrict order assignments: The labels on a vehicle determine the types of orders it can handle.
  • Matching labels ensures compatibility: Assigning orders to vehicles with mismatched labels can lead to infeasible or inefficient routes.
  • Labeling flexibility enhances routing efficiency: A well-designed labeling system allows for more flexible and optimized routing solutions.

Example:

A delivery company uses the following labels:

  • Vehicle Labels: "Fragile," "Perishable," "Urgent," "Downtown"
  • Order Labels: "Fragile," "Perishable," "Urgent," "Downtown"

Consider these orders:

  • Order 1: "Fragile," "Downtown"
  • Order 2: "Perishable," "Urgent"

In this scenario:

  • Order 1 can be served by a vehicle with the "Downtown" label and\or with "Fragile" label.
  • Order 2 requires a vehicle with the "Perishable" label and\or "Urgent"

By using labels, the company can efficiently match orders with appropriate vehicles, ensuring that fragile items are handled carefully, perishable goods are transported in refrigerated trucks, and urgent orders are prioritized.

Implementation in SWAT APIs

tip

Within the same simulation run, you can group orders and vehicles using labels. If you need to separate simulation runs for different vehicle and order groups with matching labels, you can use filtering expressions in the simulation processor.

Labels can be applied to manage the matching process of labels between vehicles, bookings and nodes.

The booking.vehicle_labels field in the booking object lists vehicle labels of vehicles eligible for delivering the order. In the following example, optimizing orders with this vehicle_labels field ensures that only vehicles with T01, T02, or T03 labels are used to fulfill these orders:

// Booking

"vehicle_labels": {
"or": [
"T01",
"T02",
"T03"
]
}
//Vehicle

"labels": [
"T01",
"T02",
"T03"
]
tip

In Optimization API, labels should be applied at a node level for each node with the matching booking_uid

Label Matching Logic for Assignments

The assignment of an order (booking) to a vehicle depends on how their respective labels interact:

  • Order Has Labels, Vehicle Has Matching Labels:

    • Result: Assignment is possible.
    • Explanation: The vehicle possesses the characteristics required by the order. For example, if an order has vehicle_labels: {"or": ["refrigerated"]} and a vehicle has labels: ["refrigerated", "large_capacity"], the match is successful.
  • Order Has No Specific Label Requirements, Vehicle Has Labels:

    • Result: Assignment is possible.
    • Explanation: The order does not impose any specific label requirements (e.g., vehicle_labels is empty or not present). Therefore, any vehicle, including those with labels, can potentially service it, provided other constraints like capacity and time windows are met. For example, an order without specific vehicle_labels can be assigned to a vehicle with labels: ["zone_A"].
  • Order Has Labels, Vehicle Has No Labels (or Non-Matching Labels):

    • Result: Assignment is NOT possible (no offer).
    • Explanation: The order requires specific characteristics (defined by its vehicle_labels) that the vehicle does not possess. For example, if an order has vehicle_labels: {"or": ["refrigerated"]} and a vehicle has labels: ["van"] (and "van" is not considered "refrigerated"), the assignment will fail. Similarly, if the vehicle has no labels at all (labels: []), it cannot satisfy an order that requires specific labels.
  • Neither Order Nor Vehicle Has Labels:

    • Result: Assignment is possible.
    • Explanation: There are no label-based restrictions from either the order or the vehicle that would prevent an assignment.
tip

Remember that label matching is just one part of the assignment process. Other constraints such as vehicle capacity, time windows, and vehicle characteristics also play a crucial role.

The filtering logic for labels (e.g., "AND", "OR" conditions) is detailed in the filtering expressions documentation. For example, an order with labels set to {"and": [{"or: ["Label 1", "Label 2"]}, {"not": {"and": ["Label 4", "Label 5"]}}]} will have the scenarios below supported:

Examples of Matching Combinations

A combination of labels will match if it satisfies both parts of the main and clause: (Label 1 or Label 2) must be true AND not (Label 4 and Label 5) must be true.

  1. {"Label 1"}: This combination matches because it satisfies the first part of the expression ("Label 1" or "Label 2" is true) and it doesn't contain "Label 4" and "Label 5" together, so the second part (not ("Label 4" and "Label 5")) is also true.
  2. {"Label 2", "Label 3"}: This also matches. It contains "Label 2" (satisfying the first part) and doesn't contain both "Label 4" and "Label 5" (satisfying the second part). "Label 3" is an irrelevant label that doesn't affect the outcome.
  3. {"Label 1", "Label 2"}: This matches because it contains "Label 1" and "Label 2", so the first part is true. It doesn't contain both "Label 4" and "Label 5", so the second part is also true.
  4. {"Label 1", "Label 4"}: This matches. The first part is true because it contains "Label 1". The second part is also true because while it contains "Label 4", it does not contain "Label 5". Therefore, "Label 4" and "Label 5" is false, and not ("Label 4" and "Label 5") is true.

Examples of Non-Matching Combinations

A combination of labels will not match if either part of the main and clause is false.

  1. {"Label 3", "Label 4"}: This doesn't match because the first part of the expression ("Label 1" or "Label 2") is false. The combination lacks both "Label 1" and "Label 2".
  2. {"Label 1", "Label 4", "Label 5"}: This doesn't match. Although the first part is true (it contains "Label 1"), the second part is false. It contains both "Label 4" and "Label 5", making "Label 4" and "Label 5" true. The not operator then makes the second clause not ("Label 4" and "Label 5") false.
  3. {"Label 4", "Label 5"}: This doesn't match. Both parts of the expression fail. The first part is false because it lacks both "Label 1" and "Label 2". The second part is also false because it contains both "Label 4" and "Label 5".
  4. {}: An empty set of labels will not match. The first part is false since it doesn't contain "Label 1" or "Label 2".

Playground

You can try out the Vehicle Labels concept using the playground below. The example defines two vehicles with different labels ("cold" and "dry") and two jobs requiring specific labels. Observe how the solver assigns the "Cold Storage Job" to the "Cold Truck" and the "Dry Goods Job" to the "Dry Truck".

Loading...