Skip to main content

A Python package for dealing with the hospital-residents problem with ties and couples.

Project description

pyhrtc

pyhrtc is a Python module to inspect various types of stable matching problems. In particular, it can handle the Hospital-Residents problem with both Ties and Couples, also known as HRTC. Having no couples reduces this to the Hospital-Residents problem with Ties, HRT, and by letting all hospitals have capacity 1 we get the Stable Marriage with Ties and Incomplete Lists problem, SMTI.

Features

This package can currently

  • read instance files in multiple formats,
  • write instance files,
  • inspect agents (residents and hospitals),
  • combine some pairs of agents into couples,
  • find maximum size matchings,
  • find maximum size and maximum weight stable matchings.

Status

Build statuscodecov

File formats

This package supports a number of file formats. For these, we will talk about the set of "left" and "right" agents. These are the two bi-partitions of the agents, such that agents on the left may only express preferences for agents on the right, and vice-versa.

The Glasgow format

This format used by researchers working at the University of Glasgow, or their collaborators.

The first line should just be a zero (0). The next two lines contain the number of agents in the left and right partitions respectively. Following this, we have one line for each agent on the left, and then one line for each agent on the right. These are as follows:

For agents on the left, first the line contains an identifier (numeric only), and then the preferences. Preferences within brackets indicate a tie.

For agents on the right, first the line contains an identifier (numeric only), and then the agent's capacity, and then the preferences. Preferences within brackets indicate a tie.

SMTI-GRP

A CSV file containing a row-column matrix, with the first row and columns used as identifiers, can be read in to create an instance of SMTI-GRP.

There is also a second format for SMTI-GRP, which does not have headings. This file contains, as its first two lines, the number of rows and columns respectively. The rest of the file is the matrix of scores, separated by spaces only.

Future plans

This mostly started as a tool to inspect instances of HRTC for various parameters, but it is growing. One day I might even write up a model that would solve HRTC, but that day is not today.

Can I help?

Yes! If you want to add features, or request features, please just raise an issue. I can't promise anything, but it's good to know what people want.

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

pyhrtc-0.0.12.tar.gz (386.4 kB view details)

Uploaded Source

Built Distribution

pyhrtc-0.0.12-py3-none-any.whl (47.2 kB view details)

Uploaded Python 3

File details

Details for the file pyhrtc-0.0.12.tar.gz.

File metadata

  • Download URL: pyhrtc-0.0.12.tar.gz
  • Upload date:
  • Size: 386.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for pyhrtc-0.0.12.tar.gz
Algorithm Hash digest
SHA256 0a5b3bc1c1f49ec4ebb7507ac5a0acf85bf388ea3e5452ec4921a43338875159
MD5 82c2674c6e92fe8d79150fff6381266a
BLAKE2b-256 9fc37ebb24b51b6306358f0ad2be78a0ee49ca1912a5a3f09abd01a4bfb46ece

See more details on using hashes here.

File details

Details for the file pyhrtc-0.0.12-py3-none-any.whl.

File metadata

  • Download URL: pyhrtc-0.0.12-py3-none-any.whl
  • Upload date:
  • Size: 47.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for pyhrtc-0.0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 9ab7a72138235f34a16f51284728b6d3eab8a9c4529b28b0bf16ae408c03bb8c
MD5 2464bc25ae3a7a255b8b8805e5f72027
BLAKE2b-256 134e63af222a81e8e4e2fd6d693a92d555f1f9ddd7d78c40acb495f5bb5e631c

See more details on using hashes here.

Supported by

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