Solving Employee Timetabling Problems Using Boolean Satisfiability

Size: px
Start display at page:

Download "Solving Employee Timetabling Problems Using Boolean Satisfiability"

Transcription

1 Solving Employee Timetabling Problems Using Boolean Satisfiability Fai Aloul, Bashar Al-Rawi*, Anas Al-Farra, Basel Al-Roh Department of Computer Engineering, American University of Sharjah (AUS, UAE *Department of Computer Engineering, American University in Dubai (AUD, UAE Abstract The Employee Timetabling Problem (ETP is concerne with assigning a number of employees into a given set of shifts over a fixe perio of time, e.g. a week, while meeting the employee s preferences an organizational work regulations. The problem also attempts to optimize the performance criteria an istribute the shifts equally among the employees. The problem is consiere a classical NP-complete optimization problem. It has receive intensive research uring the past few years given its use in inustries an organizations. Several formulations an algorithms base on local search have been propose to solve ETPs [12, 15, 17, 18]. In this paper, we propose a complete approach using integer linear programming (ILP to solve these problems. The ILP moel of interest is evelope an solve using the generic ILP solver CPLEX an the Boolean Satisfiability ILP solver PBS. Experimental results inicate that the propose moel is tractable for reasonable-size ETP problems. Inex Terms Employee Timetabling, Optimization, Scheuling, ILP, Boolean Satisfiability. 1. INTRODUCTION Employee Timetabling Problem (ETP represent an important class of optimization problems in operational research. The problem was originally associate with timetabling of classes in schools an universities [22], but has recently been extene to scheule employees in large organizations, such as hospitals [12], factories, etc. Given a number of employees an shifts, the goal is to assign employees to shifts while satisfying all of the employees an organizational constraints. Many formulations an algorithms have been propose to solve ETP. Most of these algorithms are base on local search techniques, namely hill climbing, simulate annealing, an tabu search [15, 17, 21, 18, 7]. Such algorithms cannot prove unsatisfiability or guarantee that a solution is optimal. In other wors, if a solution is foun, it cannot guarantee that this solution has the best possible optimization cost. In this paper, we propose an integer linear programming (ILP approach to solve the ETP. The approach is complete an hence examines the entire search space efine by the problem to prove that either the problem has no solution, i.e. the problem is unsatisfiable, or that a solution oes exist, i.e. the problem is satisfiable. If the problem is satisfiable, our approach will search all possible solutions to fin the optimal solution. Recently, avance Boolean Satisfiability (SAT solvers have been extene to solve ILP problems. The SAT problem is a central problem in artificial intelligence an computer science an has receive consierable attention from researchers. Many complex Engineering problems have been successfully solve using SAT. Such problems inclue routing [20], power optimization [2], verification [4], an graph coloring [9], etc. Toay, several powerful SAT solvers exist an are able of hanling problems consisting of thousans of variables an millions of constraints. In this paper, we will also show how to formulate the ETP as an ILP problem an explore the possibility of using avance SAT techniques to solve the ETP problem. We also use the commercial generic-base ILP solver, CPLEX, to test our instances. We report results for a variety of organization sizes. Initial results inicate the effectivity of the propose approach. The propose approach is complete an is guarantee to ientify the optimal scheule. This paper is organize as follows. Section 2 provies a general overview of Boolean Satisfiability. Section 3 shows how to formulate the ETP as an ILP instance. A etaile example is shown in Section 5. Experimental results are presente an iscusse in Section 5. The paper is conclue in Section BOOLEAN SATISFIABILITY The Boolean satisfiability (SAT problem involves fining an assignment to a set of binary variables that satisfies a given set of constraints. In general, these constraints are expresse in proucts-of-sum form, also known as conjunctive normal form (CNF. A CNF formula ϕ on n binary variables x 1,, x n consists of the conjunction (AND of m clauses ω 1,, ω m each of which consists of the isjunction (OR of k literals. A literal l is an occurrence of a Boolean variable or its complement. Most current SAT solvers [13, 19, 16] are base on the original Davis-Putnam backtrack search algorithm [10]. The algorithm performs a epth first search process that traverses the space of 2 n variable assignments until a satisfying assignment is foun (the formula is satisfiable, or all combinations have been exhauste (the formula is unsatisfiable. Originally, all variables are unassigne. The algorithm begins by choosing a ecision assignment to an unassigne variable. A ecision tree is maintaine to keep track of variable assignments. After each ecision, the algorithm etermines the implications of the assignment on other variables. This is obtaine by forcing the assignment of the variable representing an unassigne literal in an unresolve clause, whose all other literals are assigne to 0, to satisfy the clause. This is referre to as the unit clause rule. If no conflict is etecte, the algorithm makes a new eci /06/$ IEEE.

2 sion on a new unassigne variable. Otherwise, the backtracking process unassigns one or more recently assigne variables an the search continues in another area of the search space. As an example, a CNF instance f = ( a+ b ( b + c consists of 3 variables, 2 clauses, an 4 literals. The assignment { a, b, c } leas to a conflict, whereas the assignment { a, b, c } satisfies f. Note that a problem with n variables will have 2 n possible assignments to test. The above example with 3 variables has 8 possible assignments. A instance with 100 variables will have 1.27e+30 assignments. Assuming a processor that can verify an assignment every 1 nanosecon, the processor will complete testing all assignments in 4e+12 years. Despite the SAT problem being NP-Complete [5], several powerful methos have been propose to expeite the backtrack search algorithm. One of the best methos is known as the conflict analysis proceure [16] an has been implemente in almost all SAT solvers. Whenever a conflict is etecte, the proceure ientifies the causes of the conflict an augments the clause atabase with aitional clauses, known as conflict-inuce clauses, to avoi regenerating the same conflict in future parts of the search process. In essence, the proceure performs a form of learning from the encountere conflicts. Significant speeups have been achieve with the aition of conflict-inuce clauses, as they ten to effectively prune the search space. Intelligent ecision heuristics an ranom restarts [19], also playe an important role in enhancing the SAT solvers performance. Chaff [19] propose an effective ecision heuristic, known as VSIDS, an implemente several other enhancements, incluing ranom restarts, which lea to ramatic performance gains on many CNF instances. Another recent extension to SAT solvers eals with its input format. Restricting the input of SAT solvers to CNF formulas can restrict their usage in various omains. Therefore, researchers have focuse on extening SAT solvers to hanle stronger input representations. Specifically, SAT solvers [1, 6, 23] have recently been extene to hanle pseuo-boolean (PB constraints which are linear inequalities with integer coefficients that can be expresse in the normalize form [1] of: a 1 x 1 + a 2 x a n x n b (1 where a i, b Z + an x i are literals of Boolean variables. Note that any CNF clause can be viewe as a PB constraint, e.g. clause ( a b c is equivalent to ( a + b + c 1. PB constraints can, in some cases, replace an exponential number of CNF constraints. They have been foun to be very efficient in expressing counting constraints [1]. Furthermore, PB extens SAT solvers to hanle optimization problems as oppose to only ecision problems. Subject to a given set of CNF an PB constraints, one can request the minimization (or maximization of an objective function which consists of a linear combination of the problem s variables. n a i x i (2 i This feature has introuce many new applications to the SAT omain. Specifically, all 0-1 ILP problems (i.e. ILP problems whose variables are Boolean can be easily solve now by SAT solvers. Recent stuies has shown that SATbase optimization solvers can in fact compete with the best generic-base ILP solvers [1, 6]. 3. PROBLEM FORMULATION This section evelops the 0-1 ILP moel for the ETP an illustrates its applicability using small examples. Consier an organization with m employees. Assume the organization runs for ays/week, has s shifts per ay, an nees w employees to be working in each shift. We first introuce the following ecision variables per employee: 1 : employee i is working E i 1 : employee i is working at ay j 1 : employee i is assigne at ay j to shift k S ijk Hence the total number of variables will be m + m + ms. Two sets of constraints are ae to represent the organizational regulations an employee preferences, respectively. These are escribe below. A. Organizational Constraints The organization nees to make sure that w employees are assigne to each possible shift. This is expresse in the following constraint: m S ijk = w j, k (6 i The constraint can be customize per shift. For example the morning shift can have more employees than the afternoon or evening shift. B. Employee Constraints The first two constraints efine the relationship between the variables E i,, an S ijk. These constraints are ae for all employees. Constraint (7 ensures that if an employee is assigne to any shift, then the employee is working: s S ijk k j, (3 (4 (5 (7

3 Constraint (8 ensures that if an employee is working uring any ay, then the employee is working, i.e. not on vacation, etc. E i (8 The following set of constraints eal with the employee preferences. They can be specifically assigne to each employee epening on his/her preferences. Alternating ays: An employee cannot work for two consecutive ays. ( + 1, j, j (9 Number of shifts per employee: An employee can work upto k max shifts per ay. s S ijk k max j, (10 k Number of working ays per employee: An employee must work not less than h min ays an no more than h max ays per week. h min h max (11 (12 Off-ays: An employee may be sick or on vacation an unable to work. Assuming employee i cannot work on ay j, this can be expresse using: (13 Off-shifts: An employee may be working part-time or unable of working uring specific shifts. Assuming employee i cannot work in the morning shifts (inicate by k, ue to another job. This can be expresse using: S ij1 (14 Note that constraints (9-(14 are optional an a vali scheule can be generate without them. However, the scheule is likely to be meaningless, since the employees preferences have not been taken into consieration. The last goal is to istribute the work evenly among all employees an maximize their usage. This is expresse in the following linear cost function which must be maximize: m Max E i (15 i This objective function will minimize the number of ile workers. Other optimization functions can be similarly expresse for other organizational purposes such as reucing the labor cost, minimizing the number of employees, etc. 4. ILLUSTRATIVE EXAMPLE In this example, we examine a company consisting of two employees. Assume the company is open 3 ays a week an inclues two shifts per ay (e.g. morning an evening shift. Each shift must be assigne to a single employee. As shown in Section 3, the number of variables is 2 + 2( ( ( 2 = 20. Figure 1 shows the istribution of variables. We use the variable naming convention use in the previous section. Each noe represents a Boolean variable. For example, E 1 an E 2 represent employees 1 an 2, respectively. D 12 represents employee 1 working in ay 2. S 231 represents employee 2 working in the morning shift of ay 3. E 1 D 12 D 13 S 112 S 122 Fig. 1. Employee Timetabling Example The company s constraint inicating that each shift must be assigne to a single employee is expresse as: The above constraint are represente in PB form. The following set of CNF constraints enforce the relationship between the variables. S 132 E 2 D 21 D 22 D 23 S 211 S 212 S 221 S S 211 S S S 221 S S S 231 S S 232 S 231 S 232 S 112 ( ( S 112 S 122 D 12 ( ( S 122 S 132 D 13 ( ( S 132

4 S 211 S 212 D 21 ( S 211 ( S 212 S 221 S 222 D 22 ( S 221 ( S 222 S 231 S 232 D 23 ( S 231 ( S 232 D 13 S 132 ( D 13 S 132 S 112 ( S 112 D 12 S 122 ( D 12 S 122 D 21 S 211 S 212 ( D 21 S 211 S 212 D 22 S 221 S 222 ( D 22 S 221 S 222 D 23 S 231 S 232 ( D 23 S 231 S 232 E 1 ( E 1 E 2 D 21 ( E 2 D 13 E 1 D 21 D 23 E 2 The final set of constraints represents the employees preferencs. Assume the following working preferences: Employee 1 works on alternative ays ( ( D 12 ( D 13 ( D 21 ( D 22 ( D 23 D 12 ( D 12 D 13 ( D 12 Employee 2 works for a maximum of 4 shifts per week PB: S S S S S S Employee 1 cannot work uring morning shifts PB: + + Employee 2 cannot work on ay 3 PB: D 23 Employee 1 must work at least 2 ays per week PB: + D 12 + D 13 2 In summary, the instance consists of 20 variables, 10 PB constraints, an 24 CNF constraints. 5. EXPERIMENTAL RESULTS In this section, we evaluate the use of ILP solvers to solve the ETP problem. A tool was evelope using Visual Basic with an easy-to-use GUI interface. The user inputs the employee preferences an organization constraints. The tool translates the user input into a 0-1 ILP instance as escribe in Section 3. The instance is then passe into an ILP solver an once the search is complete, the solution, if satisfiable, is translate into an easy-to-rea scheule. The tool can hanle an unlimite number of employees, has the ability to a unique preferences for each employee, an generates a scheule for a perio of month. We use two of the best 0-1 ILP solvers: (1 The SAT-base 0-1 ILP solver, PBS [1, 3], an (2 the leaing generic commercial ILP solver, CPLEX [14]. PBS is an avance SAT solver that can hanle both CNF an PB constraints. It employs the latest avances in the SAT technology. The experiments were conucte on a Pentium Xeon 3.2 GHz machine, equippe with 4 GBytes of RAM, an running Linux. The runtime limit was set to 1000 secons. We present runtime results for 12 examples of organizations. Table 1 shows the organization an employee preferences, the runtime in secons of PBS an CPLEX, an the result of the search. A SAT result inicates that the instance is satisfiable, an hence a scheule is generate. A UNS result inicates that the instance is unsatisfiable, an hence a scheule cannot be generate given these constraints. In this case, relaxing the constraints, such as aing more employees or reucing the number of shifts or working ays, can help make the problem satisfiable. Note that if the search is complete, both solvers must yiel the same optimal result. The first 4 columns in Table 1 show the organization regulations an the last 3 columns show the employee preferences. A brief escription of the preferences is given below: Column Constraint Description 2 Number of employees 3 Number of working ays per week 4 Number of shifts per ay Number of employees per shift. If 3 numbers are 5 liste, these correspon to the 3 shifts, respectively 6 Alternating Days policy enforce Maximum number of shifts per ay for each 7 employee Maximum number of working ays per week for 8 each employee The fairness constraint was enforce in all examples. Several observations are in orer: PBS was able to solve most instances, but time-out in 3 cases. In these cases, the instances were unsatisfiable, an hence int have a solution. CPLEX, on the other han, was able to solve all instances (both satisfiable an unsatisfiable in less than a secon.

5 The larger the organization, hence the 0-1 ILP instance, the longer is the search runtime. The approach is complete an is guarantee to fin a fair scheule given enough time an memory resources. 6. CONCLUSION In this paper, we present an ILP-base approach to generating employees timetables. The propose approach utilizes avance generic-base an Boolean satisfiabilitybase ILP solvers to fin a scheule that satisfies the organization s rules an its employees preferences. The propose approach can be use to optimize a given objective function such as minimizing labor costs or maximizing fairness among employees. We show how to formulate the employee timetabling as an ILP problem. The approach was teste on organizations with various sizes an showe promising results. The approach is complete an will fin the require timetable, or will inicate that no timetable exists that meets the current organization s conitions. Example TABLE 1. Experimental results using the ILP solvers PBS an CPLEX Organization Employee # of employees # working ays # shifts/ay # employees/shift Alternating ays Max shifts/ay Max ays/week Result PBS4 Time CPLEX Time Y 1 - SAT Y 1 - SAT Y 1 - SAT Y 1 - UNS > Y 1 - UNS > Y 1 - SAT Y 1 - SAT , 2, 1 Y 1 - SAT , 2, 1 Y 1 - SAT , 4, 2 Y 1 - SAT , 6, 3 Y 1 - SAT Y 1 2 UNS > REFERENCES [1] F. Aloul, A. Ramani, I. Markov, an K. Sakallah, Generic ILP Versus Specialize 0-1 ILP: An Upate, in Proc. of the Int l Conference on Computer Aie Design, , [2] F. Aloul, S. Hassoun, K. Sakallah, an D. Blaauw, Robust SAT-Base Search Algorithm for Leakage Power Reuction, in Proc. of the Int l Workshop on Power an Timing Moeling, Optimization, an Simulation, , [3] B. Al-Rawi an F. Aloul, PBS4 SAT Solver, Available at: [4] A. Biere, A. Cimatti, E. Clarke, M. Fujita, an Y. Zhu, Symbolic Moel Checking Using SAT Proceures Instea of BDDs, in Proc. of the Design Automation Conference (DAC, , [5] S. Cook, The Complexity of Theorem Proving Proceures, in Proc. of the ACM Symposium on the Theory of Computing, , [6] D. Chai an A. Kuehlmann, A Fast Pseuo-Boolean Constraint Solver, in Proc. of DAC, , [7] M. Chiaranini, A. Schaerf, an F. Tiozzo, Solving Employee Timetabling Problems with Flexible Workloa Using Tabu Search, in Proc. of the Int l Conf. on the Practice an Theory of Automate Timetabling, , [8] T. Cooper an J. Kingston, The Complexity of Timetable Construction Problems, in Proc. of the International Conference on Practice an Theory of Automate Timetabling, LNCS 1153, Springer-Verlag, , [9] N. Creignou, S. Kanna, an M. Suan, Complexity Classifications of Boolean Constraint Satisfaction Problems, SIAM Press, [10] M. Davis, G. Longman, an D. Lovelan A Machine Program for Theorem Proving, in Journal of the ACM. 5(7, , [11] D. e Werra, The Combinatorics of Timetabling, in European Journal of Operational Research, , [12] K. Dowslan, Nurse scheuling with tabu search an strategic oscillation, in European Journal of Operational Research, v. 106, , [13] E. Golberg an Y. Novikov, BerkMin: A Fast an Robust SAT-solver, in Proc. of the Design Automation an Test Conference in Europe (DATE, , [14] ILOG CPLEX, [15] L. Kragelun, Solving a timetabling problem using hybri genetic algorithms, in Software - Practice an Experience, v. 27, , [16] J. Marques-Silva an K. Sakallah GRASP: A Search Algorithm for Propositional Satisfiability, in IEEE Trans. on Computers, 48(5, , [17] A. Meisels, E. Gues, an G. Solotorevsky, Combining Rules an Constraints for Employee Timetabling, in Int l Journal of Intelligent Systems, v. 12, , [18] A. Meisels an A. Schaerf, Moelling an Solving Employee Timetabling Problems, in Annals of Mathematics an Artificial Intelligence, 39(1-2, 41-59, [19] K. Moskewicz, C. Maigan, Y. Zho, an S. malik Chaff: Engineering an efficient SAT solver, in Proc. of the Design Automation Conference, , [20] G. Nam, F. A. Aloul, K. A. Sakallah, an R. Rutenbar, A Comparative Stuy of Two Boolean Formulations of FPGA Detaile Routing Constraints, in ISPD, , [21] A. Schaerf an A. Meisels, Solving Employee Timetabling Problems by Generalize Local Search, in Proc. of the Italian Conference on Artificial Intelligence, , [22] A. Schaerf an L. Gaspero, Local Search Techniques for Eucational Timetabling Problems, in Proc. of the Int l Symp. on Operations Research in Slovenia, 13-23, [23] H. Sheini an K. Sakallah, Pueblo: A Moern Pseuo- Boolean SAT Solver, in Proc. of the Design, Automation, an Test Conference in Europe, vol. 2, , 2005.