Page 1 of 1

How to model vehicle with TRAILER / without TRAILER?

Posted: Wed Jan 07, 2026 12:09 pm
by Bernd Welter
The following usecase is quite generic within tour optimization and therefore I would like to describe how to model this:
  • We have a fleet with multiple vehicles we can utilize.
  • For some of the vehicles we can consider an optional trailer which means:
    • If a trailer is attached to the vehicle it's COSTS and CAPACITIES change.
    • The optimization should check whether a trailer is meaningful or not for a certain vehicle.
  • Bonus: some orders may prohibit a trailer vehicle to serve them.
Now here's the proper modeling approach - based on a single vehicle named "TheVehicle4711" (If you get this for a single vehicle you can easily derive how to use this in multiple vehicles):
  • Define a so-called Resource "Resource-4711" which is free of costs and limited to maximumVehicles=1:

    Code: Select all

    {
      "id" :"TheVehicle4711",
      "minimumBufferDuration" : 0,
      "constraints" : {
         "maximumVehicles" : 1
      },
      "costs": null,
      "categories" : ["Cat-Res-4711"]
    }
    
  • Create two alternative vehicle objects : one with the trailer based properties (higher capacity, higher costs)
    • Code: Select all

      {
        "id" : "vehicle-4711-no-trailer",
        "requiredResourceCategories": [ "Cat-Res-4711" ],
        ...
      }
      
    • Code: Select all

      {
        "id" : "vehicle-4711-with-trailer",
        "requiredResourceCategories": [ "Cat-Res-4711" ],
        ...
        "categories": ["hasTrailer"]
      }
      
  • For the bonus requirement: forbid "hasTrailer" vehicles to serve certain orders:
    • use constraints.combinations.orderVehicle:

      Code: Select all

      {
          "combinations": {
            "orderVehicle": [
               "type": "FORBIDDEN_COMBINATION",
               "orderCategory": "no-trailer",
               "vehicleCategory" : "hasTrailer"
            ]      
          }
      }
      
    • Mark the critical orders as "no-trailer" category:

      Code: Select all

      {
         "id" ; "order-23",
         "properties": {
            "categories" : [ "no-trailer" ]
         }   
      }