Gale Shapley Algorithm
Project description
Implementação de uma biblioteca para o algoritmo Gale-Shapley
Fork do projeto "matching" de Henry Wilde com modificações na API e inclusões de opções.
COMO USAR
Definir as listas com elementos que serão pareados e as preferências de cada elemento de cada lista relativas aos elementos da outra lista:
from galeshapley import Player
comerciantes = [
Player(name='Cunha SA'),
Player(name='Vieira SA'),
Player(name='Lineu SA'),
Player(name='Loubach SA'),
]
influenciadores = [
Player(name='Gildárcio'),
Player(name='Shigemura'),
Player(name='Henrique'),
Player(name='Jean'),
]
cunha, vieira, lineu, loubach = comerciantes
gildarcio, shigemura, henrique, jean = influenciadores
cunha.set_prefs([gildarcio, shigemura, henrique, jean])
vieira.set_prefs([jean, shigemura, gildarcio, henrique])
lineu.set_prefs([shigemura, henrique, gildarcio, jean])
loubach.set_prefs([shigemura, henrique, gildarcio, jean])
gildarcio.set_prefs([cunha, vieira, lineu, loubach])
shigemura.set_prefs([loubach, lineu, cunha, vieira])
henrique.set_prefs([cunha, loubach, vieira, lineu])
jean.set_prefs([vieira, cunha, loubach, lineu])
Obter os melhores pares de acordo com o algoritmo:
from galeshapley.games import StablePairing
game = StablePairing(comerciantes, influenciadores)
resultado = game.solve()
Obs.: O algoritmo de Gale-Shapley retorna uma das soluções ótimas possíveis
REFERÊNCIAS
- Gale, David, and Lloyd S. Shapley. "College admissions and the stability of marriage." The American Mathematical Monthly 69.1 (1962): 9-15.
- Wilde, Henry, Vincent Knight, and Jonathan Gillard. "Matching: A Python library for solving matching games." Journal of Open Source Software 5.48 (2020): 2169.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file galeshapley-0.1.4.tar.gz.
File metadata
- Download URL: galeshapley-0.1.4.tar.gz
- Upload date:
- Size: 20.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfd80de0509da61e847cf4533396272a230cb8ba748a88a7dc1c1e0255d44707
|
|
| MD5 |
bab93830a0c14032604d8c14e6c35ee3
|
|
| BLAKE2b-256 |
452ef66b435ee6deb6c56597fcc4f8ff3bdad86af3c0ba9234fc0999bf13d427
|
File details
Details for the file galeshapley-0.1.4-py3-none-any.whl.
File metadata
- Download URL: galeshapley-0.1.4-py3-none-any.whl
- Upload date:
- Size: 28.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7210cceee0c75978d13db57e42659224e1a2c10b691acf921154f7257a5a637d
|
|
| MD5 |
e8a13918183d46e198da000274c21ac5
|
|
| BLAKE2b-256 |
2d0d02b11926d7606c250b9c50c87b1f8ad176563d1dfaed27b1cf62993a40d0
|