1 Constraint Programming: An Introduction Adapted by Cristian OLIVA from Peter Stuckey (1998) Ho Chi Minh City.

Slides:



Advertisements
Similar presentations
Constraint Satisfaction Problems
Advertisements

Constraint Satisfaction Problems Russell and Norvig: Chapter
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.
1 Chapter 8: Modelling with Finite Domain Constraints Where we examine how modelling and controlling search interact with finite domain constraints.
1 Constraint operations: Simplification, Optimization and Implication.
Parallel Scheduling of Complex DAGs under Uncertainty Grzegorz Malewicz.
Computability and Complexity 23-1 Computability and Complexity Andrei Bulatov Search and Optimization.
4 Feb 2004CS Constraint Satisfaction1 Constraint Satisfaction Problems Chapter 5 Section 1 – 3.
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
Branch and Bound Similar to backtracking in generating a search tree and looking for one or more solutions Different in that the “objective” is constrained.
1 Optimisation Although Constraint Logic Programming is somehow focussed in constraint satisfaction (closer to a “logical” view), constraint optimisation.
1 Constraint Programming Maurizio Gabbrielli Universita’ di Bologna Slides by: K. Marriott.
Constraint Satisfaction Problems
Approximation Algorithms
Constraint Satisfaction
CSE461: Constraint Programming & Modelling --Constraint Satisfaction Problems-- u Constraint satisfaction problems (CSPs) u A backtracking solver u Node.
1 Chapter 1: Constraints What are they, what do they do and what can I use them for.
26 April 2013Lecture 5: Constraint Propagation and Consistency Enforcement1 Constraint Propagation and Consistency Enforcement Jorge Cruz DI/FCT/UNL April.
Chapter 5 Outline Formal definition of CSP CSP Examples
Linear Systems The definition of a linear equation given in Chapter 1 can be extended to more variables; any equation of the form for real numbers.
Daniel Kroening and Ofer Strichman Decision Procedures An Algorithmic Point of View Deciding ILPs with Branch & Bound ILP References: ‘Integer Programming’
Constraint Satisfaction Problems
Decision Procedures An Algorithmic Point of View
Introduction to Job Shop Scheduling Problem Qianjun Xu Oct. 30, 2001.
Constraint Satisfaction Problems (CSPs) CPSC 322 – CSP 1 Poole & Mackworth textbook: Sections § Lecturer: Alan Mackworth September 28, 2012.
Constraint Satisfaction Problems Chapter 6. Review Agent, Environment, State Agent as search problem Uninformed search strategies Informed (heuristic.
Chapter 5 Section 1 – 3 1.  Constraint Satisfaction Problems (CSP)  Backtracking search for CSPs  Local search for CSPs 2.
Constraint Satisfaction CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Hande ÇAKIN IES 503 TERM PROJECT CONSTRAINT SATISFACTION PROBLEMS.
Artificial Intelligence CS482, CS682, MW 1 – 2:15, SEM 201, MS 227 Prerequisites: 302, 365 Instructor: Sushil Louis,
Chapter 5: Constraint Satisfaction ICS 171 Fall 2006.
CSCI 5582 Fall 2006 CSCI 5582 Artificial Intelligence Fall 2006 Jim Martin.
A Logic of Partially Satisfied Constraints Nic Wilson Cork Constraint Computation Centre Computer Science, UCC.
Chapter 5 Constraint Satisfaction Problems
Review Test1. Robotics & Future Technology Future of Intelligent Systems / Ray Kurzweil futurist Ray Kurzweil / A Long Bet A Long Bet / Robot Soccer.
Chapter 2) CSP solving-An overview Overview of CSP solving techniques: problem reduction, search and solution synthesis Analyses of the characteristics.
1 Chapter 3: Finite Constraint Domains Where we meet the simplest and yet most difficult constraints, and some clever and not so clever ways to solve them.
An Introduction to Artificial Intelligence Lecture 5: Constraint Satisfaction Problems Ramin Halavati In which we see how treating.
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.
Chapter 13 Backtracking Introduction The 3-coloring problem
1 Constraint Satisfaction Problems (CSP). Announcements Second Test Wednesday, April 27.
1 Chapter 1: Constraints What are they, what do they do and what can I use them for.
CS 561, Session 8 1 This time: constraint satisfaction - Constraint Satisfaction Problems (CSP) - Backtracking search for CSPs - Local search for CSPs.
Chapter 2: Simplification, Optimization and Implication
What are they, what do they do and what can I use them for.
Constraint Programming
Finite Domain Propagation
Integer Programming An integer linear program (ILP) is defined exactly as a linear program except that values of variables in a feasible solution have.
Optimization Problems
CSC Modeling with FD Constraints
Chapter 2: Simplification, Optimization and Implication
Finite Constraint Domains
Constraint Satisfaction
Chapter 3: Finite Constraint Domains
Chapter 3: Finite Constraint Domains
Constraint Satisfaction Problems
Artificial Intelligence
Constraints and Search
Advanced consistency methods Chapter 8
Chapter 3: Finite Constraint Domains
Constraint satisfaction problems
Constraint Satisfaction Problems. A Quick Overview
Graphplan/ SATPlan Chapter
Graphplan/ SATPlan Chapter
CS 8520: Artificial Intelligence
Constraint Satisfaction Problems
Constraint satisfaction problems
Presentation transcript:

1 Constraint Programming: An Introduction Adapted by Cristian OLIVA from Peter Stuckey (1998) Ho Chi Minh City

2 Definitions  A constraint C is of the form where m  0 y c 1,c 2,…,c m are primitives constraints. There are two distinct constraints : TRUE and FALSE The empty conjunction of constraints is written as true. The conjunction of two constraints C 1 and C 2 is written

3 Definitions Given a domain D and a constraint C, we can determine values of variables for which the constraint holds. EXAMPLE 1. X=Y+Z The assignment : Holds the constraint and for that the constraint is TRUE. The assignment : Doesn’t hold the constraint and then the constraint is FALSE.

4 Definitions  A set of pairs  for a set V of variables is an asignment of values from the domaine D to variables in V. Let be V={x 1,x 2,…,x n } and V'V, then (V') is : where

5 Definitions  (V') is an instantiation of the variables in V'.  An instantiation (V'), where V'V, is a partial solution if it satisfy all primitive constraints that contain the variables of V'.  An instantiation (V) is a solution if it satisfy the constraint C with domain D.

6 Definitions  A constraint C is satisfiable if it has at least one solution. Otherwise, it is unsatisfiable.  Two constraints C 1 and C 2 are equivalent if they have the same set of solutions.

7 Definitions  The function primitivas takes a constraint. and returns the set of primitive constraints {c 1,c 2,…,c m }

8 Definitions  Given a constraint C and given a domain D, Satisfaction : Does the constraint have a solution? Solution : Give me a solution to the constraint if one exists. Constraint solver is an algorithm that determine the satisfaction of a constraint. However, these algorithms find solutions too.

9 Domains  In general, constraints in Constraint programming mainly operate on domains which are either discrete or continuous. The most known are : Linear arithmetics constraints Booleans constraints Sequence constraints Blocks world constraints Finite constraints domains Others…

10 Finite Constraint Domains  Constraint Satisfaction Problems (CSP).  A CSP consist in : A set of variables V={x 1,x 2,…,x n } For each variable x i there is a finite set of possible values D(x i ) (domain) A set of constraints C that restrict possible values that a variable can take.  A solution to the CSP is an instantiation (V) that satisfy C.

11 Constraint Satisfaction Problem  ¿How to model an optimisation problem by using CSP ? It can be express as a sequence of CSP. For instance, we can create a variable that represents the objective value. We can add the following constraint: Objective_function<objective_current_value

Different kinds of constraint satisfaction techniques  Some of the constraint satisfaction techniques are: Chronological backtracking: Exponential time complexity. Complete solver. Polynomial time complexity. Incomplete Solver. Local consistency  Node consistency  Arc Consistency  Hyper-arc Consistency  Bounds consistency 12

13 Local Consistency Notion  The arity of a primitive constraint is the number of variables it involves. The arity of a CSP is equal to the arity of the highest arity constraint.

14 Local Consistency Notion  An instantiation (V'), where V'V, is consistent if and only if (V') is a partial solution of CSP.  A solution to the CSP is a consistent instantiation (V).

15 Node and Arc consistency  Basic Idea: Find a CSP equivalent to the original one with smaller domains.  Key: examine 1 prim. constraint c, one at a time.  Consistency-Node: (vars(c)={x}) remove the values of the domain of x that no satisfy c  Consistency-Arc: (vars(c)={x,y}) remove the values of D(x) for which there is not a value in D(y) that satisfy c and vice-versa.

16 Node consistent  A primitive constraint c es node consistent with domain D if |vars(c)| 1 or if vars(c) = {x} then for each d in D(x) d  x is a solution of c.  A CSP is node consistent if each primitive constraint is node consistent with D.

17 Node-consistent Example 1: This CSP is node-consistent? NO!!!

18 Achieving Node Consistency 18  Node_consistent  Node_consistent(c,d) For each prim. Constraint c in C node_consistent_primitive  D := node_consistent_primitive(c, D) Return D  Node_consistent_primitive  Node_consistent_primitive(c, D) If |vars(c)| =1 then  Let {x} = vars(c) Return D

19 Arc Consistency  A primitive constraint c is arc consistent with domain D if |vars{c}| ≠2 or Vars(c) = {x,y} and for each d in d(x) there exists e in d(y) such that and similarly for y  A CSP is arc consistent if each prim. Constraint in it is arc consistent

20 Arc-Consistency Example 2: This CSP is arc-consistent? NO!!!

21 Achieving Arc Consistency  Arc_consistent  Arc_consistent(c,d) Repeat  W := d  For each prim. Constraint c in C arc_consistent_primitive  D := arc_consistent_primitive(c,d) Until W = D Return D

22 Achieving Arc Consistency  Arc_consistent_primitive  Arc_consistent_primitive(c, D) If |vars(c)| = 2 then Return D  Removes values which are not arc consistent with c

23 Using node and arc consistency.  We can build constraint solvers using the consistency methods  Two important kinds of domain False domain: some variable has empty domain Valuation domain: each variable has a singleton domain

24 Node and Arc Cons. Solver  Arc_solve(C,D) node_consistent D := node_consistent(C,D) arc_consistent D := arc_consistent(C,D) if D is a false domain  return false if D is a valuation domain  return satisfiable(C,D) return unknown

25 Example : Graph colouring A B C D E F G

26 Node and Arc Solver Example Colouring graph: with constraints A B C D E F G Node consistent

27 A B C D E F G Arc consistent Node and Arc Solver Example Colouring graph: with constraints

A B C D E F G Arc- consistent Node and Arc Solver Example Colouring graph: with constraints

A B C D E F G Arc- consistent Reponse: Unknown Node and Arc Solver Example Colouring graph: with constraints

30 Backtracking Constraint Solver  We can combine consistency with the backtracking solver.  Apply node and arc consistency before starting the backtracking solver and after each variable is given a value.

31 A B C D E F G Backtracking Choice a variable whose domain has a cardinality >1, G Add constraint G=redApply consistency Reponse: satisfiable (TRUE) Backtracking Constraint Solver Colouring graph: with constraints

32 Hyper-arc consistency  What happens when we have primitive constraints that contains more than two variables?  hyper-arc consistency: extending the arc consistency to a arbitrary number of variables.  Unfortunately determine the hyper-arc consistency is NP-hard.  What is the solution?

33 Hyper-arc consistency  A primitive constraint c is hyper-arc consistent with domain D if for each variable x in c and domain assignment tD(X), there is an assignment t 1,…,t k to the remaining variables in c such that t j D(X j ) for 1j k and ((t 1,X 1 ),…(t k,X k )) is a solution of c.  A CSP is hyper-arc consistent if each primitive constraint c i is hyper-arc consistent.

34 Bounds Consistency  arithmetic CSP: constraints are integer  range: [l..u] represents the set of integers {l, l+1,..., u}  idea use real number consistency and only examine the endpoints (upper and lower bounds) of the domain of each variable  Define min(D,x) as minimum element in domain of x, similarly for max(D,x)

35 Bounds consistency  A prim. constraint c is bounds consistent with domain D if for each var x in vars(c) exist real numbers d 1,..., d k for remaining vars x1,..., xk such that : is a solution of c And similarly for  An arithmetic CSP is bounds consistent if all its primitive constraints are.

36 Examples What domain is bounds consistent? Compare with the hyper-arc consistent domain

37 Achieving Bounds Consistency  Given a current domain D we wish to modify the endpoints of domains so the result is bounds consistent  propagation rules do this

38 Achieving Bounds Consistency Consider the primitive constraint X = Y + Z which is equivalent to the three forms Reasoning about minimum and maximum values: : Propagation rules for the constraint X = Y + Z

39 Propagation rules for X=Y+Z Bounds_consistency(D) Return D

40 Propagation rules for Disequations give weak propagation rules, only when one side takes a fixed value that equals the minimum or maximum of the other is there propagation.

41 Alldifferent  alldifferent({V 1,...,V n }) holds when each variable V 1,..,V n takes a different value alldifferent({X, Y, Z}) is equivalent to  Arc consistent with domain  BUT there is no solution! specialized consistency for alldifferent can find it

42 Other Complex Constraints  schedule n tasks with start times Si and durations Di needing resources Ri where L resources are available at each moment  array access if I = i, then X = V i and if X ≠ V i then I ≠ i

43 Optimization for CSP  Because domains are finite can use a solver to build a straightforward optimizer  retry_int_opt  retry_int_opt(C, D, f, best) int_solv D2 := int_solv(C,D) if D2 is a false domain then return best let sol be the solution corresponding to D2 retry_int_opt return retry_int_opt(C /\ f < sol(f), D, f, sol)

44 Optimization Backtracking  Since the solver may use backtrack search anyway combine it with the optimization  At each step in backtracking search, if best is the best solution so far add the constraint f < best(f)

45 Branch and Bound Opt.  The previous methods,unlike simplex don't use the objective function to direct search  branch and bound optimization for (C,f) use simplex to find a real optimal, if solution is integer stop otherwise choose a var x with non-integer opt value d and examine the problems use the current best solution to constrain prob.