Search Algorithms for a System of Different Representatives of Subsets of a Finite Set

The paper considers various aspects and approaches regarding the search for a system of differenrt representatives ( SDR ) of subsets of a finite set. Algorithm 3 has been developed, which is an algorithmization of the search process for SDR on the basis of Hall's theorem on the existence of SDR . Algorithms 1-5 for searching for partial and complete SDRs based on the technology for solving problems of the transport type, in particular, the algorithm associated with the construction of cycles, are given. SDR search algorithms can be used as auxiliary tools for solving combinatorial problems. It is also shown, conversely, that the search for SDR can be considered as a combinatorial optimization problem.


Introduction
Let S be a non-empty finite set,  . An SDR for any subsequence of the sequence M is said to be partial.
The need to construct a system of distinct representatives (SDR) arises both in purely combinatorial mathematical studies and in their applications to linear programming, mathematical economics, and combinatorial optimization (Hall, M. 1967;Wilson R. 1972;Brualdi, RA. 2009;Jukna S. 2011;Morris, J. 2023). Within the framework of combinatorial mathematics, SRPs are mainly used in solving problems of choice and optimization, in particular, in studying Latin rectangles, in the assignment problem, and in studying special matrices with non-negative elements. At the same time, the analysis of studies on SDR shows that the task of developing SDR search algorithms, especially algorithms that build SDR with certain properties, is relevant. In this regard, the algorithms 1-5 presented in the paper can be useful. Let us give examples of practical interpretation of SDR: a) There are m commissions in some institution. It is required from the composition of each commission to appoint their chairmen so that no one person presides over more than one commission. Here the SDRs of the commissions will be composed by their chairmen (Lipski W. 1982;Rybnikov, K.A. 1985); b) There are n vacancies in the company, each of which requires a certain qualification. There are m people who apply for n jobs. What is the largest number of vacancies that can be filled from the pool of applicants, if the vacancy can only be filled by a person corresponding to his qualifications. In this problem, the interesting question is the largest number of jobs that can be filled by qualified candidates and the specific assignment of the largest number of applicants to the jobs they apply for; c) Suppose we are given a set of hours per week, a set of n teachers, each of whom has the opportunity to teach during some subset of hours, a set of m classes, each of which has only a few hours per week in the schedule, and an nxm matrix of non-negative integers numbers, in which the (i,j)-th element means the number of hours during which the i-th teacher must teach in the j-th class. It is required to determine whether it is possible to schedule lessons and distribute teachers in such a way that each class met at the required hours, each teacher could be in his classes, there would be only one teacher per class and no teacher would be assigned to two classes at the same time.
In problems of type a)-b), it is required to determine a complete system of different representatives or a partial system, but with the maximum number of representatives. When studying the problems associated with SDR, the practical issue of algorithmization of the process of searching for such systems is relevant. , , . s s s The idea of replacing sets with their representatives turned out to be fruitful and was further developed. Systems of representatives are singled out taking into account the conditions of the tasks or the goals of theoretical generalizations. For example, task research about splitting sets, led to the concept of systems of common representatives. Such a problem, like many other problems of combinatorial optimization, reduces to the problem of finding an SDR for subsets of a finite set.

Criteria for the Existence of SDR a Family of Subsets
With search SDR the following questions are solved: is there a complete SDR for a given family of subsets of a finite set (a partial SDR always exists because subsets are non-empty); how to determine the maximum (by the number of subsets) system of representatives. Further, we assume that 1 2 , ,..., k S S S are subsets of a finite sets S={1,2,3,…,n}. If the total number of sets is finite, and the sets themselves are infinite, then we can discard all elements except n in each i S , i=1,…,k. The existence of an SDR can be established by the following criteria a)b).
a) The first criterion follows from Hall's theorem.
are such that neither is part of the other. In this case, for these sets, there exists an SDR.
Each of the criteria allows us to conclude that subsets have SDRs, but not about their definition. Therefore, such criteria are used, one might say, at the stage of preliminary information processing. The question of searching for a complete or partial SDR is solved by special methods of combinatorics or graph theory. Let us consider some of these algorithms for searching for partial or complete SDR, preferring to present them in a more natural combinatorial interpretation.

Algorithms for Constructing SDR
The subsets i S of the set S are represented by the matrix C. Each row corresponds to one subset. As a demonstration example of the operation of algorithms, we note that for the set (1)  In the description of the following search algorithms for SDR such a matrix form of representation of subsets i S , i=1,…,m, from a finite set S={1,2,…n} is used, which is more consistent with the formulation of criteria in combinatorial form.

Algorithm 1. Alternate choice of representatives of sets.
The choice of set representatives is carried out in turn, looking at the rows of the matrix C from left to right.
The first non-zero element 1 j s of the first row and j of the column will be a representative of the set 1 S . Cross out the first row and column j; b) Go to the next uncrossed line i. The first non-zero and not crossed out element of row i will be a representative of the set i S ; c) Repeat step b) as far as possible in order to determine the representatives of the sets. If there is no representative for i S on some i, i≤n, then the search process stops and we get a partial SDR.
Such a method in many cases can reveal the full SDR. However, it may happen that in the presence of a complete SDR for the sets i S , by Algorithm 1 we can determine only a partial SDR. The volume of such a system depends on the order of viewing the sets i S .

Algorithm 2. Search for SDR. taking into account the number of elements in subsets
1) Find all rows i containing only one positive element. Each such element will be a representative of the set i S , and the corresponding row i and column j of the matrix C are crossed out; 2) Find all columns j containing only one positive element. Each such element from row i will be a representative of the set i S , and the corresponding row i and column j of the matrix C are deleted; 3) If representatives for all sets are determined, then the process ends; 4) If there are uncrossed rows or columns, then the numbers i k and j k are determined: i k is the number of uncrossed out elements in the i-th line, j k is the number of non-crossed-out elements in the j-th column; 5) 1 k and 2 k are defined as the minimum of i k and j k , respectively; 6) If 1 k ≤ 2 k , then a row containing 1 k elements is selected, one of the elements is selected, and the row and column are crossed out; 7) If 1 k > 2 k , then a column containing 2 k elements is selected, one of the elements is highlighted, and the row and column are crossed out.
All selected elements at the end of the algorithm constitute the SDR, which can be full or partial. For an example with matrix (2) Algorithm 2 can be used as an auxiliary algorithm in more complex algorithms that always determine a complete SDR. (if such a system exists) or establish that such a system does not exist for given subsets of a finite set.

Algorithm 3. Search for SDR using Hall's theorem
At the beginning of Algorithm 3, Algorithm 1 is applied. The sets 1 , , n S S  are considered to be numbered and fixed in a certain order. The process of searching for representatives is carried out in turn, starting from the first set and up to the set k S . If k is equal to n, then we get the full SDR. If k<n, then this means that all elements of 1 k S  are representatives of other sets. In such a situation, the SDR search process is not stopped. The possibility of the existence of an SDR is clarified, in particular, the existence of a representative for the set 1 k S  . This part of Algorithm 3 requires the algorithmization of the process of further search for SDR. A sequence of sets 0 T is the initial set, consisting of elements k S , i T is a set consisting of those elements of the set p S whose representative is an element from the set 0 T and not yet used. The elements of the set i T are written to the set 0 T after the elements that have already been used. The process of constructing sets i T continues until some element is found that belongs to some set from 1 , , k S S  with representatives 1 , , k a a  . In parallel, a set Q is constructed, whose elements are the numbers of the sets from which the elements were added to 0 T . With the completion of the construction of the sets 0 T and Q, the SDR is rebuilt and a transition is made to the consideration of the next subset.
For matrix (2), following Algorithm 3, we obtain representatives a={1,3,2,4,7} for the first five sets (represented by the first five rows). For the sixth set, 6 S ={1,2,3}, it is not possible to find a representative, since all its elements are representatives of other sets. However, in this situation, one can also find a representative for 6 S using the following function included in Algorithm 3. Let us compose the initial set 0 T from the elements of 6 S . The corresponding set is Q={6,6,6}. We include element 7 from the first set in 0 T and correct Q. We get 0 T ={1,2,3,7} and Q={6,6,6,1}. After the second adjustment, 0 T and Q are 0 T ={1,2,3,7,5} and Q={6,6,6,1,2}. Now we rebuild the SDR. As a result, a representative is determined for the set 6 S , and in general, for six sets, after the restructuring, we obtain a set of representatives a and a set P of the corresponding numbers of the sets i S , i=1,2,…,6, i.e. a = {3,5,1, 2,4,7}, P = {6,2,1,3,4,5}.
The main part of the SDR reforming algorithm 3 is represented using MatLab (Attaway Stormy, 2019). The function is applied with the following data: the set 0 T consists of t elements 1 k S  that have been used as representatives of other sets; rs=k+1; Q -consists of the numbers of the sets whose elements are included in 0 fprintf('\n SDR is defined for the sets S1,...,S6:'); fprintf('\n a='); for ic=1:k fprintf(' %d',a(ic)); end fprintf('\n P='); for ic=1:k fprintf(' %d',P(ic)); end