Solving a Complex Problem with a Mathematical Resolution Engine


One of our projects this year was geared at optimizing internship placements for pharmacy students.

The Problem

Every year, several hundred pharmacy students must complete an internship as part of their classes. These internships are completed in health-care facilities, under the supervision of a licensed pharmacist.

Internship Data

  • List of students.
  • List of classes students are registered for.
  • Internship periods (one week).
  • Cities where internships are offered, including distance from university.
  • Students’ regional preferences.
  • Types of facilities.
  • Pharmacists’ availability (per class, per period and per quarter).
  • Break weeks.
  • Conflicts and non-traditional study programs.


Students and placements had to be matched up according to the following parameters:

  • Students in conflict with a facility could not be assigned to this facility.
  • Students in conflict with a supervisor could not be assigned to this supervisor, or to any facility where the supervisor is working.
  • Supervisors could not have more than one intern, since one supervisor could work at several different facilities..
  • Students could not be assigned to the same facility more than a set number of times.
  • Manually-assigned internships had precedence.
  • Students could not be assigned to an out-of-town internship more than a set number of times, unless their own preferences indicated otherwise.
  • Students in certain exceptional situations had to be assigned to their preferred internship.

The Purpose of optimization

Mathematically resolve an internship assignment problem with 600 students divided into cohorts and registered for several classes at a time, and 1,000 facilities with licensed pharmacists. This work was being performed by one person full-time, with no guarantees as to the observance of all rules or the optimal assignment of internships. A mathematical model was required to achieve the following goals:

  1. Place as many students as possible while respecting all the parameters.
  2. Accommodate student preferences as much as possible (optimal assignments).

The Solution

1. Modeling the Variables

The problem was modeled as a multi-dimensional table that would be readable by the mathematical resolution engine. With each cell in the table representing one variable, the number of combinations of variables was in the millions.

Each one of the following variables represented one dimension:

  • Students.
  • Facilities and pharmacists.
  • Classes.
  • Weeks.

2. Modeling the Parameters

A system of “penalties” was adopted and calculated for each student-internship combination. The penalty value was a function of the suitability of the student-internship combination, where the ideal internship, with all parameters respected, had a penalty value of 0. Assigning an internship in a city outside of a student’s preferences had a lesser penalty than not assigning an internship at all.

For example, placing a student in their fourth-choice internship carried a certain penalty; placing the student entirely outside of their preferences carried a heavier penalty, and not placing them at all carried the heaviest penalty. The overriding consideration was therefore to place every single student.

3. The Resolution Engine

  • The engine started by eliminating impossible and trivial combinations in order to make the model as small as possible.
  • The engine then looked for the optimal combination of students and internships, finding several potential scenarios and presenting the best options, with the lowest total number of penalties.

The challenge for the programmer was to obtain a model that would be easy to read by the engine and that would be small enough for the engine to calculate the potential solutions as quickly as possible.


A well thought-out model and the right engine allowed university staff to assign over 1,000 internships in just a few hours, while allowing them to run several different scenarios and to adapt to scenarios with a dearth of internships. The time saved in this way allowed staff to turn their efforts to managing exceptional cases and following up on internships.

[Illustration Ivan T, licence CC by 2.0.]