Skip to content

Replace similar constraints with value-bound-constraint #61

@bmeesters

Description

@bmeesters

Introduction

In the past few releases we see more and more requests for new constraint types. As a result, the list of constraint types gets quite big and can get overwhelming for parties just starting out with OTM5. We had a few discussions about this and came to the conclusion that there are two paths forward.

  1. Continue as is. The amount of constraints can be a bit overwhelming, but the constraints themselves are precise, and you are not required to use all of them.
  2. Merge constraints that are similar to less constraints, and easier see the similarities between the type of constraints. The benefit would be less constraints to implement while having more modelling power. The downside would be that you 'hid' some of the complexities. It is less overwhelming at first, but there is still the same amount of constraints you need to deal with.

Example

To help decide what would be the best way forward we looked at a more advanced use case and see how both approaches would evolve with the following constraints.

  • The consignments contains dangerous goods (ADR) with two pallets of gasses
  • The driver needs a license to be able to deal with the ADR (constraint on the consignment itself)
  • The consignment is involved in two actions, loading in Breda and unloading in Amsterdam
  • The unloading needs to happen between 07:00 and 10:00 on 2 June 2022. (constraint on the unloading action)
  • The vehicle has to be less than 25.000 kg and 3.80m and only emit according to EUR6 standard
  • The location is only accessible between 07:00 and 10:00.

Current approach with constraint for each sub type

This is the original Constraint as defined in https://otm5.opentripmodel.org/#tag/Constraint but extended with some new constraint types (ForkLift to indicate the unloading location needs one to unload the locations, DriverLicense ADR to indicate the driver needs to be in possession of this license to able to operate the vehicle, Tailgate to indicate the vehicle used needs a tailgate to load/unload the goods) to fit the example. The upside of this approach is that it is easier to clearly document each new constraint and the type of values that are allowed. The downside is that the amount of constraints grows rapidly and it becomes hard to see the 'forest' through the trees.

{
  "id":"fa6c683c-7130-4955-9789-f99f2bb4eba3",
  "name":"SUTC consignment with constraints",
  "goods":[
    {
      "entity":{
        "id":"9503d7bd-a9e7-413b-9828-2e6581d1029e",
        "quantity":2,
        "containedGoods":[
          {
            "entity":{
              "adr":{
                "UNNumber":"<UN number>",
                "description":"dangerous gasses",
                "packagingGroup":"???",
                "tunnelCode":"???",
                "language":"NLD"
              },
              "type":"items"
            },
            "associationType":"inline"
          }
        ],
        "equipmentType":"pallet",
        "type":"transportEquipment"
      },
      "associationType":"inline"
    }
  ],
  "actions":[
    {
      "entity":{
        "location":{
          "entity":{
            "geoReference":{
              "name":"Breda",
              "type":"addressGeoReference"
            }
          },
          "associationType":"inline"
        },
        "actionType":"load"
      },
      "associationType":"inline"
    },
    {
      "entity":{
        "location":{
          "entity":{
            "geoReference":{
              "name":"Some warehouse in Amsterdam",
              "type":"addressGeoReference"
            },
            "constraint":{
              "entity":{
                "value":{
                  "and":[
                    {
                      "startTime":"2022-06-02T07:00:00Z",
                      "endTime":"2022-06-02T09:00:00Z",
                      "description":"Location accessible",
                      "type":"timeWindowConstraint"
                    },
                    {
                      "constraintType":"maximum",
                      "maximum":{
                        "value":25000,
                        "unit":"kg"
                      },
                      "description":"vehicle weight",
                      "type":"weightConstraint"
                    },
                    {
                      "constraintType":"maximum",
                      "maximum":{
                        "value":3.8,
                        "unit":"m"
                      },
                      "description":"vehicle height",
                      "type":"weightConstraint"
                    },
                    {
                      "emissionTypes":[
                        "euro6"
                      ],
                      "type":"emissionTypeConstraint"
                    }
                  ],
                  "type":"andConstraint"
                }
              },
              "associationType":"inline"
            }
          },
          "associationType":"inline"
        },
        "constraint":{
          "entity":{
            "value":{
              "startTime":"2022-06-02T07:00:00Z",
              "endTime":"2022-06-02T10:00:00Z",
              "type":"timeWindowConstraint"
            }
          },
          "associationType":"inline"
        },
        "actionType":"unload"
      },
      "associationType":"inline"
    }
  ],
  "constraint":{
    "entity":{
      "value":{
        "value":[
          "ADRLicense"
        ],
        "type":"driverLicenseConstraint"
      }
    },
    "associationType":"inline"
  }
}

Combined constraints

This is a modified constraint type that supports:

  • The combination constraints: and, or and not (same as original constraint)
  • time window constraints: boundaries that indicate contractual obligations or limitations of when locations are reachable/open. (same as original constraint)
  • Value type constraints that limit what types are permitted (e.g. only refrigerated trailers, EV fuel type, EUR6 emission type, etc.). NEW
    Value bound constraints: certain types have a max/min or range that is allowed, such as temperature, speed, size, or weight. NEW
    Property type constraints: locations, vehicles or people that need to be in possession of certain properties such as forklifts, tailgates, ADR licenses. NEW
{
  "id":"fa6c683c-7130-4955-9789-f99f2bb4eba3",
  "goods":[
    {
      "entity":{
        "id":"9503d7bd-a9e7-413b-9828-2e6581d1029e",
        "quantity":2,
        "containedGoods":[
          {
            "entity":{
              "adr":{
                "UNNumber":"<UN number>",
                "description":"dangerous gasses",
                "packagingGroup":"???",
                "tunnelCode":"???",
                "language":"NLD"
              },
              "type":"items"
            },
            "associationType":"inline"
          }
        ],
        "equipmentType":"pallet",
        "type":"transportEquipment"
      },
      "associationType":"inline"
    }
  ],
  "actions":[
    {
      "entity":{
        "location":{
          "entity":{
            "geoReference":{
              "name":"Breda",
              "type":"addressGeoReference"
            }
          },
          "associationType":"inline"
        },
        "actionType":"load"
      },
      "associationType":"inline"
    },
    {
      "entity":{
        "location":{
          "entity":{
            "geoReference":{
              "name":"Some warehouse in Amsterdam",
              "type":"addressGeoReference"
            }
          },
          "associationType":"inline"
        },
        "constraint":{
          "entity":{
            "value":{
              "startTime":"2022-06-02T07:00:00Z",
              "endTime":"2022-06-02T10:00:00Z",
              "type":"timeWindowConstraint"
            }
          },
          "associationType":"inline"
        },
        "actionType":"unload"
      },
      "associationType":"inline"
    }
  ],
  "constraint":{
    "entity":{
      "value":{
        "needs":[
          "adrLicense"
        ],
        "type":"propertyTypeConstraint"
      }
    },
    "associationType":"inline"
  }
}

Most notably this means a few new constraint types:

image

image

image

But it would also mean we can delete

  • sizeConstraint
  • weightConstraint
  • speedConstraint
  • sensorValueConstraint
  • temperatureConstraint
  • vehicleTypeConstraint
  • transportEquipmentConstraint
  • fuelTypeConstraint

And would support the earlier requested emissionTypeConstraint.

Metadata

Metadata

Assignees

No one assigned

    Labels

    OTM 5.5This ticket is included in OTM 5.5enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions