Next Article in Journal
On a Bivariate Generalization of Berrut’s Barycentric Rational Interpolation to a Triangle
Next Article in Special Issue
Spatial-Temporal Traffic Flow Control on Motorways Using Distributed Multi-Agent Reinforcement Learning
Previous Article in Journal
Incremental DoE and Modeling Methodology with Gaussian Process Regression: An Industrially Applicable Approach to Incorporate Expert Knowledge
Previous Article in Special Issue
A ResNet50-Based Method for Classifying Surface Defects in Hot-Rolled Strip Steel
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Dynamic Programming Algorithms for Computing Optimal Knockout Tournaments

1
Department of Statistics and Business Informatics, University of Craiova, 200585 Craiova, Romania
2
Department of Computers and Information Technology, University of Craiova, 200585 Craiova, Romania
3
Faculty of Computer Science and Engineering, Frankfurt University of Applied Sciences, Nibelungenplatz 1, 60318 Frankfurt am Main, Germany
*
Author to whom correspondence should be addressed.
Mathematics 2021, 9(19), 2480; https://doi.org/10.3390/math9192480
Submission received: 7 September 2021 / Revised: 25 September 2021 / Accepted: 27 September 2021 / Published: 4 October 2021

Abstract

:
We study competitions structured as hierarchically shaped single-elimination tournaments. We define optimal tournaments by maximizing attractiveness such that the topmost players will have the chance to meet in higher stages of the tournament. We propose a dynamic programming algorithm for computing optimal tournaments and we provide its sound complexity analysis. Based on the idea of the dynamic programming approach, we also develop more efficient deterministic and stochastic sub-optimal algorithms. We present experimental results obtained with the Python implementation of all the proposed algorithms regarding the optimality of solutions and the efficiency of the running time.

1. Introduction

Tournament design is a combinatorial problem with many theoretical implications, as well as with a lot of practical applications. There are many types of tournaments that have been theoretically analyzed and practically used in various contexts. Basically, there are two main principles used in tournament design: “round-robin” principle and “knockout” principle. They can be used in isolation or combined for obtaining different tournaments designs, depending on various factors, such as the number of players, time available to carry out the tournament, and application domain.
In this paper we propose a formal definition of competitions that have the shape of single-elimination tournaments, also known as knockout tournaments. We introduce methods to quantitatively evaluate the attractiveness and competitiveness of a given tournament. We consider that a tournament is more attractive if competition is encouraged in higher stages, i.e., higher-ranked players will have the chance to meet in higher stages of the tournament, thus increasing the stake of their matches.
In knockout tournaments, the result of each match is always a win of one of the two players, i.e., draws are not possible. A knockout tournament is hierarchically structured as a binary tree such that each leaf represents one player or team that is enrolled in the tournament, while each internal node represents a game of the tournament.
The tournament is carried out in a series of rounds. If there is a number N of players equal to a power of 2, for example N = 8 = 2 3 then the tournament tree is a complete binary tree with all the players entering the tournament in the first round; however, in the general case, the number of players might not be a power of 2, for example N = 9 . In this case some of the players will receive waivers thus entering the tournament directly in the the second round, while the rest of the players will enter the tournament in the first round.
In this paper we significantly extend our preliminary results reported in [1] for fully balanced tournaments (the number of players is N = 2 k ) to general tournaments where the number of players can be an arbitrary natural number, not necessarily a power of 2. Our new results are summarized as follows:
  • An exact formula for counting the total number of knockout tournaments in the general case, showing that the number of tournaments grows very large with the number of players.
  • A tournament cost function based on players’ quota that assigns a higher cost to those tournaments where highly ranked players tend to meet in higher stages, thus making the tournament more attractive and competitive.
  • An exact dynamic programming algorithm for computing optimal tournaments in the general case.
  • A more efficient generic sub-optimal algorithm derived from the idea of the dynamic programming approach.
  • Deterministic and stochastic versions of the generic sub-optimal algorithm.
  • The complexity analysis of all the proposed algorithms.
  • The implementation issues of the proposed algorithms using Python, as well as the experimental results obtained with our implementation.

2. Related Works

Tournament design attracted research in operations research, combinatorics, and statistics. The problem is also related to intelligent planning and activity scheduling, broadly covered also by artificial intelligence.
There are two main principles used in tournament design, namely the “round-robin” principle and “knockout” principle, and they can be used in isolation or combined for obtaining different tournaments designs. The “round-robin” principle states that in a tournament, each two players should meet at least once, sometimes exactly once. “Knockout”, also known as the “elimination” principle states that players are eliminated after a certain number of games, sometimes exactly after one game.
For example, in a round-robin tournament in which each two players should meet exactly once, an important aspect is the scheduling of the tournament, a problem also known as league scheduling [2]. This is an important component of the tournament design. Note that the “round robin” principle can also be applied with restrictions. Consider for example a two-team tournament, in which each team has the same number of players. Each game involves two players from different teams and any two players from different teams must play exactly once. In this case, we can still apply the round-robin principle, but players of the same team are not allowed to play. This type of tournament is called a bipartite tournament. A good coverage of the combinatorial aspects of round-robin tournaments can be found in monograph [2].
On the other hand, in a knockout tournament where two players will play at most one game and after each game exactly one player advances in the tournament, while the other is kicked off, the tournament schedule results directly from the tournament design, i.e., no separate scheduling stage is needed.
Note also that the round-robin and knock-out principles can be combined into a single tournament design. Consider for example the UEFA Champions League football tournament. In the groups’ phase, round-robin is used inside each group, while after the group phase, knockout is used to determine the tournament winner.
In this paper we consider knockout tournaments in which two players meet at most once. These are specialized tournaments with possible applications in sports (e.g., football and tennis tournaments), online games (e.g., online poker), and election processes. While in the former case there is a relatively low number of players, thus not raising special computational challenges, the number of players in massive multiplayer online games can grow such that computing the optimal tournament becomes a more difficult problem.
A comprehensive analysis of knockout tournaments is proposed in [3,4]. Traditionally, the method for designing a tournament involves two stages: (i) tournament structure design and (ii) seeding. In the first stage, the structure of the tournament tree is proposed. In the second stage, players are assigned to each leaf of the tournament tree; however, as we can argue that this method of tournament design has some limitations, we proposed different “integrated” approach. One limitation is for example the fact that once fixed, the tournament structure cannot be changed. On one hand this will result in a smaller search space during the seeding process, on the other hand it limits the total number of tournament designs. So our model of tournament trees includes both the tree structure, as well as the players’ seeding; a separate seeding process is not necessary.
Research in combinatorics of knockout tournaments also produced interesting mathematical results. The structure of a knockout tournament can be modeled as a special kind of binary tree, called an Otter tree [5]. The number of knockout tournament structures (i.e., prior to seeding) for N players is given by the Wedderburn—Etherington number [6] of order N that is known to have an exponential growth approximately equal to 0.3188 × 2 . 4832 N N 1.5 .
An important aspect concerns the factors that can be used to evaluate a tournament design. This problem has been also considered in previous works [3,4]. An interesting discussion of economic aspects of tournament attractiveness, such as spectator interest, is provided by [7].
A method for augmenting a tournament with probabilistic information based on tournament results was proposed in [8]. The effectiveness of tournament plans based on dominance graphs is studied in [6]. The tournament problem was also a source of inspiration for programming competitions [9]. A more recent work addressing competitiveness development and ranking precision of tournaments is [10].
For example, the more recent work [3,4] proposes a probabilistic approach to define the tournament cost, by including in their model the win–loss probabilities of each game between two players i and j. On one hand, we can question the robustness of such values. On the other hand, we recognize that some approximations of such values might be empirically obtained based on several factors, e.g., global player rankings (when available) or on the history of games between the players (if a nonempty history exists). In our work we do not use this information, i.e., we assume by default that there are equal winning chances for the players of each game. While this simplification clearly has drawbacks, it has the advantage of enabling a clean algorithm design based on dynamic programming principles. Our approach can be extended by adding probabilistic information to the cost function, but then it will require further analysis of algorithmic solutions within our “integrated” approach.
A theoretical investigation of knockout tournaments is provided by [11]. Their analysis is focused only on tournaments with a power of 2 number of players, i.e., similar with [1], but definitely less general than in the current work, where an arbitrary number of players is considered. Interesting results of this work concern the discussion of new seeding approaches named “equal gap” and “increasing competitive”, as well as the investigation of their theoretical properties.
There has been also theoretical interest in analyzing the possible outcomes of knockout tournaments. Upper and lower bounds of winning probabilities of players of a random knockout tournament are provided in [12]. Note that the analysis is focused on the random knockout tournament where the definition of matches to be carried out in each round is defined randomly. Moreover, this work assumes as [3,4], that the win–loss probabilities of each match between two players are known.
There is also interest in the literature in designing new formats of knockout tournaments. For example, a new format based on actively involving the teams in defining the tournament format, was recently proposed in [13] for the specific competition of UEFA Champions League. The proposed format was coined “Choose your opponent” with the claimed benefit to make group stages more exciting. The authors also show how this model can be used for the objective of maximizing the number of home games during the knockout stage.
Knockout tournament structures are sometimes called tournament brackets. According to [14], two types of tournament brackets are possible: fixed and adaptive. In fixed brackets, the tournament structure is fixed, while in adaptive brackets pairings in stage i + 1 are defined based on winners of stage i. Our approach is clearly fixed, with the difference that we use an integrated approach to define both the structure as well as the seeding. What is different in [14] is the fact that authors look for optimizing a fixed bracket by using utility functions and Bayesian optimal design. They propose a simulated annealing algorithm to optimize the expected value of a given utility function on a fixed tournament bracket. While interesting, this endeavor is clearly different from our approach. We plan however to investigate in the future the suitability of extending integrated approach and proposed algorithms by incorporating probabilistic information.
Clearly tournaments have a lot of practical applications, for example in the sports’ domain. In this context, the recent work [15] provides an interesting discussion on the economics of sports from operations research, as well as practical applicability perspectives. The discussion is centered around several paradoxes of tournament rankings, with clear examples from the practice of tournament design.

3. Knockout Tournaments

We consider hierarchically structured knockout tournaments such that the result of each match is always a win of one of the two players, i.e., draws are not possible. A tournament is modeled as a binary tree such that each leaf node represents a unique player and each internal node represents a game between two players and its winner.
Definition 1
(Tournaments). Let Σ be a finite nonempty set of players. We define the set of trees T ( Σ ) with leaves Σ as follows:
1. 
If Σ = { i } is a singleton set then T ( Σ ) = { i } , i.e., there is a single tree containing a single node i.
2. 
If Σ 1 and Σ 2 are two disjoint sets of players then let Σ = Σ 1 Σ 2 . Then:
T ( Σ ) = { t | t = { t 1 , t 2 } , t 1 Σ 1 , t 2 Σ 2 }
Note that the set notation in Equation (1) implies that the trees are not ordered, i.e., the order of the left and right branches does not matter.
Example 1.
We consider examples of tournaments for sets of players with 1 , 2 , 3 and 4 elements:
1. 
If Σ = { 1 } then T ( Σ ) = { 1 } .
2. 
If Σ = { 1 , 2 } then T ( Σ ) = { { 1 , 2 } } .
3. 
If Σ = { 1 , 2 , 3 } then T ( Σ ) = { { { 1 , 2 } , 3 } , { { 1 , 3 } , 2 } , { { 3 , 2 } , 1 } } .
4. 
If Σ = { 1 , 2 , 3 , 4 } then T ( Σ ) = { { { 1 , 2 } , { 3 , 4 } } , { { 1 , 3 } , { 2 , 4 } } , { { 1 , 4 } , { 2 , 3 } } , { { { 1 , 2 } , 3 } , 4 } , } . It is not difficult to see that in this case there are 15 trees.
Some of the tournaments introduced in Example 1 are depicted graphically in Figure 1. Observe that the tournaments on the first row (labeled “a” and “b”) involve a number of elements that is a power of two ( 2 = 2 1 and 4 = 2 2 , respectively) and are fully balanced. However, the tournaments on the second row are not fully balanced, although the lower rightmost tournament involves 4 = 2 2 players. However, intuitively, the tournament with three players (labeled “c”) should be accepted, as player 3 will enter the tournament only 1 round after players 1 and 2, i.e., it has a sense of “balancing”. However, the lower rightmost tournament with four players (labeled “d”) is not acceptable, as player 4 received an exemption from playing in the first two rounds, and this is considered unfair.
Proposition 1
(Counting tournaments). The set T ( Σ ) with | Σ | = N players contains:
( 2 N 2 ) ! ( N 1 ) ! × 2 N 1
elements.
Proof. 
The number of full binary tree structures with N leaves is equal to C N 1 where C N is Catalan’s number [16] defined by:
C N = 1 N + 1 2 N N
Now, each permutation of the N players can be attached to the leaves of a binary tree, thus obtaining N ! · C N 1 trees. However, the branches of each internal node can be exchanged, resulting in the same tree. There are N 1 internal nodes and therefore a total number of 2 N 1 exchanges, resulting a number of trees given by:
N ! · C N 1 2 N 1 = ( 2 N 2 ) ! ( N 1 ) ! · 2 N 1
q.e.d.    □
Example 2.
For example, if N = 3 we obtain 4 ! 2 ! × 2 2 = 3 trees, while if N = 4 we obtain 6 ! 3 ! × 2 3 = 15 trees. These results are consistent with Example 1.
A valid tournament should be balanced, i.e., each player should play (almost) the same number of games to win the tournament.
Analyzing the tournaments from Example 1 and Figure 1 we can observe that if | Σ | 3 then each element of T ( Σ ) represents a valid tournament. However, if | Σ | = 4 then only 3 trees of T ( Σ ) represent valid tournaments. For example, { { 1 , 2 } , { 3 , 4 } } is a valid tournament as each player should play exactly two games to win the tournament. In this case we have a fully balanced tournament consisting of N = 2 2 players. Moreover, { { 1 , 2 } , 3 } is also considered a valid tournament, as players 1 and 2 must play two games to win, while player 3 must play one game to win, i.e., has an exemption for the first round (the difference between the number of games played by each player is at most 1). However, { { { 1 , 2 } , 3 } , 4 } is not a valid tournament, as players 1 and 2 must play three games to win the tournament, while player 4 must play a single match to win the tournament (the difference between the number of games played by each player is above 1, i.e., more than one exemption for a player is considered unfair).
Observe that a tree representing a valid tournament has the property that all its leaves are of height n or n + 1 for a suitable value of n. Actually, the value of n can be determined from the given number of players N of the tournament and it represents the number of rounds of the tournament.
Let us consider a tournament with n rounds. It is not difficult to see that the maximum number of players is N m a x = 2 n and it is obtained when in the first round we have a maximum number of 2 n 1 games; therefore, for a tournament with n rounds we have:
2 n 1 < N 2 n
Observe that from Equation (5) it follows that:
n = log 2 N
Definition 2 (Balanced (valid) tournaments). Let n N be the number of rounds. Let Σ be a nonempty set of N players such that conditions (5) and (6) are fulfilled. Then the set T n ( Σ ) of balanced trees with n layers representing the set of balanced (valid) tournaments with n rounds is defined as follows:
1. 
If n = 0 then N = 1 so we have a singleton set Σ = { i } . In this case T 0 ( Σ ) = { i } .
2. 
If n 1 , t 1 T n 1 ( Σ 1 ) , t 2 T n 1 ( Σ 2 ) , Σ 1 Σ 2 = and Σ 1 Σ 2 = Σ then t = { t 1 , t 2 } T n ( Σ ) .
3. 
If n 2 , t 1 T n 1 ( Σ 1 ) , t 2 T n 2 ( Σ 2 ) is a fully balanced tree (i.e., | Σ 2 | = 2 n 2 ), Σ 1 Σ 2 = and Σ 1 Σ 2 = Σ then t = { t 1 , t 2 } T n ( Σ ) .
If n 1 then there are N 2 n 1 + 1 2 n players. Then a tree t T n ( Σ ) can be obtained either (i) by joining two balanced trees with n 1 layers or (ii) by joining one balanced tree with n 1 layers and one fully balanced tree with n 2 layers (all its leaves are on layer n 2 ), so in both cases the balancing condition of t is properly preserved.
Proposition 2
(Structure of a balanced tournament). Let t T n ( Σ ) be a tournament of N players such that n is defined by Equation (6). Then the number of players starting in the first round is β = 2 N 2 n and the number of players starting in the second round (waivers) is γ = 2 n N . Moreover, if n 1 then the number of internal nodes of level 2 in the tree is equal to α = N 2 n 1 , i.e., β = 2 α and γ = 2 n 1 α .
Proof. 
First observe that if the number of players is a power of 2, i.e., N = 2 n , then α = 2 n 1 = N / 2 , β = N , and γ = 0 . This is trivially true, as in this case the tournament is fully balanced and all the players start in the first round (there are no exemptions).
The proof for the general case can be shown by induction on n N .
For n = 0 the tournament has N = 1 players. In this case there is a single balanced tournament with γ = 0 and β = 1 , so the property trivially holds.
For n = 1 the tournament has N = 2 players. In this case there is a single balanced tournament with α = 1 , β = 2 and γ = 0 , so the property trivially holds.
Let us now assume that the property holds for k = 0 , 1 , , n and let us prove it for k = n + 1 . There are two cases.
Case 1. If n 1 , t 1 T n ( Σ 1 ) , t 2 T n ( Σ 2 ) , Σ 1 Σ 2 = and Σ 1 Σ 2 = Σ , let us consider t = { t 1 , t 2 } T n + 1 ( Σ ) such that the second condition of Definition 2 is fulfilled. According to the induction hypothesis we have γ i = 2 n N i , β i = 2 N i 2 n , α i = N i 2 n 1 for i = 1 , 2 and N = N 1 + N 2 . Then γ = γ 1 + γ 2 = 2 n + 1 ( N 1 + N 2 ) = 2 n + 1 N . Similarly β = β 1 + β 2 = 2 N 2 n + 1 and α = α 1 + α 2 = N 2 n q.e.d.
Case 2. If n 2 , t 1 T n ( Σ 1 ) , t 2 T n 1 ( Σ 2 ) is a fully balanced tree (i.e., | Σ 2 | = 2 n 1 ), Σ 1 Σ 2 = and Σ 1 Σ 2 = Σ , let us consider t = { t 1 , t 2 } T n + 1 ( Σ ) such that the third condition of Definition 2 is fulfilled. According to the induction hypothesis we have γ 1 = 2 n N 1 , β 1 = 2 N 1 2 n , α 1 = N 1 2 n 1 , γ 2 = 0 , β 2 = 2 n 1 and α 2 = 2 n 2 , N 2 = 2 ( n 1 ) , and N = N 1 + 2 n 1 . Then β = β 1 = 2 ( N 1 + 2 n 1 ) 2 n 2 n = 2 N 2 n + 1 . Similarly γ = γ 1 + β 2 = 2 n N 1 + 2 n 1 = 2 n + 2 n 1 + 2 n 1 N = 2 n + 1 N and similarly for α = α 1 = N 1 2 n 1 = N 2 n 1 2 n 1 = N 2 n q.e.d.
The relations β = 2 α and γ = 2 n 1 α can be now easily checked.    □
Example 3
(Tournament structure design). Let us consider a tournament with N = 5 players. In this case n = 3 , γ = 2 3 5 = 3 , α = 2 2 3 = 1 , β = 2 × 5 2 3 = 2 . A tree representing a tournament with five players will have three layers such that the first layer consists of β = 2 leaves (players) and the second layer consists of 2 n 1 = 2 2 = 4 nodes among which there is α = 1 internal node and γ = 3 leaves (players). One such a balanced tournament is depicted in Figure 2.
Proposition 3
(Counting balanced tournaments). The set T n ( Σ ) with | Σ | = N players contains:
N ! · ( 2 n 1 γ ) 2 N 1
elements.
Proof. 
There are ( 2 n 1 γ ) ways of choosing how the γ players will enter second round. Their ordering matters so we multiply with γ ! . Moreover those γ players are arbitrarily chosen from the set of N players, so we multiply with ( N γ ) . Finally, the ordering of those β remaining players that enter first round matters, so we also multiply with β ! . For each internal node of the tree, exchanging its left and right sub-tree is a tournament invariant. There are 2 N 1 independent ways of exchanging left and right sub-tree of the tree, so we must divide by 2 N 1 . We obtain:
N γ · 2 n 1 γ · γ ! · β ! 2 N 1 = N ! · 2 n 1 γ 2 N 1
A simpler proof is obtained by thinking about structures (i.e., “shapes”) of tournament trees. The selection of the “locations” of those γ players entering second round can be achieved in 2 n 1 γ ways. For each tree structure defined in this way there are N ! permutations of the leaves (players), thus defining a total number of N ! · 2 n 1 γ balanced tournament trees. Finally we divide by 2 N 1 and we obtain Equation (7).    □
Example 4.
Let us check the number of balanced tournaments for several cases.
1. 
The number of balanced tournaments with N = 5 players can be obtained as follows:
5 ! × 2 2 3 2 4 = 30
It is not difficult to verify that this result is correct. In this case β = 2 . There are 5 2 = 10 ways of selecting those two players that will enter first round. We have one separate tournament by letting the winner of the game of these two players playing against each of the remaining three players in the second round. So in total there are 10 × 3 = 30 balanced tournaments with five players.
2. 
For n = 3 players we obtain:
3 ! × 2 1 1 2 2 = 3
3. 
If N = 2 n then γ = 0 , thus we obtain our result for fully balanced tournaments from [1] stating that the total number of fully balanced tournaments is given by:
( 2 n ) ! 2 2 n 1 .
The number of fully balanced tournaments with two rounds is ( 2 2 ) ! 2 2 2 1 = 4 ! 8 = 3 . Observe that applying the formula, we obtain 315 fully balanced tournaments with three rounds. Let us obtain this result using a different reasoning. Let us count the number of a set with eight elements consisting of two subsets of four elements each. There are 8 4 / 2 = 35 possibilities, as we consider the four combinations of eight elements, and we divide by two as the order of the subsets of a partition does not matter; however, for each set of each partition there are three fully balanced tournaments of three rounds, so multiplying we obtain a total of nine possibilities. So the number of three-stage tournaments is 9 × 35 = 315 .

4. Optimal Tournaments

Each round of a tournament with n rounds defines possible games between players. Note that in a given tournament any two players can play in a game at one and only one of its rounds. This follows from the fact that for any two leaves of a binary tree there is a unique closest common ancestor. It follows that the tournament round s i , j where players i , j can meet is a unique value in 1 , 2 , , n and it is well defined. For example, referring to the tournament shown in Figure 2, s 2 , 4 = 3 , s 1 , 5 = 2 , and s 4 , 5 = 1 .
Intuitively, the higher the quotations of players i and j, the better it is to let them meet in a higher stage of the tournament in order to increase the stakes of their games.
We assume in what follows that a quotation q i ( 0 , + ) is available for each player i Σ . Quotations can be obtained from the players’ current ranking (as for example in international tennis tournaments ATP and WTA) or by other means.
Definition 3
(Tournament cost). Let t T n ( Σ ) be a tournament with n rounds and let s i , j t { 1 , 2 , , n } be the stage of t where players i , j can meet. Let q i > 0 be the quotations of players for all i Σ . The cost of t is defined as:
C o s t ( t ) = i , j Σ , i < j q i q j s i j t
Definition 4
(Optimal tournament). A tournament such that its cost computed with Equation (12) is maximal is called an optimal tournament and it is defined by:
O p t C ( Σ ) = max t T n ( Σ ) C o s t ( t ) t = argmax t T n ( Σ ) C o s t ( t )
Obviously, better ranked players have a higher quotation. We assume that if player i has rank r i then its quota is q i such that whenever r i < r j we have q i > q j . For example, if there are N = 2 n players then we can choose q i = N + 1 r i for all i = 1 , , N .
Example 5.
Let us consider the tournaments t 1 , t 2 , and t 3 with three players shown in Figure 3. Let us introduce:
A = q 1 q 2 + q 1 q 3 + q 2 q 3 S = q 1 + q 2 + q 3
We obtain:
C o s t ( t 1 ) = q 2 q 3 1 + q 1 q 2 2 + q 1 q 3 2 = A + q 1 ( q 2 + q 3 ) = A + q 1 ( S q 1 ) C o s t ( t 2 ) = A + q 2 ( S q 2 ) C o s t ( t 3 ) = A + q 3 ( S q 3 )
The ordering of the costs depends on the ordering of the values of the function q ( S q ) for q = q 1 , q 2 , q 3 [ 0 , S ] . This function is monotonically increasing on [ 0 , S / 2 ] and monotonically decreasing on [ S / 2 , S ] . Observe that if q i S / 2 , i.e., if neither player gets more than a half of the total quotation stake, then the ordering of the costs is given by the ordering of the quotations q i .
Example 6.
Let us consider four players (see Table 1). We assume that each player has a unique rank from 1 to 4. Now, if we choose q i = 5 r i then, using this approach for defining players’ quota, player 2 with rank 4 is assigned quotation q 2 = 1 . We consider the three tournaments t 1 , t 2 , t 3 T 2 ( { 1 , 2 , 3 , 4 } ) from Figure 4. According to Equation (12), the cost of a tournament t T 2 ( { 1 , 2 , 3 , 4 } ) is:
C o s t ( t ) = 1 i < j 4 4 s i j t q i q j C o s t ( t ) = s 12 t · 4 × 1 + s 13 t · 4 × 2 + s 14 t · 4 × 3 + s 23 t · 1 × 2 + s 24 t · 1 × 3 + s 34 t · 2 × 3
Substituting stage values s i j t for each tournament from Table 2 into Equation (16) we obtain the tournaments’ cost values from Table 2. We observe that in this case the best tournament is t 3 . Actually it can be easily checked that the best tournament is t 3 for whatever values of the quota that are decreasingly ordered according to the ranks.

5. Dynamic Programming Algorithm for Computing Optimal Tournaments

For any set of players Σ we denote by q Σ the sum of quotations of the players in Σ .
q Σ = i Σ q i
Proposition 4
(Recurrence for tournament cost). Let t T n ( Σ ) be an n-stage tournament such that Σ is a finite nonempty set with N 2 n 1 + 1 2 n elements. Then:
C o s t ( t ) = 0 n = 0 q i · q j n = 1 , N = 2 , Σ = { i , j } C o s t ( t 1 ) + C o s t ( t 2 ) + n q Σ 1 q Σ 2 n 2 , t = { t 1 , t 2 } , t 1 T ( Σ 1 ) , t 2 T ( Σ 2 ) , Σ 1 Σ 2 = Σ , Σ 1 Σ 2 = , t 1 and t 2 are balanced , at most one has n 2 levels and in this case it is fully balanced
Proof. 
If n = 0 then Σ has a single player so the result is obvious, as no games are played to determine the winner of the tournament.
If n = 1 then Σ has two players i and j so the result is obvious, as a single game is played to determine the winner of the tournament, between player i and player j.
If n 2 then t = { t 1 , t 2 } . If i Σ 1 and j Σ 2 then s i j t = n . So Equation (12) gives:
C o s t ( t ) = i , j Σ 1 , i < j q i q j s i j t 1 + i , j Σ 2 , i < j q i q j s i j t 2 + i Σ 1 , j Σ 2 q i q j s i j t = C o s t ( t 1 ) + C o s t ( t 2 ) + n i Σ 1 , j Σ 2 q i q j = C o s t ( t 1 ) + C o s t ( t 2 ) + n q Σ 1 q Σ 2
The conditions from the Equation (18) follow directly from the recursive definition of balanced tournaments (Definition 2).    □
Proposition 5
(Recurrences for optimal tournaments).
1. 
The optimal tournament cost O p t C introduced by Equation (13) can be defined recursively as follows:
O p t C ( Σ ) = 0 n = 0 , | Σ | = 1 q i · q j n = 1 , Σ = { i , j } max Σ 1 Σ 2 = Σ Σ 1 Σ 2 = O p t C ( Σ 1 ) + O p t C ( Σ 2 ) + n q Σ 1 q Σ 2 n 2 , 2 n 1 < | Σ | 2 n 2 n 2 | Σ 1 | | Σ 2 | 2 n 1
2. 
The optimal tournament can be determined by recording the pairs of subsets O p t ( Σ ) = ( Σ 1 , Σ 2 = Σ Σ 1 ) that maximize O p t C in Equation (20) for n 2 , 2 n 1 < | Σ | 2 n as follows:
O p t S ( Σ ) = argmax Σ 1 , Σ 2 Σ O p t C ( Σ 1 ) + O p t C ( Σ 2 ) + n q Σ 1 q Σ 2
Note that the limits of argmax in Equation (21) must satisfy the conditions from the third branch of Equation (20). Note also that it is enough to record O p t ( Σ ) = Σ 1 as Σ 2 = Σ Σ 1 .
Proof. 
The proof follows by applying the maximization operation in Equation (18) and observing that the term n q Σ 1 q Σ 2 does not depend on t = { t 1 , t 2 } . The condition | Σ 1 | | Σ 2 | ensures that a pair { Σ 1 , Σ 2 } is uniquely considered (otherwise each pair will be considered twice as { Σ 1 , Σ 2 } and { Σ 2 , Σ 1 } ).
Moreover, the sets O p t S ( Σ ) can be used to construct an optimal tournament. Let Σ n = Σ . We define: Σ n 1 = O p t S ( Σ n ) , , Σ 0 = O p t S ( Σ 1 ) . Then the optimal tournament t can be defined recursively as follows:
t = t n ( Σ n ) t i ( Σ i ) =   { t 1 i 1 ( Σ i 1 ) , t 2 i 1 ( Σ i Σ i 1 ) } i 1 j i = 0 , Σ 0 = { j }
   □
Proposition 5 (Equation (20) in particular) can be used to design a dynamic programming algorithm for computing the optimal tournament and its cost. The dynamic programming algorithm can be implemented either with a bottom-up approach or using a top-down approach with memoization [17]. We will explore these possibilities in what follows by deriving a bottom-up dynamic programming algorithm for fully balanced tournaments as well as a top-down dynamic programming algorithm with memoization for the general case.

5.1. Top-Down Dynamic Programming Algorithm with Memoization

Proposition 6
(Top-down recursive application of Equation (20)). Let us assume that we want to compute O p t C ( Σ ) for | Σ | = N , N 2 , 2 n 1 + 1 N 2 n . According to Proposition 5, we must recursively explore all tournaments of shape t = { t 1 , t 2 } such that t i T ( Σ i ) , | Σ i | = N i , i = 1 , 2 , N = N 1 + N 2 . Then we should recursively apply Equation (20) only for the following values of N 1 :
max { N 2 n 1 , 2 n 2 } N 1 N / 2
Proof. 
As N = N 1 + N 2 and N 1 N 2 we obtain:
N 1 N / 2
As N = N 1 + N 2 and 2 n 2 N 1 2 n 1 we obtain:
2 n 2 N 1 2 n 1 N 2 n 1 N 1 N 2 n 2
Combining (24) and (25) we obtain:
max { N 2 n 1 , 2 n 2 } N 1 min { 2 n 1 , N 2 n 2 , N / 2 }
It is not difficult to see that N / 2 N / 2 2 n 1 and N / 2 N / 2 < N 2 n 2 so the value of right-hand side of Equation (26) is N / 2 , q.e.d.    □
Observe that for fully balanced tournaments N = 2 n , so this top-down recursive process will generate subsets of sizes 2 n 1 , 2 n 2 2 , 1 .
Example 7.
Let us illustrate the application Equation (20) for N = | Σ | = 25 players. The results are summarized in Table 3. It follows that solving the problem for a set of 25 players requires the solving of all subproblems corresponding to its subsets of 1 , 2 , , 16 players; however, solving the problem for a set of 15 players requires the solving of all subproblems corresponding to its subsets of 1 , 2 , 3 , 4 , 7 , 8 players. Moreover, solving the problem for a set of 14 players requires the solving of all subproblems corresponding to its subsets of 1 , 2 , 3 , 4 , 6 , 7 , 8 players, while solving the problem for a set of 12 or 13 players requires the solving of all subproblems corresponding to its subsets of 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 players.
Proposition 6 sets the iteration bounds for exploring the subsets of players in the top-down approach. Combining the results of Propositions 5 and 6, we obtain the top-down approach for computing optimal balanced tournaments; see Algorithm 1.
Algorithm 1 O p t T o u r C o s t T D ( Σ , N , q ) top-down dynamic programming algorithm with memoization for computing the cost of the optimal tournament.
Global: O p t C , initially ∅, maps subsets of players to costs of optimal tournaments.
      O p t S , initially ∅, maps subsets to sub-subsets for building optimal tournaments.
Input:  N N represents the number of players.
   q. Vector of size N representing the players’ quota.
    Σ such that | Σ | = N . Σ represents the set of players.
Output:  C m a x . Cost of the optimal tournament for set Σ of players.
   n log 2 N
  if  n = 0  then
        C m a x 0
        S m a x
  else if  n = 1 (i.e., Σ = { i , j } ) then
        C m a x q i q j
        S m a x { i }
  else
        P 1 2 n 2
        P 2 2 P 1
        k m a x N / 2
      if  N P 1 + P 2  then
            k m i n P 1
       else
            k m i n N P 2
       end if
        C m a x
       for  k = k m i n , k m a x  do
           for  Σ 1 Σ s.t. | Σ 1 | = k  do
              if  Σ 1 O p t C  then
                   C 1 O p t T o u r C o s t T D ( Σ 1 , k , q )
              else
                   C 1 O p t C [ Σ 1 ]
              end if
               Σ 2 Σ Σ 1
              if  Σ 2 O p t C  then
                   C 2 O p t T o u r C o s t T D ( Σ 2 , k , q )
              else
                   C 2 O p t C [ Σ 2 ]
              end if
               C C 1 + C 2
               q l 0
              for  i Σ 1  do
                   q l q l + q i
              end for
               q r 0
              for  i Σ 2  do
                   q r q r + q i
              end for
               C C + k q l q r
              if  C > C m a x  then
                   C m a x C
                   S m a x Σ 1
              end if
           end for
       end for
  end if
   O p t C [ Σ ] C m a x
   O p t S [ Σ ] S m a x

5.2. Bottom-Up Dynamic Programming Algorithm for Fully Balanced Tournaments

The cost of the optimal tournament is computed with the help of O p t C vector that is indexed by all the subsets of Σ generated recursively by Equation (20), starting from the topmost set Σ . Note that for a fully balanced tournament we have | Σ | = 2 n and the process will generate exactly all the subsets of Σ of cardinal: 2 0 , 2 1 , … 2 n . Note that in this case the size of O p t C can be determined as:
S n = i = 0 2 n 2 n 2 i
Additionally we must save in vector O p t S of size S n the subsets Σ determined using Equation (21), such that we can reuse them to construct the optimal tournament using Equation (22). Our proposed algorithm is presented as Algorithm 2.
Algorithm 2 O p t T o u r C o s t B U ( Σ , N = 2 n , q ) bottom up dynamic programming algorithm for computing the cost of optimal fully balanced tournaments.
Input:  N = 2 n , n N . N represents the number of players.
    q. Vector of size N representing the players’ quota.
     Σ such that | Σ | = 2 n . Σ represents the set of players.
Output:  O p t C . Vector of costs of the optimal sub-tournaments.
      O p t S . Vector of sets to construct the optimal tournament.
 1: for i = 1 , N do
 2:       O p t C [ { i } ] 0
 3: end for
 4: for k = 1 , n do
 5:        for  Σ 1 Σ s.t. | Σ 1 | = 2 k  do
 6:            C m a x
 7:           for  Σ Σ 1 s.t. | Σ | = 2 k 1  do
 8:               C O p t C ( Σ ) + O p t C ( Σ 1 Σ )
 9:               q l 0
10:              for  i Σ  do
11:                 q l q l + q i
12:              end for
13:               q r 0
14:              for  i Σ 1 Σ  do
15:                  q r q r + q i
16:              end for
17:               C C + k q l q r
18:              if  C > C m a x  then
19:                  C m a x C
20:                  S m a x Σ
21:              end if
22:           end for
23:            O p t C [ Σ 1 ] C m a x
24:            O p t S [ Σ 1 ] S m a x
25:          end for
26: end for

5.3. Computing an Optimal Tournament

Note that both Algorithms 1 and 2 determine the O p t S structure that records the split points for each subset of players according to Equation (20). The O p t S structure can be used to actually build an optimal tournament according to Algorithm 3 using Equation (22).
Algorithm 3: O p t T o u r ( Σ , N , O p t S ) algorithm for computing the optimal tournament.
Input: Σ representing the set of players.
    N N representing the number of players.
    O p t S . Structure determined either by Algorithm 1 or by Algorithm 2.
Output: Returns the optimal tournament.
1: if N = 1 (i.e., Σ = { j } ) then
2:   return j
3: end if
4: Σ 1 O p t S ( Σ )
5: N 1 | Σ 1 |
6: Σ 2 Σ Σ 1
7: t 1 O p t T o u r ( Σ 1 , N 1 , O p t S )
8: t 2 O p t T o u r ( Σ 2 , N N 1 , O p t S )
9: return { t 1 , t 2 }

5.4. Correctness and Complexity Results

Proposition 7
(Correctness of Algorithms 1–3).
a. 
The value C m a x = O p t C [ Σ ] computed by Algorithms 1 and 2 represents the cost of the optimal tournament in both cases.
b. 
The tournament determined by Algorithm 3 is the optimal tournament.
Proof. 
Proof of a. Algorithms 1 and 2 compute the values of O p t C and O p t S either in top-down or bottom-up fashion for all the subsets that are required to determine the optimal tournament for the set Σ of players. The computation follows Equations (20) and (21); therefore the correctness of this point follows from Propositions 5 and 6.
Proof of b. Algorithm 3 computes the optimal tournament using Equations (22). As values of O p t S are correctly determined according to point “a”, it follows that the tournament computed by Algorithm 3 is the optimal tournament.    □
Proposition 8
(Complexity of Algorithms 2 and 3). Let us consider tournaments with N players.
a. 
Space complexity of Algorithm 2 is Θ 2 N N .
b. 
Time complexity of Algorithm 2 is Θ ( ( 2 2 ) N ) .
c. 
Space complexity of Algorithm 1 is Θ 2 N N for fully balanced tournaments and O ( 2 N ) in the general case.
d. 
Time complexity of Algorithm 1 is O ( 3 N · N N ) .
e. 
Time complexity of Algorithm 3 is Θ ( N ) .
Proof. 
The proof is using the Stirling approximation of the factorial, written in inequality form ([18]), in fact showing that p ! = Θ p p e p :
2 π p ! p p e p e
Using this observation it is not difficult to prove that:
2 p p = Θ 2 2 p p
Proof of a. The space complexity of Algorithms 2 and 3 is given by the size of structures O p t C and O p t S (see Equation (27)); however, the asymptotically dominant term of this summation is 2 n 2 n 1 . Then the result follows using Equation (29) for p = 2 n 1 .
Proof of b. Algorithm 2 contains one “for” loop (lines 4–26) including other three nested “for” loops. The first inner “for” loop (lines 5–25) is executed N 2 k times. The second inner “for” loop (lines 7–22) is executed 2 k 2 k 1 times. The third inner “for” loop (lines 10–12 and 14–16) is executed 2 k 1 times. The total number of steps of Algorithm 2 is given by:
k = 1 n N 2 k 2 k 2 k 1 2 k 1
Observe that the asymptotically dominant term of this summation is obtained for k = n 1 and it can be transformed using Equation (29), thus concluding the proof:
N 2 n 1 2 n 1 2 n 2 2 n 2 = Θ 2 2 n 2 n 1 2 2 n 1 2 n 2 2 n 2 = Θ 1 2 2 N 2 N / 2 = Θ ( ( 2 2 ) N )
Proof of c. If N is a power of two, i.e., we have a fully balanced tournament, the memory consumption is exactly as in case a, so the first result follows trivially. Otherwise, the space consumption of tables O p t C and O p t S has an upper bound given by the size of the power set of Σ , and the result follows immediately.
Proof of d. Let us first observe that in order to determine the cost of an optimal tournament with N players we need to know the costs of optimal tournaments for N 1 and N 2 players such that N = N 1 + N 2 and condition of Equation (23) holds. It is not difficult to observe that:
N 4 < N 1 N 2 < 3 N 4
First note that the upper bound of N 2 follows from the lower bound of N 1 , so it is enough to show the lower bound of N 1 . Let us assume by contradiction that:
N 4 max { N 2 n 1 , 2 n 2 }
It follows that:
N 2 = N 4 + N 4 N 2 n 1 + 2 n 2 = N 2 n 2
so:
N 2 n 1
and thus contradicting (5).
It is easier to analyze the complexity of Algorithm 1 by thinking “bottom-up” rather than “top-down”. The complexity will be the same, as the role of the memorization technique is just to evaluate exactly once the cost of a tournament for each subset of players. So we must determine the cost for a subset of i = N 4 , N 4 + 1 , , 3 N 4 players ( · can be omitted without losing generality); therefore the total running time has the following upper bound:
p = N 4 p = 3 N 4 N p k = p 4 3 p 4 p k k
Although p k = p p k , so grouping terms with complementary binomial coefficients of inner sum of (36), noticing that p k p p 2 and using (29), the inner sum has an upper bound of:
p · k = p 4 p 2 p k p · p 4 · Θ ( 2 p p ) N N · Θ ( 2 p )
Now, substituting (37) in (36) we obtain the following upper bound of the running time:
N N · p = N 4 p = 3 N 4 N p · Θ ( 2 p ) N N · p = 0 p = N N p · Θ ( 2 p ) = Θ ( 3 N · N N )
As this is in fact only an upper bound of our running time, the result of point e follows (i.e., with O rather than Θ ).
Proof of e. Observe that the time complexity of Algorithm 3 satisfies the recursive equation T ( | Σ | ) = T ( | Σ 1 | ) + T ( | Σ 2 | ) . Unfolding this equation with the substitution method yields an asymptotic execution time Θ ( | Σ | ) = Θ ( N ) .    □

5.5. Sub-Optimal Algorithms

The dynamic programming approach for construing optimal tournaments has the disadvantage that the full exploration of the search space becomes prohibitive for larger tournaments. Our experiments (see Section 6) clearly show that this approach is unfeasible for tournaments of more than n = 16 players; however, the dynamic programming algorithms can be easily adapted to explore a smaller size of the search space, leading to sub-optimal solutions. The exploration strategy can be used to tune the trade-off between the complexity of the computation and the “gap” between the provided sub-optimal solution and the actual optimal solution.
The resulting sub-optimal algorithms follow a strictly top-down approach that can be the best described as divide-and-conquer. At each decision point, rather than exploring all pairs of subsets ( Σ 1 , Σ 2 ) satisfying conditions of Equation (20), only few such pairs (ideally only 1) are selected for exploration. This selection strategy can be deterministic, based on heuristic principles, or stochastic based on stochastic sampling subsets of Σ satisfying the conditions of Equation (20). The strictly top-down approach has the advantage that it avoids the use of temporary structures O p t S and O p t C and of the additional algorithm O p t T o u r to build the solution. Rather, the top-down approach will build the solution directly, using the recursive divide-and-conquer approach.
The general approach of a sub-optimal algorithm following a top-down divide and conquer approach is presented as Algorithm 4. Note that this algorithm is using a specific strategy to explore only a few subsets of Σ defined by S t r a t e g y ( Σ , k m i n , k m a x ) 2 Σ and satisfying the conditions of Equation (20).
Proposition 9
(Complexity of Algorithm 4). Let us consider tournaments for N players and let n be the number of stages of a balanced tournament. Then the time complexity of Algorithm 4 is O ( N 1 + log 2 s ) where s is the average number of subsets of Σ explored by the strategy of the algorithm.
Proof. 
It is not difficult to observe that the time complexity of Algorithm 4 satisfies the following recurrence:
T ( | Σ | ) = s · ( T ( | Σ 1 | ) + T ( | Σ Σ 1 | ) )
Applying the substitution method for Equation (39) we obtain:
T ( | Σ | ) = i Σ s h i · O ( 1 )
For each i Σ , h i from Equation (40) denotes the height of leaf i in the tournament tree, so h i n log 2 N . So:
T ( | Σ | ) = N · O ( s l o g 2 N ) = O ( N 1 + log 2 s )
q.e.d.    □
Algorithm 4 O p t T o u r C o s t S u b O p t ( Σ , N , q , S ) top-down divide-and-conquer algorithm for computing a sub-optimal tournament.
Input: N N represents the number of players.
   q. Vector of size N representing the players’ quota.
    Σ such that | Σ | = N . Σ represents the set of players.
    S = i Σ q i . Sum of players’ quotations.
Output: C m a x . Cost of the sub-optimal tournament for set Σ of players.
      t m a x . Sub-optimal tournament tree.
 1: n log 2 N
 2: if n = 0 (i.e., Σ = { i } ) then
 3:     C m a x 0
 4:     t m a x i
 5: else if n = 1 (i.e., Σ = { i , j } ) then
 6:     C m a x q i q j
 7:     t m a x { i , j }
 8: else
 9:     P 1 2 n 2
10:     P 2 2 P 1
11:     k m a x N / 2
12:    if  N P 1 + P 2  then
13:       k m i n P 1
14:    else
15:       k m i n N P 2
16:    end if
17:     C m a x
18:    for  Σ 1 S t r a t e g y ( Σ , k m i n , k m a x )  do
19:       S 1 0
20:      for  i Σ 1  do
21:         S 1 S 1 + q i
22:      end for
23:       k | Σ 1 |
24:       ( C 1 , t 1 ) O p t T o u r C o s t S u b O p t ( Σ 1 , k , q , S 1 )
25:       ( C 2 , t 2 ) O p t T o u r C o s t S u b O p t ( Σ Σ 1 , N k , q , S S 1 )
26:       C C 1 + C 2 + k S 1 ( S S 1 )
27:      if  C > C m a x  then
28:         C m a x C
29:         t m a x ( t 1 , t 2 )
30:      end if
31:     end for
32: end if
33: return ( C m a x , t m a x )
Observe that if s = 1 then the time complexity of Algorithm 4 is linear in the number N of players. Moreover, if s > 1 then the time complexity of the algorithm is polynomial in N and the degree of the polynomial grows logarithmically with s.

5.5.1. Deterministic Sub-Optimal Algorithms

We define a deterministic sub-optimal algorithm by letting Σ 1 consist of the smallest set of players 1 , 2 , , k such that k k m i n and q Σ 1 > q Σ / 2 .
The rationale of this choice is to try to make the product q Σ 1 q Σ 2 from Equation (20) as high as possible. As q Σ 1 + q Σ 2 = q Σ is constant, we try to make the values q Σ 1 and q Σ 2 as close as possible, while maintaining the constraints on the size of subset Σ 1 .
We can define three variants of the deterministic sub-optimal algorithm by considering the sequence of players’ quotations to be: (i) unchanged, i.e., as it was provided as input; (ii) increasingly sorted; (iii) decreasingly sorted.

5.5.2. Stochastic Sub-Optimal Algorithms

We define a stochastic sub-optimal algorithm by letting Σ 1 consist of a family of randomly chosen subsets of players of Σ 1 Σ such that k m a x | Σ 1 | k m i n . This is easily achieved by randomly choosing the number of players k uniformly distributed in [ k m i n , k m a x ] and then randomly choosing a subset Σ 1 of k elements and uniformly distributed in Σ .
The number of chosen subsets Σ 1 explored by the algorithm is a parameter denoted by N s a m p l e and it usually has a low number, as it directly influences the complexity of the algorithm according to Proposition 9, s = N s a m p l e . For example, if N s a m p l e = 1 the complexity of the algorithm is O ( N ) , if N s a m p l e = 2 the complexity of the algorithm is O ( N 2 ) and if N s a m p l e = 4 the complexity of the algorithm is O ( N 3 ) .

6. Implementation and Experiments

6.1. Implementation Issues

There were several issues that we had to address by our experimental implementation of Algorithms 1–3.
Firstly, we have chosen to represent sets as arrays of bits, as well as using the integer value that is equivalent to the binary representation as an array of bits.
Secondly, for generating subsets of given size (i.e., combinations) we have used Algorithm 7.2.1.2L from [19] for generating permutations with repetitions of binary arrays. Basically the subsets representing combinations of k elements of a set with n k elements are all the permutations with repetitions of a binary vector of n elements containing exactly k elements equal to 1.
Thirdly, we had to choose an efficient representation of O p t C and O p t S structures. Their operation is crucial for the efficient implementation of some of our algorithms. As for our implementation we have chosen Python platform, we decided to implement O p t C and O p t S using subset-indexed dictionaries that map subsets of Σ to costs and to subsets necessary for building optimal tournaments, respectively. The subsets representing the dictionary keys are defined as integer values of their characteristic vector in binary format. As Python dictionaries are efficiently implemented using hash tables, an average O ( 1 ) time complexity is expected for lookup operations.
Finally, for the implementation of the random selection of subsets we have used the array of bits representation of sets and we have applied the random.permute function from NumPy package to return a randomly permuted array representing a random subset.

6.2. Experimental Results

Our experiments were developed in Python 3.7.3 using Jupyter Notebook on an x64-based PC with a 2 cores/4 threads Intel© Core™i7-5500U CPU at 2.40 GHz running Windows 10 (The experimental code is available at http://software.ucv.ro/~cbadica/tour.zip accessed on 2 September 2021).
According to our findings, there are no algorithms directly available to be compared with our own proposals. There are two main causes for this. First, we consider an integrated approach of tournament design, rather than a process involving two separated stages for structure design and seeding. Secondly, we do not use probabilistic information in our cost function, thus hindering the direct comparison of tournament cost values.
We took a different path for evaluating our proposals. We have implemented optimal algorithms, as well as several versions of sub-optimal algorithms and then compared their outcomes in terms of running time and optimality. So finally we have implemented and experimentally evaluated eight algorithms, as presented in Table 4.
Note that for the optimal algorithms there are at least two restrictions that hinder a complete experimental comparison with the rest of the algorithms. Firstly, their high computational complexity limits their applicability only to small number of players. Secondly, the dynamic programming bottom-up algorithm works only for a number of players that is an exact power of 2. We have only checked it for N = 4 , 8 , 16 .
Our data set includes multiple sequences of players’ quotations. For each N = 3 , 4 , 50 we generated a sequence of quotations q 1 , q 2 , , q N with integer values q i randomly chosen with a uniform distribution in the interval [ q m i n = 1 , q m a x = 9 ] . This data set was used to experimentally evaluate the algorithms from Table 4, as follows:
  • All the sequences of the data set were used for testing algorithms S u b O p t D i and S u b O p t S i for i = 1 , 2 , 3 .
  • The optimal algorithm O p t T D was evaluated only for sequences corresponding to N = 3 , , 16 players. The reason is that the algorithm has a too high computational complexity and we limited the running time of each problem instance to 5 min.
  • The optimal algorithm O p t B U was evaluated only for sequences corresponding to N = 4 , 8 , 16 players. The reason is both the high computational complexity of the algorithm and the fact that this algorithm was designed to work only with a number of players that is an exact power of 2.
For each algorithm, we recorded the (sub-)optimal cost of the output tournament, as well as the running time. Stochastic algorithms S u b O p t S i for i = 1 , 2 , 3 were evaluated by repeating their execution 10 times for each input sequence of quotations from the data set and recording the minimum, maximum, and average costs, as well as the average running times.
Figure 5 presents the sub-optimal costs produced by S u b O p t D i and S u b O p t S i algorithms for i = 1 , 2 , 3 . The figure plots costs C i produced by algorithms S u b O p t D i for i = 1 , 2 , 3 , as well as average costs C S a i produced by algorithms S u b O p t S i for i = 1 , 2 , 3 and the maximum cost C S M 3 produced by the 10-times repeated execution of algorithm S u b O p t S 3 . Note that we included maximum cost only for this case, as it should be obvious that it is expected that stochastic algorithm S u b O p t S 3 will produce the best results among S u b O p t S i for i = 1 , 2 , 3 because it uses the highest number of samplings N s a m p l e = 3 .
Analyzing Figure 5, we first observe that the relative difference of the costs produced by the various algorithms on the same input sequence is rather low. This is expected, as quotations q i were generated as integer values from a small interval 1 q i 9 while the cost tends to reach significantly higher values. For example, analyzing in detail the results obtained for the sample with N = 50 players we observe that the relative difference between the smallest and the highest cost obtained (147,555 and 156,203) is of only 5.53 % . We can also notice that the best results among sub-optimal algorithms were obtained by algorithm S u b O p t S 3 , while the worst results were obtained by algorithms S u b O p t D 2 and S u b O p t D 3 . It might look a bit surprising that algorithm S u b O p t D 1 appears to be superior to S u b O p t D 2 and S u b O p t D 3 ; however, taking into account how the data set was generated, this could be explained by the fact that algorithm S u b O p t D 1 is actually using a random permutation of the quotations’ sequence that provides a better balance of the total quotation distribution between the two subsets Σ 1 and Σ Σ 1 (see Algorithm 4) than algorithms S u b O p t D 2 and S u b O p t D 3 . One final remark, also observed experimentally, is that algorithms S u b O p t D 2 and S u b O p t D 3 produce the same sub-optimal costs if the number of players is an exact power of 2 (i.e., 16 and 32 on Figure 5). This is an immediate consequence on the logic behind their strategy definition.
Figure 6 presents the running times T D i and T S i of algorithms S u b O p t D i and S u b O p t S i for i = 1 , 2 , 3 . The time figures are given in milliseconds and presented on a logarithmic scale and they were computed by taking the average for 10 executions of the algorithm on the same input data. First observe that deterministic versions S u b O p t D i are the fastest and they have virtually almost the same running times. This can be easily explained by the low computational complexity of the implementation of their underlying strategies. Basically, their strategies use the same mechanism, while the additional sorting of the sequence of quotations adds a negligible cost as it is performed before the actual core processing of the algorithms. Second, the highest execution time is achieved, as expected, by S u b O p t S 3 . This algorithm has the highest computational complexity among sub-optimal algorithms, as it is using three subset samples during the top-down search. From Figure 6 it also follows that the highest average execution time was obtained for the sequence of quotations with N = 46 players and its value was 2.49 s.
Figure 7 presents results obtained with optimal algorithms O p t T D and O p t B U , as well as their comparison with results obtained by sub-optimal algorithm S u b O p t S 3 for N = 3 , 4 , , 16 players, on our input data set.
In Figure 7a we show the comparison of relative maximum and average costs obtained by algorithm S u b O p t S 3 ( C S M 3 and C S a 3 ) with the actual optimal cost obtained by algorithm O p t T D . The relative sub-optimal cost is a measure C r ( 0 , 1 ] computed with Equation (42) using the absolute values of sub-optimal cost C 0 and optimal cost C 1 C 0 > 0 . Observe that C r = 1 if and only if C 1 = C 0 , i.e., if the algorithm providing sub-optimal cost C 0 is in fact optimal. Note that the computation of the relative sub-optimal cost assumes the the exact value C 1 of the optimal cost is known. In our case, this value is known, as it was determined using the O p t T D optimal algorithm for N = 3 , 4 , , 16 players.
C r = C 0 C 1
In Figure 7b we show the comparison of running times T T D , T B U , and T S 3 of algorithms O p t T D , O p t B U , and S u b O p t S 3 for N = 3 , 4 , , 16 players. The running times were evaluated by repeating the algorithm execution 10 times for the same input data. They are plotted on a logarithmic scale. Observe that by far the most efficient among them is algorithm S u b O p t 3 . The linear increasing trend of T T D and T B U on the logarithmic scale is consistent to our findings that the complexity of algorithms O p t T D and O p t B U is exponential with the number of tournament players. Note that this tendency is also observed on the plot of T B U , for which the values were recorded only for an exact power of two of the number of players, i.e., N = 4 , 8 , 16 . Moreover, the sub-linear increasing trend of T S 3 on the logarithmic scale is consistent with the fact that algorithm S u b O p t 3 has a polynomial time complexity.

7. Conclusions

In this paper we defined optimal competitions structured as hierarchically shaped single-elimination tournaments. The optimality criterion aimed to maximize tournament attractiveness by letting the topmost players meet in higher stages of the tournament. We proposed a dynamic programming algorithm for computing optimal tournaments and we provided a thorough analysis of its correctness and computational complexity. Based on the idea of the dynamic programming approach, we also developed deterministic and stochastic sub-optimal algorithms. We realized an experimental evaluation of the proposed algorithms by providing experimental results that we obtained with their Python implementation. The results addressed the optimality of solutions and the efficiency of the running time.

Author Contributions

Conceptualization, A.B. and C.B.; methodology, A.B. and C.B.; software, C.B.; formal analysis, C.B. and A.B.; investigation, I.B., L.I.C. and D.L.; writing, C.B. and A.B. All authors have read and agreed to the published version of the manuscript.

Funding

This research received no external funding.

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Conflicts of Interest

The authors declare no conflict of interest.

References

  1. Bădică, A.; Bădică, C.; Buligiu, I.; Ciora, L.I.; Logofătu, D. Optimal Knockout Tournaments: Definition and Computation. In Proceedings of the Large Scale Scientific Computing—LSSC’2021, LNCS, Sozopol, Bulgaria, 7–11 June 2021. in press. [Google Scholar]
  2. Anderson, I. Combinatorial Designs and Tournaments; Oxford University Press Inc.: New York, NY, USA, 1997. [Google Scholar]
  3. Vu, T.; Shoham, Y. Fair Seeding in Knockout Tournaments. ACM Trans. Intell. Syst. Technol. 2011, 3, 9:1–9:17. [Google Scholar] [CrossRef]
  4. Vu, T.D. Knockout Tournament Design: A Computational Approach. Ph.D. Thesis, Stanford University, Stanford, CA, USA, 2010. [Google Scholar]
  5. Bóna, M.; Flajolet, P. Isomorphism and symmetries in random phylogenetic trees. J. Appl. Probab. 2009, 46, 1005–1019. [Google Scholar] [CrossRef] [Green Version]
  6. Maurer, W. On Most Effective Tournament Plans with Fewer Games than Competitors. Ann. Statist. 1975, 3, 717–727. [Google Scholar] [CrossRef]
  7. Dagaev, D.; Suzdaltsev, A. Tournament design allows for spectator interest increase. Front. Econ. Res. 2015. Available online: https://voxeu.org/article/tournament-design-allows-spectator-interest-increase (accessed on 23 August 2021).
  8. Hartigan, J.A. Probabilistic Completion of a Knockout Tournament. Ann. Math. Statist. 1966, 37, 495–503. [Google Scholar] [CrossRef]
  9. CodeChef. Tennis Tournament. Available online: https://www.codechef.com/COOK27/problems/TOURNAM (accessed on 9 August 2021).
  10. Bao, N.P.H.; Xiong, S.; Iida, H. Reaper Tournament System. In Intelligent Technologies for Interactive Entertainment. INTETAIN 2017. Lecture Notes of the Institute for Computer Sciences, Social Informatics and Telecommunications Engineering; Chisik, Y., Holopainen, J., Khaled, R., Luis Silva, J., Alexandra Silva, P., Eds.; Springer: Cham, Switzerland, 2018; Volume 215, pp. 16–33. [Google Scholar]
  11. Karpov, A. A Theory of Knockout Tournament Seedings; Discussion Paper Series; University of Heidelberg, Department of Economics: Heidelberg, Germany, 2015; Volume 600. [Google Scholar]
  12. Adler, I.; Cao, Y.; Karp, R.; Peköz, E.A.; Ross, S.M. Random Knockout Tournaments. Oper. Res. 2017, 65, 1589–1596. [Google Scholar] [CrossRef] [Green Version]
  13. Guyon, J. “Choose Your Opponent”: A New Knockout Design for Hybrid Tournaments. J. Sport. Anal. 2021, 1–21, pre-press. [Google Scholar] [CrossRef]
  14. Hennessy, J.; Glickman, M. Bayesian optimal design of fixed knockout tournament brackets. J. Quant. Anal. Sports 2016, 12, 1–15. [Google Scholar] [CrossRef]
  15. Csató, L. Tournament Design. How Operations Research Can Improve Sports Rules; Palgrave Macmillan: London, UK, 2021. [Google Scholar]
  16. Stojadinović, T. On Catalan numbers. Teach. Math. 2015, XVIII, 16–24. [Google Scholar]
  17. Cormen, T.H.; Leiserson, C.E.; Rivest, R.L.; Stein, C. Introduction to Algorithms, 3rd ed.; The MIT Press: Cambridge, MA, USA; London, UK, 2009; pp. 365–367. [Google Scholar]
  18. Dutka, J. The early history of the factorial function. Arch. Hist. Exact Sci. 1991, 43, 225–249. [Google Scholar] [CrossRef]
  19. Knuth, D.E. The Art of Computer Programming, Volume 4A: Combinatorial Algorithms, Part 1; Addison-Wesley Professional: Boston, MA, USA, 2011; pp. 319–320. [Google Scholar]
Figure 1. Tournaments of two and three players (first column) and four players (second column).
Figure 1. Tournaments of two and three players (first column) and four players (second column).
Mathematics 09 02480 g001
Figure 2. A balanced tournament of five players.
Figure 2. A balanced tournament of five players.
Mathematics 09 02480 g002
Figure 3. Balanced tournaments with three players.
Figure 3. Balanced tournaments with three players.
Mathematics 09 02480 g003
Figure 4. Balanced tournaments with four players.
Figure 4. Balanced tournaments with four players.
Mathematics 09 02480 g004
Figure 5. Sub-optimal tournament costs determined by sub-optimal algorithms on different quotations’ sequences for various number of players.
Figure 5. Sub-optimal tournament costs determined by sub-optimal algorithms on different quotations’ sequences for various number of players.
Mathematics 09 02480 g005
Figure 6. Running times on logarithmic scale of sub-optimal algorithms on different quotations’ sequences for a variable number of players.
Figure 6. Running times on logarithmic scale of sub-optimal algorithms on different quotations’ sequences for a variable number of players.
Mathematics 09 02480 g006
Figure 7. Comparing costs and running times of our implemented algorithms.
Figure 7. Comparing costs and running times of our implemented algorithms.
Mathematics 09 02480 g007
Table 1. Players’ ranking and quotation for n = 4 .
Table 1. Players’ ranking and quotation for n = 4 .
Player iRank r i Quota q i = n + 1 r i
114
423
332
241
Table 2. Games playing stages for each tournament of Figure 4 and their costs.
Table 2. Games playing stages for each tournament of Figure 4 and their costs.
s t 1 123;4 s t 2 1234 s t 3 1234
1 2121 2211 122
2 212 122 22
3 23 23 1
C o s t 59 56 60
Cost of t 1 Cost of t 2 Cost of t 3
Table 3. Games playing stages for each tournament and tournament costs.
Table 3. Games playing stages for each tournament and tournament costs.
|N| n = log 2 n N 2 N 2 n 1 2 n 2 N 1 min , N 1 max N 2 min , N 2 max
2551298 9 , 12 13 , 16
164884 8 , 8 8 , 8
154774 7 , 7 8 , 8
144764 6 , 7 7 , 8
134654 5 , 6 7 , 8
124644 4 , 6 6 , 8
114534 4 , 5 6 , 7
104524 4 , 5 5 , 6
94414 4 , 4 5 , 5
83442 4 , 4 4 , 4
73332 3 , 3 4 , 4
63322 2 , 3 3 , 4
53212 2 , 3 2 , 3
42221 2 , 2 2 , 2
32111 1 , 1 2 , 2
21solved directly
10solved directly
Table 4. Table presenting the list of implemented optimal and sub-optimal algorithms for balanced tournaments.
Table 4. Table presenting the list of implemented optimal and sub-optimal algorithms for balanced tournaments.
AlgorithmDescriptionOptimalityPlayers’ Number
O p t T D Dynamic programming top-down with memoization approach—Algorithm 1OptimalArbitrary natural number
O p t B U Dynamic programming bottom-up approach—Algorithm 2OptimalExact power of 2
S u b O p t D 1 Deterministic sub-optimal approach—Algorithm 4 with deterministic strategy and unchanged quotation sequenceSub-optimalArbitrary natural number
S u b O p t D 2 Deterministic sub-optimal approach—Algorithm 4 with deterministic strategy and increasingly sorted quotation sequenceSub-optimalArbitrary natural number
S u b O p t D 3 Deterministic sub-optimal approach—Algorithm 4 with deterministic strategy and decreasingly sorted quotation sequenceSub-optimalArbitrary natural number
S u b O p t S 1 Stochastic sub-optimal approach—Algorithm 4 with stochastic strategy and N s a m p l e = 1 Sub-optimalArbitrary natural number
S u b O p t S 2 Stochastic sub-optimal approach—Algorithm 4 with stochastic strategy and N s a m p l e = 2 Sub-optimalArbitrary natural number
S u b O p t S 3 Stochastic sub-optimal approach Algorithm 4 with stochastic strategy and N s a m p l e = 3 Sub-optimalArbitrary natural number
Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Share and Cite

MDPI and ACS Style

Bădică, A.; Bădică, C.; Buligiu, I.; Ciora, L.I.; Logofătu, D. Dynamic Programming Algorithms for Computing Optimal Knockout Tournaments. Mathematics 2021, 9, 2480. https://doi.org/10.3390/math9192480

AMA Style

Bădică A, Bădică C, Buligiu I, Ciora LI, Logofătu D. Dynamic Programming Algorithms for Computing Optimal Knockout Tournaments. Mathematics. 2021; 9(19):2480. https://doi.org/10.3390/math9192480

Chicago/Turabian Style

Bădică, Amelia, Costin Bădică, Ion Buligiu, Liviu Ion Ciora, and Doina Logofătu. 2021. "Dynamic Programming Algorithms for Computing Optimal Knockout Tournaments" Mathematics 9, no. 19: 2480. https://doi.org/10.3390/math9192480

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop