Coder Social home page Coder Social logo

fairpy's Introduction

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

fairpy's People

Contributors

adidahari avatar asif-rot avatar avieha avatar avihuugoren avatar chkp-yairra avatar cybersrul avatar daniel231195 avatar erelsgl avatar frieddv avatar helenyunes avatar ishay1997 avatar israel0545488592 avatar itayhasidi avatar liadn7 avatar maksimtimokhin avatar mor234 avatar naamaberman avatar noamya-sh avatar op1995 avatar orizitzer365 avatar rivkastrilitz avatar sfishbai avatar shaiaharon avatar shalev61 avatar shlomog12 avatar tahelzecharia avatar tom-gold avatar tomlatin avatar yairraviv avatar yonlif avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

fairpy's Issues

partitions_to_exactly_c expects collection to be type set

The function 'partitions_to_exactly_c' in partitions.py inside the 'indivisible' package expects to receive a set for collections and passes it on to 'partitions_to_at_most_c' which expects to receive a list,and in fact dose not work with a set.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.