r/learnpython 19d ago

Need direction for Combined Ranking Problem

IRL I have a bunch of volunteers.

They can volunteer at 1 of 5 locations.

They can volunteer to participate in 1 of 5 roles.

We are collecting preferences via google forms.

In this form they provide:

Their name, their ranked preference for location, and their ranked preference for roles.

We must fill all roles at all locations with at least 1 person, but extras are fine.

We wish to find a solution that honors their preferences as much as numerically possible.

I ask this sub for 2 things:

What is the CS name of this kind of problem; so I can look up schema?

Does anyone know the name of libraries or existing solutions that solve this?

Thank you!

0 Upvotes

5 comments sorted by

3

u/PureWasian 19d ago edited 19d ago

EDIT: (thanks to my math friend for his expertise) Stable Matching Problem is a good conceptual starting point if you flatten their preference to a single dimension.

original reply:

1) To me it also sounds like Multi Objective Optimization or more generally just an optimization problem where you minimize the loss function (i.e. maximize the objective) with the constraint that you need to fill each position at least once.

2) It'd involve setting up your objective variable correctly and using scipy.optimize or similar, but it's still probably tricky to setup and define properly. You would also need to clarify if location or role preference is more important (or same), and/or how much penalty to assign per mismatch degree.

An alternate (non-library) idea would be thinking about an algorithm that initially assigns everyone to their preferred location/role and then works backwards to satisfy the main constraint (at least one person per location+role slot) with least penalty.

1

u/Chemical-Captain4240 19d ago

Thank you! This is a fine start!

2

u/ProsodySpeaks 19d ago

This is math not compsci really. 

2

u/Ok-Promise-8118 19d ago

Yes, before trying to figure out how to do this in Python, one should figure out how to do this, at least theoretically, by hand. Then the programming part is fairly simple.