Skip to content

erelsgl/fairpy

Repository files navigation

fairpy

fairpy is an open-source library of fair division algorithms in Python.

** NOTE: fairpyx is a newer library, that provides cleaner handling of fair allocation with constraints, e.g. course-seat allocation. Please visit there first. **


PyTest result

fairpy 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

clone https://github.com/erelsgl/fairpy.git cd fairpy pip install -r requirements.txt pip install -e . 

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

python examples/items.py python examples/cake.py 

or run the tests:

pytest 

Usage

The function fairpy.divide can be used to activate all fair division algorithms. For example:

import fairpy valuations = {"Alice": {"w":11,"x":22,"y":44,"z":0}, "George": {"w":22,"x":11,"y":66,"z":33}} ### Allocating indivisible items using the Iterated Maximum Matching algorithm: fairpy.divide(algorithm=fairpy.items.iterated_maximum_matching, input=valuations) ### Allocating divisible goods using the leximin algorithm: fairpy.divide(fairpy.items.leximin, valuations) ### Dividing a cake using cut-and-choose: from fairpy import PiecewiseConstantAgent Alice = PiecewiseConstantAgent([33,33], "Alice") George = PiecewiseConstantAgent([11,55], "George") fairpy.divide(algorithm=fairpy.cake.cut_and_choose.asymmetric_protocol, input=[George, Alice]) 

Features and Examples

  1. Item allocation algorithms, for both divisible and indivisible items;

  2. Cake-cutting algorithms;

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

  4. Various output formats;

  5. Optional logging, to learn and understand how the algorithms work.

Adding new algorithms

To add a new algorithm for item allocation, write a function that accepts one of the following parameters:

Your function may accept any other custom parameters.

See also

About

An open-source library of fair division algorithms in Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages