Dynamic Programming for Computing Power Indices for Weighted Voting Games with Precoalitions

: We study the efﬁcient computation of power indices for weighted voting games with precoalitions amongst subsets of players (reﬂecting, e.g., ideological proximity) using the paradigm of dynamic programming. Starting from the state-of-the-art algorithms for computing the Banzhaf and Shapley–Shubik indices for weighted voting games, we present a framework for fast algorithms for the three most common power indices with precoalitions, i.e., the Owen index, the Banzhaf–Owen index and the symmetric coalitional Banzhaf index, and point out why our new algorithms are applicable for large numbers of players. We discuss implementations of our algorithms for the three power indices with precoalitions in C++ and review computing times, as well as storage requirements.


Introduction
Weighted voting games (also known as weighted majority games) are a common model for decision-making and voting in committees, panels or boards. There are n players and each player i is assigned a positive weight w i , which, in some situations, may reflect the number of votes of a voting bloc. The decision-making body accepts a measure or motion if a certain quota q, normally more than 50 percent of the sum of all weights, is reached or exceeded, i.e., if and only if there is a winning coalition S with ∑ i∈S w i ≥ q. In cooperative game theory, weighted voting games can be regarded as a special class of simple games, i.e., games in which coalitions are either winning with value 1 or losing with value 0. Power indices are applied to simple games and provide measures for the players' abilities to influence results in voting situations. On the basis of different bargaining models and different axiomatic assumptions, numerous power indices have been introduced; see e.g., [1] for an overview, with the two most-widely used power indices being the Banzhaf index [2,3] and the Shapley-Shubik index [4].
Weighted voting games and power indices are applicable well beyond classical voting situations in politics, described e.g., in [5][6][7][8]. For example, power indices can also be used to analyze genetic networks and rank genes that may be responsible for genetic diseases [9], to solve reliability problems in the maintenance of computer networks [10], to understand indirect control power in corporate shareholding structures [11][12][13] or to analyze social networks [14,15]. In social, economic or corporate networks, and in voting settings alike, it is common for agents to agree beforehand to form a union and act as a voting bloc.
This article deals with the special case of a partition of the player set into disjoint precoalitions (also known as a priori unions), i.e., we assume that either all or none of the members of a precoalition join a certain coalition. Precoalitions can model strict party discipline in a legislative chamber, but they can also be interpreted as a way to reduce negotiation costs, with each precoalition sending a delegate as its negotiator. The practical relevance of cooperative games with precoalitions is hard to overstate and there are practical applications abound. Vázquez-Brage et al. (1996) [16] point out that one needs to consider airlines rather than individual aircraft in order to determine aircraft landing fees; Alonso-Meijide and Bowles (2005) [17] investigate voting at the International Monetary Fund (IMF), where member states are obliged to form a limited number of groups before allowing a vote at its main decision-making committee (called the Executive Board); Alonso-Meijide et al. (2005) [18] discuss union formation in the Parliament of Catalonia during legislature from 1995 to 1999; Mayer (2018) [19] highlights the role of Luxembourg in the early days of the European Economic Community (EEC) by showing that this small country was no longer a powerless null player as soon as it formed a voting bloc together with the two other Benelux countries. As pointed out in the book by Owen [20], pp. 303, the players in such a union have agreed to keep together, but, even though they will do so in most situations, they are not forced to comply, and hence there is a need to evaluate their influence in a two-stage process. In an external stage, the power of the precoalition is evaluated, and in an internal stage, the results for the members of the precoalition are determined. Using the language of cooperative game theory, this two-stage process translates into an external game (also known as the quotient game) between the precoalitions and an internal game within each precoalition.
Owen generalized the Shapley value from the cooperative game theory to the framework with a priori unions amongst subsets of players in his seminal 1977 paper [21]. However, the internal game within each precoalition is no longer a simple game if the external game is simple. Malawski [22] pointed out how this problem can be overcome by computing more than one simple game on the internal stage. For our study, this implies that, in general, the solution of more than one weighted voting game will be necessary on the internal level. Following an article by Alonso-Meijide et al. [23], this paper studies the efficient computation of the three power indices for weighted voting games with precoalitions discussed therein: the Owen index [21] employing the Shapley-Shubik index on both the external and the internal level, the symmetric coalitional Banzhaf index [24] employing the Banzhaf index on the external level and the Shapley-Shubik index on the internal level and the Banzhaf-Owen index [25] employing the Banzhaf index on both the external and the internal level. Computing these three power indices for weighted voting games with precoalitions is challenging, as we are dealing with NP-hard problems [26], and, as the voting and network applications outlined in the first two paragraphs [5][6][7][8][9][10][11][12][13][14][15], may involve large numbers of players.
Power indices for simple games can be computed using generating functions; see, e.g., [5,27,28] and the work by Alonso-Meijide and Bowles [17] for the case of a priori unions. If the subsets of players reach only very few different weight sums, this method is favored [8] and fast-access data structures for polynomials with few coefficients in computer algebra systems, such as Mathematica [29], can be used. In this paper, we use the strongly related, though mathematically less sophisticated, paradigm of dynamic programming for power index computation [30][31][32]. The recent article [32] presents a new algorithm for the Johnston index [33], discusses algorithms for power indices based on minimal winning coalitions [34][35][36], surveys the state-of-the-art and introduces publicly available software. The work by Molinero and Blasco [37] studies algorithms for the Banzhaf-Owen and Owen indices and, to our knowledge, is the only paper on dynamic programming algorithms for weighted voting games with precoalitions. This paper presents new algorithms for the Banzhaf-Owen, Owen and symmetric coalitional Banzhaf indices with more favorable pseudopolynomial complexities. Our algorithms are based on a generalization of the concepts for computing the Banzhaf and Shapley-Shubik indices from the papers by Uno (2012) [31] and Kurz (2016) [8].
In Section 2, we introduce the basic concepts from cooperative game theory, including simple games, power indices and games with precoalitions along the lines of [23,38]. Section 3 explains how dynamic programming is used to count coalitions efficiently for weighted voting games and presents the state-of-the-art algorithms for computing the Banzhaf and Shapley-Shubik indices following the paper by Kurz [8]. Section 4 forms the heart of this paper and presents the new algorithms for the three power indices with precoalitions. We point out how our algorithms reflect both the definition of the indices as well as the internal games described by Malawski [22]. Section 5 discusses numerical experiments, reports supportive computing times and storage requirements for our methods and provides the reader with links to our C++ software and test problems. We end with some concluding remarks and an outlook to open problems in Section 6.

Preliminaries from Cooperative Game Theory
Cooperative game theory [39] deals with the outcomes and benefits that players can gain by forming coalitions. In the following, we briefly review some terminology for cooperative games and precoalitions along the lines of the papers by Alonso-Meijide et al. (2008) [23] and Mercik and Ramsey (2017) [38].

Cooperative Games and Simple Games
Let N = {1, ..., n} denote a finite set of n players. A group of players S ⊆ N is called a coalition, whereas 2 N stands for the set of all subsets of N. ∅ symbolizes the empty coalition and N is called the grand coalition. By |S|, we express the cardinality of a coalition S, i.e., the number of its members; hence, |N| = n. An n-person cooperative game can be characterized as a pair (N, v), where v : 2 N → R is referred to as the characteristic function assigning a real value to all coalitions We call a cooperative game simple if it is monotone and there holds v(N) = 1 and v(S) = 0 or v(S) = 1 for each coalition S ⊂ N. Coalitions for which v(S) = 1 are classified as winning coalitions in simple games, whereas coalitions for which v(S) = 0 are called losing coalitions. A player i is a critical player (also known as a decisive player or swing player) in a winning coalition S if v(S\{i}) = 0, i.e., the winning coalition S turns into a losing one if player i leaves S. We call a coalition S with at least one critical player vulnerable.
We finally note that not every simple game allows for a representation as a weighted voting game, and refer to the article by Molinero, Riquelme and Serna (2015) [40] for an overview of different forms of representation for simple games.

Power Indices and Marginal Contributions
Let S ⊂ N denote a coalition and i / ∈ S a player not contained in S. We call the difference v(S ∪ {i}) − v(S) the marginal contribution of player i to coalition S. For simple games, the marginal contribution of player i to coalition S is 1 if and only if i is a critical player in the winning coalition S ∪ {i}; in any other case, the marginal contribution is 0.
A power index is a function f that obtains an n-person simple game specified by its player set N and its characteristic function v as its input, and provides a unique vector f (N, v) = ( f 1 (N, v), . . . , f n (N, v)) as its output. We only introduce the Banzhaf index [2,3] and the Shapley-Shubik index [4] following the notation of the paper [23]. For a deeper discussion of the subject, we refer to the overview article [1] by Bertini, Freixas, Gambarelli and Stach.
Let v be a simple n-player game. The (absolute) Banzhaf index [3] of player i and the Shapley-Shubik index [4] of player i can be written in the form with the coefficients α i S = 1 2 n−1 for the Banzhaf index and for the Shapley-Shubik index. We note that, for the coefficients α i S , the cardinality of a coalition S (which is turned from a losing coalition to a winning coalition by the entrance of critical player i) plays a crucial role for the Shapley-Shubik index, whereas it can be ignored for the Banzhaf index. The coefficients α i S make it obvious that the Banzhaf index can seen as the probability of a player being crucial to a coalition it does not belong to, whereas the Shapley-Shubik index can be interpreted as the probability of a player being decisive over all permutations of players, i.e., assuming all sequential coalitions are equiprobable. We note that the Shapley-Shubik index is efficient, i.e., ∑ n i=1 f i (N, v) = v(N) = 1, whereas the (absolute) Banzhaf index is not.

Simple Games with Precoalitions and Coalitional Power Indices
In this subsection, we introduce simple games with precoalitions and coalitional power indices borrowing some notation from [23,38].
We are establishing an external division of our set of players N = {1, . . . , n} into precoalitions (also known as a priori unions) whose members will either enter a coalition together or not at all. Let P (N) stand for the set of all partitions of N, a partition being a set of non-empty subsets of N satisfying the condition that N is a disjoint union of these subsets. We refer to an element P ∈ P (N) as a coalition structure (also known as a system of unions) of the set N. A simple game with a coalition structure can be identified as a triplet (N, v, P). Following [23], we write our coalition structure in the form P = {P 1 , . . . , P m }, i.e., we have m precoalitions P 1 , . . . , P m and the set M = {1, . . . , m} serves as the index set of the partition P. For a weighted voting game with a coalition structure P, the external game (also known as the quotient game) is defined as the weighted voting game played between the m precoalitions [22,23]. The external game is formally defined as the weighted voting game [q; w(P 1 ), . . . , w(P m )], i.e., it is represented by the (unaltered) quota q and the weights w(P 1 ), . . . , w(P m ) of the m precoalitions, where w(P k ) = ∑ i∈P k w i with k ∈ M, M = {1, . . . , m}.
A coalitional power index g is a function that obtains an n-person simple game with a coalition structure specified by its player set N, its characteristic function v and a partition P as its input, and provides a unique vector g(N, v, P) = (g 1 (N, v, P), . . . , g n (N, v, P)) as its output. As in [23], we define three coalitional power indices, i.e., the Banzhaf-Owen index (hereafter BO index) [25], the symmetric coalitional Banzhaf index (SCB index) [24] and the Owen index (OW index) [21], within a unified framework.
Let P = {P 1 , . . . , P m } stand for a set of m precoalitions P 1 , . . . , P m and the set M = {1, . . . , m} serve as the index set of P. Further, let Q R = ∪ l∈R P l denote the subset of players belonging to any precoalition referred to by the index subset R ⊆ M. For any player i ∈ N contained in precoalition k, i.e., i ∈ P k , we write a coalitional power index as follows (cf. [38]): As in [38], α k R is an appropriately defined weight for the external game, whereas α i T corresponds to internal games within a precoalition. For the BO index, we employ the weighting coefficients For the SCB index, and for the OW index, We note that the OW index is efficient, i.e., ∑ n i=1 g i (N, v, P) = v(N) = 1, whereas the BO and SCB indices are not.
Let us emphasize a crucial difference between Formulas (1) and (2). While both expressions rely on marginal contributions of player i, in (2), we assume that precoalitions other than P k (which contains player i) have either joined with all of their members or not at all. As pointed out in [38], the power of player i ∈ P k comes from scenarios in which both P k is critical in the external game and i is a critical player in its precoalition in an appropriately defined internal voting game.
For illustration, we look at the coalitional game (N, v, P) represented by the weighted voting game [5; 3, 1, 1, 1, 3] and the coalition structure for the BO indices, for the SCB indices and g OW (N, v, P) = (  1  3  ,  1  9  ,  1  9  ,  1  9  ,  1 3 ) for the OW indices. Looking at the extreme coalition structures P n = {{1}, {2}, . . . , {n}} and P N = {N}, we recognize that the BO index reduces to the Banzhaf index in both cases, whereas the OW index reduces to the Shapley-Shubik index in both cases. As for the SCB index, it becomes the Banzhaf index for P n = {{1}, {2}, . . . , {n}} and the Shapley-Shubik index in case P N = {N}. The BO index [25] applies the Banzhaf index in both the external game and in the internal process between unions. As pointed out by Laruelle and Valenciano [41], the BO index assesses the a priori decisiveness of every voter within their bloc in the context of the coalitional structure, i.e., assuming that all of the other precoalitions will act as voting blocs. We refer the reader to that paper [41] for a detailed discussion of the probabilistic interpretations of the BO index. The SCB index by Alonso-Meijide and Fiestras-Janeiro [24] employs the Banzhaf index for the external game and the Shapley-Shubik index for the internal processes, whereas the OW index [21] invokes the Shapley-Shubik index on both levels of a two-level decision-making process. Taking a closer look at these two-level decision-making processes will play a crucial role in Section 4, where we derive efficient dynamic programming algorithms for the BO, SCB and OW indices for weighted voting games with precoalitions.

Dynamic Programming for the Banzhaf and Shapley-Shubik Indices
In this section, we introduce the technique of dynamic programming for counting coalitions in weighted voting games efficiently, discuss the state-of-the-art algorithms for the Banzhaf and Shapley-Shubik indices [8,31,32] and present generalizations of existing algorithms that will prove to be useful when we deal with precoalitions and internal games within precoalitions in Section 4. In other words, we are not computing any power indices with precoalitions in this section, but lay the groundwork for doing so in Section 4.

Counting Winning and Losing Coalitions via Dynamic Programming
It is well known that every weighted voting game allows for an integer representation [8]. Hence, we assume that the weights w i of the n players in our weighted voting game, as well as the quota q, are positive integers for the rest of the article. We set w = w(N) = ∑ n i=1 w i and assume q >w 2 . Players with integer weight 0 are null players, i.e., they are never critical players, and for all power indices discussed in this paper, they can be handled in a preprocessing step and assigned the value 0 without any need to include them in any further computation.
When we want to compute the Banzhaf index of player i, we need to be able to answer one of the following two questions: How many losing coalitions are turned into winning coalitions when player i is joining? Alternatively, in how many winning coalitions is player i critical? For the Shapley-Shubik index of player i, the same two questions are relevant, but we also need to take account of cardinalities of coalitions.
Dynamic programming is an algorithmic paradigm resting on two pillars: dividing a given problem into subproblems and storing intermediate results efficiently. We will use dynamic programming to count losing and winning coalitions and present algorithms following the work by Kurz [8]. For a more general introduction to counting coalitions via dynamic programming (including examples), we refer to the recent article [32] or the textbook by Chakravarty, Mitra and Sarkar [39], chapter 12.
Algorithm 1 is a generalization of the first algorithm in the article by Kurz [8]. Equipped with the number n of players, the quota q, a vector w = (w 1 , . . . , w n ) of positive integer weights and an integer vector T with T(0) = 1 and T(x) = 0 for x = 1, . . . , q − 1, as its four input arguments, it outputs a vector T, with T(x) listing the number of losing coalitions attaining weight 0 ≤ x ≤ q − 1. We briefly note that, in our discussion of memory space requirements, we follow the convention by Uno [31] throughout the paper and do not include the need to store the n weights itself-and, later, we also omit the memory space for the corresponding n values of the power indices-as this allows for a clearer and more concise presentation. According to this convention, Algorithm 1 needs O(nq) time and O(q) memory space. for i from 1 to n do 3: if (q > w(i)) then 4: for x from q − 1 to w(i) do 5: if (x-w(i) == 0) then 6: T(x) ← T(x) + T(0) initialize T(0)=1 for empty set 7: end if 10: end for 11: end if 12: end for 13: return T number of losing coalitions of weight x ∈ [0, q − 1] 14: end procedure Note that Algorithm 1 echoes a boundary condition stating that we can obtain the sum 0 in exactly one way, i.e., via the empty set, reflected in T(0) = 1. We admit that the if-else statement in lines 5 to 8 in Algorithm 1 is superfluous, as T(x − w(i)) = T(0) in case x = w(i), but we wanted to highlight the role of T(0). The actual recursion in line 8 in Algorithm 1 mirrors the fact that the first i weights can deliver a sum x > 0 either with or without player i. We will find providing an initial vector T as an input useful in the following section, where we wish to incorporate results from the external game in computations of internal games.
Kurz [8] pointed out that, rather than counting losing coalitions from below, we can also count winning coalitions from above, making use of the fact that we can write the sum of all weights in exactly one way, i.e.,w = w(N) = ∑ n i=1 w i . Algorithm 2 is a generalization of the second algorithm in the article by Kurz [8]. Provided with the number n of players, the quota q, the sum of all weightsw = w(N), a vector w = (w 1 , . . . , w n ) of positive integer weights and an integer vector T with T(w) = 1 and T(x) = 0 for x = q, . . . ,w − 1, as its five input arguments, it outputs a vector T, with T(x) listing the number of winning coalitions attaining weight q ≤ x ≤w. Algorithm 2 needs O(n(w − q + 1)) time and O(w − q + 1) space. for i from 1 to n do 3: if (q + w(i) ≤w) then 4: for x from q + w(i) tow do 5: return T number of winning coalitions of weight x ∈ [q,w] 10: end procedure Algorithms 1 and 2 can be generalized for the distribution of cardinalities of coalitions in a straightforward manner [8,32]. Given that we normally assume q >w 2 (and hencẽ w − q + 1 ≤ q), we prefer to work with the winning coalitions from above. Therefore, we provide only the corresponding algorithm for winning coalitions and cardinalities from above in Algorithm 3. Provided with the number n of players, the quota q, the sum of all weightsw = w(N), a vector w = (w 1 , . . . , w n ) of positive integer weights and a two-dimensional array C with C(w, n) = 1 and C(x, s) = 0 for all other combinations of weights x = q, . . . ,w, and cardinalities s = 1, . . . , n, as its five input arguments, it outputs a two-dimensional array C, with C(x, s) listing the number of winning coalitions attaining weight q ≤ x ≤w and cardinalities s = 1, . . . , n. Algorithm 3 needs O(n 2 (w − q + 1)) time and O(n(w − q + 1)) space.

Algorithm 3
Generalized counting of number of winning coalitions per weight and cardinality 1: procedure WinningCoalitionsByWeightCardinality(n, q,w, w, C) 2: for i from 1 to n do 3: if q + w(i) ≤w then 4: for x from q + w(i) tow do 5: for s from 2 to n do 6:

Computing the Banzhaf and Shapley-Shubik Indices
The paper by Uno (2012) [31] presented the first algorithm for computing the Banzhaf and Shapley-Shubik indices of all players in a weighted voting game in O(qn) and O(qn 2 ) time, respectively. By working from above, as in Algorithms 2 and 3, Kurz (2016) [8] improved this result to O(∆n) and O(∆n 2 ) with ∆ = min(q,w − q + 1) for the Banzhaf and Shapley-Shubik indices, respectively. It is worthwhile to summarize these results and their proofs, together with some new generalizations of algorithms, which we will use later in Section 4. Proof. Let us focus on the case (w − q + 1) ≤ q and compute the Banzhaf indices from above. We obtain the vector T(x) for q ≤ x ≤w via Algorithm 2 in O((w − q + 1)n) time and O(w − q + 1) space by calling T = WinningCoalitionsByWeight(n, q,w, w, T) using an integer vector T with T(w) = 1 and T(x) = 0 for x = q, . . . ,w − 1, as our input. We set T +i (x) = T(x) for all x ∈ {w − w i + 1, . . . ,w} and then loop for x fromw − w i down to q in order to find T +i (x) = T(x) − T +i (x + w i ).
T +i (x) states how frequently player i belongs to a winning coalition with weight x and gives us the Banzhaf index of player i. Algorithm 4 is a generalization of this idea that we will use in the next section. It counts the number of coalitions containing a player with a specified weight.

Algorithm 4
Count coalitions containing a player specified by its weight 1: procedure CoalitionsWithPlayer(q,w, weight, T) 2: for x from q tow do 3: Tw(x) ← T(x) 4: end for 5: if (w − weight ≥ q) then 6: for x fromw − weight to q do 7: Tw(x) ← T(x) − Tw(x + weight)  Proof. Again, we concentrate on the case (w − q + 1) ≤ q and compute the Shapley-Shubik indices from above. We obtain C(x, s) for q ≤ x ≤w and all cardinalities 1 ≤ s ≤ n from above via Algorithm 3 in O((w − q + 1)n 2 ) time and O((w − q + 1)n) space by calling C = WinningCoalitionsByWeightCardinality(n, q,w, w, C) using a two-dimensional array C with C(w, n) = 1 and C(x, s) = 0 for all other combinations of weights x = q, . . . ,w, and cardinalities s = 1, . . . , n, as our input. We set C +i (x, c) = C(x, c) for all weights x ∈ {w − w i + 1, . . . ,w} and all cardinalities s ∈ {1, . . . , n}. We loop for x fromw − w i down to q in an outer loop and for s from 0 to n − 1 in an inner loop in order to find C +i (x, s) = C(x, s) − C +i (x + w i , s + 1). Now, C +i (x, c) tells us how often player i belongs to a winning coalition with weight x and cardinality s, and via we obtain the Shapley-Shubik index of player i.
Algorithm 5 is a generalization of this idea that we will need in the next section. It counts the number of coalitions and cardinalities containing a player with a specified weight.
Algorithm 5 Count coalitions and cardinalities containing a player specified by its weight 1: procedure CoalitionsCardinalityWithPlayer(n, q,w, weight, C) 2: for x from q tow do 3: for s from 1 to n do 4: Cw(x, s) ← C(x, s) ifw − weight ≥ q then 8: for x fromw − weight to q do 9: for s from 1 to n − 1 do 10: Cw(x, s) ← C(x, s) − Cw(x + weight, s + 1) 11: end for 12: end for 13: end if 14: return Cw 15: end procedure Finally, we wish to highlight an observation from both Theorems 1 and 2 and their proofs. In each case, the pseudopolynomial complexity estimates that computing the respective power index of only one player and computing the respective power indices of all players are identical in terms of both memory space and computing time. This is due to the fact that the setup phases in the forms of Algorithms 2 and 3, respectively, each require an additional loop over all players, whereas Algorithms 4 and 5 (which are employed to find the respective power index of an individual player) do not. Hence, in terms of the O-notation, it does not make a difference (in terms of space or speed) whether we wish to find only some or all power indices. This observation will be reflected in the results of the following section.

Computing Power Indices with Precoalitions via Dynamic Programming
This section forms the heart of the article. It presents new dynamic programming algorithms for the BO, SCB and OW indices. As we outlined in Section 2.3, we assume that there are m precoalitions P 1 , . . . , P m . The external game (also known as the quotient game) is defined as the weighted voting game played between the precoalitions [22,23], i.e., a weighted voting game represented by the (unaltered) quota q and the m weights w(P 1 ), . . . , w(P m ), where w(P k ) = ∑ i∈P k w i with k ∈ M, M = {1, . . . , m}. Furthermore, we define p as the maximal size of a precoalition, i.e., p = max k∈M |P k |.
To our knowledge, the paper by Molinero and Blasco [37] is the only work on dynamic programming algorithms for weighted voting games with a precoalition structure. Their algorithms for the BO and OW indices combine backtracking with the algorithms from section 5.2 of the survey paper by Matsui and Matsui (2000) [30] for power index computation. For computing the BO or OW index of a single player i with i ∈ P k , i.e., player i contained in precoalition P k , their algorithm needs O((n |P k |) 2 q) computing time and O(n q) space with n = m + |P k | − 2.
In the following, we point out how the concepts and algorithms from the previous section translate into external and internal weighted voting games and algorithms for the BO, SCB and OW indices with favorable pseudopolynomial computing times and storage requirements. Each subsection will be devoted to one of the three indices, with the proof of each theorem serving as a description of an algorithm for computing the index. We follow the convention that the superscript +k indicates that we count only those winning coalitions containing precoalition k on the external level, whereas the subscript +i indicates that we look at only those coalitions containing player i on the level of individual players within precoalition P k . Furthermore, the superscript ext symbolizes the external level, i.e., the level of the precoalitions, whereas the superscript int stands for the internal level, i.e., the level of individual players within a precoalition.

Efficient Computation of the Banzhaf-Owen (BO) Index
For the BO index, our idea is to reflect the external game and one internal game per precoalition via dynamic programming. Proof. Let us focus on the case (w − q + 1) ≤ q and compute the BO indices from above. Let w ext = (w(P 1 ), . . . , w(P m )) be the vector of the weights of the m precoalitions. We obtain the vector T ext (x) for q ≤ x ≤w with the number of winning coalitions on the level of the precoalitions for weights q ≤ x ≤w via Algorithm 2 in O((w − q + 1)m) time and O(w − q + 1) space by computing T ext = WinningCoalitionsByWeight(m, q,w, w ext , T) using an integer vector T with T(w) = 1 and T(x) = 0 for x = q, . . . ,w − 1, as our input. Next, we deal with precoalition P k . Algorithm 4 gives us the number of those winning coalitions containing precoalition k with weight w ext k via T ext,+k = CoalitionsWithPlayer(q,w, w ext k , T ext ) Now, we switch to the level of precoalition P k . We incorporate the individual weights w int = (w 1 , . . . , w |P k | ) of the players in precoalition P k into our vector T ext,+k using Algorithm 2 by computing T int,+k = WinningCoalitionsByWeight(|P k |, q,w, w int , T ext,+k ) The vector T int,+k (x) states the number of winning coalitions for weights q ≤ x ≤w when players from precoalition P k join on an individual level, whereas the other precoalitions join as unions. From the vector T int,+k (x), we can work out how frequently an individual player i ∈ P k with weight w int i belongs to a winning coalition with weight q ≤ x ≤w using Algorithm 4 via T int,+k +i = CoalitionsWithPlayer(q,w, w int i , T int,+k ) From T int,+k +i , we can assess how frequently player i is a swing player within precoalition P k , i.e., assuming that all the other precoalitions are acting as unions. The expression yields the BO index of player i.

Efficient Computation of the Symmetric Coalitional Banzhaf (SCB) Index
As for the SCB index, our approach for the external game will be identical to the BO index. However, in the internal game of each precoalition, we will need to include cardinalities.

Theorem 4.
For a weighted voting game with positive integer weights and a precoalition structure P = {P 1 , . . . , P m }, the symmetric coalitional Banzhaf (SCB) indices for all players can be computed in O(∆m + ∆p 2 ) time and O(∆p) memory space with ∆ = min(q,w − q + 1). For computing the SCB index of an individual player i ∈ P k , i.e., player i is contained in precoalition P k , we need O(∆m + ∆|P k | 2 ) time and O(∆|P k |) space.
Proof. Again, we discuss the case (w − q + 1) ≤ q and compute the SCB indices from above. On the external level, we perform the identical computations as for the BO indices. Let w ext = (w(P 1 ), . . . , w(P m )) denote the vector of the weights of the m precoalitions. We obtain the vector T ext (x), with the number of winning coalitions on the level of the precoalitions for weights q ≤ x ≤w via Algorithm 2 by computing T ext = WinningCoalitionsByWeight(m, q,w, w ext , T) using an integer vector T with T(w) = 1 and T(x) = 0 for x = q, . . . ,w − 1, as our input. As before, Algorithm 4 gives us the number of those winning coalitions containing precoalition k with weight w ext k via T ext,+k = CoalitionsWithPlayer(q,w, w ext k , T ext ) Now, we switch to the level of precoalition P k with the individual weights w int = (w 1 , . . . , w |P k | ). We create a two-dimensional array C int,+k with for all weights q ≤ x ≤w, and C int,+k (x, s) = 0 for all other combinations of weights x = q, . . . ,w, and cardinalities s = 1, . . . , |P k | − 1. We note that Equation (3) states how many winning coalitions were joined by P k as a union. We incorporate the individual weights w int and their cardinalities using Algorithm 3 by computing C int,+k = WinningCoalitionsByWeightCardinality(|P k |, q,w, w int , C int,+k ) From our updated array C int,+k (x, s), we learn the numbers of winning coalitions with weights x ∈ [q,w] with s players from P k , assuming that players from precoalition P k join on an individual level whereas the other precoalitions join as unions. We can work out how frequently an individual player i ∈ P k with weight w int i belongs to a winning coalition with s players from P k via Algorithm 5 by computing C int,+k +i = CoalitionsCardinalityWithPlayer(|P k |, q,w, w int i , C int,+k ) C int,+k +i states how frequently player i is a part of a winning coalition containing s players from P k , i.e., assuming that all of the other precoalitions are acting as unions. From we obtain the SCB index of player i.

Efficient Computation of the Owen (OW) Index
The computation of the OW index is slightly more sophisticated. As observed by Malawski (2004) [22], more than one weighted voting game is needed on the internal level. These internal games reflect how many precoalitions have joined a vulnerable coalition for which a certain player is critical. We translate the observations from [22] into a dynamic programming algorithm.
Theorem 5. For a weighted voting game with positive integer weights and a precoalition structure P = {P 1 , . . . , P m }, the Owen (OW) indices for all players can be computed in O(∆(mp) 2 ) time and O(∆(m + p)) memory space with ∆ = min(q,w − q + 1). For computing the OW index of an individual player i ∈ P k , i.e., player i is contained in precoalition P k , we need O(∆(m|P k |) 2 ) time and O(∆(m + |P k |)) space.
Proof. We discuss the case (w − q + 1) ≤ q and compute the OW indices from above. On the external level, we need to reflect cardinalities of precoalitions. As before, the vector w ext = (w(P 1 ), . . . , w(P m )) stands for the weights of the m precoalitions. We obtain the two-dimensional array C ext (x, s) with the number of winning coalitions on the level of the precoalitions via Algorithm 3 for weights x ∈ [q,w] and cardinalities s = 1, . . . , m, in O(m 2 (w − q + 1)) time and O(m(w − q + 1)) space by computing C ext = WinningCoalitionsByWeightCardinality(m, q,w, w ext , C) using a two-dimensional array C with C(w, m) = 1 and C(x, s) = 0 for all other combinations of weights x = q, . . . ,w, and cardinalities s = 1, . . . , m, as our input. Algorithm 5 gives us the number of those winning coalitions containing precoalition k with weight w ext k , together with their cardinalities, via C ext,+k = CoalitionsCardinalityWithPlayer(m, q,w, w ext k , C ext ). Now, we need to loop for r from 0 to m − 1 and work out the internal games on the level of precoalition P k with the individual weights w int = (w 1 , . . . , w |P k | ). We create a two-dimensional array C int,+k with C int,r+1,+k (x, |P k |) = C ext,+k (x, r + 1) for all weights q ≤ x ≤w and C int,r+1,+k (x, s) = 0 for all other combinations of weights x = q, . . . ,w, and cardinalities s = 1, . . . , |P k | − 1. We note that Equation (4) states how many winning coalitions of cardinality r + 1 joined by P k as a union there are on the external level. We incorporate the individual weights w int and their cardinalities using Algorithm 3 by computing C int,r+1,+k = WinningCoalitionsByWeightCardinality(|P k |, q,w, w int , C int,r+1,+k ).
From our updated array C int,r+1,+k (x, s), we learn the numbers of winning coalitions with weights x ∈ [q,w] with s players from P k , assuming that players from precoalition P k join on an individual level whereas the other r precoalitions join as unions. We can work out how frequently an individual player i ∈ P k with weight w int i belongs to a winning coalition with s players from P k via Algorithm 5 by computing C int,r+1,+k +i = CoalitionsCardinalityWithPlayer(q,w, w int i , C int,r+1,+k ).
C int,r+1,+k +i states how frequently player i is a part of a winning coalition containing s players from P k , i.e., assuming that all of the other r precoalitions are acting as unions. From we obtain the OW index of player i in O(∆(m + |P k |) 2 ) time and O(∆(m + |P k |)) space.
Finally, we quickly take up an observation from the final paragraph of the previous section. The proofs of Theorems 3-5 make it obvious that the pseudopolynomial complexity estimates for computing the respective power index of only one player i in a precoalition P k and for computing the respective power indices of all players in a precoalition P k are identical in terms of both computing time and memory space.

Numerical Results and Software
In the recent article [32], a powerful software package named EPIC (Efficient Power Index Computation) that provides efficient C++ implementations of various power indices (without precoalitions) for weighted voting games was introduced. We implemented our new algorithms for the BO, SCB and OW indices presented in the previous section in EPIC and tested our software thoroughly under MS Windows and Ubuntu Linux. Our implementations are freely available at https://github.com/jhstaudacher/EPIC/ (accessed on 25 December 2021) as parts of the software package EPIC introduced in [32].
Users can specify weighted voting games as CSV (comma separated values) files, i.e., EPIC supports a simple and widely used data format that allows for users to edit input files using notepad, MS Excel and many other text editors. An input file contains one precoalition per line, and weights of the players in the same precoalition are specified in the same line separated by commas; see https://github.com/jhstaudacher/EPIC//blob/ master/readme.md (accessed on 25 December 2021) for more details.
When computing power indices for large weighted voting games, counting coalitions may force us to handle very large integers. For arbitrary-precision arithmetic, EPIC uses GMP [42], i.e., the GNU Multiple Precision Arithmetic Library. GMP [42] is a very widely used, established and well-tested C++ library for working with very large integers. We are using GMP in the same vein as described in [32].
In order to test our new algorithms, we created a number of test problems and made them available at https://github.com/jhstaudacher/EPIC/tree/master/test_cases/ precoalitions (accessed on 25 December 2021).
In the following, we discuss computing times and memory requirements for three of these example problems. The numerical results in Tables 1-3 were obtained under Ubuntu 20.04 focal (64-bit) on an AMD FX(tm)-4170 Quad-Core CPU with a clock speed of 4.20 GHz and 8 GB RAM, i.e., on a standard laptop PC. In all three Tables 1-3, we report computing times and storage requirements for a quota of 50% plus 1 vote and compare them to a quota of 75% of the votes. By default, we compute power indices from above, since, normally, q > 1 2w . As expected from our theoretical considerations, computing times and storage are approximately cut in half for the larger quota of 75%. All three Tables 1-3 investigate the BO, SCB and OW indices using the new algorithms for handling precoalition structures introduced in Section 4 and compare the Banzhaf (BZ) index (without the precoalition structure). Table 1 is the only instance where we additionally compare the Shapley-Shubik (SH) index (without the precoalition structure). The results in Table 1 illustrate the pseudopolynomial time and space complexities reported in Theorems 2 and 5. The presence of a coalition structure makes computing the OW index slower rather than faster compared to the SH index. However, the OW index can be computed with significantly smaller storage requirements than the SH index. For the problems in Tables 2 and 3, each containing more than 3000 players, we chose to omit the SH indices for storage reasons. In Tables 1-3, the computations of both the BO indices and the BZ index (without a coalition structure) never need more than one minute, indicating that our algorithms could handle much larger problems. As predicted from the pseudopolynomial complexities in Theorems 1 and 3, computing times and storage needs are lower for the BO indices than for the BZ indices for large problem instances, as exemplified in the test problems in Tables 2 and 3. In the smaller test problem in Table 1 with 741 players, this effect is not yet visible, as the implementation of the BO index is more sophisticated and more small arrays need to be allocated (in order to deal with the precoalition structure) than for the BZ index. As predicted in Section 4, the SCB indices need more storage and computing time than the BO indices due to the Shapley-Shubik computations for the internal games.
For the BZ indices (without precoalitions), we observe large time differences between Tables 2 and 3 due to the fact that the game in Table 2 has a weight sum that is more than twice as large as the game in Table 3, even though the latter game has 13.2% more players. Comparing the results from Tables 2 and 3 for the SCB indices, we confirm the theoretical findings from Theorem 4. For computing SCB indices, it is more favorable to have more precoalitions rather than large average coalition sizes (both in terms of speed and storage). For the computation of the OW indices, no such statement can be made, as the OW index uses the Shapley-Shubik index for both the external and internal decision processes. This is reflected in the pseudopolynomial time and storage complexities from Theorem 5 and is confirmed in the numerical results in Tables 2 and 3.

Outlook and Conclusions
In this paper, we present new dynamic programming algorithms for the three most common power indices with precoalitions, i.e., the Owen (OW), Banzhaf-Owen (BO) and symmetric coalitional Banzhaf (SCB) indices. Our algorithms reflect the external and internal decision processes between and within precoalitions used to specify these indices. We provide efficient C++ implementations of our new algorithms and point out that our methods can be applied for large numbers of players.
Still, there are many open questions in connection with the computation of power indices with precoalitions. Certain power indices with a priori unions, such as e.g., [43,44], do not fit the framework used in this paper, and it will be interesting to see how dynamic programming can be applied efficiently in these cases. In this context, we would like to stress that the very general framework for computing power indices via quasi-ordered binary decision diagrams [45][46][47][48], i.e., a recent approach based on relational algebra, has not yet been extended to power indices with a coalition structure. Furthermore, the mathematical relations between dynamic programming and generating functions [5,17,27,28] for power index computation justify further research, both in the cases with and without precoalitions. We expect these two paradigms to be very fruitful for each other, and such investigations have the potential to lead to even faster algorithms.
Another challenge is the parallel computation of power indices. To our knowledge, there are no publications on parallel computations of any of the power indices (without precoalitions) discussed in [32] or the dynamic programming algorithms presented therein. The new algorithms for power indices with precoalitions presented in the proofs of Theorems 3-5 appear to be particularly well suited for parallel processing, given that the internal games can be computed independently.
In terms of practical calculations for cooperative games with a coalition structure, we regret a lack of software offering more than the computation of the Owen value [21], i.e., the most widely used solution concept. In our view, even a prototypical implementation of various solution concepts for games with a partition structure, e.g., similar to the freely available R package CoopGame [49] for cooperative games, might be helpful in popularizing these ideas for analyzing real-world problems. A very concrete real-world application we wish to study using our new algorithms is the problem of indirect control in complex shareholding structures [11][12][13]. These networks are usually large and, to our knowledge, precoalitions of companies and investors within corporate networks have yet to be investigated.