# Assigning Candidate Tutors to Modules: A Preference Adjustment Matching Algorithm (PAMA)
## 4 The Preference Adjustment Matching Algorithm (PAMA)
### The PAMA Logic
We can consider it as a constant-time operation for simplicity. The worst-case time complexity of the algorithm can be approximated as \(\mathbf{O}(\mathrm{M}*\mathrm{T}*\mathrm{P})\), where

M is the number of modules. T is the average number of tutors in a module's rankings list. P is the average number of modules in a tutor's preferences list. The actual performance can vary significantly based on the specific input data and the implementation details. By carefully considering the data structures, algorithms, and optimization techniques, it is possible to achieve practical and efficient solutions for this problem. ### Mathematical Definition

To define the mathematical framework of the algorithm, we introduce the following preliminaries:

\(\mathrm{M_{i}}\) represents module \(\mathrm{i}\), where \(\mathrm{i}\in\{1,2,\ldots,|\mathrm{M}|\}\), and \(|\mathrm{M}|\) is the total number of modules. \(\mathrm{T_{i}}\) represents the ordered set of tutors ranked for potential assignment in module \(\mathrm{i}\), a list for module \(\mathrm{i}\), based on their suitability score, where \(\mathrm{T_{i}}=\{\mathrm{t_{i}}|\mathrm{j}\in\{1,2,\ldots,|\mathrm{T_{i}}|\}\}\) with \(|\mathrm{T_{i}}|\) being the number of tutors ranked for module \(\mathrm{i}\). Tutors are ranked in descending order for each specific module. The total set of tutors across all modules represents the unique set of tutors, defined as \(\mathrm{T}=\cup_{\mathrm{i=1}}^{|\mathrm{M}|}\mathrm{T_{i}}\), where \(\mathrm{T}\) is the set of all distinct tutors, and it holds that \(|\mathrm{T_{i}}|\leq|\mathrm{T}|\) and \(\sum_{\mathrm{i=1}}^{|\mathrm{M}|}\mathrm{T_{i}}\mathrm{j}\geq|\mathrm{T}|\). \(\mathrm{s_{i}}\) represents the capacity (available slots) of module \(\mathrm{i}\), where \(\mathrm{s_{i}}\in\mathbb{N}\backslash\{0\}\). \(\mathrm{pr_{ji}}\) denotes the preference score of tutor \(\mathrm{j}\) for module \(\mathrm{i}\), where \(\mathrm{pr_{ji}}\in\mathbb{N}\backslash\{0\}\). \(\mathrm{P_{j}}\) denotes the total number of modules preferred by tutor \(\mathrm{j}\), where \(\mathrm{P_{j}}\subseteq\{1,2,\ldots,|\mathrm{M}|\}\). \(\mathrm{P_{ji}}\) is a binary variable indicating whether tutor \(\mathrm{j}\) has a pending slot in module \(\mathrm{i}\), (\(\mathrm{p_{ji}}=1\) if pending, \(0\) otherwise). \(\mathrm{o_{ji}}\) is a binary variable indicating whether tutor \(\mathrm{j}\) has been assigned to module \(\mathrm{i}\), (\(\mathrm{o_{ji}}=1\) if assigned, \(0\) otherwise). \(\mathrm{r}\) denotes the algorithm iteration, where \(\mathrm{r}\in\mathbb{N}\). To ensure consistency, we impose the following constraints: 1. **A tutor can either be assigned or remain pending for a module, but not both**: \[\mathrm{o_{ji}}+\mathrm{p_{ji}}\leq 1\ \forall\,\mathrm{j}\in\{1,2,\ldots,| \mathrm{T}|\},\ \forall\,\mathrm{i}\in\{1,2,\ldots,|\mathrm{M}|\}\] 2. **A tutor can be assigned to at most one module**: \[\sum_{\mathrm{i}=1}^{|\mathrm{M}|}\mathrm{o_{ji}}\leq 1,\ \ \forall\,\mathrm{j}\in\{1,2,\ldots,| \mathrm{T}|\}\] 3. **A tutor can hold a pending status across multiple modules**: \[\sum_{\mathrm{i}=1}^{|\mathrm{M}|}\mathrm{P_{ji}}\geq 0,\ \ \forall\,\mathrm{j}\in\{1,2,\ldots,| \mathrm{T}|\}\] Given these preliminaries, the mathematical framework of the PAMA algorithm is defined in the following stages: 1. **Initialization** * Set iteration counter \(\mathrm{r}=0\) * For each module \(\mathrm{i}\), set the initial capacity \(\mathrm{s_{i}^{(0)}}=\mathrm{x_{i}}\), where \(\mathrm{x}\) is a positive integer indicating the available slots for module \(\mathrm{i}\) (\(\mathrm{x}\in\mathbb{N}\backslash\{0\}\)) 2. **Iterative procedure** \[\forall\,\mathrm{r}\in\mathbb{N}\backslash\{0\},\ \forall\,\mathrm{M_{i}},(\mathrm{i}\in\{1,2,\ldots,| \mathrm{M}|\}):\] **Step 1: Module Processing Eligibility Check** For each module \(\mathrm{M_{i}}\), * If \(\mathrm{s_{i}^{(r-1)}}\
eq 0\bigwedge\mathrm{T_{i}^{(r-1)}}\
eq\varnothing\), then proceed to the following steps.