Skip to content

Error with inconsistent vehicle capacity arrays #1086

@jcoupey

Description

@jcoupey

My intent when parsing json what to ensure all vehicles either have no capacity key, or have all the same length for the capacity array. In particular I expect a missing capacity array to trigger an error. This happens for example when using:

{
  "vehicles": [
    {
      "id":0,
      ...
    },
    {
      "id":1,
      "capacity": [1],
      ...
    ],
    ...

resulting in an error with the message "Inconsistent capacity length: 1 and 0."

So far so good, but I just found out that reversing the order of vehicles above changes the behavior: we no longer get an error, instead the capacity for vehicle with id 0 is considered as zero and we move on with solving.
In this situation the vehicle won't get a route assigned if all tasks have a non-zero demand, so this is not such a big problem if considering that no capacity key means zero capacity.

Yet I think we should change this because:

  • it would be more consistent to enforce always explicitly providing a capacity array as initially intended;
  • it is clearer to get an error in the first place than to have to debug why those vehicles do not get routes (the reason I stumbled upon this);
  • getting either a "usual" solution or an error just by changing vehicle order in input is not really acceptable.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions