180 likes | 379 Views
Exsched. Solving Constraint Satisfaction Problems with the Spreadsheet Paradigm. Motivation. Designing schedules is a problem that arises quite frequently: Class schedules Employee schedules Examination schedules These schedules have a tabular, 2-D structure
E N D
Exsched Solving Constraint Satisfaction Problems with the Spreadsheet Paradigm
Motivation • Designing schedules is a problem that arises quite frequently: • Class schedules • Employee schedules • Examination schedules • These schedules have a tabular, 2-D structure • In general, many constraint satisfaction problems such as timetabling problems, scheduling problems, recreational puzzles can be modeled as tables of constraints • Use of spreadsheet paradigm for this purpose • Goal: Design an interface that facilitates the interactive development of such tabular schedules
Spreadsheet Paradigm • Our solution: Use the spreadsheet paradigm • Spreadsheets: Popular for arithmetic computations • Uses the paper and pencil approach • Arithmetic expressions are interactively entered and evaluated until desired results are obtained • Repetitive computations are performed by copying expressions from one cell to another, with appropriate transformation applied • Regular spreadsheets can not handle constraints • We generalize spreadsheets so that finite domain constraints can also be entered in the cells • Knowledgesheet • Exsched: plug-in for Microsoft Excel
Interface • Interface similar to regular spreadsheet (extension of MS Excel) • Each cell can be thought of as a variable or place holder • A user can enter finite domain values in a cell. These finite domain values denote the finite domain of the variable corresponding to the cell. Example: [1..5] • Constraints can also be entered in the cell. Constraints contain variable names (cell coordinates) and constants. Example: B3 #= C4 + 1
Interface (cont’d) • Constants can also be entered in the cell: the variable corresponding to that cell is set to the constant entered • Constraints/constants/finite domains can either be entered into the current cell or via dialog boxes • Lots of built-ins are available as clickable buttons • Once constraints/constants/finite domains are entered, the system automatically collects them, composes a clp(FD) program, solves it using clp(FD) engine running in the background and displays the solution • The user must enter at least one Query Table and zero or more Auxiliary Tables • Query Table is used to compose the query • Auxiliary table turns into facts • Computed results for the query are displayed in the query table
Example: Employee schedule • Scheduling managers at a store: • Store opens 8 AM to 11 PM, 7 days/week • Each manager must work 8.5 hr / day (includes 0.5 hrs for lunch) • Each manager must work 5 days / week • At least one manager must be present at any moment • Someone with night shift should not get morning shift next day • Schedule must be fair to all managers • In most cases, this scheduling is done manually • Erroneous, leads to employee dissatisfaction
Solution: Employee Schedule • Assume that there are 5 managers • Each manager works 8.5 hrs per day either in • The morning shift (8:00 AM to 4:30 PM), or • The midday shift (10:00 AM to 6:30 PM), or • The evening shift (2:30 PM to 11:00 PM)
Solution: Employee Schedule (cont’d) An Empty Table
Solution: Employee Schedule (cont’d) • Morning, midday and evening shifts are denoted by 5, 2 and 4 respectively • 0 will be used to indicate a manager’s day off • Domain of each cell: [0,2,4,5] • User enters domain in one cell, copies it to rest • For no morning after night restriction, we enter the constraint: C2 != B2 + 1 (copied everywhere) • At least one manager is present at any time during the day: member(4,[D2,D3,D4,D5,D6]), member(5,[D2,D3,D4,D5,D6]) • No manager works for more than 5 days a week: frequency(0,[B2,C2,D2,E2,F2,G2,H2],2) • Every manager has more or less same proportion of morning, midday and evening shifts: sublist([2,4,5],[B2,C2,D2,E2,F2,G2,H2])
Solution: Employee Schedule (cont’d) Table after adding further constraints
Solution: Employee Schedule (cont’d) Note: Cell constraints are replicated in all 35 cells, column constraints in B7 through H7 and row constraints in I2 through I6. count(0,[B2,C2,D2,E2,F2,G2,H2],=,2), sublist([2,4,5], [B2,C2,D2,E2,F2,G2,H2]) (Row Constraints) [0,2,4,5], C2 != B2 + 1 (Cell Constraints) member(4,[D2,D3,D4,D5,D6]), member(5,[D2,D3,D4,D5,D6]) (Column Constraints)
Solution: Employee Schedule (cont’d) Displaying a solution
Solution: Employee Schedule (cont’d) Displaying a solution
Example: The 3x3 Grid Puzzle Cell constraints: • B3: B3+C3+D3 #= 15, B3+B4+B5 #= 15 • C3: C3+C4+C5 #= 15 • D3: D3+D4+D5 #= 15 • B4: B4+C4+D4 #= 15 • B5: B5+C5+D5 #= 15, B5+C4+D3 #= 15 • D5: B3+C4+D5 #= 15, alldiff([B3,B4,B5,C3,C4,C5,D3,D4,D5])
Example: Cryptarithmetic Puzzles Most puzzles have such a graphical structure; for example, Zebra puzzle
Conclusion • Advantages of the Knowlodgesheet Approach: • Flexibility • Interactivity • Non-experts can use it • Domain specific knowledge can be incorporated • User and clp(FD) system cooperate to produce solutions • User can give partial solutions, compute rest with Knowledgesheet • Disadvantages: • Works only for tabular clp(FD) programs • No help if the system is overconstrained