Git Product home page Git Product logo

dsmatchingult's Introduction

Matching Policies

The code includes Python code for the OR paper "Dynamic Stochastic Matching Under Limited Time".

Link to paper: https://pubsonline.informs.org/doi/epdf/10.1287/opre.2022.2293.

"matching_policies.py" contains the Python class "simulation" used to run the algorithms for the case study in the paper. This class supports the following methods that are used to create the objects to be used by the matching algorithms:

  • __init__(): Initializes the class "simulation".
  • generate_input(): Calculates the cbar values for every type as explained in Appendix E.3 via the method initial_cbar() and the data files. "ClusteredInput....feather" and "TypeCoordinate....feather". Then, prepares the time data for arrivals that will be used by the algorithms. Finally, calculates the minimum distance required to satisfy two rides in one route via the method MinDist().
  • init_simulation(): Calculates departure times due to abandonment by generating exponentially distributed waiting times.
  • MinDist(): Uses the data "TypePairDistance....csv" that contains the distance between every type pair to create the "attributes_graph....txt" and the "edges_graph....txt". Then creates the networkx graph that will be used in relation with gurobipy to run the algorithms.
  • initial_cbar(): Uses the data file "ClusteredInput....feather" to derive agent types. Using the derived agent types, calculates the cbar values for every type via the method cbar_multiple_node(). Finally, writes the results to the file "selfcbar_from_..._trip_neutral.txt".

The following methods are used for fast computation of the cbar values that are used in initial_cbar(). We use Numba, a JIT (just-in-time) compiler. It takes Python functions designated by particular annotations, and transforms as much as it can โ€” via the LLVM (Low Level Virtual Machine) compiler โ€” to efficient CPU and GPU (via CUDA for Nvidia GPUs and HSA for AMD GPUs) code:

  • cbar_single_node(): Calculate the cbar value for a particular node.
  • cbar_multiple_node(): Uses cbar_single_node() to calculate cbar values for multiple nodes.

The following methods of the class "simulation" run the matching algorithms:

  • threshold_policy(): Runs the threshold policy in the paper and writes the results to a csv file "ResultFrame_Threshold....csv".
  • Gurobi_LP_policy(): Runs the LP policy in the paper using the Gurobi Solver and writes the results to a csv file "ResultFrame_Gurobi_LP....csv".
  • Gurobi_batching_policy(): Runs the batching policy using the Gurobi Solver and writes the results to a csv file "ResultFrame_Gurobi_Batching....csv".

Run File

The code "RunFile.py" includes a sample code to run the algorithms in the case study of the paper.

Dependencies

The codes are run on Python 3.7. They require the following packages:

numpy==1.16.2 networkx==2.2 pandas==0.24.2 gurobipy==8.1.1 plotly==4.1.0 feather==0.4.0 pickle==4.0 glob==0.6 numba==0.43.1

dsmatchingult's People

Contributors

omersaritac avatar ma-aouad avatar

Stargazers

 avatar

Watchers

 avatar

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.