Example 11.4 Scheduling

This example is intended for users who prefer to use the SAS DATA step, PROC SQL, and similar programming methods to prepare
data for input to SAS/OR optimization procedures. SAS/OR users who prefer to use the algebraic modeling capabilities of PROC
OPTMODEL to specify optimization models should consult Example 7.1 in Chapter 7: The Mixed Integer Linear Programming Solver, for a discussion of the same business problem in a PROC OPTMODEL context.

Scheduling is an application area where techniques in model generation can be valuable. Problems that involve scheduling are
often solved with integer programming and are similar to assignment problems. In this example, you have eight one-hour time
slots in each of five days. You have to assign four people to these time slots so that each slot is covered every day. You
allow the people to specify preference data for each slot on each day. In addition, there are constraints that must be satisfied:

Each person has some slots for which they are unavailable.

Each person must have either slot 4 or 5 off for lunch.

Each person can work only two time slots in a row.

Each person can work only a specified number of hours in the week.

To formulate this problem, let denote person, denote time slot, and denote day. Then, let if person is assigned to time slot on day , and 0 otherwise; let denote the preference of person for slot on day ; and let denote the number of hours in a week that person will work. Then, you get

To solve this problem, create a data set that has the hours and preference data for each individual, time slot, and day. A
10 represents the most desirable time slot, and a 1 represents the least desirable time slot. In addition, a 0 indicates that
the time slot is not available.

The following DATA step takes the solution data set SOLUTION and generates a report data set named REPORT. It restores the original interpretation (person, shift, day) of the variable names xijk so that a more meaningful report
can be written. Then PROC TABULATE is used to display a schedule that shows how the eight time slots are covered for the week.

Output 11.4.1 from PROC TABULATE summarizes the schedule. Notice that the constraint that requires a person to be assigned to each possible
time slot on each day is satisfied.

Output 11.4.1: A Scheduling Problem

Reported Solution

mon

tue

wed

thu

fri

slot

name

xxx

xxx

xxx

1

bill

marc

xxx

mike

xxx

2

bill

xxx

xxx

bob

xxx

marc

xxx

xxx

3

bill

xxx

xxx

bob

xxx

xxx

marc

xxx

4

bob

xxx

xxx

xxx

mike

xxx

xxx

5

bill

xxx

bob

xxx

marc

xxx

xxx

xxx

6

bill

xxx

bob

xxx

xxx

mike

xxx

xxx

7

bob

xxx

xxx

xxx

xxx

mike

xxx

8

bob

xxx

xxx

mike

xxx

xxx

xxx

Recall that PROC OPTMILP puts a character string in the macro variable _OROPTMILP_ that describes the characteristics of the
solution on termination. This string can be parsed using macro functions, and the information obtained can be used in report
writing. The variable can be written to the log with the following command: