gbtami / pychess-variants

Chess variant server
https://www.pychess.org
GNU Affero General Public License v3.0
232 stars 112 forks source link

Maximum weighted matching algorithm for arena pairings #991

Open antma opened 1 year ago

antma commented 1 year ago

Lichess uses maximum weight matching algorithm for arena parings.

The edge weight could be cumulative sum of some of these heuristics:

Before summation heuristics should be normalized (multiplied by hand crafted coefficients). Since rank difference is more valuable than rating difference.

Minimal Weighted Matching problem could be solved by Maximal Weighted Matching algorithm by negation weights (replacing by MAXW - W(i,j), where MAXW - maximal weight among all edges in graph, W(i, j) - old weight for edge (i, j)).

Python implementation for the algorithm could be found here. Problem description for proposed implementation could be found here.

gbtami commented 1 year ago

Possible we should use networkx. It has max_weight_matching(), see in https://github.com/JeffHoogland/pypair

antma commented 1 year ago

I confirm that network implementation is equally slow for python3 as implementation I had mentioned before (around 90 seconds for graphs with 500 vertices). But I don't think that so much waiting players will be in pychess arena. Or for such marginal cases pychess could take only first 100 players sorted by ranking in the pool of waiting players and start next wave of pairing immediately.

Link to networkx documentation.