Skip to main content

Intuitive framework that allows researchers to implement and test matching methodologies

Project description

Framework for PPE Matching

Table of Contents

Overview

What is the PPE matching problem?

The PPE Matching Problem consists of optimally matching a set of requests, D, made by donors interested in donating Personal Protective Equipment (or PPE, such as masks, gowns, gloves, etc) with a set of requests, R, made by recipients interested in receieving PPE. Requests are characterized by a timestamp (date), a type and quantity of PPE to donate or request, and a donor or recipient id. The input of the problem also includes a matrix M of distances between donors and recipients. The objectives are multiple, and include maximizing the recipients' fill rate, minimizing the total shipping distance, minimizing the holding time of PPE, and minimizing the number of shipments of each donor.

Who needs to solve the PPE matching problem?

During health crises like the Covid-19 pandemic, organizations such as GetUsPPE.org provide a platform that aims at connecting prospective donors of PPE to prospective recipients of PPE. Requests by donors and recipients are collected over time. Every delta days, the organization solves the PPE Matching Problem, in order to direct each donor to ship a certain quantity of PPE to a given recipient.

What does this software package do?

Our package provides an open-source simulation framework for researchers interested in developing and testing methodologies to solve the PPE matching problem.

The user only needs to implement a function ppestrategy(D,R,M), which solves the PPE matching problem. Our simulation framework evaluates the performance of that user-defined solution method on real-world requests received by GetUsPPE.org in the early months of the Covid-19 pandemic (April-July 2020).

Installation

In a virtual environment with Python 3.6+, ppe_match can be installed via pip

pip install ppe_match

Import the package using

from ppe_match import Simulation

Test the installation with the code snippet below

from ppe_match import Simulation

# Initiate the simuation framework with default parameters
s = Simulation()

# Run the simulation on the GetUsPPE.org data set
s.run()

# Check outputs
s.get_decisions() # Pandas dataframe that can be stored

# Display metrics
s.get_metrics() # Pandas dataframe that can be stored

User-defined matching solution methods

To test a new matching solution method, start by defining a function that takes as input the current date (date, a datetime object), the current donor and recipient requests (Dt and Rt), and the distance matrix between donors and recipients. Dt is a DataFrame with columns (don_id,date,ppe,qty), Rt is a DataFrame with columns (rec_id,date,ppe,qty), M is a DataFrame with columns (don_id,rec_id,distance). The function must return the DataFrame Xt of matching decisions (don_id, rec_id, ppe, qty).

For example, a first-come-first-matched strategy that matches the i-th donor's request with the i-th recipient's request is implemented as follows:

import pandas as pd
def my_strategy(date,Dt,Rt,M):
    # prepare the result DataFrame (X^t)
    result = pd.DataFrame(columns=['don_id','rec_id','ppe','qty'])

    # the ppe to consider are the intersection of the PPEs in the table of current donors Dt (D^t) and the table of current recipients Rt (R^t)
    ppes_to_consider = set(Dt.ppe.unique())
    ppes_to_consider = ppes_to_consider.intersection(set(Rt.ppe.unique()))

    # for each ppe to consider, match the i-th donor request with the i-th recipient request
    for ppe in ppes_to_consider:
        donors_ppe = Dt[Dt.ppe == ppe]
        recipients_ppe = Rt[Rt.ppe == ppe]

        n = min(len(donors_ppe),len(recipients_ppe))
        for i in range(n):
            don = donors_ppe.iloc[i]
            rec = recipients_ppe.iloc[i]
            qty = min(don.qty,rec.qty)

            # add
            result.loc[len(result)] = [don.don_id,rec.rec_id,ppe,qty]
    return result

To run a simulation on the GetUsPPE.org data set, modify the code above by passing the user-defined function to the Simulation constructor:

s = Simulation(strategy=my_strategy)

The ppe_match package contains the implementation of two strategies: the first-come-first-matched strategy illustrated above (strategies.FCFM_strategy) and the "proximity matching" strategy tested by Bala et al. (2021) (strategies.proximity_match_strategy).

Simulation Class

Parameters

donor_path

Path to the data set containing the donors' requests. See expected format in the data folder.

Expected input type: csv

Default: anon_donors.csv (which is the anonymized table of donors' requests from GetUsPPE.org)


recipient_path

Path to the data set containing the recipients' requests. See expected format in the data folder.

Expected input type: csv

Default: anon_recipients.csv (which is the anonymized table of recipients' requests from GetUsPPE.org)


distance_matrix_path

Path to distance matrix between donors and recipients. See expected format in the data folder.

Expected input type: csv

Default: anon_distance_matrix.csv (which is the anonymized distance matrix from GetUsPPE.org)


strategy

User defined strategy to allocate PPE The function must have the following arguments:

ppestrategy(date, Dt,Rt,M)

where,

  • date is a datetime with the current date
  • Dt is a pandas.DataFrame object whose rows contain the current donor requests
  • Rt is a pandas.DataFrame object whose rows contain the current recipient requests
  • M is a pandas.DataFrameobject that reports the distance between each donor and each recipient.

Default: proximity_match_strategy

Returns:

pd.dataframe of decisions with columns (don_id, rec_id, ppe, qty). Each row represents the decision of shipping from donor don_id to recipient rec_id qty units of PPE of type ppe.


interval

Day Interval set for framework to iterate over. Default: 7 (days)


max_donation_qty

Maximum quantity limit for donor to donate (helps filter out dummy entries or test entries) Default: 1000 (ppe units)


writeFiles

Boolean flag to save intermediate outputs and final decisions as csv Default: False

If set to True intermediate data will be saved for every iteration as follows:

output
├── 2020-04-09
	 ├── decisions.csv
	 ├── distance_matrix.csv
	 ├── donors.csv
	 └── recipients.csv
├── 2020-04-16
	 ├── decisions.csv
	 ├── distance_matrix.csv
	 ├── donors.csv
	 └── recipients.csv
├── ...

output_directory

Sets the directory where the intermediate files and results will be saved Default: output/


Methods

run()

Executes the strategy function over the data in a date simulation


get_decisions()

Returns the list of all matching decisions made during the simulation.


get_metrics()

Returns the performance metrics described in Section 4 of the research article. The metrics are reported at the PPE level, the recipient level, and the "overall" level (see Section 4). The "overall" metrics are at the bottom of the DataFrame.


debug(bool_flag)

Sets the logging level to DEBUG if True Default: False (Loglevel sets to WARN)


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ppe_match-0.1.2.2.tar.gz (18.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ppe_match-0.1.2.2-py3-none-any.whl (19.1 MB view details)

Uploaded Python 3

File details

Details for the file ppe_match-0.1.2.2.tar.gz.

File metadata

  • Download URL: ppe_match-0.1.2.2.tar.gz
  • Upload date:
  • Size: 18.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.4

File hashes

Hashes for ppe_match-0.1.2.2.tar.gz
Algorithm Hash digest
SHA256 406fd5c880c31b2b40be487d57bf3dcc2f50ae3672453796eed05b9ab03370bd
MD5 f5d00627805c3a1aeadb8c4d661c61fa
BLAKE2b-256 415b0926f0681a8c42d02faa581381d6619acba0471b6ab7bb1d0da3eb85ebf2

See more details on using hashes here.

File details

Details for the file ppe_match-0.1.2.2-py3-none-any.whl.

File metadata

  • Download URL: ppe_match-0.1.2.2-py3-none-any.whl
  • Upload date:
  • Size: 19.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.4

File hashes

Hashes for ppe_match-0.1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6756facb6212a6d7457046bea38aa988ae21749656d0c7b9d79ae49c6edfd7fb
MD5 19105dd5cf43935c43188ac6b98f3715
BLAKE2b-256 4f690c9bfcd5850f3b62746ad63888cf49f80b291da052ea4ad16d39853ed085

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page