问题
I'm building a system that will create a tournament based on a list of contenders.
Contenders have properties that might make them not able to be placed in brackets with eachother, such as gender, weight, skill level, etc.
In some cases this gets pretty complex:
- contender may go up one weight class, but never down
- Genders may be mixed under a certain age.
What would be a good way to get these people into optimal brackets (for instance, sizes of 4, 8, 16)? Is there a known algorithm for this without trying all permutations?
回答1:
This is called a constraint satisfaction problem (CSP). One of the simplest and in many cases most effective way of solving it is by brute-force search with backtracking.
There are some good heuristic guidelines to follow though when assigning values.
The minimum remaining value (MRV) heuristic says that when deciding which spot in the bracket to assign next, pick the one with the fewest people that could possibly be assigned to it.
The least constraining value (LCV) heuristic says that when assigning a person to a spot, you should pick the person that would rule out the fewest choices.
AIMA has an excellent chapter on CSPs: http://aima.cs.berkeley.edu/newchap05.pdf
来源:https://stackoverflow.com/questions/9759690/optimizing-brackets-for-a-tournament