Carla P. Gomes CS4700 CS 4700: Foundations of Artificial Intelligence Carla P. Gomes Module: CSP2 (Reading R&N: Chapter 5)

Slides:



Advertisements
Similar presentations
Non-Binary Constraint Satisfaction Toby Walsh Cork Constraint Computation Center.
Advertisements

Complexity Classes: P and NP
Constraint Satisfaction Problems
Optical networks: Basics of WDM
1 Constraint Satisfaction Problems A Quick Overview (based on AIMA book slides)
1 Finite Constraint Domains. 2 u Constraint satisfaction problems (CSP) u A backtracking solver u Node and arc consistency u Bounds consistency u Generalized.
ICS-271:Notes 5: 1 Lecture 5: Constraint Satisfaction Problems ICS 271 Fall 2008.
Artificial Intelligence Constraint satisfaction problems Fall 2008 professor: Luigi Ceccaroni.
Problem Solving by Searching Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 3 Spring 2007.
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
Tutorial 6 of CSCI2110 Bipartite Matching Tutor: Zhou Hong ( 周宏 )
TECH Computer Science Graphs and Graph Traversals  // From Tree to Graph  // Many programs can be cast as problems on graph Definitions and Representations.
Yangjun Chen 1 Bipartite Graphs What is a bipartite graph? Properties of bipartite graphs Matching and maximum matching - alternative paths - augmenting.
4 Feb 2004CS Constraint Satisfaction1 Constraint Satisfaction Problems Chapter 5 Section 1 – 3.
Anagh Lal Monday, April 14, Chapter 9 – Tree Decomposition Methods Anagh Lal CSCE Advanced Constraint Processing.
CPSC 322, Lecture 12Slide 1 CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12 (Textbook Chpt ) January, 29, 2010.
Impact of Structure on Complexity Carla Gomes Bart Selman Cornell University Intelligent Information Systems.
NP-Complete Problems Reading Material: Chapter 10 Sections 1, 2, 3, and 4 only.
Introduction to Graphs
Yangjun Chen 1 Bipartite Graph 1.A graph G is bipartite if the node set V can be partitioned into two sets V 1 and V 2 in such a way that no nodes from.
AAAI00 Austin, Texas Generating Satisfiable Problem Instances Dimitris Achlioptas Microsoft Carla P. Gomes Cornell University Henry Kautz University of.
Structure and Phase Transition Phenomena in the VTC Problem C. P. Gomes, H. Kautz, B. Selman R. Bejar, and I. Vetsikas IISI Cornell University University.
Lecture 11. Matching A set of edges which do not share a vertex is a matching. Application: Wireless Networks may consist of nodes with single radios,
Lecture 11. Matching A set of edges which do not share a vertex is a matching. Application: Wireless Networks may consist of nodes with single radios,
On Channel-Discontinuity-Constraint Routing in Multi-Channel Wireless Infrastructure Networks Abishek Gopalan, Swaminathan Sankararaman 1.
2 March 2006 Constraints - Finite Domains 1 Constraints – Finite Domains  Advanced Constraints Cardinality Constraints Propositional Constraints Constructive.
1 Shortest Path Calculations in Graphs Prof. S. M. Lee Department of Computer Science.
CP Summer School Modelling for Constraint Programming Barbara Smith 1.Definitions, Viewpoints, Constraints 2.Implied Constraints, Optimization,
Nattee Niparnan. Easy & Hard Problem What is “difficulty” of problem? Difficult for computer scientist to derive algorithm for the problem? Difficult.
Combinatorial Algorithms Unate Covering Binate Covering Graph Coloring Maximum Clique.
Structure and Phase Transition Phenomena in the VTC Problem C. P. Gomes, H. Kautz, B. Selman R. Bejar, and I. Vetsikas IISI Cornell University University.
Discrete Structures for Computer Science Muad M. Abu-Ata Summer 2013.
GRAPHS CSE, POSTECH. Chapter 16 covers the following topics Graph terminology: vertex, edge, adjacent, incident, degree, cycle, path, connected component,
Incidentor coloring: methods and results A.V. Pyatkin "Graph Theory and Interactions" Durham, 2013.
CP Summer School Modelling for Constraint Programming Barbara Smith 2. Implied Constraints, Optimization, Dominance Rules.
The AllDifferent Constraint: Efficiency Measures Ian P. Gent, Ian Miguel, Peter Nightingale.
Chapter 5: Constraint Satisfaction ICS 171 Fall 2006.
GRAPHS THEROY. 2 –Graphs Graph basics and definitions Vertices/nodes, edges, adjacency, incidence Degree, in-degree, out-degree Subgraphs, unions, isomorphism.
Data Structures & Algorithms Graphs
Graph Colouring L09: Oct 10. This Lecture Graph coloring is another important problem in graph theory. It also has many applications, including the famous.
CSE 589 Part VI. Reading Skiena, Sections 5.5 and 6.8 CLR, chapter 37.
CSE373: Data Structures & Algorithms Lecture 22: The P vs. NP question, NP-Completeness Lauren Milne Summer 2015.
Explorations in Artificial Intelligence Prof. Carla P. Gomes Module 6 Binary CSP.
NP-COMPLETE PROBLEMS. Admin  Two more assignments…  No office hours on tomorrow.
Quality of LP-based Approximations for Highly Combinatorial Problems Lucian Leahu and Carla Gomes Computer Science Department Cornell University.
Graphs A ‘Graph’ is a diagram that shows how things are connected together. It makes no attempt to draw actual paths or routes and scale is generally inconsequential.
CP Summer School Modelling for Constraint Programming Barbara Smith 3. Symmetry, Viewpoints.
CHAPTER 5 SECTION 1 – 3 4 Feb 2004 CS Constraint Satisfaction 1 Constraint Satisfaction Problems.
Graphs A graphs is an abstract representation of a set of objects, called vertices or nodes, where some pairs of the objects are connected by links, called.
1 Combinatorial Problems in Cooperative Control: Complexity and Scalability Carla P. Gomes and Bart Selman Cornell University Muri Meeting June 2002.
GRAPHS. Graph Graph terminology: vertex, edge, adjacent, incident, degree, cycle, path, connected component, spanning tree Types of graphs: undirected,
Computer Sciences Department1.  Property 1: each node can have up to two successor nodes (children)  The predecessor node of a node is called its.
1. 2 Outline of Ch 4 Best-first search Greedy best-first search A * search Heuristics Functions Local search algorithms Hill-climbing search Simulated.
Chapter 13 Backtracking Introduction The 3-coloring problem
Chapter 5 Team Teaching AI (created by Dewi Liliana) PTIIK Constraint Satisfaction Problems.
Introduction to NP Instructor: Neelima Gupta 1.
The NP class. NP-completeness Lecture2. The NP-class The NP class is a class that contains all the problems that can be decided by a Non-Deterministic.
EMIS 8373: Integer Programming Combinatorial Optimization Problems updated 27 January 2005.
CS 561, Session 8 1 This time: constraint satisfaction - Constraint Satisfaction Problems (CSP) - Backtracking search for CSPs - Local search for CSPs.
The NP class. NP-completeness
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
The minimum cost flow problem
Problem Solving by Searching
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
Bipartite Graph 1. A graph G is bipartite if the node set V can be partitioned into two sets V1 and V2 in such a way that no nodes from the same set are.
Constraint Satisfaction Problems
Implementation of Learning Systems
Presentation transcript:

Carla P. Gomes CS4700 CS 4700: Foundations of Artificial Intelligence Carla P. Gomes Module: CSP2 (Reading R&N: Chapter 5)

Carla P. Gomes CS4700 Encodings Global Constraints Redundant Constraints Streamlining Complexity

Carla P. Gomes CS4700 Case Study

Carla P. Gomes CS4700 Given an N X N matrix, and given N colors, a Latin Square of order N is a colored matrix, such that: -all cells are colored. - each color occurs exactly once in each row. - each color occurs exactly once in each column. Latin Square (Order 4) Latin Squares: An Abstraction for Real World Applications

Carla P. Gomes CS4700 Fiber Optic Networks Nodes are capable of photonic switching --dynamic wavelength routing -- which involves the setting of the wavelengths. Nodes connect point to point fiber optic links Each fiber optic link supports a large number of wavelengths Wavelength Division Multiplexing (WDM) the most promising technology for the next generation of wide-area backbone networks.

Carla P. Gomes CS4700 Routing in Fiber Optic Networks Routing Node How can we achieve conflict-free routing in each node of the network? Dynamic wavelength routing is an NP-hard problem. Input PortsOutput Ports preassigned channels

Carla P. Gomes CS4700 Application Example: Routers in Fiber Optic Networks Application Example: Routers in Fiber Optic Networks Dynamic wavelength routing in Fiber Optic Networks can be directly mapped into the Latin Square Completion Problem. each channel cannot be repeated in the same input port (row constraints); each channel cannot be repeated in the same output port (column constraints); CONFLICT FREE LATIN ROUTER Input ports Output ports Input PortOutput Port

Carla P. Gomes CS4700 Design of Statistical Experiments We have 5 treatments for growing beans. We want to know what treatments are effective in increasing yield, and by how much. The objective is to eliminate bias and distribute the treatments somewhat evenly over the test plot. Latin Square Analysis of Variance B A D E B C C B A E D B D C B A E E A C D B B E D C A (*) Already in use in this sub-plot

R2 X R4 R1 R3 R5 XR1R5R4R3 R2R4R1R3R5 R1XR3R5R2 R5R3 X R2 R4 R5R2 X R1 R3R2R4 R1 X teams Scheduling and timetabling Many more applications… Sudoku Underlying Latin Square structure Characterizes many real world applications

Carla P. Gomes CS4700 Given an N X N matrix, and given N colors, a Latin Square of order N is a colored matrix, such that: -all cells are colored. - each color occurs exactly once in each row. - each color occurs exactly once in each column. Latin Square (Order 4) Latin Squares: An Abstraction for Real World Applications How do you generate a Latin square, say a 5x5? Is it computationally hard?

Carla P. Gomes CS4700 Given a partial assignment of colors (10 colors in this case), can the partial quasigroup (latin square) be completed so we obtain a full quasigroup? Example: Completing Latin Squares: A Hard Computational Problem Deciding if a Latin Square is completable is NP-Complete

Carla P. Gomes CS4700 How to Encode the Latin Square Completion as a CSP?

Latin Square Completion as a Binary CSP Variables - Constraints - How do we represent the Latin Square problem as a binary CSP? Graph Coloring Problem

C. P. Gomes Forward CheckingArc Consistency Domain Reduction in LSCP

C. P. Gomes Other Examples of Applications of Graph Coloring

C. P. Gomes Scheduling of Final Exams What are the constraints between courses? Find a valid coloring Time Period I II III IV Courses 1,6 2 3,5 4,7

C. P. Gomes Scheduling of Final Exams How can the final exams at Cornell be scheduled so that no student has two exams at the same time? A vertex correspond to a course; An edge between two vertices denotes that there is at least one common Student in the courses they represent; Each time slot for a final exam is represented by a different color. A coloring of the graph corresponds to a valid schedule of the exams.

C. P. Gomes Frequency Assignments T.V. channels 2 through 13 are assigned to stations in North America so that no no two stations within 150 miles can operate on the same channel. How can the assignment of channels be modeled as a graph coloring? A vertex corresponds to one station; There is a edge between two vertices if they are located within 150 miles of each other Coloring of graph --- corresponds to a valid assignment of channels; each color represents a different channel. Many other problems can be represented as graph coloring…

C. P. Gomes Index Registers In efficient compilers the execution of loops can be sped up by storing frequently used variables temporarily in index registers in the central processing unit, instead of the regular memory. For a given loop, how many index registers are needed? Each vertex corresponds to a variable in the loop. An edge between two vertices denotes the fact that the corresponding variables must be stored in index registers at the same time during the execution of the loop. Chromatic number of the graph gives the number of index registers needed.

C. P. Gomes Other Representations

C. P. Gomes Latin Square Completion as an n-ary CSP Variables - Constraints - row column [ vs. for Binary CSP] Why would we use this formulation?

C. P. Gomes Exploiting Structure for Domain Reduction A very successful strategy for domain reduction in CSP is to exploit the structure of groups of constraints and treat them as a sub-problem. Example using Network Flow Algorithms: All-different constraints (Alldiff)

C. P. Gomes Exploiting Structure in QCP ALLDIFF as Global Constraint Two solutions: we can update the domains of the column variables Analogously, we can update the domains of the other variables Matching on a Bipartite graph All-different constraint (Matching on a bipartite graph)

C. P. Gomes Exploiting Structure Arc Consistency vs. All Diff Arc Consistency (Binary CSP) Solves up to order 20 Size search space AllDiff Solves up to order 40 Size search space

C. P. Gomes Global Constraints: alldiff Example: X 1 : 1,2,3X 6 : 1,2,3,4,5,6,7,8,9 X 2 : 1,2,3,4,5,6X 7 : 1,2,3,4,5,6,7,8,9 X 3 : 1,2,3,4,5,6,7,8,9X 8 : 1,2,3 X 4 : 1,2,3,4,5,6X 9 : 1,2,3,4,5,6 X 5 : 1,2,3 It is clear that constraint propagation based on maintenance of node-, arc- or even path-consistency would not eliminate any redundant label. Yet, it is very easy to infer such elimination with a global view of the constraint! Example from Pedro Barahona

C. P. Gomes Global Constraints: alldiff Variables X 1, X 5 and X 8 may only take values 1, 2 and 3. Since there are 3 values for 3 variables, these must be assigned these values which must then be removed from the domain of the other variables. Now, variables X2, X4 and X9 may only take values 4, 5 e 6, that must be removed from the other variables domains. X 1 : 1,2,3 X 2 : 1,2,3,4,5,6 X 3 : 1,2,3,4,5,6,7,8,9 X 4 : 1,2,3,4,5,6 X 5 : 1,2,3 X 6 : 1,2,3,4,5,6,7,8,9 X 7 : 1,2,3,4,5,6,7,8,9 X 8 : 1,2,3X 9 : 1,2,3,4,5,6 X 1 : 1,2,3 X 2 : 1,2,3,4,5,6 X 3 : 1,2,3,4,5,6,7,8,9 X 4 : 1,2,3, 4,5,6 X 5 : 1,2,3 X 6 : 1,2,3,4,5,6,7,8,9 X 7 : 1,2,3,4,5,6,7,8,9 X 8 : 1,2,3X 9 : 1,2,3,4,5,6

C. P. Gomes Global Constraints: alldiff In this case, these prunings could be obtained, by maintaining (strong) 4-consistency. For example, analysing variables X 1, X 2, X 5 and X 8, it would be “easy” to verify that from the d 4 potential assignments of values to them, no assignment would include X 2 =1, X 2 =2, nor X 2 =3, thus leading to the prunning of X 2 domain. However, such maintenance is usually very expensive, computationally. For each combination of 4 variables, d 4 tuples whould be checked, with complexity O(d 4 ). In fact, in some cases, n-strong consistency would be required, so its naïf maintenance would be exponential on the number of variables, exactly what one would like to avoid in search!

C. P. Gomes Global Constraints: all_diff Key Ideas: Formulate the problem as “Matching” on a bipartite graph: For each variable-value pair, there is an arc in the bipartite graph. A subset of arcs of a graph is called a matching, if no two arcs have a vertex in common. A matching of maximum cardinality is called a maximum matching. Note that when we have a bipartite graph a matchibng that covers all the nodes is a maximum matching. For any solution of the all_diff constraint there is one and only one maximum matching. See Regin AAAI 1994

C. P. Gomes Global Constraints: all_diff Example: A,B:: 1..2, C:: 1..3, D:: 2..5, E:: 3..6, all_diff([A,B,C,D,E]). A B C D E A = 1 B = 2 C = 3 D = 4 E = 5 Maximum Matching

C. P. Gomes Global Constraints: all_diff Given a CSP P, it is diff-arc-consistent iff every arc belongs to a matching which covers all the nodes of the graph associated with P. Given a matching M, an arc in M is a matching arc. Every arc not in M is free. A node or vertex is matched if it is incident to a matching arc and free otherwise. An alternating path or cycle is a simple path or cycle whose arcs or edges are alternately matching and free. The length of an alternating path or cycle is the number of arcs or edges it contains. An arc or edge which belongs to every matching is vital.

C. P. Gomes Global Constraints: all_diff The propagation (domain filtering) is done according to the following principles: If an arc does not belong to any maximal matching, then it does not belong to any all_diff solution. Given a maximal matching, an arc belongs to any maximal matching iff it belongs (Berge 1970): To an even alternating cycle; or To an even alternating path, starting at a free node. Given a CSP P, it is diff-arc-consistent iff every arc belongs to a matching which covers all the nodes of the graph associated with P.

C. P. Gomes Global Constraints: all_diff Example: For the maximal matching (MM) shown 6 is a free node; 6-E-5-D-4 is an even alternating path, alternating arcs from the MM (E-5, D-4) with arcs not in the MM (D-5, E-6); A-1-B-2-A is an even alternating cycle; E-3 does not belong to any even alternating cycle E-3 does not belong to any even alternating path starting in a free node (6) E-3 may be filtered out! A B C D E

C. P. Gomes Global Constraints: all_diff Compaction Before this analysis, the graph may be “compacted”, aggregating, into a single node, “equivalent nodes”, i.e. those belonging to even alternating cycles. Intuitively, for any solution involving these variables and values, a different solution may be obtained by permutation of the corresponding assignments.

C. P. Gomes Global Constraints: all_diff A-1-B-2-A is an even alternating cycle; By permutation of variables A and B, the solution = becomes = Hence, nodes A e B, as well as nodes 1 and 2 may be grouped together (as may the nodes D/E and 4/5). A/B C 4/5 3 6 D/E 1/2 A B C D E With these grouping the graph becomes much more compact

C. P. Gomes Global Constraints: all_diff Analysis of the compacted graph shows that A/B C 4/5 3 6 D/E 1/2 A/B C 4/5 3 6 D/E 1/2 Arc D/E - 3 may be filtered out (notice that despite belonging to cycle D/E C - 1/2 - D/E, this cycle is not alternating. Arcs D/E - 1/2 and C - 1/2 may also be filtered. The compact graph may thus be further simplified to

C. P. Gomes Global Constraints: all_diff By expanding back the simplified compact graph, one gets the graph on the right that A/B C 4/5 3 6 D/E 1/2 Which immediately sets C=3 and, more generaly, filters the initial domains to A,B :: 1..2, C:: 1,2,3, D:: 2,3,4,5, E:: 3,4,5,6 A B C D E

C. P. Gomes Global Constraints: all_diff Upon elimination of some labels (arcs), possibly due to other constraints, the all_diff constraint propagates such prunings, incrementally. There are 3 situations to consider: Elimination of a vital arc (the only arc connecting a variable node with a value node): The constraint cannot be satisfied. A B C D E A B C D E ?

C. P. Gomes Global Constraints: all_diff Elimination of a non-vital arc which is a not member to the maximal matching Eliminate the arcs that do not belong any more to an alternating cycle or path. A B C D E A B C D E Arc A-4 does not belong to the even alternating path started in node 6. D-5 also leaves this path, but it still belongs to an even alternating cycle.

C. P. Gomes Global Constraints: all_diff Elimination of a non-vital arc which is not a member to the maximal matching Determine a new maximal matching and restart from there. A new maximal matching includes arcs D-5 and E-6. In this matching, arcs E-4 and E-5 do not belong to even alternating paths or alternating cycles. A B C D E A B C D E

C. P. Gomes Global Constraints Alldiff  example of a “global constraint.” “Global” – since they typically involve several variables and constraints (as in the alldiff). Poor choice of name…they are still local… Global constraints encapsulate a sub-problem, (typically, why?) solved efficiently (polytime). Network flow algorithms are used for several global constraints. Lots of global constraints, e.g., element constraint, cardinality constraint, sequence constraint, etc, etc Active Research Area

C. P. Gomes Catalog of global constraints (300+) ConstraintStructure/technique alldifferentbipartite matching [Régin, 1994] symmetric- alldifferent general matching [Régin, 1999] soft-alldifferentmatching [Petit, Régin & Bessière, 2001], minimum-cost flow [van Hoeve, 2004] Cardinality matrixnetwork flow, transportation problem [Régin & Gomes, 2004] cardinalitynetwork flow [Régin, 1999, 2002] soft-cardinality minimum-cost flow [van Hoeve, Pesant & Rousseau, 2005], [Milano & Zanarini, 2006] open-cardinalitynetwork flow [van Hoeve & Régin, 2006] knapsack/sumdynamic programming [Trick, 2003] regulardirected acyclic graph [Pesant, 2004] soft-regularshortest paths [van Hoeve, Pesant & Rousseau, 2005] circuitnetwork flow [Kaya & Hooker, 2006] sequencededicated algorithm [van Hoeve, Pesant, Rousseau & Sabharwal, 2006] disjunctive/cumulati ve dedicated algorithm [Carlier & Pinson, 1994] [Mercier & Van Hentenryck, 2006] inter-distancededicated algorithm [Quimper, Lopez-Ortiz & Pesant, 2006]...