an introduction to cp cp a technique to solve csps and
play

An Introduction to CP CP = A technique to solve CSPs and COPs CSP = - PowerPoint PPT Presentation

An Introduction to CP CP = A technique to solve CSPs and COPs CSP = Constraint Satisfaction Problem COP = Constraint Optimization Problem It. Problema di Soddisfacimento/Ottimizzazione di/con Vincoli A declarative approach Model


  1. An Introduction to CP

  2. CP = A technique to solve CSPs and COPs ■ CSP = Constraint Satisfaction Problem ■ COP = Constraint Optimization Problem ■ It. Problema di Soddisfacimento/Ottimizzazione di/con Vincoli A declarative approach ■ Model & then solve (a bit like MIP) ■ Model = variables + constraints ■ Rich set of constraints (much more than linear in-equalities) Is it worth learning?

  3. ■ Netherlands railways: 5,500 trains per day ■ In 2009: timetable complete redesign (OR and CP) ■ Less delay, more trains, profit increase: ~\$75M

  4. ■ Port of Singapore: > 200 shipping lines, > 600 connected ports ■ Problem: yard location assignment, loading plans ■ For years, the Yard planning system (CP based) assisted the job

  5. ■ Rosetta-Philae mission ■ In 2014, first (partially successful) probe landing on a Comet ■ Probe-spacecraft communication pre-scheduled via CP

  6. A few reasons for using CP: ■ Rich modeling language ■ Fast prototyping ■ Easy to maintain (modifications are simple) ■ Extensible (new constraints, customizable search...) ■ Very good framework for hybrid approaches Overall: ■ It's a good solution technique! ■ Especially for messy, real-world, problems

  7. Before we tackle complex stuff Let's take our first steps...

  8. 4 available colors, different colors for contiguous regions How would you solve it?

  9. 4 available colors, different colors for contiguous regions ■ Pick and color a region ■ Pick another region, choose a compatible color ■ Rinse & repeat

  10. 4 available colors, different colors for contiguous regions Eventually we find something like this

  11. ■ Think of that as "Poor's man sudoku" ■ Different numbers (1 to 4) on rows and columns 2 3 3 4 How would you solve it?

  12. ■ Think of that as "Poor's man sudoku" ■ Different numbers (1 to 4) on rows and columns 2 3 3 4 ■ Pick a cell, insert compatible value ■ Rinse & repeat

  13. ■ Think of that as "Poor's man sudoku" ■ Different numbers (1 to 4) on rows and columns 2 3 3 2 1 4 What now?

  14. ■ Think of that as "Poor's man sudoku" ■ Different numbers on rows and columns 2 3 3 2 1 4 ■ Clear one of more moves ■ Restart to insert numbers

  15. ■ Think of that as "Poor's man sudoku" ■ Different numbers on rows and columns 1 3 2 4 3 2 1 4 4 2 3 1 3 1 2 4 Eventually, we find something like this

  16. You see? There is a pattern. ■ We reason on the constraints to narrow down the possible choice ■ We make (and unmake) some choices The core ideas in Constraint Programming are the same! To the point that for many people: CP = constraint reasoning + search

  17. You see? There is a pattern. ■ We reason on the constraints to narrow down the possible choice ■ We make (and unmake) some choices The core ideas in Constraint Programming are the same! But I am not many people! I think this formula is much better: CP = model + constraint reasoning + search ■ CP is a declarative approach, remember? ■ So it all starts with a declarative model In the next slides we will focus on each of the three aspects

  18. CP = model + ...

  19. ■ First, we need to define the kind of problem we are interested in: where: ■ is a set of variables ■ is a single variable ■ In principle: any kind of variable! ■ is a set of domains ■ takes values in ■ is a set of constraints

  20. Constraint scope (Italian: ambito) ■ A constraint is defined over a subset of of the variables ■ is called the scope of the constraint Tuple ■ A tuple or arity is just a sequence of values Relation ■ Let be a sequence of sets ■ A relation over is a subset of the Cartesian product. I.e.:

  21. Constraint ■ A constraint is a relation over the domains of . I.e.: Here's the main idea: ■ A tuple in the Cartesian product = an assignment of the variables ■ A constraint is just a list of feasible assignments A bit abstract, so let's make an example

  22. Variables: Domains: , Constraints:

  23. A solution for a CSP is an assignment of all the variables that is feasible for all constraints. Formally: where: ■ is the projection of over ■ = sequence of values assigned by to variables in

  24. A solution for a CSP is an assignment of all the variables that is feasible for all constraints. Formally: The solutions in our example: , , , A CSP with no solution is called infeasible.

  25. Any kind of domain?

  26. Any kind of domain? In practice: ■ Integer variables ■ Real variables ■ Set variables! (e.g. ) ■ Graph variables! ■ ... In this course: ■ Strong emphasis on finite, integer domains ■ The most studied case

  27. Any kind of constraints?

  28. Any kind of constraints? ■ With finite domain variables, yes! ■ We can actually list all the feasible assignments This is called extensional representation ■ Very general ■ Possibly inconvenient and inefficient (large domains) We may prefer a symbolic or intensional representation: ■ More compact, more clear, less general

  29. Intensional forms are made possible by Constraint libraries ■ Constraint library = collection of constraint types Our first constraint library: Equality: ■ Notation: ■ Semantic: satisfied if is equal to Disequality: ■ Notation: ■ Semantic: satisfied if is not equal to

  30. Variables and domains: ■ , for each region Constraints: ■ if region and are contiguous

  31. 2 3 3 4 Variables and domains: ■ , for each cell ■ = row index, = column index Constraints: ■ ■

  32. 2 3 3 4 Variables and domains: ■ , for each cell = row index, = column index ■ Constraints: ■ is cell is pre-filled with value

  33. CP = model + constraint reasoning + ...

  34. 2 3 3 3 4 ■ We would never put a 3 there (not compatible) ■ Can we formalize this deduction? Main idea: reason on the domains

  35. 2 3 3 1 2 4 3 4 ■ ■ ■

  36. 2 3 3 1 4 ■ The only possible value for is 1

  37. Filtering for = removing provably infeasible values from the domains of the variables in the constraint scope ■ Alternative terms: pruning, propagation ■ My convention: ■ Pruning = the act of removing a single value ■ Filtering = the process that guides pruning ■ Propagation = later! ■ Italian: propagation = propagazione

  38. Filtering for = removing provably infeasible values from the domains of the variables in the constraint scope ■ For constraints in extensional form: ■ General methods (we will see them later) ■ For constraints in intensional form: ■ Specialized filtering algorithms ■ Those are specified in the constraint library ■ Alternative names: filtering rules, propagators

  39. Equality constraint: ■ Rule 1: ■ Rule 2: Examples: ■ Before filtering: ■ After filtering:

  40. Disequality constraint: ■ Rule 1: ■ Rule 2: Examples: ■ Before filtering: ■ After filtering:

  41. 1 2 1 2 1 2 2 3 4 3 4 3 4 1 2 1 2 1 2 3 3 4 3 4 3 4 1 2 1 2 1 2 3 3 4 3 4 3 4 1 2 1 2 1 2 4 3 4 3 4 3 4 ■ All original domains are ■ Let's filter all the constraints in order ■ By row and then column

  42. 1 1 2 1 2 2 3 4 3 4 3 4 1 2 1 2 1 2 3 3 4 3 4 3 4 1 2 1 2 1 2 3 3 4 3 4 3 4 1 2 1 2 1 2 4 3 4 3 4 3 4 ■ Constraint prunes 2 from

  43. 1 1 1 2 2 3 4 3 4 3 4 1 2 1 2 1 2 3 3 4 3 4 3 4 1 2 1 2 1 2 3 3 4 3 4 3 4 1 2 1 2 1 2 4 3 4 3 4 3 4 ■ Constraint prunes 2 from

  44. 1 1 1 2 3 4 3 4 3 4 1 2 1 2 1 3 3 4 3 4 3 4 1 2 1 2 1 2 3 3 4 3 4 3 4 1 2 1 1 2 4 3 4 3 4 3 4 ■ Constraints and prune a lot

  45. 1 1 1 2 3 4 3 3 4 1 2 1 2 1 3 4 4 1 2 1 2 1 2 3 4 4 1 2 1 2 4 3 ■ By filtering all constraints in order, we get this Can we do more?

  46. 1 1 1 2 3 4 3 3 4 1 2 1 2 1 3 4 4 1 2 1 2 1 2 3 4 4 1 2 1 2 4 3 ■ Yep: and are now singletons ■ Hence, our filtering rules for the constraints can be triggered ■ If we do, we can filter more

  47. Propagation = the process by which filtering from one constraint may enable filtering from another constraint ■ Propagation is controlled by a propagation algorithm

  48. Algorithm: AC1 dirty = true while dirty: dirty = false for : if : dirty = true Where is a procedure that: ■ Given the current variable domains... ■ ...Applies the filtering algorithm of ... ■ ...And then returns the updated domains

  49. AC1 always converges to a fix point, which is independent on the constraint processing order. Proof: We will prove the result in two steps: ■ First, we show that AC1 always terminates... ■ ...When no more pruning can be done ■ Second, we show that the processing order does not matter The proof relies on some properties of

  50. The function filter( ) is inflationary, i.e.: ■ True because a filtering algorithm can only remove domains values ■ Caveat: ■ Technically, is inflationary w.r.t. the order ■ Hence, the term may sound a bit misleading Consequence: AC1 always terminates ■ In the worst case, when becomes empty

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