Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/orvn/go-gale-shapley
A Gale-Shapley game theory matching implementation in Go
https://github.com/orvn/go-gale-shapley
Last synced: 12 days ago
JSON representation
A Gale-Shapley game theory matching implementation in Go
- Host: GitHub
- URL: https://github.com/orvn/go-gale-shapley
- Owner: orvn
- License: apache-2.0
- Created: 2024-01-17T19:20:20.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-01-18T04:34:07.000Z (12 months ago)
- Last Synced: 2024-12-09T16:13:33.133Z (28 days ago)
- Language: Go
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Go Gale-Shapley
An implementation of the Gale-Shapley algorithm in Golang, with minimal depdendencies.
In this implementation two groups (generally people) are matched together in a stable way, assuming the group sizes are equal or near equal. A list of enumerated preferences for each member of the group must be provided.
## Usage
Follow these steps from `main.go`, which calls the `stableMatching()` function defined in `matching.go`.
First, define preferences: before running the program, define the preference lists for both groups (defined as Group A and Group B). These preferences are arrays of integers, where each array represents the preference list of a member of a group. What these enumerations actually mean are up to you. For example:
```go
groupAPref := [][]int{{3, 1, 2, 0}, {1, 0, 2, 3}, {0, 1, 2, 3}, {0, 1, 2, 3}}
groupBPref := [][]int{{0, 1, 2, 3}, {0, 1, 2, 3}, {0, 1, 2, 3}, {0, 1, 2, 3}}
```In this example, each member of Group A and Group B has ranked the members of the opposite group in order of preference, with 0 being the most preferred.
Next, run the program like
```bash
go run main.go
```This will output the stable matches between members of Group A and Group B.
## Interpreting the Output
The output will be a series of lines indicating the matching pairs, with each line showing a member of Group B and their matched partner in Group A.
## Customization
You can modify `main.go` to change the preferences or the number of members in each group. The `stableMatching` function will handle the matching process based on the provided preferences.