wrapping up
play

Wrapping up CP course, lecture 11 Constraint programming is a - PowerPoint PPT Presentation

Wrapping up CP course, lecture 11 Constraint programming is a problem-solving technique for combinatorial problems that works by incorporating constraints into a programming environment. (after Apt 2003) S E N D + M O R E M O N E Y


  1. Wrapping up CP course, lecture 11

  2. Constraint programming is a problem-solving technique for combinatorial problems that works by incorporating constraints into a programming environment. (after Apt 2003)

  3. S E N D + M O R E M O N E Y Send More Money

  4. CSPs • Variables • Valuations and assignments • Constraint: set of valuations • CSP: Variables + Constraints

  5. Solving CSPs � X ∪ { x : ∅ } ; C � fail � X ∪ { x : D } ; C � | D | > 1 D = D 1 ⊎ · · · ⊎ D k � X ∪ { x : D 1 } ; C � | · · · | � X ∪ { x : D k } ; C � � X ∪ { x : D } ; C ∪ { C } � d ∈ D sat (C) ∩ { α ∈ ass (X) | α x = d } = ∅ � X ∪ { x : D − { d }} ; C ∪ { C } �

  6. Propagators � X ∪ { x : D } ; C ∪ { C } � d ∈ D sat (C) ∩ { α ∈ ass (X) | α x = d } = ∅ � X ∪ { x : D − { d }} ; C ∪ { C } � • Functions S → S (mapping stores to stores) • Properties: Domain • contracting (p(s) ≤ s) Reduction • correct (maintain solutions) Test • checking (decisive for assignments)

  7. That’s not enough! • Assume a propagator p(s) = if s(x) = {1,2,3} then {x:{1}} else s and s 1 ={x:{1,2,3}} s 2 ={x:{1,2}} • Then s 2 ≤ s 1 but p(s 1 ) ≤ p(s 2 ) • Propagators must be monotonic: s 1 ≤ s 1 ⇒ p(s 1 ) ≤ p(s 2 )

  8. How much can we propagate? • Idea: Propagate as much as possible, only then resort to branching • This means: Compute the largest simultaneous fixpoint of all propagators! (exists + is unique)

  9. Linear equations • Propagator for ∑ a i x i =c • How can bounds information be propagated efficiently? • Example: ax + by = c

  10. All-distinct • Naive: • check that no two determined variables have the same value • remove values of determined variables from domains of undetermined variables • Advantage: simple implementation, avoid O(n 2 ) propagators • Disadvantage: not very strong

  11. Variable-value Graph 1 x1 ∈ {1,3} x1 2 x2 ∈ {1,3} x2 3 4 x3 ∈ {1,3,4,5} x3 5 x4 ∈ {3,5,6} x4 6

  12. Matching • Compute union of all 1 maximal matchings x1 2 • Delete unmatched x2 3 edges 4 x3 5 x4 6

  13. Two questions • How to branch? • branching strategy (naive, first-fail, …) • determines the shape of the search tree • How to make the choice operation deterministic? • search strategy (depth-first, b & b, …) • determines the order in which the nodes of the search tree are visited

  14. Backtracking strategies • copying: backup the state of the system before making a choice • trailing: remember an undo action for the choice • recomputation: recompute the state of the system before the choice was made

  15. Recomputation 1 fun recompute s nil = clone s 2 | recompute s (i::ir) = let val s’ = recompute s ir 2 in commit(s’, i) s’ 2 end

  16. Recomputation • fundamental idea: trade space for time • full recomputation: pro: no backup copies, constant space con: time overhead • can we do better?

  17. Finite-set variables • let Δ be a finite interval of integers • finite domain variables take values in Δ • finite set variables take values in P ( Δ ) • domain : fixed subset of Δ

  18. Non-basic constraints just as with FD • express non-basic constraints in terms of basic constraints, using sets of inference rules • monotonicity: more specific premises yield more specific conclusions • express inferences in terms of the currently entailed lower and upper bounds b S c D [f D j D � S g d S e D \f D j S � D g

  19. Union and intersection S 1 [ S 2 D S 3 � S 3 � d S 1 e [ d S 2 e ^ b S 1 c [ b S 2 c � S 3 S 1 \ S 2 D S 3 � b S 1 c \ b S 2 c � S 3 ^ S 3 � d S 1 e \ d S 2 e

  20. Binary Relations • define the notion of the ‘relational image’ Rx D f y 2 C j Rxy g • understand binary relations as total functions from the carrier to subsets of the carrier f R D f x 7! Rx j x 2 C g • represent these functions as vectors on finite set variables

  21. Selection constraints • generalisation of binary set operations • participating elements are variable, too • example: union with selection [ S D S i i 2 S 0 • propagation in all directions

  22. Composition f . x ; z / 2 C 2 j 9 y 2 C W R 1 xy ^ R 2 yz g R 1 B R 2 D R 1 B R 2 D R 3 � R 3 D h[ R 2 Œ R 1 Œ 1 ��; : : : ; [ R 2 Œ R 1 Œ n �� i

  23. Rooted tree constraint rootedTree . v 1 ; : : : ; v n ; R / ) succ D pred � 1 H H ) succ � D Id [ succ C H ) succ C D succ B succ � H ) j R j D 1 H ) V D R ] succ .v 1 / ] : : : succ .v n / v 2 V H ) v 2 R ( ) pred . x / D ;

  24. Dominance constraints

  25. Scheduling • Tasks a (aka activities) • duration dur(a) • resource res(a) • Precedence constraints • determine order among two tasks • Resource constraints • e.g. at most one task per resource

  26. Building a Bridge

  27. Model in CP • Variable for start-time of task a • Precedence constraints: a before b • Resource constraints: a before b ∨ b before a similar to temporal relations

  28. Think global • Model employs local view: • constraints on pairs of tasks • O(n 2 ) propagators for n tasks • Global view: • order all tasks on one resource • employ smart global propagator

  29. Ordering Tasks: Serialization • Consider all tasks on one resource • Deduce their order as much as possible • Propagators: • Timetabling: look at free/used time slots • Edge-finding: which task first/last? • Not-first / not-last

  30. Potential Projects • Are you interested in a Fopra, Bachelor’s, Master’s, or Diploma thesis? • Projects: Gecode (C++), Gecode/Alice, Alice, CoLi

  31. Grading

  32. Grading scheme • 4 graded assignments = 120 points • Exam = 180 points • Total: 300 points • You will pass the course with 150 points

  33. Exam

  34. When, where, how... • Thursday, July 14 • 14:00 (that’s 2pm, sine tempore!) • here! (lecture room III) • 90 min, 180 points • just bring a pen and your student id

  35. and... what? I already told you...

  36. Thank you!

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend