Constraint Processing and Programming Introductory Exemple Javier Larrosa.

Slides:



Advertisements
Similar presentations
Constraint Satisfaction Problems
Advertisements

DCS Lecture how to solve it Patrick Prosser. Put a different number in each circle (1 to 8) such that adjacent circles cannot take consecutive numbers.
Constraint Programming Peter van Beek University of Waterloo.
Constraint Satisfaction Problems Russell and Norvig: Chapter
Constraint Satisfaction Introduction to Artificial Intelligence COS302 Michael L. Littman Fall 2001.
Lecture 11 Last Time: Local Search, Constraint Satisfaction Problems Today: More on CSPs.
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.
Constraint Programming for Compiler Optimization March 2006.
Programming with Constraints Jia-Huai You. Subject of Study Constraint Programming (CP) studies the computational models, languages, and systems for solving.
Constraint Satisfaction Problems. Constraint satisfaction problems (CSPs) Standard search problem: – State is a “black box” – any data structure that.
4 Feb 2004CS Constraint Satisfaction1 Constraint Satisfaction Problems Chapter 5 Section 1 – 3.
CPSC 322, Lecture 12Slide 1 CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12 (Textbook Chpt ) January, 29, 2010.
Artificial Intelligence Constraint satisfaction Chapter 5, AIMA.
Constraint Satisfaction Problems
CS460 Fall 2013 Lecture 4 Constraint Satisfaction Problems.
© J. Christopher Beck Lecture 11: Constraint Programming 1.
Constraint Satisfaction Problem Solving Chapter 5.
Chapter 5 Outline Formal definition of CSP CSP Examples
Distributed Scheduling. What is Distributed Scheduling? Scheduling: –A resource allocation problem –Often very complex set of constraints –Tied directly.
Constraint Satisfaction Problems
Constraint Satisfaction Problems
Constraint Programming for Supply Chain Management J. Christopher Beck Cork Constraint Computation Centre (4C) SCM Information Day, Nov.
CP Summer School Modelling for Constraint Programming Barbara Smith 1.Definitions, Viewpoints, Constraints 2.Implied Constraints, Optimization,
CONSTRAINT PROGRAMMING Computer Science Seminar April 9 th, 2004 Kerem Kacel.
© J. Christopher Beck Lecture 13: Modeling in Constraint Programming.
N Model problem ä specify in terms of constraints on acceptable solutions ä define variables (denotations) and domains ä define constraints in some language.
Constraint Satisfaction Problems Chapter 6. Review Agent, Environment, State Agent as search problem Uninformed search strategies Informed (heuristic.
Constraint Satisfaction Read Chapter 5. Model Finite set of variables: X1,…Xn Variable Xi has values in domain Di. Constraints C1…Cm. A constraint specifies.
Chapter 5 Section 1 – 3 1.  Constraint Satisfaction Problems (CSP)  Backtracking search for CSPs  Local search for CSPs 2.
Sudoku Solver Comparison A comparative analysis of algorithms for solving Sudoku.
Constraint Satisfaction CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Hande ÇAKIN IES 503 TERM PROJECT CONSTRAINT SATISFACTION PROBLEMS.
Chapter 5: Constraint Satisfaction ICS 171 Fall 2006.
CSCI 5582 Fall 2006 CSCI 5582 Artificial Intelligence Fall 2006 Jim Martin.
1 Chapter 5 Constraint Satisfaction Problems. 2 Outlines  Constraint Satisfaction Problems  Backtracking Search for CSPs  Local Search for CSP  The.
Chapter 5 Constraint Satisfaction Problems
Constraints and Search Toby Walsh Cork Constraint Computation Centre (4C) Logic & AR Summer School, 2002.
Principles of Intelligent Systems Constraint Satisfaction + Local Search Written by Dr John Thornton School of IT, Griffith University Gold Coast.
Constraint Satisfaction Problems
Constraint Satisfaction Problems (Chapter 6)
CP Summer School Modelling for Constraint Programming Barbara Smith 3. Symmetry, Viewpoints.
1 Constraint Satisfaction Problems Chapter 5 Section 1 – 3 Grand Challenge:
CHAPTER 5 SECTION 1 – 3 4 Feb 2004 CS Constraint Satisfaction 1 Constraint Satisfaction Problems.
Constraint Satisfaction Problems University of Berkeley, USA
Put a different number in each circle (1 to 8) such that adjacent circles cannot take consecutive numbers.
1. 2 Outline of Ch 4 Best-first search Greedy best-first search A * search Heuristics Functions Local search algorithms Hill-climbing search Simulated.
BIL 472 SADI EVREN SEKER Constraint Satisfaction.
Computing & Information Sciences Kansas State University Friday, 08 Sep 2006CIS 490 / 730: Artificial Intelligence Lecture 7 of 42 Friday, 08 September.
Chapter 5 Team Teaching AI (created by Dewi Liliana) PTIIK Constraint Satisfaction Problems.
Constraint Satisfaction CSE 473 University of Washington.
1 Constraint Satisfaction Problems (CSP). Announcements Second Test Wednesday, April 27.
Alternative Search Formulations and Applications
ARTIFICIAL INTELLIGENCE (CS 461D) Dr. Abeer Mahmoud Computer science Department Princess Nora University Faculty of Computer & Information Systems.
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
Monster (“Mega”) Sudoku
Constraint Satisfaction Problems (CSPs)
Constraint Satisfaction
Lecture 7 Constraint Satisfaction Problems
Chapter 3: Finite Constraint Domains
Artificial Intelligence
Incorporating Constraint Checking Costs in Constraint Satisfaction Problem Suryakant Sansare.
Constraints and Search
Constraint satisfaction problems
Constraint Satisfaction
CS 8520: Artificial Intelligence
Constraint Satisfaction Problems
Constraint satisfaction problems
Presentation transcript:

Constraint Processing and Programming Introductory Exemple Javier Larrosa

Combinatorial Problem Solving Science and Engineering are full of Combinatorial Problems Solving algorithms are exponentially expensive A lot of tricks can be applied to improve performance Naive Approach For each problem, design and implement an efficient algorithm

Place numbers 1 through 8 on nodes each number appears exactly once no connected nodes have consecutive numbers ? ? ? ? ? ? ?? Note the graph symmetry Acknowledgement: Patrick Prosser

Heuristic Search Which nodes are hardest to number? ? ? ? ? ? ? ?? Guess a value, but be prepared to backtrack

Heuristic Search ? ? ? ? ? ? ?? Which nodes are hardest to number?

Heuristic Search Which are the least constraining values to use? ? ? ? ? ? ? ?? Values 1 & 8

Heuristic Search Symmetry means we don’t need to consider: 8 1 ? 1 ? ? 8 ? ??

Inference/propagation We can now eliminate many values for other nodes ? 1 ? ? 8 ? ?? {1,2,3,4,5,6,7,8}

Inference/propagation By symmetry ? 1 ? ? 8 ? ?? {3,4,5,6}

Inference/propagation ? 1 ? ? 8 ? ?? {3,4,5,6} {1,2,3,4,5,6,7,8}

Inference/propagation By symmetry ? 1 ? ? 8 ? ?? {3,4,5,6}

Inference/propagation ? 1 ? ? 8 ? ?? {3,4,5,6} {3,4,5,6,7}{2,3,4,5,6}

Inference/propagation ? 1 ? ? 8 ? 27 {3,4,5,6}

Inference/propagation ? 1 ? ? 8 ? 27 {3,4,5,6} And propagate

Inference/propagation ? 1 ? ? 8 ? 27 {3,4,5} {4,5,6}

Inference/propagation 3 1 ? ? 8 ? 27 {3,4,5} {4,5,6} By symmetry

Inference/propagation 3 1 ? ? 8 ? 27 {3,4,5} {4,5,6} And propagate

Inference/propagation 3 1 ? ? 8 ? 27 {4,5} {5,6} {4,5,6} More propagation?

Inference/propagation A solution

The Declarative Approach to Combinatorial Problem Solving Declarative Approach 1. Model the problem using a well-defined language 2. Solve the problem using general-purpose techniques Constraint Programming and SAT solving follow this approach.

Constraint programming methodology Model problem Solve model Verify and analyze solution specify in terms of constraints on acceptable solutions define/choose constraint model: variables, domains, constraints define/choose algorithm define/choose heuristics

Constraint programming methodology Model problem Solve model Verify and analyze solution specify in terms of constraints on acceptable solutions define/choose constraint model: variables, domains, constraints define/choose algorithm define/choose heuristics Constraint Satisfaction Problem

Constraint satisfaction problem A CSP is defined by a set of variables a domain of values for each variable a set of constraints between variables A solution is an assignment of a value to each variable that satisfies the constraints

Given a CSP Determine whether it has a solution or not Find any solution Find all solutions Find an optimal solution, given some cost function

Constraint model for puzzle variables v 1, …, v 8 domains {1, …, 8} constraints | v 1 – v 2 |  1 | v 1 – v 3 |  1 … | v 7 – v 8 |  1 alldifferent(v 1, …, v 8 ) ? ? ? ? ? ? ??

Example: instruction scheduling (a + b) + c Given a basic-block of code and a single-issue pipelined processor, find the minimum schedule

Example: evaluate (a + b) + c instructions A r1  a B r2  b C r3  c D r1  r1 + r2 E r1  r1 + r AB DC E dependency DAG

Example: evaluate (a + b) + c non-optimal schedule Ar1  a Br2  b nop Dr1  r1 + r2 Cr3  c nop Er1  r1 + r AB DC E dependency DAG

Example: evaluate (a + b) + c optimal schedule Ar1  a Br2  b Cr3  c nop Dr1  r1 + r2 Er1  r1 + r AB DC E dependency DAG

Constraint model variables A, B, C, D, E domains {1, …, m} constraints D  A + 3 D  B + 3 E  C + 3 E  D + 1 alldifferent(A, B, C, D, E) AB DC E dependency DAG

Example: Graph coloring Given k colors, does there exist a coloring of the nodes such that adjacent nodes are assigned different colors

Example: 3-coloring variables: v 1, v 2, v 3, v 4, v 5 domains: {1, 2, 3} constraints: v i  v j if v i and v j are adjacent v2v2 v3v3 v1v1 v5v5 v4v4

Example: 3-coloring A solution v 1  1 v 2  2 v 3  2 v 4  1 v 5  3 v2v2 v3v3 v1v1 v5v5 v4v4

Example: n-queens Place n-queens on an n  n board so that no pair of queens attacks each other

Constraint model x1 x1 x2x2 x3 x3 x4 x4 variables: x 1, x 2, x 3, x 4 domains: {1, 2, 3, 4} constraints: x i  x j and | x i - x j |  | i - j |

Example: 4-queens A solution x 1  2 x 2  4 x 3  1 x 4  3 Q Q Q Q x1 x1 x2x2 x3 x3 x4 x

Constraint programming methodology Model problem Solve model Verify and analyze solution specify in terms of constraints on acceptable solutions define/choose constraint model: variables, domains, constraints define/choose algorithm define/choose heuristics

Constraint programming methodology Model problem Solve model Verify and analyze solution specify in terms of constraints on acceptable solutions define/choose constraint model: variables, domains, constraints define/choose algorithm define/choose heuristics

Application areas Paradigm of choice for many hard combinatorial problems scheduling planning vehicle routing configuration bioinformatics …

Commercial applications