Skip to main content

Py-school-match, a Python package that implements matching algorithms for the student-to-school assignation problem.

Project description

https://img.shields.io/badge/License-GPL%20v3-blue.svg

Py-school-match

Py-school-match is an open-source Python package that implements multiple matching algorithms in order to assign students to schools.

It provides multiple algorithms ready to use:

  • Top Trading Cycles (TTC)

  • Deferred acceptance with multiple tie-breaking (DAMTB)

  • Deferred acceptance with single tie-breaking (DASTB)

  • Stable improvement cycles (SIC)

  • Deferred Acceptance with multiple tie-breaking, plus stable cycles (MSIC)

  • Deferred Acceptance with single tie-breaking, plus non-stable cycles (NSIC)

Py-school-match is designed specifically for the student-to-school assignation problem. Because of this, you can focus on evaluating different settings and algorithms, without the need to adapt or develop a complete solution.

Sample code

import py_school_match as psm

# Creating three students.
st0 = psm.Student()
st1 = psm.Student()
st2 = psm.Student()

# Creating a criteria. This means 'vulnerable' is now a boolean.
vulnerable = psm.Criteria('vulnerable', bool)

# Assigning st1 as vulnerable
student_vulnerable = psm.Characteristic(vulnerable, True)
st1.add_characteristic(student_vulnerable)

# Creating three schools, each with one seat available.
sc0 = psm.School(1)
sc1 = psm.School(1)
sc2 = psm.School(1)

# Defining preferences (from most desired to least desired)
st0.preferences = [sc0, sc1, sc2]
st1.preferences = [sc0, sc2, sc1]
st2.preferences = [sc2, sc1, sc0]

# Creating a lists with the students and schools defined above.
schools = [sc0, sc1, sc2]
students = [st0, st1, st2]

# Defining a ruleset
ruleset = psm.RuleSet()

# Defining a new rule from the criteria above.
rule_vulnerable = psm.Rule(vulnerable)

# Adding the rule to the ruleset. This means that a 'vulnerable' student has a higher priority.
# Note that rules are added in order (from higher priority to lower priority)
ruleset.add_rule(rule_vulnerable)

# Creating a social planner using the objects above.
planner = psm.SocialPlanner(students, schools, ruleset)

# Selecting an algorithm
algorithm = psm.SIC()

# Running the algorithm.
planner.run_matching(algorithm)

# inspecting the obtained assignation
for student in students:
    print("Student {} was assigned to School {}".format(student.id, student.assigned_school.id))

Installation

Dependencies

  • graph-tool (>= 2.27)

User installation

pip install py-school-match

Or you can clone the repo and install it:

git clone https://github.com/igarizio/py-school-match
cd py-school-match
python setup.py install

Remember to first install graph-tool.

Development

Contributions are more than welcome. Feel free to open an issue or contact me!
Remember that this package does not provide ANY WARRANTY OF ANY KIND.

How to cite?

Insert citation here.

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

py-school-match-0.2.0.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

py_school_match-0.2.0-py2-none-any.whl (28.5 kB view details)

Uploaded Python 2

File details

Details for the file py-school-match-0.2.0.tar.gz.

File metadata

  • Download URL: py-school-match-0.2.0.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5

File hashes

Hashes for py-school-match-0.2.0.tar.gz
Algorithm Hash digest
SHA256 53afb5d04a2b6114dffc01d5cefc7a3a7059c25ba7b76a2fe22e54c60b40b2da
MD5 12ba9bd30b1ef3e09fd0e08822854e48
BLAKE2b-256 19a9341964233bc40046b5010b60daf8032d922c93da55b7722318d04cf90972

See more details on using hashes here.

File details

Details for the file py_school_match-0.2.0-py2-none-any.whl.

File metadata

  • Download URL: py_school_match-0.2.0-py2-none-any.whl
  • Upload date:
  • Size: 28.5 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5

File hashes

Hashes for py_school_match-0.2.0-py2-none-any.whl
Algorithm Hash digest
SHA256 e6785c4b85ca5e01a781ceda2738fa00d45e3503f0158b37dd7e730bc2f44cd1
MD5 0b69b468c82a57cf12bd2d43a14bf184
BLAKE2b-256 c745bb344f9ff722a265ee4fc3bac394a8cf243d16a0eae5ec8afec1676f42d5

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