200 likes | 212 Views
Understand constraint programming, its basics, methods for solving constraints, optimization, different constraint systems, logic programming, applications like scheduling, layout planning, and manpower allocation.
E N D
Constraint Programming 2001 Edition Jan Maluszynski and Ulf Nilsson TCSLAB, LiU {janma, ulfni}@ida.liu.se http://www.ida.liu.se/~ulfni/cp2001
Course organization (cont) • Obligatory course assignments (23 Oct) with deadline 20 Nov, and examination 27 Nov • Course credit points 4 • Literature:K. Marriott and P. StuckeyProgramming with Constraints: An IntroductionMIT Press, 1998.+ handouts and on-line manuals
A simple definition • Constraint programming is the study of computational systems based on constraints. • Constraints are roughly systems of equations, inequations and disequations over some algebraic structure. • The idea of constraint programming is to solve problems by encoding the problem as a set of constraints and exploring solutions to the constraints.
Typical problem • Processes A-D may start at times 1,2,3,4,5,6,7 • Process A uses 3 resources during 2sec • Process B uses 1 resource during 4sec • Process C uses 2 resources during 1sec • Process D uses 2 resources during 1sec • There are 4 resources • Process A must finish before C can start • When are A, B, C, D earliest finished?
Overview • Constraints, basics, operations, domains • Focus on finite domains, intervals • Constraint logic programming • Modeling and applications • Systems • CLP-systems • Systems for defining constraints CHR, HAL
Constraints • A constraint problem consists of a set of problem variables ranging over some domain and a set of constraints restricting the values that may be assigned to the variables. • Example:x in {1,2,3}, y in {2,3,4,5}, 2x = y • Examples of domains:Reals/rationals, intervals, finite domains, Booleans, sets, monoids (strings) etc
Methods for constraint solving • Reals/rational constraints • Gauss-Jordan elimination + Simplex • Real/Rational intervals • interval narrowing, box consistency, • Gauss-Seidel elimination, interval Newton method, • Booleans • for example, operations on BDD’s • Finite domains • arc, node and path consistency methods • constraint propagation (forward checking, look-ahead)
Optimization • Finding a solution which satisfies constraints and minimizes/maximizes objective function • Different types • combinatorial optimization of discrete (finite domain) variables • linear optimization for continuous variables
Different constraint systems • Real/rational constraints: CLP(R), CLP(Q)CLP(R), Sicstus Prolog, CHIP • Finite domains constraints: CLP(FD)Sicstus Prolog, CHIP • Boolean constraints: CLP(B)Sicstus Prolog, CHIP • Interval constraints: CLP(I)CLP(BNR), Numerica, Prolog IV
Systems discussed in the course • SICStus Prolog • Chip 5.2 • Prolog IV • CHR • HAL
Logic programming Constraint satisfaction/solving Optimization The programming paradigm CLP
Logic programming • Logic (relations) for problem description • Declarative description style (problem description separated from its solving) • Unification (a kind of constraint solving) • Builtin search • Constraint programming does not need LP !!!
Some applications • Spatial and temporal problems • Placment and layout • Manpower planning • Scheduling • Resource allocation • Configuration management • Verification (e.g. correctness, safety+liveness)
Placement/Layout A window contains a number of widgets. As the window is shrinking or growing the widgets have to be repositioned while satisfying certain constraints (e.g. certain widgets must always be visible or must be in a certain relation to other widgets). Given a certain window size, produce a layout that satisfies the constraints.
Scheduling A conference consists of 11 sessions of equal length. The program is to be organized as a sequence of slots,where a slot contains up to 3 parallel sessions: 1. Session 4 must take place before Session 11. 2. Session 5 must take place before Session 10. 3. Session 6 must take place before Session 11. … 8. Session 6 must not be in parallel with 7 and 10. 9. Session 7 must not be in parallel with 8 and 9. 10. Session 8 must not be in parallel with 10. Minimize the number of slots.
Job shop scheduling There are n jobs and m machines. Each job requires execution of a sequence of operations within a time interval, and each operation Oi requires exclusive use of a designated machine Mi for a specied amount of processing time pi. Determine a schedule for production that satisfies the temporal and resource capacity constraints.
Manpower planning Airport Counter Allocation problem: Allocate enough counters and staff (the number depends on the aircraft type) to each flight. The counters are grouped in islands and for each flight all assigned counters have to be in the same island. The staff has working regulations that must be satisfied (breaks etc).
Black-box vs Glass-box solvers • Most systems rely on non-extensible, black-box constraint solvers • Efficiency unpredictable • Hard to debug • Some systems facilitate defining new constraints and solvers (glass-box approach) • Improved control of propagation and search • Examples CHR, HAL, ... • Then again, most problems are NP-complete...