Skip to main content

A Python implementation of the celebrated Gale-Shapley Algorithm.

Project description

gale-shapley

A Python implementation of the celebrated Gale-Shapley (a.k.a. the Deferred Acceptance) Algorithm.

Time complexity is O(n^2), space complexity is O(n).

CI Docs PyPI Python Ruff uv License: MIT

Installation

pip install gale-shapley-algorithm

With CLI support:

pip install "gale-shapley-algorithm[cli]"

With GUI:

pip install "gale-shapley-algorithm[gui]"

Quick Start

As a Library

import gale_shapley_algorithm as gsa

result = gsa.create_matching(
    proposer_preferences={
        "alice": ["bob", "charlie"],
        "dave": ["charlie", "bob"],
    },
    responder_preferences={
        "bob": ["alice", "dave"],
        "charlie": ["dave", "alice"],
    },
)
print(result.matches)  # {'alice': 'bob', 'dave': 'charlie'}

As a CLI

# Run with default settings
uvx --from "gale-shapley-algorithm[cli]" python -m gale_shapley_algorithm

# See all options
uvx --from "gale-shapley-algorithm[cli]" python -m gale_shapley_algorithm --help

With Docker

# Build the image
docker build -t gale-shapley .

# Run with a config file
docker run --rm -it \
  -v $(pwd)/config/example_config_custom_input.yaml:/app/config/config.yaml \
  -v $(pwd)/logs:/app/logs \
  gale-shapley

# Run the GUI
docker run --rm -p 8000:8000 gale-shapley \
  uv run uvicorn gale_shapley_algorithm._api.app:app --host 0.0.0.0 --port 8000

Development

This project is managed with uv and uses taskipy for task running.

git clone https://github.com/oedokumaci/gale-shapley-algorithm
cd gale-shapley
uvx --from taskipy task setup   # Install dependencies
uvx --from taskipy task run     # Run the application
uvx --from taskipy task fix     # Auto-format + lint fix
uvx --from taskipy task ci      # Run all CI checks
uvx --from taskipy task test    # Run tests
uvx --from taskipy task docs    # Serve docs locally

Install pre-commit hooks:

uv run pre-commit install

Documentation

Full documentation is available at oedokumaci.github.io/gale-shapley-algorithm.

License

MIT

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

gale_shapley_algorithm-1.1.3.tar.gz (374.3 kB view details)

Uploaded Source

Built Distribution

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

gale_shapley_algorithm-1.1.3-py3-none-any.whl (19.7 kB view details)

Uploaded Python 3

File details

Details for the file gale_shapley_algorithm-1.1.3.tar.gz.

File metadata

  • Download URL: gale_shapley_algorithm-1.1.3.tar.gz
  • Upload date:
  • Size: 374.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for gale_shapley_algorithm-1.1.3.tar.gz
Algorithm Hash digest
SHA256 562f4a95a98cf1bf742067535fec633296e13e2413d4f91f48282b2793da5528
MD5 70a8a6e7c728ea66d0def9185b3a3563
BLAKE2b-256 ace3dbbfc13c1b7b280a487606390a05ec907e119add0c91b1dbe7911f8031da

See more details on using hashes here.

File details

Details for the file gale_shapley_algorithm-1.1.3-py3-none-any.whl.

File metadata

  • Download URL: gale_shapley_algorithm-1.1.3-py3-none-any.whl
  • Upload date:
  • Size: 19.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for gale_shapley_algorithm-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9d7949cbcc4ac68fbc1821e5b2cad48e3279386253f132420c322e9b087025a5
MD5 34a2e779e2b85a89bd3b4542514765ce
BLAKE2b-256 0181ea9d73596942f817d1eff5374fbeadf8b0c0d64c630c4ff70966781805e3

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