## 1. Introduction

Alice and Bob are planning their wedding. They have agreed on the gift registry and the music to be played, but they still need to decide on the seating plan for the wedding reception. They expect 120 guests, and the reception venue has 20 tables, with each table seating 6 guests. However, this task is far from being easy: e.g., Alice’s great-aunt does not get along with Bob’s family and prefers not to share the table with any of them; on the contrary, Bob’s younger brother is keen to meet Alice’s family and would be upset if he were stuck with his relatives. After spending an evening trying to find a seating plan that would keep everyone happy, Alice and Bob are on the brink of canceling the wedding altogether.

Bob’s friend Charlie wonders if the hapless couple may benefit from consulting the literature on the stable roommate problem. In this problem, the goal is to find a stable assignment of agents into rooms of size , where every agent has a preference relation over her possible roommates. The most popular notion of stability in this context is core stability: no two agents should strictly prefer each other to their current roommate. Another relevant notion is exchange stability: no two agents should want to swap their places. However, for the stable roommate problem, neither core stable nor exchange stable outcomes are guaranteed to exist. Further, while Irving (1985) proved that it is possible to decide in time linear in the size of the input if an instance of the roommate problem with strict preferences admits a core stable outcome, many other algorithmic problems for core and exchange stability are computationally hard (Ronn, 1990; Cechlárová and Manlove, 2005). For the -dimensional stable roommate problem, where each room has size and agents have preferences over all -subsets of agents as their potential roommates, even the core non-emptiness problem for strict preferences is NP-complete for (Ng and Hirschberg, 1991; Huang, 2007).

However, Charlie then notes that Alice and Bob’s problem has additional structure: the invitees can be classified as bride’s family or groom’s family, and it appears that all constraints on seating arrangements can be expressed in terms of this classification: each person only has preferences over the ratio of groom’s relatives and bride’s relatives at her table. Thus, the problem in question is closely related to

hedonic diversity games, recently introduced by Bredereck et al. (2019). These are coalition formation games where agents have diversity preferences, i.e., they are partitioned into two groups (say, red and blue), and every agent is indifferent among coalitions with the same ratio of red and blue agents. However, positive results for hedonic diversity games are not directly applicable to the roommate setting: in hedonic games, agents form groups of varying sizes, while the wedding guests have to be split into groups of six.In this paper, we investigate the multidimensional stable roommate problem (for arbitrary room size ) with diversity preferences; we refer to the resulting problem as the roommate diversity problem. This model captures important aspects of several real-world group formation scenarios, such as flat-sharing, splitting students into teams for group projects, and seating arrangements at important events. We consider common solution concepts from the literature on the stable roommate problem; for each solution concept, we analyze the complexity of checking if a given outcome is a valid solution, whether the set of solutions is guaranteed to be non-empty, and, if not, how hard it is to check if an instance admits a solution as well as to compute a solution if it exists.

Our Contribution To begin with, we show that for room size two, every roommate diversity problem admits an outcome that is core stable, exchange stable and Pareto optimal; moreover, we show that such an outcome can be computed in linear time. For , we provide counterexamples showing that core stable, exchange stable or envy-free outcomes may fail to exist; these negative results hold even when agents’ preferences over type ratios are restricted to be strict and single-peaked (see Section 2 for formal definitions). We also prove that for core stability, strong exchange stability and envy-freeness, the existence questions are computationally hard; for Pareto optimality, we show that it is not only hard to find a Pareto optimal outcome, but also to verify whether a given outcome is Pareto optimal. We provide an overview of our results in Table 1.

On the positive side, we show that all existence questions we consider are in FPT with respect to the room size. To the best of our knowledge, apart from some work on the multidimensional stable roommate problem with cyclic preferences (Hofbauer, 2016), this is one of the first positive results for the multidimensional stable roommate problem. Thus, the roommate diversity problem offers an attractive combination of expressive power and computational tractability.

In the end, we also investigate the multidimensional stable marriage problem with diversity preferences. In our model, there are agent categories, with agents in each category, and each agent can be classified as red or blue irrespective of her category. An admissible outcome is a partition of agents into groups, with each group having one representative from each category; the agents’ preferences over groups are governed by the fraction of red and blue agents in each group. We show that our negative results for the roommate diversity problem extend to this model, but for the positive results the picture is more complicated.

Related Work The stable roommate problem was proposed by Gale and Shapley (1962) and has been studied extensively since then (Cechlárová, 2002; Irving, 1985; Irving and Manlove, 2002; Ronn, 1990; Huang, 2007). It can be seen as a special case of hedonic coalition formation (Bogomolnaia and Jackson, 2002), where agents have to split into groups (with no prior constraints on the group sizes) and have preferences over groups that they can be part of; precisely, a stable roommate problem with room size is a hedonic coalition formation problem where each agent considers all coalitions of size other than unacceptable.

In contrast to the closely related stable marriage problem (Gale and Shapley, 1962), for the stable roommate problem, it is not guaranteed that the core is not empty. While Irving (1985) proved that it is possible to check in time linear in the input whether a roommate problem admits a core stable outcome if the preferences are restricted to be strict, Ronn (1990) showed that this problem becomes NP-complete if ties in the preference relations are allowed. As in practice a group deviation usually requires some regrouping, Alcalde (1994) initiated the study of local stability notions that do not require reallocating non-deviating agents, by introducing the notion of exchange stability. Subsequently, Cechlárová and Manlove (2005) proved that it is NP-complete to decide whether an instance of the roommate problem with strict preferences admits an exchange stable outcome. Another concept that is relevant for the roommate problem is Pareto optimality (Abraham and Manlove, 2004; Sotomayor, 2011; Cseh et al., 2019). Morrill (2010) proved that for room size two, it is possible to check if a given outcome is Pareto optimal, and to find a Pareto improvement if it exists, in time cubic in the number of agents. This implies that a Pareto optimal outcome can be found in polynomial time. Researchers have also considered various notions of fairness in the context of the roommate problem (Aziz and Klaus, 2019; Abdulkadiroğlu and Sönmez, 2003). One such notion is envy-freeness: an outcome is said to be envy-free if no agent wants to take the place of another agent.

While much of the work on the stable roommate problem focuses on the case , there are a few papers that consider the three-dimensional stable roommate problem (Ng and Hirschberg, 1991; Huang, 2007). In some of this work, the agents’ preferences are defined over individual agents and then lifted to pairs (Iwama et al., 2007; Huang, 2007), while other authors define preferences directly over pairs (Ng and Hirschberg, 1991; Huang, 2007). In both models, it is NP-complete to decide whether an instance with strict preferences admits a core stable outcome (Iwama et al., 2007; Ng and Hirschberg, 1991; Huang, 2007). For this reason, despite its great practical relevance, the multidimensional version of the stable roommate problem has not attracted much attention yet.

One possibility to circumvent these negative results is to search for reasonable subclasses of the stable roommate problem, i.e., to identify realistic restrictions on the agents’ preferences for which the associated computational problems become tractable. This approach has been successful in the study of the two-dimensional stable roommate problem (Cseh and Juhos, 2019; Abraham et al., 2007; Bartholdi III and Trick, 1986; Bredereck et al., 2017; Chung, 2000), as well as in the context of hedonic games (Banerjee et al., 2001; Bogomolnaia and Jackson, 2002; Aziz et al., 2019). In particular, Bredereck et al. (2019) and Boehmer and Elkind (2020) analyzed the complexity of finding stable outcomes in hedonic diversity games for several notions of stability, such as Nash stability, individual stability and core stability. However, these results do not directly translate to our model: first, with the exception of core stability, the solution concepts we consider are different from those considered in hedonic diversity games, and second, the hard constraint on the room sizes in the roommate problem changes both the set of feasible allocations and the set of possible deviations.

Finally, we note that Bredereck et al. (2019) and Boehmer and Elkind (2020) related hedonic games with diversity preferences to anonymous hedonic games (Bogomolnaia and Jackson, 2002), where the agents’ preferences over coalitions only depend on coalition sizes. This connection proves useful in our setting as well: e.g., in our hardness reductions we use the fact that it is NP-complete to decide whether an anonymous hedonic game admits a Nash, core or individually stable outcome (Ballester, 2004).

Diversity related questions have been also previously studied in the context of stable matching problems (Huang, 2010; Kamada and Kojima, 2015). However, our model is fundamentally different, as, here, agents have preferences over types and, in contrast to previous research, types are not used to formulate distributional constraints on the outcome.

## 2. Preliminaries

For every positive integer , we denote the set by , and we write to denote .

###### Definition 2.1 ().

A roommate diversity problem with room size is a quadruple with and for some . The preference relation of each agent is a weak order over the set .

In the following, we call all agents in red agents and all agents in blue agents, and write , and . We refer to size- subsets of as coalitions or rooms; the quantity is then the number of rooms. For each , let denote all size- subsets of containing , i.e., all possible rooms that can be part of.

An outcome of is a partition of all agents into rooms such that for all . Let denote ’s coalition in . Given a coalition , let denote the fraction of red agents in , i.e., : we say that is of fraction . A coalition is called pure if or and mixed otherwise.

For each agent , we interpret her preference relation over as her
preferences over the fraction of red agents in her coalition; for instance,
means that agent prefers a room
where two out of five agents
are red to a room where three out of five agents are red.^{1}^{1}1We could equivalently
define the agents’ preferences over the number of red agents in each room; we chose the ratio-based
definition for consistency with the hedonic diversity games literature
and to emphasize the room size.
Thereby, induces agent ’s preferences over all possible rooms she can be
part of.^{2}^{2}2For succinctness and consistency with prior work, we assume that each agent has preferences
over the entire set , including and , even though a red agent cannot
be part of a room with ratio and a blue agent cannot be part of a room with ratio .
Allowing agents to have preferences over ‘impossible’ ratios has no impact on our results:
even if, say, a blue agent ranks highly, she cannot deviate
to a coalition with this ratio. In all of our examples, the impossible
ratios are ranked at the bottom of agent’s preferences.
Given two rooms , overloading notation, we write and say that
strictly prefers to if and
. Further,
we write and say that
weakly prefers to if or
. If weakly prefers to and to ,
we write and say that is indifferent between and .

The preference relation of agent is said to be single-peaked if there exists a peak such that for all such that or it holds that . The preference relation of is said to be dichotomous if it is possible to partition into two sets and so that for all it holds that , for all it holds that and for all it holds that . We say that approves all fractions in and disapproves all fractions in .

Generalizing the definition of Gale and Shapley (1962), we say that a coalition with blocks an outcome if for all it holds that ; we say that weakly blocks an outcome if for all it holds that and there exists an such that . An outcome is called (strongly) core stable if no coalition (weakly) blocks it.

In an outcome , a pair of agents with has an exchange deviation if they would like to exchange places, i.e., and . Further, a pair of agents with has a weak exchange deviation if and . An outcome is called (strongly) exchange stable if no pair of agents has a (weak) exchange deviation (Alcalde, 1994).

An outcome is called Pareto optimal if there is no other outcome that makes all agents weakly better off and some agents strictly better off, i.e., there is no outcome such that for all and for some .

An outcome is called envy-free if there does not exist a pair of agents with such that envies ’s place, i.e., .

Besides the study of the classic computational complexity of a problem,
we can also investigate its complexity as a function of a specific parameter
of the input; e.g., in the context of the roommate diversity problem, this
parameter could
be the size of the rooms or the size of the smaller of the two groups
.
We say that a problem is fixed-parameter tractable with respect to a
parameter
if, given an instance where this parameter takes value ,
it is solvable in time
, where is some computable
function.^{3}^{3}3For
further details on the theory of parameterized complexity and the
significance of , the reader is referred to textbooks by
Downey and
Fellows (2013) and by Niedermeier (2006).

## 3. Roommate Diversity Problem With Room Size Two

For , the roommate diversity problem becomes a special case of the classic stable roommate problem. Our first observation is that diversity preferences make the classic problem significantly easier: we can efficiently find an outcome that is Pareto optimal, core stable and exchange stable. This result motivates us to focus on the case in the remainder of the paper.

###### Theorem 3.1 ().

Every instance of the roommate diversity problem with room size two admits an outcome that is Pareto optimal, core stable and exchange stable, which can be computed in linear time, even if we allow for indifferences in the preferences.

###### Proof.

In the following, we prove the theorem by proving that every outcome returned by Algorithm 1, which runs obviously in linear time, is guaranteed to be core stable, exchange stable and Pareto optimal. However, we start by giving a high-level description of the algorithm. We say that a mixed pair is happy if both agents in the pair weakly prefer a mixed pair to a pure pair. Algorithm 1

first create as many happy mixed pairs as possible. The algorithm then attempts to put the remaining agents in pure pairs. If at this point the number of blue agents is odd, this is not possible. In this case, depending on the preferences of agents in mixed pairs, it either inserts an additional mixed pair or breaks up one of the mixed pairs to create two pure pairs: one red and one blue.

Core stability First of all, note that the outcome computed by Algorithm 1 is core stable, as for each agent in a pure coalition it either holds that this is one of her most preferred coalitions or all agents of the other type strictly preferring mixed coalitions are already in a mixed coalition. Moreover, for agents in a mixed coalition it either holds that this is one of their most preferred coalitions or all agents of the same type strictly preferring a pure coalition are already in one.

Exchange stability To prove that is exchange stable, we examine all agents who might have an incentive to swap and prove that there never exists an agent willing to swap with them: an agent in one of the coalitions from never strictly prefers swapping with another agent, as she is already in one of her most preferred coalitions.

If , only in the case that , agent strictly prefers to swap with a red agent in a pure coalition or with a blue agent in a mixed coalition. However, as argued above, no blue agent in one of the other mixed coalitions has an incentive to swap. Moreover, by construction, implies that for all red agents in pure coalitions. Thereby, no red agent in a pure coalition wants to swap with . The same holds if has an incentive to swap.

Lastly, a red agent in a pure coalition with strictly prefers swapping with a red agent in a mixed coalition or a blue agent in a pure coalition. However, from the fact that a red agent with is in a pure coalition it follows that all red agents in mixed coalitions also have this preference relation. Moreover, it also follows that all blue agents who weakly prefer a mixed coalition are already in a mixed coalition. For blue agents in pure coalitions with an incentive to swap, the reasoning is analogous. Note that if the preferences of agents are strict, is also guaranteed to be strongly exchange stable.

Pareto optimality For the sake of contradiction, let us assume that there exists an outcome that weakly Pareto dominates . By definition, there needs to exist at least one agent who strictly prefers to . Consequently, cannot be indifferent between the two realizable fractions in her domain.

Assuming that the condition in line is triggered, no agent strictly preferring a pure coalition can be in a mixed coalition in . Thereby, needs to strictly prefer a mixed coalition and needs to be part of a pure coalition in . However, from this it follows that all agents of her type in mixed coalitions also strictly prefer a mixed coalition. Consequently, needs to include more mixed pairs than . However, this cannot be achieved without making some of the agents of the other type worse off, as all agents from the other type weakly preferring a mixed coalition are already placed in a mixed coalition in .

Assuming that the condition in line is triggered, needs to be in a pure coalition and strictly prefers a mixed coalition. However, it is not possible that such an agent exists in this case, as this would imply that either or also strictly prefers a mixed coalition.

Assuming that the condition in line is triggered, it either holds that strictly prefers a mixed coalition—and the reasoning from the first case applies—or is member of and strictly prefers a pure coalition. In the latter case, every agent of ’s type who is in a pure coalition strictly prefers a pure coalition. Thereby, in every outcome that weakly Pareto dominates , the number of pure coalitions needs to be higher than in . It is only possible to increase the number of pure coalitions by putting at least one red and one blue agent from in a pure coalition. However, as the condition in line does not hold, at least one of these agents strictly prefers a mixed coalition and is thereby worse off in . ∎

## 4. (Strong) Core Stability

We have seen that for the roommate diversity problem with , a core stable outcome is guaranteed to exist. However, for larger values of this is not the case.

###### Theorem 4.1 ().

An instance of the roommate diversity problem may fail to have a core stable outcome, even if no indifferences in the preferences are allowed.

###### Proof.

Let with

Assume for the sake of contradiction that has a core stable outcome . If consists of two coalitions of fraction , is blocking. If consists of one coalition of fraction and one coalition of fraction , is blocking. If consists of a purely blue and a purely red coalition, is blocking. ∎

Further, if we assume that the room size is an unfixed part of the input, the associated existence question becomes NP-complete.

###### Theorem 4.2 ().

It is NP-complete to decide whether a given instance of the roommate diversity problem admits a core stable outcome. The hardness result holds even if no indifferences in the preferences are allowed.

###### Proof.

To check whether an outcome is core stable, we iterate over all and check if there are red agents and blue agents preferring to the fraction of their current coalition. To prove hardness, we reduce from the problem of deciding whether an anonymous hedonic game admits a core stable outcome (Ballester, 2004). Given an anonymous game with agents, we build an -dimensional instance of the roommate diversity problem. The general idea of the reduction is to map coalitions of size in the anonymous game to coalitions of fraction in the roommate diversity problem.

Construction: Let be an anonymous game. In the corresponding roommate diversity problem, the room size is set to , and for each original agent , one red agent is introduced. The preference relation of is defined by:

Additionally, for each we insert blue agents:

Correctness: () Given a core stable outcome of the anonymous game, we construct a core stable outcome of the corresponding roommate diversity problem. For each with , we introduce a coalition consisting of the red agents corresponding to the agents in together with blue agents of type : . All remaining blue agents are put into pure coalitions of size .

For the sake of contradiction, let us assume that there exists a blocking coalition with in . First of all, note that at least one red agent needs to be in . Let us assume that includes red agents . For all , it holds that . However, by construction of the preference relation of and the outcome , this implies that for all it holds that . Consequently, blocks which leads to a contradiction.

To prove the other direction, let us assume that the roommate diversity problem admits a core stable outcome where w.l.o.g. we assume that the first coalitions contain red agents and all other coalitions are purely blue coalitions. From , we construct an outcome of the anonymous game with for all . For the sake of contradiction, let us assume that there exists a blocking coalition with in for some . This implies that for all . Let . By construction, it holds that is non-empty and that for all . Moreover, note that there always exists a set of blue agents with , as at most blue agents can be part of a mixed coalition and blue agents prefer to a pure coalition. Therefore, with blocks which leads to a contradiction. ∎

Using the construction in the proof of Theorem 4.2, we can map the single-peaked anonymous hedonic game with empty core constructed by Banerjee et al. (2001) to a single-peaked instance of the roommate diversity problem with an empty core. We obtain the following corollary.

###### Corollary 4.3 ().

An instance of the roommate diversity problem may fail to have a core stable outcome, even if all agents’ preferences are single-peaked.

In contrast, if agents’ preferences are dichotomous, the core is non-empty, and an outcome in the core can be computed efficiently: following the approach of Peters (2016), to construct a core stable outcome we iterate over all fractions for and add the maximum possible number of rooms consisting of red agents and blue agents who all approve . The rest of the agents are split into the remaining rooms. We obtain the following result.

###### Theorem 4.4 ().

Every instance of the roommate diversity problem with dichotomous preferences admits a core stable outcome; moreover, an outcome in the core can be computed in polynomial time.

However, this positive result does not extend to the more demanding notion of strong core stability.

###### Theorem 4.5 ().

It is NP-complete to decide whether a given roommate diversity problem admits a strongly core stable outcome, even if the preferences are restricted to be dichotomous and every agent approves at most four fractions.

## 5. (Strong) Exchange Stability

As pointed out in the introduction, it is not always plausible to assume that agents are allowed to perform group deviations. Therefore, in this section we focus on stability concepts that are defined in terms of agent swaps.

### 5.1. Same-Type Swaps

If the set of possible deviations is limited to agent swaps, it may be the case that only agents of the same type are allowed to swap their places: we call the resulting stability notion same-type-exchange stability. For example, if a professor forms fixed-size teams for a group project, she may want to fix the fraction of graduate students in each group (e.g., to ensure that the experienced students are equally distributed) but still allow for swaps between two undergraduate students or between two graduate students. Under this weaker version of exchange stability, the agents are guaranteed to eventually converge to a stable outcome.

###### Theorem 5.1 ().

Every instance of the roommate diversity problem has a (strongly) same-type-exchange stable outcome, and some such outcome can be computed in polynomial time.

###### Proof.

To compute a (strongly) same-type-exchange stable outcome, we start at an arbitrary outcome and swap pairs who have a (weak) same-type-exchange deviation until this is no longer possible. To see that this procedure always terminates, note that same-type exchange deviations do not change the fraction of red agents in any coalition. Thereby, nothing changes for agents who are not involved in the swap, while both agents involved in the swap weakly improve and at least one of them strictly improves. As every agent’s preference relation is defined over elements, the total number of swaps is at most . ∎

### 5.2. Unrestricted Swaps

Unfortunately, the existence guarantee for same-type swaps does not extend to unrestricted swaps.

###### Theorem 5.2 ().

An instance of the roommate diversity problem may fail to have an exchange stable outcome, even if the preferences are single-peaked and no indifferences in the preferences are allowed.

###### Proof.

The following single-peaked roommate diversity game

with:

does not admit an exchange-stable outcome.

We will first argue that there is no exchange stable outcome containing a purely red coalition . Indeed, if such an outcome exists, either (i) both of the remaining red agents are in the same coalition, or (ii) the remaining red agents are in two different coalitions.

In case (i), there also exists a purely blue coalition, which we denote by . At least one of and has to be in , and at least one of and has to be in ; thus, at least one agent in and at least one agent in would like to swap places.

In case (ii), as strictly prefers to , she would like to swap with the red agent in the other mixed coalition. As all red agents prefer to , this red agent would be happy to swap with , too.

It remains to argue that there is no exchange stable outcome with no purely red coalition. In this case, there exist two mixed coalitions of fraction and one mixed coalition of fraction . Consequently, at least one of and belongs to a coalition of fraction ; this agent would like to swap with the blue agent in the other mixed coalition of fraction . As all blue agents prefer to , this blue agent would be happy with the swap as well, so no such outcome can be exchange stable. ∎

Further, the associated existence problem for strong exchange stability is NP-complete.

###### Theorem 5.3 ().

It is NP-complete to decide whether a given instance of the roommate diversity problem admits a strongly exchange stable outcome. The hardness result still holds if the preferences are dichotomous and every agent approves at most four fractions.

###### Proof.

To show membership, note that it is possible to verify in polynomial time whether an outcome is strongly exchange stable by iterating over all pairs of agents and checking whether they have a weak exchange-deviation.

To show hardness, we reduce from the problem of deciding whether an anonymous hedonic game admits a Nash stable outcome (Ballester, 2004); recall that an outcome of a hedonic game is said to be Nash stable if no agent wants to move from her current coalition to another existing coalition or to form a singleton coalition. Our reduction is similar to the one in the proof of Theorem 4.2; however, here, we introduce blue agents who are indifferent among all fractions. Thereby, each time an agent has a Nash deviation in the anonymous game, the corresponding red agent has a weak exchange-deviation with a blue agent in the corresponding outcome of the constructed roommate diversity problem and the other way round.

Construction: Given an anonymous game , the room size in the corresponding roommate diversity problem is set to . Moreover, for each agent , a red agent is introduced whose preference relation is defined by:

Further, for all , a blue agent who is indifferent among all fractions is introduced.

Correctness: We start by assuming that admits a Nash stable outcome . From , we construct a strongly exchange stable outcome of the corresponding roommate diversity problem. First of all, for all , we insert one coalition consisting of all red agents corresponding to the agents in and blue agents into : . The remaining blue agents are put into pure coalitions of size . is not guaranteed to be strongly exchange stable, as there might exist a pair of red agents with an exchange-deviation. However, as is Nash stable, for all it holds that:

To construct a strongly exchange stable outcome from , we execute
weak same-type-exchange-deviations as long as there exists a pair with a
weak
same-type-exchange-deviation to obtain an outcome .^{4}^{4}4As
discussed in
Theorem 5.1, this process is always guaranteed to
terminate. It remains to
show that no two agents of a different type have a weak exchange-deviation
in
: recall that by performing weak same-type-exchange-deviations every
agent’s situation can only be improved. Consequently, in , it holds
for all that:
. Applying this to
the equation from above, it follows that no red agent has an incentive to
swap with a blue agent in . Consequently, is strongly
exchange stable.

() To prove the other direction, let us assume that the roommate diversity problem admits a strongly exchange stable outcome where w.l.o.g. the first coalitions contain red agents, while the remaining coalitions are purely blue coalitions. Let with for all be an outcome of the anonymous game. To prove that is Nash stable, note that in , for all , there always exists at least one blue agent in every coalition is not part of. As is strongly exchange stable, from this and the fact that each blue agent is indifferent among all coalitions it follows that for all it holds that:

By construction, from this it follows that for all it holds that:

which implies that is Nash stable.

It is also possible to show that the proven NP-hardness result still holds if the agents’ preferences are dichotomous and every agent approves at most four fractions by reducing from the related problem for anonymous games, which is NP-complete as proven by Peters (2016). The construction of the reduction needs to be slightly adapted: for all red agents, the set of approved fractions is the transformed set of the corresponding agent in the anonymous game, and all blue agents do not approve any fraction. ∎

We believe that deciding whether a roommate diversity problem admits an exchange stable outcome is NP-complete as well, but we were unable to extend the proof of Theorem 5.3 to show this.

## 6. Pareto Optimality

In the roommate problem, Pareto optimality emerges as a natural notion of stability. Indeed, an outcome is not Pareto optimal if and only if we can rearrange the agents so that all of them are weakly better off and at least some of them are strictly better off, i.e., there is a weakly improving deviation by the grand coalition (Morrill, 2010; Elkind et al., 2016).

While for many other stability concepts we consider stable outcomes are not guaranteed to exist, by the definition of Pareto optimality, every instance of the roommate diversity problem admits a Pareto optimal outcome. Indeed, we can start at an arbitrary outcome and perform a sequence of at most Pareto improvements, i.e., rearrangements of the agents that make all agents weakly better off and some agents strictly better off. However, it is still computationally hard to compute a Pareto optimal outcome, as finding a Pareto improvement is difficult.

###### Theorem 6.1 ().

For the unrestricted roommate diversity problem, it is coNP-complete to decide whether a given outcome is Pareto optimal; moreover, we cannot compute a Pareto optimal outcome in polynomial time unless P=NP. These results hold even if preferences are dichotomous.

###### Proof.

To show that an outcome is not Pareto optimal, it suffices to guess a Pareto improvement and verify that it indeed makes all agents weakly better off and some agents strictly better off; this establishes that our decision problem is in coNP.

For both hardness results, we utilize the fact that Aziz et al. (2013) proved that deciding whether an outcome of an anonymous game is Pareto optimal is coNP-complete and computing a Pareto optimal outcome is NP-hard. Note that their proofs also hold for the case where agents’ preferences are dichotomous and every agent approves at most four sizes.

To show hardness of verifying whether a given outcome is Pareto optimal, we construct a reduction from the related problem for anonymous games. The reduction works analogously to the reduction in the proof of Theorem 5.3. To prove the correctness of the reduction, let us assume that is a Pareto optimal outcome of the original anonymous game. Let be the outcome of the corresponding roommate diversity problem where all agents are replaced by their corresponding red agent and free spots are filled with blue agents. Then, needs to be Pareto optimal, as every outcome that weakly Pareto dominates can be converted into an outcome that weakly Pareto dominates by removing all blue agents and replacing all red agents by their corresponding agent in the anonymous game. This reasoning also holds for the other direction.

Secondly, computing a Pareto optimal outcome in a roommate diversity problem is NP-hard: it is possible to apply the reduction from Theorem 5.3 to transform every anonymous game into a corresponding roommate diversity problem. Assuming that we have found a Pareto optimal outcome of this roommate diversity problem, it is possible to obtain a Pareto optimal outcome of the original anonymous game as described above. ∎

## 7. Envy-Freeness

We can think of envy-freeness as a “one-sided” version of exchange stability. Thus, similarly to same-type-exchange stability, we can define same-type-envy-freeness by only considering envy among agents of the same type. Same-type-envy-freeness is a plausible variant of envy-freeness, as people tend to envy those who are similar to them (Salovey and Rodin, 1984). Moreover, same-type-envy-freeness is also an appealing notion of fairness: if agent and agent are of the same type and envies , swapping and has no effect on other agents, so the decision which of these agents should get a better set of roommates is essentially arbitrary. Unfortunately, an outcome that is fair in this sense is not guaranteed to exist.

###### Theorem 7.1 ().

There exists an instance of the roommate diversity problem with room size two that has no same-type-envy-free outcome and thereby also no envy-free outcome. Moreover, in this instance the agents’ preferences are single-peaked and dichotomous.

###### Proof.

Let with:

This game is clearly single-peaked and can be transformed into a dichotomous game where all agents disapprove their two bottom fractions and approve their top-fraction. As every outcome of this game consists of one mixed and one purely blue coalition, the blue agent in the mixed coalition always envies the two blue agents in the pure coalition. ∎

On the positive side, there exist two special cases where the existence of a same-type-envy-free outcome is guaranteed.

###### Theorem 7.2 ().

A same-type-envy-free outcome is guaranteed to exist if the number of red agents is divisible by or by .

###### Proof.

If divides , there exists an outcome consisting of pure coalitions only. If divides , there exists an outcome where the fraction of each coalition is . In either case, all agents of the same type are in coalitions of the same fraction, so no agent envies another agent of her type. ∎

Nevertheless, it can be proven by a reduction from Exact Cover by 3-Sets that the general existence question for envy-freeness is NP-complete.

###### Theorem 7.3 ().

It is NP-complete to decide whether a given instance of the roommate diversity problem admits an envy-free outcome, even if no indifferences in the preference relations are allowed. This hardness result also holds if the agents’ preferences are dichotomous and every agent is allowed to approve at most four fractions.

###### Proof.

To prove membership in NP, note that it is possible to check in polynomial time whether an outcome is envy-free by iterating over all pairs of agents and checking whether one of them envies the other.

In the following, we utilize the fact that the problem Exact Cover By 3-Sets (X3C) is NP-complete (Garey and Johnson, 1979). An instance of this problem is given by a set and a collection of 3-element subsets of . It is a yes-instance if there exists a subset such that is a partition of .

To prove hardness, we construct a reduction from X3C. Let and be a collection of 3-element subsets of . For , let be the set of all indices of sets in to which belongs, i.e. if and only if . In the following, we construct a corresponding roommate diversity problem. The general idea of the construction is to introduce for each element a corresponding agent such that in an envy-free outcome for all there either exists a coalition of fraction including the three agents corresponding to the elements in or a coalition of fraction .

Construction: To begin with, let us set and let us introduce one red so-called set agent for each with the following preference relation:

Moreover, for each , we introduce red so-called redundant agents with the following preference relation:

Furthermore, for each , we insert blue so-called filling agents with the following preference relation:

Additionally, for each we introduce three blue so-called additional agents with the following preference relation:

We further insert blue agents strictly preferring to all other fractions until the total number of agents is divisible by . Lastly, for each red agent of the game, we introduce blue agents strictly preferring to all other fractions.

Correctness: We start by assuming that there exists a partition of . In the following, using , we construct an envy-free outcome of the roommate diversity problem. Therefore, for each , we add one coalition consisting of the corresponding three red set agents, the designated red redundant agents and the designated blue filling agents: . Moreover, for each , we create a coalition consisting of the designated red redundant agents together with the designated blue filling agents and the designated three additional blue agents: . Finally, we put the remaining blue agents into purely blue coalitions. consists of purely blue coalitions and mixed coalitions of fraction or for .

We prove that is envy-free by iterating over all agents and showing that they do not envy another agent: as is a partition, all red set agents are in one of their most preferred coalitions. Moreover, by construction, all redundant agents and all filling agents are in one of their most preferred coalitions.

Concerning the additional agents, for all such that , are in their top coalition. For all such that , are in a purely blue coalition. However, as , there does not exist a coalition of fraction . As there also does not exist a coalition within distance to this fraction, and do not envy another agent for all .

As all blue agents strictly preferring a purely blue coalition to all other coalitions are in a pure coalition, no agent envies another agent in .

Let us assume that there exists an envy-free outcome of the constructed roommate diversity problem. In the following, we prove that this implies that there exists a partition of . First of all, note that due to the introduction of blue agents for each red agent, every outcome of the game includes at least one purely blue coalition .

Using this, we prove that each red agent is part of one of her most preferred coalitions. For the sake of contradiction, let us assume that there exists a red agent for which this is not the case. Then, it either holds that is in a coalition of fraction or in a coalition of a fraction to which she prefers . In the former case, all blue agents in ’s coalition envy the agents in , as all blue agents prefer to . In the latter case, envies the agents in . Consequently, every red agent is in one of her most preferred coalitions.

From this it follows that every coalition of fraction for some includes at most red redundant agents and thereby exactly three set agents with . By removing all non-set agents from , it is possible to obtain a partition of .

Note that the reduction still holds if no indifferences in the agents’ preferences are allowed. It is possible to replace the indifferences in the agents’ preference relations by strict preferences in an arbitrary way without influencing the validity of the proof. The second part of the proof remains unaffected, while the outcome constructed in the first part is still envy-free, as for all only either a coalition of fraction or of fraction exists and for all it holds that .

Note further that it is also possible to transform every X3C instance into a corresponding dichotomous roommate diversity problem. To do so, the construction given above needs to be only slightly adapted: for all agents, their set of approved fractions consists of all explicitly listed fractions. ∎

We were not able to extend Theorem 7.3 to same-type-envy-freeness, but conjecture that the hardness result still holds. If preferences are strict, there exists a simple algorithm that solves this problem in time linear in and single-exponential in , i.e., this problem is in FPT with respect to .

###### Theorem 7.4 ().

Given an instance of the roommate diversity problem with room size and strict preferences, it is possible to check in time whether this instance admits a same-type-envy-free outcome and to find one if it exists.

###### Proof.

Let be a same-type-envy-free outcome. Then, for every agent there does not exist a coalition such that strictly prefers to the fraction of her own coalition .

This observation gives rise to the following algorithm. First, we guess a subset of precisely the fractions that occur in one same-type-envy-free outcome of the game. Then, for each , we determine the set of all agents for whom is the most preferred element of . If for each , the set includes red agents and blue agents for some positive integer , we create rooms of fraction consisting of exactly the agents from ; if for some fraction in this is not the case, we reject the current guess of . If all guesses are rejected, there is no same-type-envy-free outcome. ∎

## 8. Parameterized Analysis

In Section 3, we saw that fixing the size of the rooms to has a significant impact on the complexity of finding stable outcomes. Motivated by this result, as well as by Theorem 7.4, in this section, we study the parameterized complexity of the roommate diversity problem with respect to parameter . This is a promising parameter, since in most of our hardness reductions we converted an anonymous hedonic game with agents into an instance with room size ; it is also appealing because in practice the room size can be much smaller than the number of agents. Indeed, most of the algorithmic problems considered in this work turn out to be in FPT with respect to . We start by considering (strong) core stability.

###### Theorem 8.1 ().

The problem of determining whether an instance of the roommate diversity problem admits a (strongly) core stable outcome is fixed-parameter tractable with respect to the room size.

###### Proof.

Throughout the proof, we focus on finding core stable outcomes; in the end, we will comment on how to modify the proof for strong core stability.

As every agent is fully characterized by her preference relation and type, both the number of different red agents and the number of different blue agents can be upper-bounded by . Let (respectively, ) be an enumeration of all possible preference relations of red (respectively, blue) agents. Then, an instance of our problem can be fully described by a -tuple , where (resp., ) denotes the number of red (resp., blue) agents with preference relation (resp., ).

Now, we need a concise encoding of outcomes that enables us to check whether a given outcome is core stable. For a given outcome, let (resp., ) denote the number of red (resp., blue) agents with preference relation (resp., ) in rooms with red agents. Moreover, given and , let (resp., ) denote the number of red (resp., blue) agents who strictly prefer a room with red agents to their current room:

The values of these variables determine whether an outcome is core stable: for example, there exists a blocking coalition with three red agents if and only if and .

Hence, to decide whether an instance admits a core stable outcome, it is sufficient to check whether there exists an assignment to the variables and

inducing an outcome for which no blocking coalition exists. We formalize this problem as an Integer Linear Program (ILP) and use the fact that it is possible to solve an ILP with

variables and input length in time (Lenstra Jr, 1983; Kannan, 1987). To build the ILP, for each , we define an additional variable denoting the number of rooms with red agents. The intuition detailed above results in the following collection of constraints:(1) | ||||

(2) | ||||

(3) | ||||

(4) |