integrating a real-world scheduling problem into the basic algorithms course

22
Integrating a Real-World Scheduling Problem into the Basic Algorithms Course Yana Kortsarts Computer Science Department Widener University, Chester, PA

Upload: gur

Post on 20-Jan-2016

18 views

Category:

Documents


0 download

DESCRIPTION

Integrating a Real-World Scheduling Problem into the Basic Algorithms Course. Yana Kortsarts Computer Science Department Widener University, Chester, PA. The SAP Problem. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Integrating a Real-World Scheduling Problem into the  Basic Algorithms Course

Integrating a Real-World Scheduling Problem into

the Basic Algorithms

CourseYana Kortsarts

Computer Science Department

Widener University, Chester, PA

Page 2: Integrating a Real-World Scheduling Problem into the  Basic Algorithms Course

The SAP Problem The shifts assignment problem (SAP) is a

scheduling problem that commonly arises in work-force management activities

Input: A collection of shifts and work-force requirements

Output: The number of workers to assign to each shift in order to fulfill a pre-specified staff requirements at every hour.

Page 3: Integrating a Real-World Scheduling Problem into the  Basic Algorithms Course

Definitions

Working hours are denoted by 1, 2, . . , n The [i, i + 1] hour is called the i-th hour of the day. The staffing requirement for the i-th hour is bi -

the number of persons needed at work from time i until time i + 1.

A shift Ii is a consecutive integral subinterval

[si, si + 1, . . . , fi] of [1, . . . , n], si < fi

Shift Ii covers a time j: the shift starts at time j or earlier and ends at time j +1 or later.

If Ii covers j we say that j Ii (time j belongs to shift i)

Page 4: Integrating a Real-World Scheduling Problem into the  Basic Algorithms Course

The SAP Problem Solution Defines how many persons xi are going to work

in each shift Ii. A solution is feasible if the number of workers

present at time j is bj - the load bound for hour j (1 j n, 1 i m, m is a number of shifts) :

A feasible solution might not exist.

jIj

i bx

i

Page 5: Integrating a Real-World Scheduling Problem into the  Basic Algorithms Course

Example

First hour is 08 : 00 to 09 : 00 and n = 5. I1=[8:00, 9:00, 10:00] = [1, 2]

I2 = [11 : 00, 12 : 00] = [4]

I3=[10:00, 11:00, 12:00, 13:00] = [3, 4, 5] The load requirements: 4, 4, 5, 8, 5 Solution: x1= 4, x2 = 3, x3 = 5

x2 + x3 = 8

Page 6: Integrating a Real-World Scheduling Problem into the  Basic Algorithms Course

SAP – Integer Linear Programming Problem

Consider shifts Ii as column vectors

A shift Ii (from si to fi ) is represented by a vector that has all 0 entries except the si to fi entries that are 1

Create a 0, 1 matrix A out of all column vectors Ii. A is consecutive 1’s matrix. Let The problem is to find a solution for:

or determine that no such solution exists.

.),..,(),..,( 11T

nT

m bbbandxxx

iZxbAx i allfor,

Page 7: Integrating a Real-World Scheduling Problem into the  Basic Algorithms Course

Example I1=[8:00, 9:00, 10:00] = [1, 2]

I2 = [11 : 00, 12 : 00] = [ 4]

I3=[10:00, 11:00, 12:00, 13:00] = [3, 4, 5]

The load requirements: 4, 4, 5, 8, 5

5

8

5

4

4

100

110

100

001

001

bA

5

3

4

3

2

1

x

x

x

Page 8: Integrating a Real-World Scheduling Problem into the  Basic Algorithms Course

SAP – Integer Linear Programming Problem

SAP is an example of an integer linear programming (ILP) problem.

The integer linear programming problem is NP-hard.

Special case of integer linear programming over a consecutive 1’s matrix admits a simple solution by reduction to the max-flow problem

Page 9: Integrating a Real-World Scheduling Problem into the  Basic Algorithms Course

From SAP to Max Flow Problem Add an all-0 row before the first row to the shifts matrix A

and vector b A is (n + 1) m matrix. n+1 is the number of hours

(including hour 0), the number of columns is m which is the number of shift types.

M is (n+1) (n+1) matrix. M has 1 in the main diagonal, and (−1) in the diagonal immediately above the main diagonal. Other entries are 0.

10..................

11..................

00..................

00...00110

00...00011

M

Page 10: Integrating a Real-World Scheduling Problem into the  Basic Algorithms Course

Multiply the equality Ax = b from the left by matrix M

For 0 i < n row i in A is replaced by the row Ai − Ai+1 and row n does not change.

A is a consecutive 1’s matrix. Matrix M A has exactly two non-zero entries in every column.

M b = B = (-b1, b1 - b2, … bn-1 - bn, bn)T

B = (B1, B2, …Bn), Bi= bi – bi+1

The matrix M is invertible M Ax = B is equivalent to Ax = b

Page 11: Integrating a Real-World Scheduling Problem into the  Basic Algorithms Course

EXAMPLE n = 5 (start: 8:00, finish: 12:00) Shifts: I1=[10:00, 11:00, 12:00], I2=[9:00, 10:00, 11:00, 12:00],

I3 =[8:00, 9:00, 10:00, 11:00, 12:00], I4 =[12:00, 13:00],

I5 = [8:00, 9:00, 10:00, 11:00], I6 = [8:00, 9:00, 10:00]

Work load: 3, 3, 5, 2, 5

5

3

3

2

0

3

001000

001111

010000

100001

000010

110100

5

2

5

3

3

0

001000

000111

010111

110110

110100

000000

bMMAbA

Page 12: Integrating a Real-World Scheduling Problem into the  Basic Algorithms Course

Network Flows A flow network is a weighted connected directed

graph N(V,E) in which each edge (vi, vj) has a nonnegative capacity c(vi, vj)

We also distinguish two vertices in N, a source s and a destination (sink) t

A legal flow f in N is an assignment of a nonnegative real numbers f(e) to each edge e of N that satisfies two conditions: Capacity constraints: For each edge e, 0 f(e) c(e) Flow conservation: For each vertex v in N other

than s and t, the flow into v equals the flow out of it

Page 13: Integrating a Real-World Scheduling Problem into the  Basic Algorithms Course

Define the flow network N(A, b) The vertices of the network are vi, 0 i n

vi corresponds to row (hour) i in the matrix Add a source s and a sink t. The connection of the vertices to the

source/sink are defined via the signs and values of B: Bi < 0: add an edge of capacity -Bi from s to vi

Bi > 0: add an edge of capacity Bi from vi to t

Page 14: Integrating a Real-World Scheduling Problem into the  Basic Algorithms Course

The shifts define the edges between vertices. If shift starts at time q and ends at time p we

add an edge from vq−1 to vp. The edge has infinite capacity.

Each column j of the matrix M·A is represented by the edge ej

Each ej with (M·A)kj = -1 and (M·A)ij =1

goes out of vk into vi

Page 15: Integrating a Real-World Scheduling Problem into the  Basic Algorithms Course

sv4

v2

v5

v0

v3

tv13

2

3

3

5

5

3

3

2

0

3

001000

001111

010000

100001

000010

110100

bMMA

Page 16: Integrating a Real-World Scheduling Problem into the  Basic Algorithms Course

SAP admits a feasible solution if and only if there is a saturating flow in N(A, b): there is a legal flow so that the flow along all edges entering t equals their capacity.

The flow along edges gives the values to be given to shifts: a flow value f(ej) on edge ej corresponds to the choice of xj = f(ej) and vice-versa

Page 17: Integrating a Real-World Scheduling Problem into the  Basic Algorithms Course

s

v4

v2

v5

v0

v3

tv13/3

2/2

3/3

3/3

5/5

6shift

5shift

4shift

3shift

2shift

1shift

edgeon flow

edgeon flow

edgeon flow

edgeon flow

edgeon flow

edgeon flow

0

3

5

0

0

2

20

30

54

40

41

42

vv

vv

vv

vv

vv

vv

x

Solution

2

0

0

05

3

Page 18: Integrating a Real-World Scheduling Problem into the  Basic Algorithms Course

Teaching SAP One of the arguments raised at times by students

of the basic algorithms classes is that the material taught seems to be “detached” from real-world applications. This claim has some foundation.

It seems useful and encouraging to illustrate for the students the power of the algorithms taught in the basic algorithms course through a real-world problem. A concrete application that is important enough for commercial companies to actually write a code for it.

Page 19: Integrating a Real-World Scheduling Problem into the  Basic Algorithms Course

Teaching SAP

Solving the SAP problem is indeed a component in some real-world software applications, such as the OPA software designed by Ximes Inc. corporation, located in Vienna

Could be integrated into content conventionally taught in the basic algorithms course which includes polynomial time algorithms for the maximum flow problem.

Illustrates practical application of flow algorithms

Page 20: Integrating a Real-World Scheduling Problem into the  Basic Algorithms Course

Teaching SAP Illustrates the importance of the seemingly abstract

topic of linear algebra in real-world problems Allows to introduce a fundamental problem: integer

linear programming, which is a central problem in combinatorial optimization

SAP is an excellent programming project. The students gain experience in important things such as constructing graphs, multiplying matrices, and programming classic algorithms for maximum flow.

Page 21: Integrating a Real-World Scheduling Problem into the  Basic Algorithms Course

References[1] N. Balakrishnan and R.T. Wong, A network model for the rotating workforce

scheduling problem, Networks, 20:25–42, 1990.[2] J.J. Bartholdi, J.B. Orlin, and H.D. Ratliff, Cyclic scheduling via integer programs

with circular ones, Operations Research, 28:110–118, 1980.[3] T. H. Cormen, C. E. Leiserson, R. L. Rivest, and C. Stein, Introduction to

Algorithms, Second Edition. MIT press, 2001.[4] T.G. Crainic, M. Gendreau, and J.M. Farvolden, A simplex-based tabu search for

capacitated network design, INFORMS Journal on Computing, 12(3), 2000.[5] J. R. Driscoll, H. N. Gabow, R. Shrairman, and R. E. Tarjan, Relaxed heaps: An

alternative to fibonacci heaps with applications to parallel computation, Communications of the ACM, 31(11):1343–1354, 1988.

[6] Michael R. Garey and David S. Johnson, Computers and Intractability: A Guide to the Theory of NP-Completeness, Freeman and Co., 1979.

[7] Johannes G¨artner, Nysret Musliu, and Wolfgang Slany, Rota: a research project on algorithms for workforce scheduling and shift design optimization, AI Communications: The European Journal on Artificial Intelligence, 14(2):83–92, 2001.

[8] Fred Glover and Manuel Laguna, Tabu search, Kluwer Academic Publishers, 1997.

Page 22: Integrating a Real-World Scheduling Problem into the  Basic Algorithms Course

References[9] V. Klee and G. Minty, How good is the simplex algorithm? Academic Press,

1972. In Shisha, O., ed.: Inequalities, Volume III.[10] S. R. Kosaraju and A. L. Delcher, Large-scale assembly of DNA strings and

space-efficient construction of suffix trees, In Proceedings of the twenty-seventh annual ACM symposium on Theory of computing, pages 169 – 177, 1995.

[11] G. Laporte, The art and science of designing rotating schedules, Journal of the Operational Research Society, 50:1011–1017, 1999.

[12] Nysret Musliu, Johannes G¨artner, and Wolfgang Slany, Efficient generation of rotating workforce schedules, Discrete Applied Mathematics, 118(1-2):85–98, 2002.

[13] Nysret Musliu, Andrea Schaerf, and Wolfgang Slany, Local search for shift design, European Journal of Operational Research (to appear).

[14] Nysret Musliu, Andrea Schaerf, and Wolfgang Slany, Local search for shift design, Technical Report DBAI-TR-2001-45, Technische Universit ¨at Wien, 2001, http://www.dbai.tuwien.ac.at/proj/Rota/DBAI-TR-2001-45.ps.

[15] G.M. Thompson, A simulated-annealing heuristic for shift scheduling using non-continuously available employees, Comput. Oper. Res., 23(3):275–288, 1996.