Global Constraints Toby Walsh National ICT Australia and University of New South Wales www.cse.unsw.edu.au/~tw.

Slides:



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

INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
Global Constraints Toby Walsh National ICT Australia and University of New South Wales
Global Constraints Toby Walsh National ICT Australia and University of New South Wales
Global Constraints Toby Walsh NICTA and University of New South Wales
Global Constraints Toby Walsh National ICT Australia and University of New South Wales
Global Constraints Toby Walsh National ICT Australia and University of New South Wales
Global Constraints Toby Walsh National ICT Australia and University of New South Wales
Global Constraints Toby Walsh NICTA and University of New South Wales
Complexity Classes: P and NP
Global Constraints Toby Walsh National ICT Australia and University of New South Wales
Graphs and Finding your way in the wilderness
Order encoding x i ↔ (X ≥ i)(X = 3) = [1,1,1,0,0] Problem (hard) Problem (hard) Solution CNF Encoding Finite Domain Problem Solving Model Constraint Model.
Global Constraints Toby Walsh National ICT Australia and University of New South Wales
Global Constraints Toby Walsh National ICT Australia and University of New South Wales
1 Finite Constraint Domains. 2 u Constraint satisfaction problems (CSP) u A backtracking solver u Node and arc consistency u Bounds consistency u Generalized.
Regular Expressions and DFAs COP 3402 (Summer 2014)
Exploiting Symmetry in Planning Maria Fox Durham Planning Group University of Durham, UK.
Getting started with ML ML is a functional programming language. ML is statically typed: The types of literals, values, expressions and functions in a.
LR-Grammars LR(0), LR(1), and LR(K).
More NP-completeness Sipser 7.5 (pages ). CS 311 Fall NP’s hardest problems Definition 7.34: A language B is NP-complete if 1.B ∈ NP 2.A≤
1 L is in NP means: There is a language L’ in P and a polynomial p so that L 1 · L 2 means: For some polynomial time computable map r : 8 x: x 2 L 1 iff.
Sliding Constraints Toby Walsh National ICT Australia and University of New South Wales Joint work with Christian Bessiere, Emmanuel.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture4: Regular Expressions Prof. Amos Israeli.
Introduction to Computability Theory
More NP-completeness Sipser 7.5 (pages ).
Constraint Models for the Covering Test Problems Authors: Brahim Hnich, Steven D. Prestwich, Evgeny Selensky, Barbara M. Smith Speaker: Pingyu Zhang CSE.
1 Operational Semantics Mooly Sagiv Tel Aviv University Textbook: Semantics with Applications.
Jean-Charles REGIN Michel RUEHER ILOG Sophia Antipolis Université de Nice – Sophia Antipolis A global constraint combining.
Global Grammar Constraints Toby Walsh National ICT Australia and University of New South Wales Joint work with Claude-Guy Quimper.
Sequential Circuits Chapter 4 S. Dandamudi To be used with S. Dandamudi, “Fundamentals of Computer Organization and Design,” Springer,  S.
1 L is in NP means: There is a language L’ in P and a polynomial p so that L 1 ≤ L 2 means: For some polynomial time computable map r : x: x L 1 iff r(x)
CP Summer School Modelling for Constraint Programming Barbara Smith 1.Definitions, Viewpoints, Constraints 2.Implied Constraints, Optimization,
Symmetry Breaking Ordering Constraints Zeynep Kiziltan Department of Information Science Uppsala University, Sweden A progress.
February 18, 2015CS21 Lecture 181 CS21 Decidability and Tractability Lecture 18 February 18, 2015.
Modelling for Constraint Programming Barbara Smith CP 2010 Doctoral Programme.
CP Summer School Modelling for Constraint Programming Barbara Smith 2. Implied Constraints, Optimization, Dominance Rules.
CS344: Introduction to Artificial Intelligence Lecture: Herbrand’s Theorem Proving satisfiability of logic formulae using semantic trees (from Symbolic.
EMIS 8373: Integer Programming NP-Complete Problems updated 21 April 2009.
CSCI 3160 Design and Analysis of Algorithms Tutorial 10 Chengyu Lin.
CP Summer School Modelling for Constraint Programming Barbara Smith 4. Combining Viewpoints, Modelling Advice.
1 P P := the class of decision problems (languages) decided by a Turing machine so that for some polynomial p and all x, the machine terminates after at.
CP Summer School Modelling for Constraint Programming Barbara Smith 3. Symmetry, Viewpoints.
Tommy Messelis * Stefaan Haspeslagh Patrick De Causmaecker *
Strings Basic data type in computational biology A string is an ordered succession of characters or symbols from a finite set called an alphabet Sequence.
Chap. 7, Syntax-Directed Compilation J. H. Wang Nov. 24, 2015.
CSCI 2670 Introduction to Theory of Computing December 2, 2004.
10.3 Reformulation The Lex-Leader Method Shant Karakashian 1.
CSCI 2670 Introduction to Theory of Computing December 7, 2005.
Operational Semantics Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson
Operational Semantics Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson
COMBINATIONAL AND SEQUENTIAL CIRCUITS Guided By: Prof. P. B. Swadas Prepared By: BIRLA VISHVAKARMA MAHAVDYALAYA.
© 2012 IBM Corporation Perfect Hashing and CNF Encodings of Cardinality Constraints Yael Ben-Haim Alexander Ivrii Oded Margalit Arie Matsliah SAT 2012.
P & NP.
Lecture 7: Constrained Conditional Models
L is in NP means: There is a language L’ in P and a polynomial p so that L1 ≤ L2 means: For some polynomial time computable map r :  x: x  L1 iff.
The Propositional Calculus
Recovering and Exploiting Structural Knowledge from CNF Formulas
Chapter 4: Decision Structures and Boolean Logic
The Satisfiability Problem
Chapter 4: Decision Structures and Boolean Logic
NP-Complete Problems.
CS21 Decidability and Tractability
Advanced LP models column generation.
CIS 720 Lecture 3.
Instructor: Aaron Roth
CIS 720 Lecture 3.
Chapter 4: Decision Structures and Boolean Logic
The Satisfiability Problem
Presentation transcript:

Global Constraints Toby Walsh National ICT Australia and University of New South Wales

Course outline ● Introduction ● All Different ● Lex ordering ● Value precedence ● Complexity ● GAC-Schema ● Soft Global Constraints ● Global Grammar Constraints ● Roots Constraint ● Range Constraint ● Slide Constraint ● Global Constraints on Sets

SLIDE meta-constraint ● Even hotter off the press than the value PRECEDENCE constraint ● Under review for IJCAI 07!

SLIDE meta-constraint ● A constructor for generating many sequencing and related global constraints – REGULAR – CONTIGUITY – LEX – CARD PATH – … ● Slides a constraint down one or more sequences of variables – Ensuring constraint holds at every point – Fixed parameter tractable

Basic SLIDE ● SLIDE(C,[X1,..Xn]) holds iff – C(Xi,..Xi+k) holds for every i ● AMONG SEQ constraint – Used by ILOG for assembly line car sequencing at Renault – At most 1 in 3 cars have a sun roof – SLIDE(C,[X1,..Xn]) where C(X1,X2,X3) holds iff AMONG([X1,X2,X3],0,1,D) where D is set of cars ordered with sunroofs

GSC ● Global sequence constraint in ILOG Solver – Combines AMONG SEQ with GCC – Regin and Puget give partial propagator – We can show why!

GSC ● Global sequence constraint in ILOG Solver – Combines AMONG SEQ with GCC – Regin and Puget give partial propagator – We can show why! ● It is NP-hard to enforce GAC on GSC ● Can actually prove this when GSC is AMONG SEQ plus an ALL DIFFERENT ● ALL DIFFERENT is a special case of GCC

GSC ● Reduction from 1in3 SAT on positive clauses – The jth block of 2N clauses will ensure jth clause – Even numbered CSP vars represent truth assignment – Odd numbered CSP vars “junk” to ensure N odd values in each block – X_2jN+2i odd iff xi true – AMONG SEQ([X1,…],N,N,2N,{1,3,..}) ● This ensures truth assignment repeated along variables!

GSC ● Reduction from 1in3 SAT on positive clauses – Suppose jth clause is (x or y or z) ● X_2jN+2x, X_2jN+2y, X_2jN+2z in {4NM+4j, 4NM+4j+1, 4NM+4j+2} ● As ALL DIFFERENT, only one of these odd – For i other than x, y or z, X_2jN+2i in {4jN+4i, 4jN+4i+1} and X_2jN+2i+1 in {4jN+4i+2, 4jn+4i+3}

SLIDE down multiple sequences ● Can SLIDE down more than one sequence at a time – LEX([X1,..Xn],[Y1,..Yn]) – Introduce sequence of Boolean vars [B1,..Bn+1] – Play role of alpha in LEX propagator

SLIDE down multiple sequences ● Can SLIDE down more than one sequence at a time – LEX([X1,..Xn],[Y1,..Yn]) – Set B1=0, and Bn+1=1 (strict lex), Bn+1 in {0,1} (lex) – SLIDE(C,[X1..Xn],[Y1,..Yn],[B1,..Bn+1]) holds iff C(Xi,Yi,Bi,Bi+1) holds for each i

SLIDE down multiple sequences ● Can SLIDE down more than one sequence at a time – LEX([X1,..Xn],[Y1,..Yn]) – Set B1=0, and Bn+1=1 (strict lex), Bn+1 in {0,1} (lex) – SLIDE(C,[X1..Xn],[Y1,..Yn],[B1,..Bn+1]) – C(Xi,Yi,Bi,Bi+1) holds iff Bi=1 or (Bi=Bi+1=0 and Xi=Yi) or (Bi=0, Bi+1=1 and Xi<Yi)

SLIDE down multiple sequences ● Can SLIDE down more than one sequence at a time – LEX([X1,..Xn],[Y1,..Yn]) – Set B1=0, and Bn+1=1 (strict lex), Bn+1 in {0,1} (lex) – SLIDE(C,[X1..Xn],[Y1,..Yn],[B1,..Bn+1]) – C(Xi,Yi,Bi,Bi+1) holds iff Bi=1 or (Bi=Bi+1=0 and Xi=Yi) or (Bi=0, Bi+1=1 and Xi<Yi) – Highly efficient, incremental,..

SLIDE down multiple sequences ● CONTIGUITY([X1,..Xn]) – 0…01…10…0 – Two simple SLIDEs

SLIDE down multiple sequences ● CONTIGUITY([X1,..Xn]) – 0…01…10…0 – Two simple SLIDEs – Introduce Yi in {0,1,2} – SLIDE(>=,[Y1,..Yn])

SLIDE down multiple sequences ● CONTIGUITY([X1,..Xn]) – 0…01…10…0 – Two simple SLIDEs – Introduce Yi in {0,1,2} – SLIDE(>=,[Y1,..Yn]) – SLIDE(C,[X1,..Xn],[Y1,..Yn]) where C(Xi,Yi) holds iff Xi=1 Yi=1

SLIDE down multiple sequences ● REGULAR(Q,[X1,..Xn]) – X1.. Xn is a string accepted by FDA Q – Encodes into simple SLIDE – Introduce Yi to represent state of the automaton after i symbols

SLIDE down multiple sequences ● REGULAR(Q,[X1,..Xn]) – X1.. Xn is a string accepted by FDA Q – Introduce Yi to represent state of the automaton after i symbols – SLIDE(C,[X1,..Xn],[Y1,..Yn+1]) where ● Y1 is starting state of Q ● Yn+1 is limited to accepting states of Q ● C(Xi,Yi,Yi+1) holds iff Q moves from state Yi to state Yi+1 on seeing Xi

SLIDE down multiple sequences ● REGULAR(A,[X1,..Xn]) – X1.. Xn is a string accepted by FDA A – Introduce Qi to represent state of the automaton after i symbols – SLIDE(C,[X1,..Xn],[Q1,..Qn+1]) where ● Y1 is starting state of A ● Yn+1 is limited to accepting states of A ● C(Xi,Qi,Qi+1) holds iff A moves from state Qi to state Qi+1 on seeing Xi – Gives highly efficient and effective propagator!

SLIDE with counters ● AMONG([X1,..Xn],v,N) ● Introduce sequence of counts, Yi ● SLIDE(C,[X1,..Xn],[Y1,..Yn+1]) where ● Y1=0, Yn+1=N ● C(Xi,Yi,Yi+1) holds iff (Xi in v and Yi+1=1+Yi) or (Xi not in v and Yi+1=Yi)

SLIDE with counters ● CARD PATH ● SLIDE is a special case of CARD PATH – SLIDE(C,[X1,..Xn]) iff CARD PATH(C,[X1,..Xn],n- k+1)

SLIDE with counters ● CARD PATH ● SLIDE is a special case of CARD PATH – SLIDE(C,[X1,..Xn]) iff CARD PATH(C,[X1,..Xn],n- k+1) ● CARD PATH is a special case of SLIDE – SLIDE(D,[X1,..Xn],[Y1,..Yn+1]) where Y1=0, Yn+1=N, and D(Xi,..Xi+k,Yi,Yi+1) holds iff (Yi+1=1+Yi and C(Xi,..Xi+k)) or (Yi+1=Yi and not C(Xi,..Xi+k))

SLIDE with parameters ● Slide constraints may share parameters ● LINKSET2BOOLEANS(S,[X1,..Xn]) – Converts set variable into characteristic function ● Encodes as SLIDE(C,[X1,..Xn]) where – C(S,Xi) holds iff Xi in S – S is parameter common to each slide constraint

SLIDE over sets ● Value precedence for set vars ● PRECENDCE([vj,vk],[S1,..Sn]) holds iff ● min(i,{i | vj in Si and vk not in Si or i=n+1}) < ● min(i,{i | vk in Si and vj not in Si or i=n+2})

SLIDE over sets ● Value precedence for set vars ● PRECENDCE([vj,vk],[S1,..Sn]) holds iff ● min(i,{i | vj in Si and vk not in Si or i=n+1}) < ● min(i,{i | vk in Si and vj not in Si or i=n+2}) ● Introduce sequence of Booleans to indicate whether vars have been distinguished apart yet or not

SLIDE over sets ● Value precedence for set vars ● PRECENDCE([vj,vk],[S1,..Sn]) holds iff ● min(i,{i | vj in Si and vk not in Si or i=n+1}) < ● min(i,{i | vk in Si and vj not in Si or i=n+2}) ● SLIDE(C,[S1,..Sn],[B1,..Bn+1]) where ● B1=0 and ● C(Si,Bi,Bi+1) holds iff Bi=Bi+1=1, or Bi=Bi+1=0 and (vj, vk in Si or vj, vk not in Si), or Bi=0, Bi+1=1, vj in Si and vk not in Si

SLIDE over sets ● Open stacks problem – IJCAI 05 modelling challenge ● Three SLIDEs and one ALL DIFFERENT – First SLIDE: Si+1 = Si u customer(Xi) – Second SLIDE: Ti-1= Ti u customer(Xi) – Third SLIDE: |Si intersect Ti| < OpenStacks

Circular SLIDE ● STRETCH used in shift rostering ● Given sequence of vars X1,.. Xn – Each stretch of identical values a occurs at least shortest(a) and at most longest(a) time – For example, at least 0 and at most 3 night shifts in a row – Each transition Xi=/=Xi+1 is limited to given patterns – For example, only Xi=night, Xi+1=off is permitted

Circular SLIDE ● STRETCH can be efficiently encoded using SLIDE ● SLIDE(C,[X1,..Xn],[Y1,..Yn+1]) where – Y1=1 – C(Xi,Xi+1,Yi,Yi+1) holds iff Xi=Xi+1, Yi+1=1+Yi, Yi+1<=longest(Xi), or Xi=/=Xi+1, Yi>=shortest(Xi) and (Xi,Xi+1) in set of permitted changes

Circular SLIDE ● Circular forms of STRETCH are needed for repeating shift patterns ● Circular form of SLIDE useful in such situations ● SLIDEo(C,[X1,..Xn]) holds iff – C(Xi,..X1+(i+k-1)mod n) holds for 1<=i<=n

SLIDE algebra ● SLIDEOR(C,[X1..Xn]) holds iff – C(Xi,..Xi+k) holds for some I ● Encodes as CARD PATH (and thus as SLIDE) ● Other more complex combinations – NOT(SLIDE(C,[X1,..Xn])) iff SLIDEOR(C,[X1,..Xn]) – SLIDE(C1,[X1,..Xn]) and SLIDE(C2,[X1,..Xn]) iff SLIDE(C1 and C2,[X1,..Xn]) –..

Propagating SLIDE ● But how do we propagate global constraints expressed using SLIDE?

Propagating SLIDE ● SLIDE(C,[X1,..Xn]) – Just post sequence of constraints, C(Xi,..Xi+k) – If constraint graph is Berge acyclic, then we will achieve GAC – Gives efficient GAC propagators for CONTIGUITY, DOMAIN, ELEMENT, LEX, PRECEDENCE, REGULAR, …

Propagating SLIDE ● SLIDE(C,[X1,..Xn]) – Just post sequence of constraints, C(Xi,..Xi+k) – If constraint graph is Berge acyclic, then we will achieve GAC – Gives efficient GAC propagators for CONTIGUITY, DOMAIN, ELEMENT, LEX, PRECEDENCE, REGULAR, … – But what about case constraint graph is not Berge- acyclic? ● Slide constraints overlap on more than one variable

Propagating SLIDE ● SLIDE(C,[X1,..Xn]) – Slide constraints overlap on more than one variable – Enforce GAC using dynamic programming ● pass support down sequence

Propagating SLIDE ● SLIDE(C,[X1,..Xn]) – Equivalently a “dual” encoding – Consider AMONG SEQ(2,2,3,[X1,..X5],{a}) where ● X1=a, X2,X3,X4,X5 in {a,b} ● AMONG([X1,X2,X3],2,{a}) ● AMONG([X2,X3,X4],2,{a}) ● AMONG([X3,X4,X5],2,{a}) ● Enforcing GAC sets X4=a – GAC can be enforced in O(nd^k+1) time and O(nd^k) space where constraints overlap on k variables – Fixed parameter tractable

Conclusions ● SLIDE is a very useful meta-constraint – Many global constraints for sequencing and other problems can be encoded as SLIDE ● SLIDE can be propagated easily – Constraints overlap on just one variable => simply post slide constraints – Constraints overlap on more than one variable => use dynamic programming or equivalently a simple dual encoding