Skip to main content

DOI

Algmatch

Algmatch contains implementations of polynomial-time algorithms for matching problems. The full list of support problem is as follow:

  • SM: Stable Marriage
  • HR: Hospital/Residents
    • Resident-optimal algorithm and hospital-optimal algorithm
  • SPA-S: Student Project Allocation with lecturer preferences over students
    • Student-optimal algorithm and lecturer-optimal algorithm
  • SPA-P: Student Project Allocation with lecturer preferences over projects (requires Gurobi)
    • for usage, see this notebook.
  • SR: Stable Roommates
  • SMT: Strong and Super-stable matchings in Stable Marriage with Ties
  • HRT: Hospital/Residents with Ties
    • Strong: Resident-optimal algorithm and hospital-optimal algorithm for strong stability
    • Super: Resident-optimal algorithm and hospital-optimal algorithm for super-stability
  • SPA-ST: Student Project Allocation with lecturer preferences over students and ties
    • Super: Student-optimal algorithm
    • There are no published lecturer-optimal algorithm for super-stability or any published algorithm for strong stability exists at this time.

Requires Python 3.10 or later.

Format data according to the guidelines in this folder.

Installation

Simply run pip install algmatch.

Usage

To import a specific algorithm, use from algmatch import <algorithm>, e.g. from algmatch import SPAS or from algmatch import StudentProjectAllocation. Create a file or dictionary with your instance, following the guidelines in the DATA_FORMAT_GUIDELINES folder. For example,

Importing data:

from algmatch import HR, SM, SPAS

spas_instance = {
    'students': {
        1: [1, 2],
        2: [2, 3],
        3: [3, 1],
        4: [4, 1]
    },
    'projects': {
        1: {
            'capacity': 1,
            'lecturer': 1
        },
        2: {
            'capacity': 1,
            'lecturer': 1
        },
        3: {
            'capacity': 1,
            'lecturer': 2
        },
        4: {
            'capacity': 1,
            'lecturer': 2
        }
    },
    'lecturers': {
        1: {
            'capacity': 2,
            'preferences': [3, 1, 2, 4]
        },
        2: {
            'capacity': 2,
            'preferences': [2, 4, 3]
        }
    }
}

spas_student = SPAS(dictionary=spas_instance, optimised_side="students")
spas_lecturer = SPAS(dictionary=spas_instance, optimised_side="lecturers")

Getting the stable matchings:

spas_2_student_stable_matching = spas_2_student.get_stable_matching()
spas_2_lecturer_stable_matching = spas_2_lecturer.get_stable_matching()

print("SPA 2 student stable matching:"
print(spas_2_student_stable_matching)

print("SPA 2 lecturer stable matching:")
print(spas_2_lecturer_stable_matching)
Student-optimal stable matching:
{'student_sided': {'s1': 'p1', 's2': 'p2', 's3': 'p3', 's4': 'p4'}, 'lecturer_sided': {'l1': ['s1', 's2'], 'l2': ['s3', 's4']}}
Lecturer-optimal stable matching:
{'student_sided': {'s1': 'p2', 's2': 'p3', 's3': 'p1', 's4': 'p4'}, 'lecturer_sided': {'l1': ['s1', 's3'], 'l2': ['s2', 's4']}}

See more example usage here.

Further details

  • All algorithms implemented (barring SPA-P) have verification testing
    • Tested by producing random instances
    • Brute force all stable matchings
    • Check algorithm is generating correct stable matchings

Metadata

Release files for algmatch 1.5.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for algmatch 1.5.2
File Size Uploaded
algmatch-1.5.2.tar.gz 71.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for algmatch 1.5.2
File Interpreter ABI Platform
algmatch-1.5.2-py3-none-any.whl Python 3 none any Details

Total release size: 193.4 kB

Release files / algmatch-1.5.2.tar.gz

Download URL algmatch-1.5.2.tar.gz
Size 71.0 kB
Tags Source
SHA-256 checksum
How to use checksums
7e3d56baf29f92de99a54c29a7e6575a631d433026e34d6e182f28b48205e15e
BLAKE2b-256 checksum
How to use checksums
7f9ba8155ded8ad4ae259cd4e78d9ba65344c39ae937acabd3cb1502b19906ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.

Transparency log

Release files / algmatch-1.5.2-py3-none-any.whl

Download URL algmatch-1.5.2-py3-none-any.whl
Size 122.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bfe4837e9115a04031a32adb4d593be12a01243098bdb4902c9b8dfece8ecf02
BLAKE2b-256 checksum
How to use checksums
73cb267b17b8342c72ea3d6d8cde57225b801363986e43f101268b09578d3a72
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.5.2 This release

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page