A package containing various matching algorithms, such as stable marriage, hospital-residents, and student-project allocation including the cases with ties/indifference.
Project description
Algmatch
A package containing various two-sided matching algorithms.
- SM: Stable Marriage (both man and woman optimal)
- HR: Hospital Residents (both residents and hospital optimal)
- SPA-S: Student Project Allocation with lecturer preferences over students (both student and lecturer optimal)
- SPA-P: Student Project Allocation with lecturer preferences over projects (requires Gurobi)
- for usage, see this notebook.
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)
SPA student stable matching:
{'student_sided': {'s1': 'p1', 's2': 'p2', 's3': 'p3', 's4': 'p4'}, 'lecturer_sided': {'l1': ['s1', 's2'], 'l2': ['s3', 's4']}}
SPA lecturer 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 check for blocking pairs and return a stable matching if no blocking pair is found, and None otherwise
- All algorithms implemented (barring SPA-P) have verification testing
- Tested by producing random instances
- File to brute force all stable matchings
- Check algorithm is generating correct stable matchings
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file algmatch-1.4.0.tar.gz.
File metadata
- Download URL: algmatch-1.4.0.tar.gz
- Upload date:
- Size: 65.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d44d2b39b211c0777cfb7f0f02df58e1ee0bfdc7f0c5b267c7a4d31c4eab173
|
|
| MD5 |
47ca114704ccfbed99498a9e941229b1
|
|
| BLAKE2b-256 |
104e0b837f7cbe52c41cd9229bcaaaa3534f1e7880c0c6c338e5ceb72390445a
|
Provenance
The following attestation bundles were made for algmatch-1.4.0.tar.gz:
Publisher:
python-publish.yml on BenOnTheBoard/algmatch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
algmatch-1.4.0.tar.gz -
Subject digest:
0d44d2b39b211c0777cfb7f0f02df58e1ee0bfdc7f0c5b267c7a4d31c4eab173 - Sigstore transparency entry: 776085755
- Sigstore integration time:
-
Permalink:
BenOnTheBoard/algmatch@ba6e33108a1ace6c92e5f69756b0438aeab55447 -
Branch / Tag:
refs/tags/v.1.4.0 - Owner: https://github.com/BenOnTheBoard
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@ba6e33108a1ace6c92e5f69756b0438aeab55447 -
Trigger Event:
release
-
Statement type:
File details
Details for the file algmatch-1.4.0-py3-none-any.whl.
File metadata
- Download URL: algmatch-1.4.0-py3-none-any.whl
- Upload date:
- Size: 87.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ccefa0147b950ed8811b10c5a585fa2d61783d00ccddb52bc30fe216410e8c2c
|
|
| MD5 |
4ee02f56a2a9d068142a0813a22064b6
|
|
| BLAKE2b-256 |
43cb61363b56248a056a860ff90cf922c724efd4268a6105b1de60bd8feb270a
|
Provenance
The following attestation bundles were made for algmatch-1.4.0-py3-none-any.whl:
Publisher:
python-publish.yml on BenOnTheBoard/algmatch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
algmatch-1.4.0-py3-none-any.whl -
Subject digest:
ccefa0147b950ed8811b10c5a585fa2d61783d00ccddb52bc30fe216410e8c2c - Sigstore transparency entry: 776085756
- Sigstore integration time:
-
Permalink:
BenOnTheBoard/algmatch@ba6e33108a1ace6c92e5f69756b0438aeab55447 -
Branch / Tag:
refs/tags/v.1.4.0 - Owner: https://github.com/BenOnTheBoard
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@ba6e33108a1ace6c92e5f69756b0438aeab55447 -
Trigger Event:
release
-
Statement type: