Matching applicants to programs is a generalization of the
stable marriage problem; as a result, the solutions are very similar. A simplified version of the algorithm that is used to perform the matching process is described below and on the NRMP website. However, this description does not include the handling of couples (pairs of applicants who participate in a Match together, perhaps to stay in the same geographic location), second-year positions, or special handling of residency positions that remain unfilled. The full algorithm is described in .
Inputs The application process for residency training begins prior to the opening of the Main Residency Match in September. Applications usually are sent to programs through the Electronic Residency Application Service (ERAS), a service of the
Association of American Medical Colleges. After applicants apply to programs, programs review applications and invite selected candidates for interviews held between October and February. After the interview period is over, programs and applicants each compile "rank order lists" that they submit to the NRMP. Programs list applicants, ranked in order from most to least preferred, whom they wish to train. Similarly, applicants rank programs where they wish to train. For applicants matching as a couple, the rank order lists include pairs of program choices that are considered simultaneously by the matching algorithm. Applicants' rank order lists can include a combination of categorical programs (training that is 3–5 years in length and begins in the first post-graduate year); preliminary programs (training that is one year in length and begins in the first post-graduate year); or advanced programs (training that is 3–4 years in length and begins after one or more years of preliminary training). For advanced programs on the rank order list, applicants can append a supplemental list of preliminary programs to attempt to match to a full course of training.
Simple case The matching process begins with an attempt to match an applicant to the program most preferred on that applicant's rank order list (ROL). If the applicant cannot be matched to that first choice program, an attempt is made to place the applicant into the second choice program, and so on, until the applicant is tentatively matched to a program that has an open position and who prefers that applicant or all the applicant's choices on the ROL have been exhausted. This process is carried out for all applicants until each applicant has either been tentatively matched to the most preferred choice possible or all choices submitted by all applicants have been exhausted. Tentative matches then become final. To understand how the current NRMP algorithm works, it is helpful to begin by considering the simpler case where there are no couples or secondary programs. As in the
stable marriage problem, the basic goal is to match applicants to programs so that the results are "stable". "Stability" in this case means that there is no applicant A and program P such that both of the following are true: • A is unmatched or would prefer to go to P over the program to which A matched • P has a free slot or would prefer A over one of the other applicants matched to the program. It can be shown that for any instance of the problem, there is at least one valid solution. Under the old (pre-1995) NRMP algorithm that favored programs' preferences over applicants', programs could benefit in certain cases from lying about their preferences. This is no longer possible under the current algorithm. Applicants cannot benefit by lying about their preferences, even if they have perfect knowledge of everyone's preferences. Under the current system, it also is impossible for an applicant to be harmed by including more residency programs at the bottom of a list if those programs are indeed preferable to not being matched.
Couples Couples' rank order lists are processed simultaneously by the matching algorithm, which complicates the problem. In some cases there exists no stable solution (with stable defined the way it is in the simple case). In fact, the problem of determining whether there is a stable solution and finding it if it exists has been proven
NP-complete. Also, while there is no randomization in the NRMP algorithm—so it will always return the same output when given exactly the same input—different outcomes can be produced by changing trivial features of the data such as the order in which applicants and programs are processed. However, in initial testing of the algorithm over 5 years of residency match data and a variety of different initial conditions, the current NRMP algorithm always terminated quickly on a stable solution. Testing also showed that "none of [the trivial] sequencing decisions had a large or systematic effect on the matching produced"—the maximum number of applicants ever observed to be affected in a single run was 12 out of 22,938. In general ''once the programs' rank order lists have been set
, there is no way for an applicant to match into a better position by deciding to match as part of a couple. For example, if a very strong applicant and a very weak applicant match as a couple, there is no mechanism in the algorithm'' that allows the stronger applicant to somehow improve the desirability of the weaker applicant. (Of course, if the programs know prior to processing the matching algorithm that the stronger and weaker applicant are participating in the Match as a couple, they are free to change their lists accordingly, which could affect the outcome.) == Failure to match ==