Skip to main content

A Python package for reading and solving single instances of kidney exchange problems.

Project description

kep_solver

This Python package is devoted to various algorithms, procedures and mechanisms that are useful when studying kidney exchange programmes in general. It is written and maintained by William Pettersson

Quick start

Create a virtual environment for kep_solver

mkvirtualenv kep_solver

Install kep_solver

pip install kep_solver

Download a sample JSON file from https://kep-web.optimalmatching.com/static/jsons/sample-1.json

Run the following Python commands

# Import the required functions
from kep_solver.fileio import read_json
from kep_solver.pool import Pool
from kep_solver.model import TransplantCount

# Read some input
instance = read_json("sample-1.json")

# Create a transplant pool with one objective
pool = Pool([TransplantCount()])

# Cycles can have at most 3 donor/recipient pairs, and chains can have at most
# 2 donors (i.e., one non-directed donor and one donor/recipient pair)
solution = pool.solve_single(instance, maxCycleLength=3, maxChainLength=2)

# Print the solution
for selected in solution.selected:
    print(f"Selected {selected}")

Current features

  • Reading instance files (json and XML formats)

  • Creation of compatibility graphs

  • Solving for the following objectives (single, or hierarchical)

    • Maximise the number of transplants
    • Maximise the number of backarcs
    • Maximise the number of effective 2-way exchanges
    • Minimise the number of three-cycles
    • Maximise the score using the UK scoring mechanisms

While the above objectives are exactly those in use by NHSBT when running the UKLKSS (the UK national KEP), I do intend to add further objectives

Expected users

I see two classes of users of this software:

  • Researchers - Depending on what questions you want answered, you can either test policy changes to determine how they affect the running of a KEP, or you can implement new models or objectives to see how they perform
  • Health care institutes - I have tried to make this software as robust as possible, but for now I cannot guarantee any particular level of performance or any exact optimality of a solution. If you do want to use this software for real-world impact, feel free to get in touch and I may be able to help.

Interface

This is just a Python module for now, a web-interface that demonstrates a basic use case is viewable at https://kep-web.optimalmatching.com, and the source code for said website is online at https://gitlab.com/wpettersson/kep_web

Future plans

  • More objective functions
  • Random instance generation
  • Simulating the development of a KEP over time
  • Supporting transnational pools
  • Implementation of faster models and modelling techniques

Contributing

I welcome input from others, whether you have ideas for improvements or want to submit code. Either get in touch directly, or raise an issue

Acknowledgements

This software has been supported by the Engineering and Physical Sciences Research Council (EPSRC) grant EP/T004878/1 (Multilayer Algorithmics to Leverage Graph Structure).

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

kep_solver-2.0.12.tar.gz (413.9 kB view details)

Uploaded Source

Built Distribution

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

kep_solver-2.0.12-py3-none-any.whl (32.4 kB view details)

Uploaded Python 3

File details

Details for the file kep_solver-2.0.12.tar.gz.

File metadata

  • Download URL: kep_solver-2.0.12.tar.gz
  • Upload date:
  • Size: 413.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for kep_solver-2.0.12.tar.gz
Algorithm Hash digest
SHA256 cb71bd6b7855378ada51a778104b65833df79c1bcb5ea7d5a81d575a5adec772
MD5 024d8e794558913a7eec3098d276d57f
BLAKE2b-256 8354d92ee62a1047dbaf87104ede7c6ddd396901c5bb122274894d1d6a4a8c81

See more details on using hashes here.

File details

Details for the file kep_solver-2.0.12-py3-none-any.whl.

File metadata

  • Download URL: kep_solver-2.0.12-py3-none-any.whl
  • Upload date:
  • Size: 32.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for kep_solver-2.0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 5d7d95a09b8e482d1049dce406b4558f26efae5a7c6e8b40e0f4e9204acf4933
MD5 41f43c0a68f5cdf8cfb0a89c7d335f23
BLAKE2b-256 4017b179042aca1b1b7831715fe60952c1a0e00ada953332aedc8fcd73b6c278

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