Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VRP with a single location #291

Closed
senhalil opened this issue Jan 28, 2020 · 8 comments
Closed

VRP with a single location #291

senhalil opened this issue Jan 28, 2020 · 8 comments
Milestone

Comments

@senhalil
Copy link
Contributor

The following VRP problem with a single location (note that all location indices are 0) but with a 2x2 matrix returns the expected solution with zero cost.

However, if the matrix is replaced by a 1x1 matrix, then vroom tries to connect to OSRM and fail with the following error {"code":3,"error":"Failed to connect to 0.0.0.0:5000"} (since there is no lat/lon, even if the connection succeeds, the query would fail anyway).

I believe the offender is if (_matrix.size() < 2) { check on src/structures/vroom/input/input.cpp:332 inside solve function.

Is the check against 2 is necessary? It seems to me that 1 does the job well.

# input
{
  "vehicles": [
    {
      "id": 0,
      "start_index": 0,
      "end_index": 0
    }
  ],
  "jobs": [
    {
      "id": 0,
      "location_index": 0
    }
  ],
  "matrix": [
    [
      0,
      6232
    ],
    [
      6239,
      0
    ]
  ]
}
# output
{
  "code": 0,
  "summary": {
    "cost": 0,
    "unassigned": 0,
    "service": 0,
    "duration": 0,
    "waiting_time": 0,
    "computing_times": {
      "loading": 0,
      "solving": 0
    }
  },
  "unassigned": [],
  "routes": [
    {
      "vehicle": 0,
      "cost": 0,
      "service": 0,
      "duration": 0,
      "waiting_time": 0,
      "steps": [
        {
          "type": "start",
          "arrival": 0,
          "duration": 0
        },
        {
          "type": "job",
          "job": 0,
          "service": 0,
          "waiting_time": 0,
          "arrival": 0,
          "duration": 0
        },
        {
          "type": "end",
          "arrival": 0,
          "duration": 0
        }
      ]
    }
  ]
}
@senhalil
Copy link
Contributor Author

I went ahead and opened a pull-request just in case.

@jcoupey
Copy link
Collaborator

jcoupey commented Jan 28, 2020

Kind of an edge case, but definitely a bug. The _matrix.size() < 2 check is a poor man's way to test if a custom matrix has been provided in input. It may have been OK back in the days (with TSP-only code) because we probably had other ways to enforce having several locations.

A clean fix would be to add a boolean member along the line of _has_custom_matrix and use it as a flag for the above test. I think it would be sufficient to have it set to false in the Input ctor and switch to true whenever Input::set_matrix is called.

@senhalil
Copy link
Contributor Author

I see the fix you suggested. I will modify the pull request accordingly.

@jcoupey
Copy link
Collaborator

jcoupey commented Feb 4, 2020

Hi @senhalil what's your schedule on this?

Just asking because I'd like to include this fix in the next release candidate, hopefully in the next few days (also #295 would benefit from having a flag member to know whether a custom matrix has been provided).

@senhalil
Copy link
Contributor Author

senhalil commented Feb 4, 2020

Sorry for the radio silence. I'll look into it now.

@senhalil
Copy link
Contributor Author

senhalil commented Feb 4, 2020

Ready for review.

@jcoupey
Copy link
Collaborator

jcoupey commented Feb 4, 2020

This is fixed in #298. Thanks @senhalil for reporting and submitting a PR!

@jcoupey jcoupey closed this as completed Feb 4, 2020
@senhalil
Copy link
Contributor Author

senhalil commented Feb 4, 2020

This is fixed in #298. Thanks @senhalil for reporting and submitting a PR!

Happy to help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants