Skip to main content

Fair division algorithms in Python

Project description

fairpyx

PyTest result PyPI version

fairpyx is a Python library containing various algorithms for fair allocation, with an emphasis on Course allocation. It is designed for three target audiences:

  • Laypeople, who want to use existing fair division algorithms for real-life problems.
  • Researchers, who develop new fair division algorithms and want to quickly implement them and compare to existing algorithms.
  • Students, who want to trace the execution of algorithms to understand how they work.

Installation

For the stable version:

pip install fairpyx

For the latest version:

pip install git+https://github.com/ariel-research/fairpyx.git

To verify that everything was installed correctly, run one of the example programs, e.g.

cd fairpyx
python examples/courses.py
python examples/input_formats.py

or run the tests:

pytest

Usage

To activate a fair division algorithm, first construct a fairpyx.instance:

import fairpyx
valuations = {"Alice": {"w":11,"x":22,"y":44,"z":0}, "George": {"w":22,"x":11,"y":66,"z":33}}
instance = fairpyx.Instance(valuations=valuations)

An instance can have other fields, such as: agent capacities, item capacities, agent conflicts and item conflicts. These fields are used by some of the algorithms. See instance.py for details.

Then, use the function fairpyx.divide to run an algorithm on the instance. For example:

allocation = fairpyx.divide(algorithm=fairpyx.algorithms.iterated_maximum_matching, instance=instance)
print(allocation)

Features and Examples

  1. Course allocation algorithms;

  2. Various input formats, to easily use by both researchers and end-users;

Contributing new algorithms

  1. Fork fairpyx and install your fork locally as follows:

    clone https://github.com/<your-username>/fairpyx.git
    cd fairpyx
    pip install -e .
    
  2. Write a function that accepts a parameter of type AllocationBuilder, as well as any custom parameters your algorithm needs. The AllocationBuilder argument sent to your function is already initialized with an empty allocation. Your function has to modify this argument using the method give, which gives an item to an agent and updates the capacities. Your function need not return any value; the allocation is read from the modified parameter. See:

See also

  • fairpy is an older library with the same goals. It contains more algorithms for fair item allocation, as well as algorithms for fair cake-cutting. fairpyx was created in order to provide a simpler interface, that also allows capacities and conflicts, which are important for fair course allocation.
  • Other open-source projects related to fairness.

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

fairpyx-0.0.4.tar.gz (33.6 kB view details)

Uploaded Source

Built Distribution

fairpyx-0.0.4-py3-none-any.whl (36.9 kB view details)

Uploaded Python 3

File details

Details for the file fairpyx-0.0.4.tar.gz.

File metadata

  • Download URL: fairpyx-0.0.4.tar.gz
  • Upload date:
  • Size: 33.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for fairpyx-0.0.4.tar.gz
Algorithm Hash digest
SHA256 363b23d40908e9c8ce623b052808470fabd05a7b03f7c50f50f6bd615182cf9f
MD5 3677e77db7598f40d2850cbc1f738c04
BLAKE2b-256 290ca0ab0f4157438829d90c93139eedf0f7d6da5c6630f613843191c3ad8a8d

See more details on using hashes here.

File details

Details for the file fairpyx-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: fairpyx-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 36.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for fairpyx-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b3380cef10a285d62b85daba3f3f04c68c26c63a01e8b6ae1bb0329aaa20e558
MD5 e080c95d213b1c1bd7aa521d55ccf1fe
BLAKE2b-256 96c96a7acda00e4bea2f74ebcde7365448cc2cb9a1ea3cc589ae5be413e3713d

See more details on using hashes here.

Supported by

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