# Assigning Candidate Tutors to Modules: A Preference Adjustment Matching Algorithm (PAMA)
## 4 The Preference Adjustment Matching Algorithm (PAMA)
### The PAMA Logic
This feature allows institutions to prioritize modules that are difficult to staff, particularly those in specialized topic areas requiring relevant experience. The path-dependent character of PAMA then provides institutional administrators with beneficial slack, enabling them to make pivotal modules of necessary low-resource pools of good candidates a priority while maintaining the algorithm's necessary fairness specifications. ```
Input: tutors' preferences, modules rankings, modules capacity Output: assignments while True: # rounds of running for each module in modules: if module is full or has no more candidates: continue # Skip module for each tutor in module's rankings list: if module is full: remove module from tutor's preferences elif (assigned_slots + pending_slots) = module.capacity: Skip tutors until you find top-preference tutors equal to pending slots. remove module from preferences of remaining tutors elif module has available slots: if tutor is the module's top choice: assign tutor to module remove tutor from all other modules' rankings lists remove all other modules from tutor's preferences else: mark slot as pending if no new assignments or preferences updates occurred: handle deadlock() if still no new assignments or preferences updates occurred: break # Terminate return assignments
```
#Deadlock Handling Procedure with example of two different policies handle deadlock() #Policy 1: Module Priority for each module in modules if module is not full and there are remaining candidates: assign tutor to module (regardless of his/her preferences). remove tutor from all other modules' rankings lists. remove all other modules from tutor's preferences break # Handle only the first deadlock ```
#Policy 2: Tutor Priority for each module in modules if module is not full and there are remaining candidates: find the high-ranked tutor's 1 st preference assign tutor to module of his 1 st preference remove tutor from all other modules' rankings lists. remove all other modules from tutor preferences break # Handle only the first deadlock
```

**Scheme 1. ** Preference Adjustment Matching Algorithm's Pseudocode. The deadlock state, while it initially seems problematic, actually provides administrators with valuable flexibility in tutors' assignments. It serves as an indicator of special situations requiring administrative decision making. Universities can choose from various strategies to automatically resolve deadlock(s) based on their priorities. Options may include (a) forcibly assigning pending tutors to prioritize module rankings, (b) giving absolute preference to tutors' first choices even if it means assignment to different modules, (c) keeping current assignments for already contracted tutors if they remain eligible, and (d) other policies. This flexibility allows institutions to tailor their approach to deadlock(s) according to specific policies or circumstances, turning a potential problem into an opportunity for decision making in the assignment process. ### Analyzing the Algorithm Time Complexity

The primary loop iterates while a condition remains true. This condition is related to the existence of unassigned modules or tutors with preferences. The loop continues until no more changes are made to the assignment's list and the tutors' preference list during two consecutive rounds. To estimate the time complexity of the algorithm, we will break down the inner loops and operations:

1. Module Iteration: For each module, a linear scan of its rankings list is performed. Operations within this loop involve constant-time operations like checking module capacity, removing modules from tutor preferences, and marking slots as pending. 2. Tutor Iteration: For each tutor in a module's rankings list, constant-time operations are performed, such as checking the tutor's preference for the module, assigning the tutor to the module, and removing modules from the tutor's preferences. 3. Deadlock Handling: Deadlock handling can involve complex algorithms, but it is typically a one-time operation or a rare event.