The introduction

In life and work, there are often times when resources need to be allocated, such as

  1. I don’t like the gift from the company. I want to exchange it with someone else
  2. Realization of exchange system for on-line egg twister
  3. Job offer selection
  4. College entrance examination filing system implementation

Among them, 1 and 2 belong to unilateral matching, which is determined by unilateral expectation, i.e., “buyer”; 3 and 4 are bilateral matching problems, and the expectation of “buyer and seller” should be considered in the matching process.

Under normal circumstances, we expect to obtain a reasonable and stable distribution result as possible, so as to maximize the overall return.

Lloyd S. Shapley and others proposed a series of stable allocation mechanisms for markets, which made great contributions to the field of game theory and economics, and eventually won the 2012 Nobel Prize in Economics, together with Alvin E. Roth.

background

I wrote earlier about encountering a decision business in a business that is really a matching problem between one set of given objects and another set of given objects:

  • A collection of(a, b, c, d)With the collection(A, B, C, D, E)The final result is multiple groups of one-to-one relationship
  • In the process of matching, many-to-one matching results may occur due to matching errors
  • In order to solve the matching conflict, it is necessary to adjust the matching result to “make every object as satisfied as possible”, that is, to achieve the local optimal state and reasonable resource allocation

In the process of adjusting and matching, the priority of results is considered to achieve the stability of resource allocation. At that time, it was not clear whether the optimal effect could be achieved by doing so. After accidentally learning the concept of “strong core allocation” of resource allocation, it was found that the logic of self-implemented allocation algorithm was the same as that of GS algorithm in the game. Confirm that this method can achieve stable resource allocation at the same time, but also understand the practical algorithm applicable to other allocation scenarios, here I hope to easily introduce to you.

Strong nuclear configuration

Strong core configuration satisfies both individual rationality and Pareto optimal state. The strong core configuration is not only present in the matching, but also unique, and has a defensive strategy, that is, neither a backroom deal nor a lie will make the result better than the strong core configuration.

Pareto optimal

Pareto Optimality, also known as Pareto Efficiency, refers to an ideal state of resource allocation. It is assumed that an inherent group of people and distributable resources change from one distribution state to another state without making anyone’s situation worse. Making at least one person better is pareto improvement or Pareto optimization.

Pareto optimality is that there is no more room for Pareto improvement. In other words, Pareto improvement is the path and method to achieve pareto optimality.

— Baidu Encyclopedia

Algorithm is introduced

Top Trading Cycle Algorithm

The first trading cycle algorithm, proposed in 1974, called TTC algorithm.

This applies to “assign” or “trade” scenarios, i.e. one-sided matching problems.

Problem is introduced into

Some companies give gifts of different colors to employees during the holidays. Employees are not satisfied with the colors after drawing the prizes and want to exchange them with others for a prize they prefer.

For employees, the colors they like are not the same, and perhaps they can get a more satisfactory result by exchanging them with others.

Problem definition

For simplicity’s sake, let’s simplify the problem and define some constraints:

  1. Given employee set E= E1, E2, e3, e4
  2. G=< E1, G1 >,

    ,

    ,
    ,>
    ,>
    ,>
  3. Only when all parties involved are satisfied
  4. You don’t have to exchange with others

TTC algorithm steps

  1. Rank each employee’s satisfaction with each gift
  2. The employee proposes the most satisfactory present, and establishes a line between the employee and the desired gift, and a line between the gift and its owner
  3. Find if the established edges form loops that allow self-loops, possibly multiple loops
  4. Employees in the loop exchange gifts and stop participating in the exchange
  5. The rest of the staff removes the list from the loop, continues to suggest the current most satisfying gift, and iterates through the loop
  6. The exchange is complete. End

Case presentation

Table based on satisfaction, sorted by satisfaction from high (left) to low (right), and established digraph

< E1, G3 > forms a loop with <e3, G1 > to make a trade and leave

<e2, G4 > and <e4, G2 > form a loop, make a trade and leave, all trades are completed

The core idea of the algorithm is to form an exchange cycle according to the current priority order. The employees who reach a consensus exchange gifts with the present first and leave, and the remaining employees continue to try to form an exchange cycle after removing the present which has left from the satisfaction table.

Problem solving

TTC has some characteristics:

  1. Every iteration must have a loop, even if it’s self-loop
  2. Multiple loops must never intersect because each node has only one outgoing edge
  3. The gift you can exchange must be as good as the one you already have, because at worst it will create a self-fulfilling cycle

Although we usually exchange company gifts using TTC algorithm, but generally there are not enough candidate trading pool and certain rules, the final result may not be optimal.

supplement

TTC algorithm can obtain strong core configuration, strong core configuration is anti-strategy, lying or private transaction will not make the result better.

Make a simple proof that is not rigorous:

  1. For employees who made a successful first deal, lying or making a private deal only made it worse, because they already had the best deal
  2. Employees who succeed in the second round of trading, no matter how their satisfaction ranking is, can not change the cycle of trading success in the first round, so they are not likely to get better; Private deals also hurt the overall picture
  3. And so on the third round

Gale-Shaply Algorithm

Gel-shapley Algorithm, also known as Deffered Acceptance Algorithm, was put forward in 1962, called GS Algorithm or delayed Acceptance Algorithm.

This applies to “pairing” scenarios (not necessarily one-to-one), i.e. bilateral matching problems.

Problem is introduced into

Job hunting is a two-way selection process. After the company recognizes the applicant and issues the offer, the applicant compares the offer in hand and makes a judgment to accept or reject it. For job seekers, the offer obviously needs to select the best result based on multiple considerations; For the company, the positions are limited, so the higher the employee is in the company’s ability evaluation, the better. Both parties hope to maximize the benefits from this matching, so which offer/receiving strategy can maximize the overall benefits, namely pareto optimal?

Problem definition

Also for simplicity, define some constraints:

  1. Given the set of companies C=c1, C2, C3, c4
  2. Given the candidate set E= E1, E2, e3, e4, apply for each company in C
  3. Each company accepts only one candidate and each candidate accepts only one offer

GS algorithm steps

  1. Each company ranks the satisfaction of each candidate, and the candidate ranks the satisfaction of each company’s offer
  2. Each company gives priority to the candidate at the top of the list, and if rejected, moves on to the next candidate
  3. Instead of making a decision immediately after receiving an offer, job seekers wait for other offers to be received and compare, only keeping the most satisfactory offer and rejecting the others
  4. The calculation process is: Party C sends a round of offer-> Party E makes a decision -> Party C sends a round of offer-> Party E makes a decision……
  5. When all decisions remain unchanged, the assignment ends and the candidate accepts the offer

Case presentation

The table of satisfaction ranking of Party C and Party E and the first round of offer distribution, where N and M represent the company’s ranking of applicants (left) and applicants’ ranking of the company (right)

E1 obtained two offers and rejected c2’s offer by comparison

C2 sent an offer to the next candidate E4, who rejected c4’s offer through comparison

C4 offers the next candidate E2, who rejects c3’s offer by comparison

C3 sends an offer to the next candidate E1, who rejects c1’s offer by comparison

C1 sends an offer to the next candidate E2, who rejects c1’s offer by comparison

C1 sends an offer to the next candidate e3, at which point the match reaches a stable state

After reaching a steady state, resources are maximized.

The core idea of the algorithm is that the active party (Party C) applies for matching according to the priority, while the passive party (Party E) makes comparison according to the priority, only retains the most suitable matching application and finally makes a unified decision, and finally achieves stable matching, so it is called “delayed acceptance”.

Problem solving

The GS algorithm is proved not to run in an infinite loop, and the final state will reach a stable matching state. This is easy to understand, since any company offers offers to people who don’t repeat and move further and further down the list, in the worst case n^2 times, and other proofs are mentioned in the references.

Of course, the actual situation is affected by the number of positions, offer period, offer time and so on, the issue will become much more complicated, but the core remains the same.

When you think about it, isn’t this almost always the way we make decisions when we actually send/receive offers? This shows that the delayed acceptance algorithm is indeed a good choice to maximize the interests of all parties in the long-term game between labor and capital, and has also withstood the test of the market.

In the most ideal state, all C party unified offer, E party unified accept/reject, can maximize the overall interests. However, for the initiative companies with weak competitiveness, their own needs may not be well met, so the offer decision time is short (if the decision is not allowed to be delayed, please refer to the secretary problem), and the offer is sent in advance to snatch people, which leads to the unstable and unreasonable allocation of overall resources, and even vicious competition.

supplement

Interestingly, as for the case data given above, it can be found that none of the applicants got the most satisfactory offer, and the employees recruited by each company were not the most satisfied either, such as the best E1 applicant and C4 company. Can’t help it, you’re doing so poorly with your favorite company/employee? This suggests that matching may be more important than matching. (Also applies to object finding scenarios)

In the following scenarios, the final results of GS algorithm are different from those initiated by party C and party E. Stable matching initiated by C has better results for C; The E is the exact opposite. So try to take the initiative in such matching scenarios, and you may get better results. (This also applies to object finding scenarios, HHH)

GS algorithm has anti-strategy for the active party.

conclusion

Under the premise of no increase or decrease of resources, the stable matching theory only rearranges and combines existing resources so that all parties can reach a relatively satisfactory state and the overall optimization can be achieved. These theories have been widely used in the fields of college admission, school allocation, organ donation exchange, job allocation and so on. There should also be many application scenarios in the field of computer, where matching problems are common.

The resources

SF2972: Game theory – www.kth.se

Gail Shapley algorithm – Baidu Encyclopedia

Zhang Weidong, Huang Chunhua. Research Progress of Bilateral Matching Theory and Its Application

Stable Matching- Stable Matching problem – rubber big stuttering Blog

This article moves my blog, welcome to visit!