VROOM-Project / pyvroom

Vehicle Routing Open-source Optimization Machine
BSD 2-Clause "Simplified" License
67 stars 14 forks source link

A more realistic example with the project #80

Open bencz opened 1 year ago

bencz commented 1 year ago

The project is very good, with this binding in python, it makes it simpler to implement rest/grpc APIs to calculate routings.

But I couldn't understand how to use the bind, with information like the ones we use in the vroom C++ version, for example, let's take the following request made to vroom-express:

{
  "jobs": [
    {
      "id": 1,
      "description": "Rue des Binelles, Sèvres",
      "location": [
        2.214431762695313,
        48.82359296752074
      ]
    },
    {
      "id": 2,
      "description": "Quai Henri Pourchasse, Ivry-sur-Seine",
      "location": [
        2.4087524414062504,
        48.813194201165274
      ]
    },
    {
      "id": 3,
      "description": "51, Allée Jules Guesde, Les Pavillons-sous-Bois",
      "location": [
        2.497329711914063,
        48.89948375541988
      ]
    },
    {
      "id": 4,
      "description": "Rue La Boétie, Paris",
      "location": [
        2.309188842773438,
        48.87239311228893
      ]
    }
  ],
  "shipments": [],
  "vehicles": [
    {
      "id": 1,
      "start": [
        2.2384643554687504,
        48.93242424920101
      ],
      "startDescription": "Quai de Bezons, Argenteuil",
      "end": [
        2.2384643554687504,
        48.93242424920101
      ],
      "endDescription": "Quai de Bezons, Argenteuil"
    }
  ],
  "options": {
    "g": true
  }
}

I saw that we can input the time matrix, for example, returned by OSRM's table API. My doubts start now, how to create a vehicle with its lat/long What is the correct way to request the time matrix for OSRM? What is the source and destination in the OSRM request?

jonathf commented 1 year ago

If you are going to use it as an API, the best I can offer in this second is doing something like:

instance = vroom.Input()
instance._from_json(json_string, geometry)

This is a direct call to the vroom json parser.

I'll update the Input.from_json soon to allow for string input in addition to filepath.

bencz commented 1 year ago

Well, that's a good start! And how is the osrm configuration?

jonathf commented 1 year ago

I haven't tried it, but the format is:

instance = vroom.Input(servers={"<profile>": "<host>:<port>"})