Skip to content

Microservice built with Flask that solves VRP using OR-Tools

License

Notifications You must be signed in to change notification settings

nizarcan/flask-vrp-microservice

Repository files navigation

FLASK-VRP-MICROSERVICE


Microservice built with Flask that solves VRP using Google's OR-Tools.

⛏️ Running

The service can be run directly with

python app.py

or with a Docker container

docker-compose up

at the root directory.


Then for the service route and examples, see the postman collection at the root directory.

🔧 Project Structure

flask-vrp-microservice
|--- app.py -> Main Script
|
|--- test.py -> Test Script
|
|--- controllers
|    |--- solver -> Controller script that handles request
|
|--- data -> Randomly generated input files and their solutions for testing
|
|--- errors -> Custom errors for appropriate response generation
|
|--- models
|     |--- vrp -> The model that solves the problem and returns solution
|
|--- wrappers
|    |--- solver -> Wrapper for OR-Tools

📝 Valid Request Structure

{
    "vehicles": [
      {
        "id": 1,                    Vehicle ID
        "start_index": 0,           Starting idx of vehicle
        "capacity": [4]             Vehicle capacity
      },
      ...
    ],
    "jobs": [
      {
        "id": 1,                    Job ID
        "location_index": 3,        Location idx of job
        "delivery": [2],            Demand of the job
        "service": 327              Predetermined service time
      },
    ...
    ],
    "matrix": List[List[Int]]       nxn matrix that represents the time it takes to get from one location_index to another
}

📝 Response Structure

{
    "routes": {
        "1": {
            "delivery_duration": 6037,
            "jobs": [
                "10",
                "2",
                "9",
                "7",
                "5",
                "4",
                "1",
                "8"
            ]
        },
        "2": {
            "delivery_duration": 1431,
            "jobs": [
                "6",
                "3"
            ]
        }
    },
    "total_delivery_duration": 7468
}

⛏️ Built Using

✍️ Author

About

Microservice built with Flask that solves VRP using OR-Tools

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published