Coder Social home page Coder Social logo

cvrp's Introduction

Modelling and Solving the Vehicle Routing Problem (VRP)

Project for the "Decision Making of Constraint Programming" course, University of Bologna (2020/2021)

Assignment

Modelling and solving the vehicle routing problem in MiniZinc (using the MiniZinc IDE or the Python API) with Gecode.

  • Given:
    • a setof customers, each with a:
      • demand (e.g.,the quantity required);
      • location;
    • a fleet of vehicles, each with a capacity, determine:
    • the vehicle serving to each customer;
    • the route of each vehicle,
  • so as to minimize the total cost:
    • e.g., total distance, total distance + number of vehicles.
  • assuming that each vehicle departs from and returns to the depot.

Given Data

  • n customers: N = {1,.., n}
  • n customer demands: D = {d1,.., n}
  • m vehicles (and routes): V = {1,.., m}
  • m vehicle capacities: C = {c1,…, cm}
  • n+1 locations: L = {l1, l2,…, ln, ln+1}
    • Each customer i is represented as a pair of x and y coordinates.
    • The final location is that of the depot.

We Also Need

  • Distance between every Ii and Ij.
    • Calculate using the coordinates.
    • Multiply by 1000 and round it.
  • Total visits = n+2m
  • Z = {1,.., n, n+1,.., n+m, n+m+1,.., n+2m}

Developers

Setup

To execute the script, Python must be installed(download), and some external libraries must be downloaded and installed using the pip (or pip3) package manager:

pip install -r requirements.txt

It is also need to have installed MiniZinc (download): it is important to have MiniZinc usable from teminal. To do that you have to add the path of the MiniZinc installation folder to the PATH environment variable (here).

Usage

python preprocessing.py dzn_path [-o OUTPUT] [[-s] -m MODEL] [-l LIMIT] [-or {customers, demands, distances}] [-p]

Below are some examples, to learn more about all the avaible parameters refer to the help.

python preprocessing.py -h

Examples

1. Preprocessing only, the default output file is named tmp.dzn

python preprocessing.py prXX.dzn

2. Preprocessing and searching for solutions with the specified model, a time limit of 300s is set

python preprocessing.py prXX.dzn -sm vrp.mzn -l 300

3. Preprocessing and searching for solutions with the specified model, setting a time limit of 300s, sorting the dataset by nearest customer and finally plot the routes for each vehicle

python preprocessing.py prXX.dzn -sm vrp.mzn -l 300 -or customers -p

cvrp's People

Contributors

prushh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

cotus997

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.