OPTIMALLY STABLE MATCHINGS FOR RESOURCE ALLOCATIONS

The stable marriage problem (SMP) and its variants have received much attention in the literature due to their wide range of applications. One of their applications is resource allocation in network environments. In this paper, we consider two resource allocation problems. The first one is to maximize the performance of a system in the fog computing environment while maintaining a low cost. In the problem, the resource allocation task will be rewritten as the MAX-SMTI variant (i.e., finding the maximum cardinality stable matching of the stable marriage with ties and incomplete lists). It is then formulated under an integer linear program to solve. The best allocation can then be chosen to be the lowest cost one among stable matchings. In the same manner, another variant called MAX-HRT (i.e., finding the maximum cardinality stable matching of the hospital-residents with ties) is applied for the second application regarding the virtual machine allocation. By using MAX-SMTI and MAX-HRT models which are solved via integer linear programs, we aim to not only find stable matchings for the resource allocation problems but also maximum length matchings. Consequently, a maximum number of user requests should be served at a time. The models are implemented in C++ using the SCIP solver. Numerical experiments are conducted for large datasets and results are given to show the efficiency of the models.


INTRODUCTION
The stable marriage problem (SMP), introduced by Gale and Shapley [6] in 1962, is a wellknown problem where we are given a set of people and each of them ranks others in strict order of preference, saying the desired levels that the person wants to match up with. A stable matching of the problem is a pairing such that there is no blocking pair in the matching. Two people form a blocking pair if they prefer each other than their current partner in a considering matching. Gale and Shapley in [6] also presented a linear-time algorithm for finding a stable matching. In some situations, it is requested that every person needs to give a preferred level over all the others, meaning that its preference list can be incomplete. This is the stable marriage problem with incomplete lists (SMI). On the other side, a person can rank equally a set of people, since he/she cannot decide a strict order preference among these people. In this case, the preference lists of the problem can include ties, giving another variant of SMP that is the stable marriage with ties (SMT). When both incomplete lists and ties are allowed in a problem, we have the problem with ties and incomplete lists (SMTI). It is not difficult to find a so-called weakly stable matching of a given instance by breaking all the ties and then applying a modified Gale and Shapley's algorithm. Since there are many ways to break the ties, many weakly stable matchings can be found in different sizes. It is natural to find a weakly stable matching of maximum cardinality (MAX-SMTI). This problem is NP-hard [15]. Some approximate algorithms proposed for the problem can be found in [12,16]. The local search approach was studied for this problem, as given in [7,8,17,21]. However, these methods will be challenged when considering variants with more constraints required in real-world applications. It is well known that integer linear programs have been well studied for a wide range of combinatorial optimization problems, for example, scheduling [26] and matching problems. For dealing with variants of SM problems, in 1989, Gusfield and Irving [9] and Vate [20] formulated linear programming models for SMP and SMI instances. They indicated that stable matchings are exactly extreme points of polytopes presenting the constraint domains. These models are then extended for the MAX-SMTI and HRT [14]. A comprehensive study of mathematical models for the problems has been recently presented by Delorme et al. in [4]. We utilize these models for the resource allocation problems in this paper. They will be reviewed in Section 2. SMP and its variants have shown their important role in a wide range of applications such as the Evolution of the Labor Market for Medical Interns and Residents [19], the Student-Project Allocation problem [1], course timetabling for maximal enrollments [23], and the Stable Roommates problem [5,10]. In the last few years, stable matching problems have been studied in the literature for resource allocation applications. In 2016, Wang et al. proposed a virtual machine allocation based on stable matching in a cloud data center [22]. They adopted a deferred acceptance procedure to handle conflicts among the preferences of virtual machines and physical hosts. Regarding the scheduling of computing and storing the resource in data centers, Chu et al. presented a three-sided stable matching scheme for arranging among computing, storage resources, and applications [3]. They showed stability and the correctness of the proposed algorithm. For the problem of device-to-device (D2D) communication in networks, relays are usually used to reduce the loss in the user data rate. A low complexity resource allocation procedure is required in the relays. Kishk et al. in [13] proposed a centralized method using time-sharing and a distributed low complexity allocation using the stable matching theory. To optimize the energy consumption in mobile devices in the D2D communication, Zhou et al. considered the joint problem of power control and spectrum resource allocation [25]. They first formulated a joint problem as two-dimensional matching between D2D pairs and cellular user equipment. Preference lists are established among two sides of the matching. They then presented an energy-efficient matching algorithm based on Gale and Shapley's algorithm. Other stable matching-based methods for resource allocation can be seen in [2]. Most of the proposed methods slightly extended Gale and Shapley's algorithm. However, due to the deferred acceptance scheme in Gale and Shapley's algorithm, it could not be ensured the optimality of the obtained matching by means of the length of the matching.
In this paper, we consider two resource allocation problems. The first problem is to maximize the performance of a system in the fog computing environment while maintaining a low cost. Recently, a micro-level cost-based method has been introduced by Batulla et al. for this problem [2], which includes two phases. They proposed first a micro-level cost model to estimate the cost of the user participating in fog environments. A resource allocation algorithm based on stable matching is then applied to benefit both users and providers in the environment. They used a modified Gale and Shapley's algorithm for the stable matching problem. In our work, the problem of resource allocation will be stated as the MAX-SMTI variant of SMP. It is then formulated under an integer linear program (ILP) to solve. The best allocation can then be chosen to be the lowest cost one among stable matchings. In the same manner, another variant called the MAX-HRT model is applied for the second application regarding virtual machine allocation. By using MAX-SMTI and MAX-HRT models which are solved via integer linear programs, we aim to not only find stable matchings for the resource allocation problems but also maximum length matchings. Consequently, a maximum number of user requests should be served at a time. The models are implemented in C++ using the SCIP solver. Numerical experiments are conducted for large data sets and the results are obtained.
The rest of the paper is organized as follows. The next section recalls the background regarding ILP formulations established for the related SMP variants. We then describe the resource allocation problem and formulate the ILP model accordingly in Section 3. Experiments will be conducted and discussed in Section 4. Finally, some concluding remarks are given in Section 5.

MAX-SMTI AND MAX-HRT BACKGROUNDS
We now recall the mathematical models for two problems which are MAX-SMTI and MAX-HRT, detailed descriptions can be found in [4]. We keep here all terminologies given in [4] for simplicity. An instance of SMTI consists of a set C of n 1 children and a set F of n 2 families. Each child (family, respectively) ranks a subset of families (children, respectively) in an order of preference, where ties are allowed. Let In the setting of SMTI, as mentioned, we can find different stable matchings with different cardinalities. We aim to find a maximum cardinality stable matching in the MAX-SMTI. Let us denote by:  the set of families acceptable for child i, for .  the set of children acceptable for family j, for .  the rank of family j for child i, defined as the integer k such that j belongs to the k th most-preferred tie in i's list, for ∈ . The smaller the value, the better family is ranked.  the rank of child i for family j, defined as the integer k such that i belongs to the k th most-preferred tie in j's list, for ∈ . The smaller the value, the better child is ranked.  F j ≤ (i) the set of families that child i ranks at the same level or better than family j, i.e.,  C i ≤ (j) the set of children that family j ranks at the same level or better than child i, i.e., Let be the binary decision variables, where x ij = 1 if child i is matched with family j, otherwise x ij = 0. The model for MAX-SMTI is given as follows.
In (P MAX-SMTI ), every agent (family or child) can engage at most a partner. This one is ensured by Eqs. (1) and (2). Eq. (3) is to make sure that there is no blocking pair in the resulting matching.
The HRT problem can be seen as a generalized form of the SMTI problem. In the HRTsetting, each hospital has a capacity to host a number of doctors, we denote by c j , for j = 1, 2, …, n 2 . In the same manner, the model of MAX-HRT is given as (P MAX-HRT ). Constraints (6) and (7) include the term c j to adapt the hosting capacity of hospitals and the blocking pair definition in the HRT problem, respectively.
Here, we replace the term "family" with "hospital", then change F(i), r f i (j), and F j ≤ (i) into H(i), r h i (j), and H j ≤ (i), respectively. Similarly, the term "child" is replaced by "doctor", and C(j), r c j (i), and C ≤ i (j) are changed into D(j), r d j (i), and D ≤ i (j), respectively. We now apply two models given by (P MAX-SMTI ) and (P MAX-HRT ) for the problem of resource allocations in networking environments.

FORMULATIONS FOR RESOURCE ALLOCATIONS
This section considers two use-cases arising in fog computing which are depicted in Fig. 1. Basically, a fog architecture can be composed of three layers, including IoT, fog, and cloud layers [18]. The IoT layer at the bottom is to collect data via sensors. Fog devices are located in the fog layer to store and process streaming collected data, and communicate to the others. The cloud layer plays the role of big data processing which can be performed via a set of virtual machines. The first will deal with the resource allocation problem in a fog layer where we need to allocate necessary resources to respond to user requests at a time. We then consider the problem of virtual machine allocations in the cloud layer in the second use case.

Minimal cost resource allocating in fog computing
In a fog environment, many user devices can be involved. Every user can send requests to be served and fog devices will need to respond to users as providers. It is required to determine suitable resources to serve as many requests as possible so that the cost is minimum, while still keep the benefits of both users and providers. In particular, we first determine how many available providers can meet the user requirements, then decide to accept or reject to serve. If accepting a user request, we need to allocate resources among currently available fog devices so that it fulfills the request while keeping a minimum cost. There are several cost estimation models presented in the literature. A micro-level compensation-based cost model is proposed by Battula et al. in 2019 [2]. After estimating the cost, the authors also presented a stable marriagebased algorithm for resource allocation. We focus on this task by summarizing the problem statement, then formulate the under an ILP form. The method presented in [2] is to match the best-suited resource to all user requests and the available resources. To this end, they used a modified Gale and Shapley's algorithm for the following stable marriage problem.
 Input: a list of user requests denoted by UR, and a list of free devices denoted by fd. The preference of the user list is formed due to the requirements and the capacity of the fog devices.
 Output: a stable matching in the form ⟨UR, fd⟩.
The algorithm first determines available devices which meet the user requirements. It then iteratively performs the matching task as follows. The device fd checks the UR's preference. If df can satisfy the requirement, fd is mapped to the user request. Then it compares the fd's preference with the fog device previously assigned to the user request. If it prefers fd to the assigned one, fd will be assigned to the user request. The algorithm continues to check for all user requests or until all available resources are allocated. This gives a stable matching between user requests and available fog devices but does not shows maximum length ones. We next formulate the problem under an integer linear program for the MAX-SMTI form of the problem. As such setting of a stable marriage problem, we now formulate it under an ILP form for efficiently solving. Let I be an instance consisting of and . We use the binary decision variable x i,j to express an acceptable pair in I which is formed by a user request ur i and a fog device fd j , for i = 1,2,...,n 1 and j = 1,2,...,n 2 . x i,j indicates that either ur i can be matched with fd j or not. If x i,j = 1 in a matching x, ur i is matched with fd j , otherwise ur i is not suitable for fd j . Let rank(ur i ,fd j ) be the rank of fd j in ur i 's preference list. We define rank(ur i ,fd j ) to be k + 1, where k is the number of fog devices that ur i prefers to fd j . For fds, all user requests in fd j 's preference list are equally preferred. We also note that rank(ur i ,fd j ) = rank(fd j ,ur i ) = ∞ for an unacceptable pair (ur i ,fd j ). For each pair (ur i ,fd j ), we also define and Applying the model given by (P MAX-SMTI ) results in the ILP model for the resource allocation as shown in (P RA ).

Virtual machine allocation
This section considers a virtual machine allocation problem in the cloud layer depicted in Fig. 1. We use the scenario given in [11] as our case study, which is briefly described as follows. Let us consider a cloud data center consisting of physical servers with different resource capacities. At a time, a number of users send requests to virtual machines. The system needs to determine all possible servers which are available to serve, then perform to allocate virtual machines to the best suitable servers.

Let
be the virtual machines, be the sever in the cloud. The capacity of ∈ is denoted by , for . Each virtual machine ∈ ranks the servers in an increased order of transmission costs, which is computed by where ( ) denotes the transmission cost, is the server which is residing, is the hop distance from to , and is the bandwidth between and . We also note that ties in the preferences of virtual machines are allowed due to the equal transmission costs. Similarly, each server ∈ also ranks the virtual machines in increasing order of migration overhead, defined by where, denotes the VM disk image size in bytes [24]. Let be the binary decision variable, indicating whether virtual machine is assigned to the server . Replacing the roles of H and D in (P MAX-HRT ), by S and V, respectively, we obtain the following equation for the virtual machine allocation.
It differs from the algorithm proposed in [11] that (P VM ) finds not only a stable virtual machine allocation but also the maximum length matching in the resulting allocation. This consequently helps to improve the performance of the system.

EXPERIMENTS RESULTS
In this section, we concentrate on the task of resource allocation for a given number of user requests and free fog devices. Unlike in [2], our method aims to respond as maximum as possible requests. Furthermore, we also conduct experiments for large data sets which can be randomly generated. One of the methods which can be used to generate random SMTI instances was given in [8]. Our models were implemented in C++ using SCIP 1 for ILP solutions and run on the Ubuntu platform, CPU Intel Core i5 -3320M 2.60GHz, 2456 MHz, 2 Cores, and 8GB RAM. In all experiments, we used the default setting of the SCIP solver. In this setting, for solving relaxed linear programs, SoPlex is used. It performs first some preprocessing steps to reduce the size of the problem before applying the simplex algorithm, such as reducing the singleton rows and detecting the linear dependencies. For branching and cutting steps, the branch rule was applied to create two subproblems by splitting a single variable's domain, while the cutting plane separation method is used.   Table 1 shows the experiment results for several data sets of an equal number of user requests and free fog devices. The sizes of data sets are 100, 200, 300, 400, and 500. For each data set, we tested for three different limited lengths of the preference lists which are 10, 30, and 50. We report here the results of matching numbers and runtime. Generally, smaller numbers of URs and fds get better matchings, even when the preference list length is small. When the preference list length is 50, most of the cases obtain more than 80 % of user requests matched (see Fig. 2). This indicates that ILP models for solving the MAX-SMTI based resource allocation are useful.
Regarding the execution time, as shown in Fig. 3, it takes about a second to complete pairing URs and fds for the preference list length of 10, for all the sizes from 100 to 500. This is acceptable to obtain maximum cardinality matchings. Naturally, the execution time is increased as the preference list length gets higher.   Figure 4 shows the execution times for larger data sets. It indicates that when the size of URs and fds is large, the time grows quickly for completing the matching. This is because of the time required for solving large ILP models. However, we also note that the models we are using in this work are in basic forms. We have not yet exploited any properties of stable matching structures of given SMTI instances which can help to eliminate unnecessary blocking pairs during searching. Consequently, it can help to have better ILP formulations for quickly obtaining solutions. This has been shown in [4], where the authors introduced some pre-processing tasks for such eliminations. On the other hand, they also improved ILP models by reducing the number of non-zero elements and used alternative stability constraints. Computational results showed that the execution time is significantly reduced for those hard variants of SMPs. It is straightforward to apply these techniques in our work to improve performance. Table 2. Results obtained when the number of requests is greater than that of free devices. Figure 5. Successfully pairing ratio compared between two cases of |URs| = |fds| versus |URs| > |fds| with respect to the user request.
We next perform experiments for the case of unequal numbers of user requests and fog devices. We consider here percentages of successfully pairing in both user requests and free fog devices. Table 2 shows the results obtained. It can be observed that for all data sets, the ratio of successfully pairing in the fog device side is higher than that on the user side. This is because of the smaller number of free fog devices which are available to serve the user requests. For the same reason, on the other hand, the ratio of successfully pairing is lower when compared with that given in Table 1 (see also Fig. 5 for a comparison we plotted for the case of limited preference list length of 50). All of these show the correctness of the proposed method.

CONCLUSIONS
The paper studied an approach to use stable marriages for the resource allocation problem in some modern networking environments. We considered two basic problems that are device allocations for user requests in the fog and virtual machine allocation in cloud computing layers of an IoT architecture. We aim to address the problem for not only large datasets but also as maximum as possible pairing number of obtained matchings. The experimental results for large data sets show the correctness as well as the usefulness of the proposed approach. The ILP models used in this work are given in the basic formulation of MAX-SMTI and MAX-HRT. This can be improved using the structural feature of the stable matchings as well as applying a better formulation of ILP forms. This will be another content in the next work to have a comprehensive study in this application of SMP.