Congress Seat Allocation Using Mathematical Optimization

After the 2015 Spanish general election a row erupted over the allocation of physical seats in the Congress of Deputies, with certain parties left feeling they possessed an inferior selection of seats compared to other parties. Using this as motivation, this paper considers how mathematical optimization can be used to generate seating plans for political chambers, an application that has not been considered before. As well as being in some way ‘fair’ to all parties, the seating plan should ensure that each block of seats is well-deﬁned and compact. Two optimization models are formulated and, due to their complexity, heuristic methods are developed to ﬁnd ‘good’ solutions. Analysis shows that the heuristics are able to produce visually appealing seating plans for basic cases, but problems can occur when there are additional requirements to be satisﬁed. We also recorded the best solutions found for the FLM and MPM by running the models in Xpress solver for 30 minutes (best found). The percentage gap between the best lower bound and best feasible solution found by the solver are shown. A gap of 0% indicates that the model was solved to optimality, in which case the time taken to ﬁnd an optimal solution is stated in parentheses. Xpress Optimizer Version 29.01.10 was used on a Core i5 machine with clock speed 3.2GHz and 8GB of RAM run on Windows 7 OS.


Introduction
In recent years there have been arguments regarding the seating plans in the Spanish Congress of Deputies, with some parties believing they have been allocated inferior seats compared to other parties. Indeed, the seating plan following the 2015 general election, shown in the top left of Figure 1, prompted Podemos spokespersonÍñigo Errejón to claim that, "They are sending the representatives of five million voters to the nosebleed section, separated from the rest." With this in mind, the aim of this paper is to investigate how mathematical optimization can assist with decisions regarding how representatives should be seated in a congress chamber and, in particular, to propose methods for generating seating plans that all parties find acceptable. The nature of the problem is inherently subjective, as there is no definitive way of determining whether one seating plan is better than another. However, we propose the following basic criteria that a good seating plan should satisfy: 1. Members of the same party should be sat close to one another, clustered together in a compact way. 2. The plan should abide by any pre-existing rules or traditions regarding where the different parties are seated. 3. No party should be allocated a block of seats that is significantly 'better' or 'worse' than those of other parties.
In particular, we consider the problem as that of optimising criterion 1, while satisfying constraints that enforce criteria 2 and 3. It should be noted that, except where stated otherwise, we suppose that the number of available seats is exactly equal to the number of representatives. The aim is to develop a flexible approach that can be applied to any congress, parliament or other political chamber in which each representative is assigned one seat based on the party they represent. This is complicated by the fact that the seats in each congress chamber are arranged differently, with different rules and traditions that need to be adhered to regarding their allocation. Figure 1 shows four examples of seating plans. The top left diagram 1 shows the Spanish Congress of Deputies, which will be discussed in detail in the case study in Section 8. The top right diagram 2 shows a seating plan the European Parliament in Strasbourg, which has a semi-circular or fan shape, and it can be seen that each political group is assigned a wedge-shaped selection of seats. The bottom right diagram 3 shows a seating plan for the New Zealand House of Representatives, where the seats are arranged in a horseshoe shape, and we can note that every party is assigned at least one front row seat. The bottom left diagram 4 shows the Canadian House of Commons, which consists of two banks of seats separated by an aisle, with the governing party predominantly seated on one side and opposition parties on the other side.
To model the problem we make the assumption that each seat can be represented by a pair of coordinates on the plane, and that these coordinates are known beforehand. Furthermore, we make the assumption that the seats can form a connected graph, with each node representing a seat and edges connecting any two seats that are adjacent. This allows us to calculate the shortest path distances between any two seats, which provide a more intuitive measure than, say, the Euclidean distance. A potential drawback of this is that it is not always clear which pairs of seats should be considered adjacent, which in turn means there are many possible graphs, each of which will result in different shortest path distances. Moreover, if the seats are arranged in two banks separated by an aisle then this would result in two disconnected graphs. Despite this issue, we still felt that shortest path distances were the best option, particularly since Euclidean distances can give counter-intuitive results if the seats are arranged in a horseshoe shape, which is a very common arrangement for congress and parliament chambers. Moreover, viewing the seats as a connected graph allows us to view the problem as a type of graph partitioning, which we briefly explore in Section 4.
The paper is organised as follows. In the literature review we compare the problem with other well-studied problems. We then develop a facility location model (FLM) and a minimum k-partitioning model (MPM). Since these models are both hard to solve for large instances, in Section 5 we develop a location-allocation heuristic (LAH) for the FLM, and in Section 6 we develop a geometric cutting heuristic (GCH) for the MPM that uses straight lines to partition the seats into blocks of the correct sizes. In Section 7, a computational study is conducted to evaluate and compare the performances of the heuristics, both numerically and visually. The paper concludes with a case study showing the results of applying the heuristics to the Spanish Congress of Deputies.

Literature Review
Although there exist papers in the literature that apply optimization methods to determine how many seats should be awarded to each party, such as Serafini (2012), to the best of our knowledge this paper is the first application of optimization methods to the allocation of physical seats within the congress. Several seat allocation problems have been studied previously, see for instance García et al. (2014), but they are concerned with assigning individual people to seats, whereas in our problem the aim is to assign collections of seats to political parties. This fundamental difference means that, in practice, the problems have little in common.
In fact, the problem has more similarities to districting problems, in which the aim is to cluster together small areas of land to form larger districts that satisfy certain desirable properties. These properties typically include that each district be connected and compact, while containing populations of approximately equal sizes. The compactness property is often included to prevent so-called gerrymandering, the practice of manipulating district borders for political gain. Horn et al. (1993) and Niemi et al. (1990) compare different approaches to achieving compactness in districting problems. For an overview of approaches to districting problems see, for example, Ricca et al. (2011).
The similarities with the congress seating problem are clear, but there are also several key differences. Firstly, in the congress seat allocation problem there are no populations as such, so the population equality condition is not applicable, but instead there is the condition that the number of seats in each block must correspond to the number of seats won by each party. Secondly, the seats in a congress do not necessarily fit together like a jigsaw in the same way that geographical areas of land do, and so some of the techniques used for districting problems may not be applicable; in particular many of the ways of measuring compactness can not be applied.
Districting problems are often modelled as facility location problems, also known as plant or warehouse location problems, for example see Hess et al. (1965) and Hojati (1996). The goal of these problems is to choose several locations from a set of candidate locations at which to build facilities. Customers are then allocated to the facilities, with the aim being to minimise the set-up costs of building the facilities together with the transportation costs of delivering goods between the facilities and their customers. The congress seat allocation problem can be thought of as a facility location in the following way. Let each seat be a candidate location for a facility and let each seat also represent a single customer, then specify that we must 'build' exactly one facility for each party so that allocating customers to facilities corresponds to allocating seats to parties. It will also be necessary to ensure that each party is allocated the correct number of seats. There are no set-up costs to speak of, but the transportation costs can be thought of as being the sum of distances between each seat and its corresponding facility. Since the goal is to minimise the sum of these distances, in an optimal solution each seat belonging to a given party should be close to that party's 'facility', which should in turn encourage each block of seats to be compact. In Section 3 the problem is modelled as a facility location problem, and in Section 5 a location-allocation heuristic is developed, similar to that proposed by Hess et al. (1965) and Kalcsics et al. (2005) for political districting problems.
Finally, if the seats are considered as nodes in a graph with adjacent seats connected by edges, then the problem can be viewed as a type of graph partitioning. In particular, a partition of the nodes that minimises the number of 'cut edges' will equate to a partition that minimises the number of adjacent seats belonging to distinct parties, which seems like a good objective to encourage a compact seating plan. General minimum k-partitioning problems are well-studied and known to be NP-hard, see for instance Chopra and Rao (1993). Kernighan and Lin (1970) developed a popular heuristic for the problem, and semi-definite programming relaxations can be used to find lower bounds, see for example Wolkowicz and Zhao (1999). In Section 4 the problem is formulated as a minimum k-partitioning problem, and in Section 6 a geometric cutting heuristic is developed that uses straight-line cuts to partition the graph while cutting as few edges as possible.

Facility Location Model
We first formulate the problem as a facility location model (FLM), which encourages compactness by minimising the sum of shortest path distances from each seat to their party's 'central seat'. To use shortest path distances it is necessary to consider the seats as nodes in a graph with adjacent seats connected by edges.In Section 7, we show how such a graph can be constructed. However, it would also be possible to use different distances, such as Euclidean. First we outline the basic model, which simply aims to partition the seats into compact blocks, and then we consider several additional constraints that could be included to promote a sense of fairness or to ensure the solutions adhere to certain rules or traditions. The following notation is used: K j = Number of seats to be allocated to party j. d ik = Shortest path distance between seats i and k. y j k = 1 if seat k is the central seat for party j, 0 othewise.
x ik = 1 if seat i is allocated to a central seat k, 0 otherwise.
The basic model is: ∑ i∈I The constraints can be interpreted as follows: (2) All seats are assigned to a central seat.
(3) If seat k is the central seat for party j then K j seats are allocated to it. If seat k is not a central seat then no seats are allocated to it. (4) Each seat k can be a central seat for at most one party.
(5) Exactly one central seat should be chosen for each party j ∈ J. (6) All variables are binary.
We now consider several additional properties that might be desirable in a seating plan, either to adhere to tradition or to encourage a degree of fairness, and we show how these properties could be modelled as constraints that can be added to the basic model. In reality, which, if any, of the additional constraints to include will depend upon the specific application.
-Certain Parties Occupy Certain Areas of the Chamber: Let the coordinates of seat i be (p i , q i ), and suppose we require that party j be seated on the left hand side of the congress chamber, or, equivalently, that they must not be allocated any seats on the right hand side. Suppose that the horizontal coordinates are on a scale from 0 to 100, with a seat i considered to be on the right hand side if p i ≥ 50. Constraints (7) then ensure that no seat on the right hand side of the congress can be allocated to party j.
The right hand side of (7) is only equal to zero for the seat k that is the central seat for party j, in which case seat i cannot be assigned to that central seat if p i ≥ 50. -No Parties Seated Too Far Back: Let R i be the row number of seat i, with the front row being row 1, the next being row 2, and so on. Let R be a constant. In constraints (8), if seat k is not a central seat then the left hand side is zero, and if k is a central seat then the average row number of the seats assigned to k must be less than or equal to R. Therefore these constraints can be used to ensure no party is seated too far back on average.
-Larger parties have more front row seats: Let F be a constant and suppose we want to impose the condition that if a party has more than or equal to F seats then they should have at least one seat in the front row. Moreover we want to impose that if a party has more than or equal to 2F seats then they should have at least two seats in the front row, and so on. Let f i = 1 if seat i is in the front row, and zero otherwise. We model this condition as follows.
For every seat k that is not a central seat the right hand side of (9) is equal to zero and so no conditions are imposed on the left hand side. However, if seat k is the central seat corresponding to party j, then the left hand side of (9) counts the number of front row seats allocated to party j and the right hand imposes a minimum value on this count. Note that for small parties with K j < F the right hand side is equal to zero and so they are not required to have any front row seats. -Every representative must be sat next to another representative of the same party: Let n il equal one if seats i and l are next to one another and zero otherwise. Constraints (10) mean that a seat i cannot be allocated to central seat k unless there is another seat next to seat i that is also allocated to central seat k.
4 Minimum k-Partitioning Model Let us now consider a graphical representation of the congress in which each node represents a seat and adjacent seats are joined by an edge. We formulate the problem as a model that aims to minimise the number of edges connecting two seats belonging to different parties. Note that this is a very different objective than that of the Facility Location Model, and hence the two models are not addressing the same mathematical problem. This model is a variant of the minimum k-partitioning problem that aims to partition the nodes in a graph into k non-empty subsets, such that the number of edges connecting distinct subsets is minimal. The following notation is used: J = Set of parties.
x i j = 1 if seat i is assigned to party j, 0 otherwise.
K j = Number of seats to be allocated to party j. a ik = 1 if seats i and k are adjacent and therefore connected by an edge, 0 otherwise.
The basic model is: ∑ j∈J As can be seen, this is a quadratic assignment problem. Constraints (12) ensure that there is a total of K j seats allocated to party j, and constraints (13) ensure that every seat i is allocated to one and only one party. The additional constraints discussed for the FLM in the previous section can easily be modified to be applied to this model.
Finally, note that the model does not explicitly aim to minimise the distances between seats belonging to the same party, although this is likely to be encouraged indirectly by minimising the number of edges connecting seats belonging to different parties. However, if it is found that this model generates solutions where the seats belonging to a party are very spread out, it could be necessary to include a distance component to the model. This could either be a constraint that limits the distance between seats belonging to the same party, or else an additional quadratic component in the objective function, such as:

Location-Allocation Heuristic
A simple approach for finding good solutions to Facility Location problems is to separate the processes of choosing where the locations are built (the location phase) and choosing how to allocate the customers to these locations (the allocation phase). Indeed, this was the approach adopted by Hess et al. (1965), in what is considered as the earliest Operational Research paper on political districting (Ricca et al., 2011).
Although this heuristic was developed for Facility Location models like the one we considered in Section 3, our overall purpose is to produce good seating plans rather than solving any particular model, and so in the computational study we will also examine how well the solutions produced by the heuristic perform for the minimum k-partitioning model from Section 4.
Suppose a set of central seats {c j : j ∈ J} has already been chosen. That is, we have fixed the variables y j k from the Facility Location model in Section 3 so that y j k = c j . The allocation problem is: Additional constraints.
The additional constraints could be any extra conditions we want to impose on the solutions generated by the heuristic, similar to those described in (7)-(10). Note that unlike the FLM, there is no constraint preventing one seat being the central seat for more than one party. This allocation problem can be solved very quickly by commercial solvers for all sizes of problem that are relevant to our application. After finding an optimal solution to the allocation problem, the next step is to choose a new set of central seats. This is done by fixing the variables x i j and finding the central seats {c j : j ∈ J} that minimise the objective of (16).
By iteratively repeating the allocation and location phases, the objective value is necessarily non-increasing from one iteration to the next. The algorithm is terminated when the new set of central seats is identical to the previous set, which means that no further reduction of the objective value will be achieved. The full Location-Allocation Heuristic (LAH) is shown in Algorithm 1.

Algorithm 1 Location-Allocation Heuristic
Step 1: Randomly designate one initial central seat, c j ∈ I for each party j ∈ J.
Step 2: Solve the allocation problem (16) to obtain the solution {x i j : i ∈ I, j ∈ J}.
Step 3: Calculate the new central seats, given bỹ Step 4: Ifc j = c j for all j ∈ J then output the solution and stop. Else, set c j =c j for all j ∈ J and return to step 2.
In its current form the objective function of the allocation problem minimises the sum of total distances from seats to their corresponding central seat. Therefore, parties with more seats will contribute more to the objective function, and so in a sense this prioritises compact blocks for the larger parties over the smaller parties. This effect can be mitigated by scaling the objective function. By dividing each term by K j we obtain the sum of average distances from each central seat to the seats assigned to it. However, the average distance will still be larger for larger parties, and so we can scale further by dividing by K j in an attempt to counteract this effect. The scaled objective function is therefore given by Figure 2 shows two example solutions generated by LAH. The first was produced by the original, unscaled objective function, while the second was produced by the scaled version. In the first solution, the smaller parties are all located around the edge of the chamber, whereas in the second solution they tend to be embedded within the larger parties. Which of the two solutions is best is ultimately a matter of opinion. On the one hand, the second solution seems less biased against the smaller parties because they are not forced to the edges of the chamber, but on the other hand it does not seem ideal for the larger parties to be 'punctured' by the smaller parties. For now, we put the scaled version to one side and continue using the unscaled version, although it is worth bearing in mind the potential problems that this could cause.

Geometric Cutting Heuristic
In this section, we outline a geometric cutting heuristic (GCH) inspired by the computational geometry heuristic for political districting proposed by Kalcsics et al. (2005). The heuristic requires that the seats be considered as a connected graph, with each seat assigned a pair of coordinates, and adjacent seats connected by edges. The heuristic then proceeds as follows: -The parties are randomly split into two groups. Suppose the parties in the first group have a total of N 1 seats between them, and the parties in the second group have N 2 seats. -An algorithm finds the straight line that partitions the seats into one group of N 1 seats and one group of N 2 seats, while cutting the fewest possible edges in the graph. Performing this cut separates the graph into two subgraphs, which are then considered separately. -If a subgraph contains the seats for only one party, then those seats are assigned to that party. Otherwise, the process is repeated for the subgraph. By continuing in this way, eventually the original graph will be broken down into one subgraph for each party, each containing the correct number of seats.
Due to the line direction being chosen to cut the fewest possible edges, the process can be considered primarily as a heuristic for the Minimum k-Partition model from Section 4, however in the computational study we will also examine how well it performs as a heuristic for the Facility Location model from Section 3. Figure 3 shows an example of how the Geometric Cutting Heuristic produces a solution for a congress with 100 seats. Suppose parties 1,2,3 and 4 have 47,32,17 and 4 seats respectively. Firstly, the parties are randomly split into two groups, in this case Parties 2 and 3 form one group with a total of 49 seats, and Parties 1 and 4 form the other group with a total of 51 seats. The seats are partitioned into two groups of sizes 49 and 51 by the straight line that cuts the fewest possible edges. This produces two subgraphs, each containing the seats for two parties. Therefore, the process is repeated for each subgraph separately, dividing each into two further subgraphs. This results in four subgraphs, each corresponding to exactly one party. Therefore, the seats in each subgraph are assigned to the corresponding party, producing the solution shown at the bottom of Figure 3. The detailed explanation of the heuristic is divided into two parts. The Bisection Algorithm (Algorithm 2) explains the process used to perform each division of the graph into two subgraphs. Figure 4 shows visually how the the bisection is performed. The Geometric Cutting Algorithm (Algorithm 3) then explains how the Bisection Algorithm is repeated iteratively until the original graph is divided into one subgraph for each party.
The key differences between this heuristic and that presented by Kalcsics et al. (2005) are as follows: -The heuristic presented by Kalcsics et al. aims to partition the space such that each district achieves approximately equal values of a given performance measure (e.g.

Algorithm 2 Bisection Algorithm
Step 1: Start with set of seats I, a set of parties J, and the number of representatives in each party {K j : j ∈ J}. Suppose each seat i ∈ I has coordinates (x i , y i ), and that a graph is formed by connecting adjacent seats with edges. Use a random procedure to separate the parties J into two groups J 1 and J 2 . Let N 1 = ∑ j∈J 1 K j and N 2 = ∑ j∈J 2 K j .
Step 2: Select a number d of line directions to try for the bisection, and for each k = 1, . . . , d: -Let θ k := k−1 d 2π. Then, for all seats i ∈ I, let p ik := x i cos θ k − y i sin θ k so that p ik is the x-coordinate of seat i rotated anticlockwise by an angle of θ k about the origin. -Sort the values p ik in non-decreasing order and then find a value τ k such that p ik < τ k for the first N 1 elements and p ik > τ k for the last N 2 elements.
If the N 1 th and N 1 + 1th elements are equal, meaning no τ k can be found, then continue to the next value of k. Otherwise, let C k be the number of edges connecting seats in the set {i ∈ I : p ik < τ k } with seats in the set {i ∈ I : p ik > τ k } .
Step 3: If no τ k was found for any k = 1, . . . , d then return to Step 2 and increase the number of directions d. Otherwise, let k * = arg min k=1,...,d C k so that k * denotes the bisection line that cuts the fewest edges of the graph. Perform the bisection by separating the seats into the sets {i ∈ I : p ik * < τ k * } and {i ∈ I : p ik * > τ k * }. population size). In our problem, the blocks need to be different sizes determined by the numbers of seats won by each party. To achieve this, we randomly split the values {K j } into two non-empty sets, then consider cuts that partition the seats into two blocks of sizes given by the total number of seats in each set. After each cut has been performed, we consider each block of seats separately and further subdivide them in the same way.

Algorithm 3 Geometric Cutting Algorithm
Step 1: Begin with the graph containing all seats in the congress. Apply Algorithm 2 to divide the graph into two subgraphs, each of which corresponds to a particular subset of parties. Set both of these subgraphs to active.
Step 2: For every active subgraph: -If the subgraph corresponds to only one party then set the subgraph to complete.
-Otherwise, apply Algorithm 2 to the subgraph to create two new active subgraphs, and set the original subgraph to inactive.
Step 3: If there are any remaining active subgraphs then return to step 2. If there are no active subgraphs then stop. The complete subgraphs all correspond to an individual party, and the seats in in the subgraph are assigned to that party to form the seating plan.
-Compactness is encouraged by Kalcsics et al. (2005) in two different ways, neither of which are adopted by the heuristic in this paper. Instead, we encourage compactness by choosing the straight line that minimizes the number of cut edges in the adjacency graph.
The parameter d, which determines the number of line directions to try on each iteration, needs to be fixed beforehand. Larger values of d provide the possibility of generating better solutions, at the expense of a longer running time. Experiments suggest that d = 32 works well, with larger values resulting in little or no improvement, and this is the value we use in the computational study.
By only allowing the seats to be partitioned by straight-line cuts we dramatically reduce the number of solutions that can be generated by the heuristic. However, the solutions that it does produce are likely to be visually appealing because the boundaries between parties will not be too meandering or 'wiggly'.
A key drawback of the heuristic is that it could be difficult to modify the algorithm to produce solutions that satisfy additional conditions, such as those discussed in Section 3. However, this is not to say it is not possible; for example, we could prohibit any cuts that would result in solutions that violate particular conditions.

Computational Study
This computational study examines the performance of the Location-Allocation Heuristic (LAH) and Geometric Cutting Heuristic (GCH), assuming the basic cases in which they do not include any additional constraints. We compare them to each other as well as to the solutions found for the Facility Location Model (FLM) (1)-(6) and the Minimum k-Partition Model (MPM) (11)-(14) by Xpress Optimization software. We also show some of the best and worst solutions generated by each heuristic and analyse them visually.

Procedure
We considered four different sizes of congress: 50, 100, 200 and 400 seats. The coordinates of the seats were generated by an online tool for generating parliament diagrams 5 which were then used in Matlab to produce the diagrams shown in this paper. The adjacency graphs were formed by drawing edges between pairs of seats whose Euclidean distance was less than a threshold, which was determined as the smallest distance such that every seat, where applicable, is connected to both seats on either side of it and at least one seat from the row in front and one from the row behind. Figure 5 shows the resulting graphs. For the GCH, the parameter d, which determines the number of line directions, was set to d = 32 in all cases. As well as varying the number of seats in the congress, the number of parties and number of representatives from each party were varied. It is typical for there to be two, three or four larger parties that win the majority of seats, followed by several much smaller parties that have only a handful of seats each. We considered these cases, as well as the case in which the number of seats belonging to parties decreases exponentially, with the largest party having half the seats, the next largest having a quarter of the seats, and so on. Table 7.1 shows all combinations of congress size and seat breakdowns that we considered.
For each variation, five sets of solutions were generated by each heuristic. For the congresses with 50, 100 and 200 seats, each set consists of 100 solutions, while for the congress of 400 seats each set consists of generating 30 solutions. For each solution generated by either of the heuristics, we recorded the objective value of the solution under both the FLM and MPM models. The results tables display the following information:     For both heuristics, the computational time required to generate each individual solution is negligible, particularly when considered in the context of the application, which would not require solutions to be generated very quickly. We also recorded the best solutions found for the FLM and MPM by running the models in Xpress solver for 30 minutes (best found). The percentage gap between the best lower bound and best feasible solution found by the solver are shown. A gap of 0% indicates that the model was solved to optimality, in which case the time taken to find an optimal solution is stated in parentheses. Xpress Optimizer Version 29.01.10 was used on a Core i5 machine with clock speed 3.2GHz and 8GB of RAM run on Windows 7 OS.

Results and Analysis
The results of the computational study are shown in Tables 2 to 12. We can make the following three key observations: 1. In 30 minutes, Xpress solver was able to find optimal solutions for the FLM with 50 and 100 seats and for the MPM with 50 seats. In both cases with 50 seats, both heuristics were able to produce solutions that were optimal for either model. For 100 seats, both heuristics were able to produce solutions that were very close to optimal for the FLM.      Of course, examining the numerical results is only useful if they correspond to our visual intuition regarding what constitutes a good seating plan. Therefore we will now show some examples of the best and worst solutions generated by each heuristic. This serves two purposes; firstly, we can judge whether the best and worse solutions numerically correspond to what we would consider to be good and bad solutions visually, and, secondly, we can visually compare and contrast the solutions generated by the two heuristics. Recall that we are only studying the basic cases, without imposing any additional conditions, and so at this point we are only looking to see whether the seats are arranged in a sensible and visually appealing way. In particular, the seats should form compact shapes that are not too 'spread out' and ideally each party's seats should be connected or contiguous. For purposes of brevity, we only look at the solutions for the congress with 400 seats. Each figure shows four solutions, which correspond to the four types of seat breakdown. Figure 6 shows the best solutions generated by the LAH under the FLM objective function. The blocks appear reasonably compact. There is a small problem with the bottom-left solution because the black seats are not connected. The boundaries between the blocks are a little irregular and wiggly, but are not too bad. Figure 7 shows the worst solutions generated by the LAH under the FLM objective function. In the top-left solution, the purple party are entirely surrounded by the yellow party, which is not ideal. In the top-right solution, the yellow block is a long, Fig. 6 The best solutions from the LAH under the FLM objective thin shape which is therefore not visually compact. In the bottom-left solution, the red and yellow blocks are not visually compact shapes, and their boundary is very irregular. In the bottom-right solution, the blue block does not appear visually compact. In general, these solutions are visually inferior to the solutions in Figure 6, which suggests that there is a correlation between the numerical quality and the visual quality of solutions.  Figure 8 shows the best solutions generated by the GCH under the MPM objective function. In all of the solutions, the blocks of seats all appear compact and connected, with well-defined borders. Fig. 8 The best solutions from the GCH under the MPM objective function Figure 9 shows the worst solutions generated by the GCH under the MPM objective function. The blocks are all connected and seem reasonably compact, with the possible exception of the pink party in the bottom-left solution. It is noticeable that the worst solutions generated by the GCH are visually much better than the worst solutions generated by the LAH. The worst solutions generated by the GCH were also numerically better than the worst solutions generated by the LAH, which again suggests that there is a correlation between the numerical and visual quality of solutions.
In summary, the results suggest that visually the GCH performs better than the LAH. However, the LAH has the advantage that it is easier to incorporate additional requirements, because they can simply be included as constraints in the allocation phase. With the GCH, on the other hand, it is not so easy to include additional requirements.

Case Study: Congress of Deputies
We now consider a case study of the Spanish Congress of Deputies. We include several requirements that are specific to the application and discuss how these can be accommodated by the heuristics.
In the Congress of Deputies there are 350 elected representatives. There are 368 physical seats in the chamber, and nine cross-party members are chosen to sit at the Mesa del Congreso at the front, meaning that in practice there is a surplus of 27 seats. To simplify matters, we remove the members at the Mesa del Congreso from consideration, so that the problem involves assigning 341 members to 368 seats. The Fig. 9 The worst solutions from the GCH under the MPM objective function size of the problem makes finding optimal solutions to the FLM or MPM impractical, and so it is necessary to use the heuristics. Partido Nacionalista Vasco (PNV) 5 pink 7 Mixto 19 black 341 Table 13 The breakdown of seats in the Spanish Congress The number of representatives from each party are obtained from the results of the election of the 26th June 2016, shown in Table 13. The table also shows the index that will be used for each party in the model and the colour that will be used to represent each party in the solutions. Traditionally, PSOE sit on the left hand side, PP sit on the right, and Ciudadanos and smaller parties somewhere in the centre. As a group that identifies as being on the the left of the political spectrum, we also make the assumption that Podemos should sit on the left. The front row of seats is only occupied by government ministers, in this case meaning only the PP can sit in the front row.
The coordinates of the seats used to produce all the diagrams in this section were obtained from a pre-existing diagram of the Spanish Congress 6 , and the coordinates were then used in Matlab to produce the diagrams shown.

The LAH with Additional Constraints
The location phase of the heuristic functions in exactly the same way as described in Section 5, but we include several additional constraints in the allocation model in an attempt to a) encourage fairness and b) adhere to the rules and traditions of the congress. The full allocation model is shown below, followed by an explanation: -The basic model is contained in equations (18)-(21), with the only difference being that what were previously equalities in constraints (19) are now inequalities due to the fact in this case there are more physical seats than there are party members, so some seats must be left unassigned. -Constraints (22) ensure that each representative is sat next to another representative from the same party. -Let f (2) i = 1 if seat i is in the second row, and zero otherwise. Then constraints (23) ensure that any party with more than 20 seats has at least one seat in the second row, any party with more than 40 seats has at least 2 seats in the second row, and so on.
-Let R i be equal to the row number of seat i, with the front row being row 1, and the back row being row 8. Constraints (24) mean that the average row number of each party must be less than or equal to seven. -Let f (1) i = 1 if seat i is in the front row and zero otherwise. Then constraints (25) mean that only PP can occupy seats in the front row.
-Let (p i , q i ) be the coordinates of seat i, as shown in Figure 10. Constraints (26)-(28) ensure that each party is restricted to the correct part of the congress. After running the LAH ten times, the two best and two worst solutions based on their objective values are shown in Figure 11. In each of the four solutions there are notable problems with the Ciudadanos seats (in green). Since there are 30 green seats, constraints (23) mean there must be at least one green seat in the second row, and due to constraints (22) every member must be sat next to another person from the same party, and so there must be at least two green seats in the second row. The problem is that in all of the solutions these two green seats in the second row are separated from the rest of the party's seats.
As was discussed in Section 5, one option to attempt to improve the solutions is to scale the objective function so that the model encourages all blocks to be compact, regardless of the number of seats they contain. Figure 12 shows the two best and two worst solutions after running the LAH with a scaled objective function (17). In three of the solutions, the scaling has prevented the previous problems with the green block, although now the PP seats (in red) do not form very compact shapes.

Filtering Solutions from the GCH
The geometric cutting heuristic (GCH) does not have the same flexibility to incorporate additional requirements as the LAH. However, the results from the computational study suggest that it is capable of producing solutions that are visually very good.
Recall that in the Congress of Deputies we need to assign 341 representatives to 368 seats and only the PP are permitted to sit in the front row. The GCH requires an equal number of representatives and seats, therefore we supposed that we have 368 representatives by increasing the number of representatives from each party, so that the breakdown is {139, 89, 70, 33, 10, 6, 21}. We then generated a solution, which we deem infeasible if it does not satisfy the party location constraints (26)-(28) from the allocation model. Finally, if the solution is still feasible, we remove all front row seats that do not belong to the PP. Provided each party is still allocated at least as many seats as they require, we accept the solution. We assume that parties that are still assigned too many seats can choose themselves which ones they leave unoccupied.
After running the GCH one thousand times with this procedure, eight of the solutions remained feasible. The best and worst of these eight solutions under the MPM objective function are shown in Figure 13 on the left and right respectively. We see that the solutions are visually very good, with clearly defined borders between blocks, and the only notably non-compact set of seats is the pink seats in the right solution.
If we were to include more additional requirements, as we did with the LAH, it will become increasingly unlikely that any of the solutions generated by the GCH will remain feasible. Therefore, at least in its current form, the GCH is unsuitable when there is a large number of specific requirements that must be satisfied. However, we have seen that the solutions produced by the GCH tend to be very good, and so if it is possible to obtain feasible solutions then they are likely to be of a high quality.

Concluding Remarks
We conclude with a brief summary of our findings, which are then discussed together with possible directions for further study.

Summary of Findings
The original aim was to investigate ways in which mathematical optimization can be used to generate congress seating plans. We began with a discussion of possible approaches to the problem, noting the similarities with three other types of problems: political districting, facility location and graph partitioning.
Next, two optimization models were developed. The first was based on a facility location approach, while the second was a minimum k-partitioning model. Due to the number of binary variables, and the non-linearity in the case of the second model, optimal solutions could not be found in reasonable time by optimization software except for very small examples, and so we proposed two heuristics to generate 'good' solutions.
The location-allocation heuristic (LAH) separated the location and allocation components of the facility location model, while the geometric cutting heuristic (GCH) used straight line cuts to partition the graph, with line directions chosen to minimise the number of edges that are cut.
A computational study was undertaken to assess the performance of the heuristics, with the solutions evaluated both numerically and visually. The results showed that under the central seats compactness measure both heuristics performed similarly on average, although the best and worst solutions found by the LAH tended to be better and worse respectively than the best and worst solutions found by the GCH. On the other hand, the GCH performed significantly better under the cut-edges measure than the LAH. Visual examination of the solutions concurred with the numerical results; the best solutions both looked of a similar quality, but the worst numerical solutions from the LAH looked significantly worse than those from the GCH. Therefore, for solving the basic problem of partitioning the seats into compact blocks, it is fair to say that the GCH performs better than the LAH. However, the GCH has the disadvantage of not being able to incorporate additional constraints easily, whereas in the LAH they can be included in the allocation phase.
We concluded with a case study of the Spanish Congress with additional constraints. When these additional constraints were included in the LAH we found that they can result in the seats forming irregular shapes, although this effect can be partly mitigated by scaling the objective function. The possibility of filtering solutions generated by the GCH was also considered and it was found that if any solutions are found then they are likely to be very good, but as the number of additional constraints increases it becomes increasingly unlikely that any solutions will remain feasible.

Discussion and Possible Further Study
The primary objective of this paper was to investigate how mathematical modelling and optimization could be used to produce seating plans for congress chambers. We have discussed several approaches, and have shown that if a set of basic rules can be agreed upon regarding how the seats should be assigned, then it is possible to generate politically unbiased seating plans that satisfy these rules. In particular, the removal of any potential political bias should help to prevent complaints such as those from the Podemos spokesperson mentioned in the introduction. On the other hand, we found that the inclusion of certain rules can result in irregular looking seating plans, and future research should try to address this problem.
In this sense, it would be particularly interesting to include explicitly in the model constraints that enforce connectivity (remember that our models encourage connectivity, but do not guarantee it). As part of our future research, we would like to study the inclusion of connectivity constraints such as those described in Carvajal et al. (2013) and Wang et al. (2017). This has not been done in this paper because here we have tried to show that some simple models can already provide unbiased and meaningful solutions to arrange seats in a congress chamber. It is true that it is not guaranteed that the solution will be perfect, but we have shown that most of the solutions are very good starting points that require a minimal manual modification to provide satisfactory solutions. The constraints described in those two papers would increase the complexity of the models and some algorithms, much more specialized, would be necessary to solve those larger models. Although very interesting to us from the practical and mathematical point of view, we feel that we would be losing from sight the simplicity aspect of this paper.
Another benefit of using a mathematical approach rather than devising seating plans by hand is that the heuristics are able to produce a large number of possible plans very quickly. Moreover, there is a lot of variety in these plans, as can be seen from the diagrams in Sections 7 and 8, which presents the user with lots of flexibility, although of course this means restoring some of the decision-making to human hands, thereby reopening the potential for bias. However, as we mentioned in the introduction, the inherent subjectivity of the problem means that trying to obtain the 'perfect' seating plan will always be impractical.
There are many possible approaches to this problem, and these could be further explored by additional study. In particular, there are many ways to interpret what makes a seating plan visually appealing and how to express this mathematically. The success of the geometric cutting heuristic (GCH) when applied to the basic problem suggests that further investigations into geometric approaches would be worthwhile.
Finally, it would be interesting to combine the topic with a more political-focused study into what the politicians themselves want from a seating plan. This would serve to clarify and consolidate the objectives, which would in turn assist the development of possible optimization-based approaches.