Round 4: Constraint Satisfaction Problems (CSP)

Size: px
Start display at page:

Download "Round 4: Constraint Satisfaction Problems (CSP)"

Transcription

1 Round 4: Constraint Satisfaction Problems (CSP) Tommi Junttila Aalto University School of Science Department of Computer Science CS-E3220 Declarative Programming Spring 2018 Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

2 Outline In this round we leave the purely Boolean domain We study CSP (constraint satisfaction problem) instances in which the domains of variables can be larger (but usually finite) sets We see some useful global constraints that make the modelling of many problems much easier.. and study how such constraints can be solved This round is a very shallow introduction to the topic see, e.g., the references in the slides and [RvBW06] for more information As a concrete problem description language, we will use the MiniZinc language in this round For simplicity, we restrict the discussion to finite domain variables here Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

3 Definitions Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

4 Basic definitions Similarly to SAT, a problem instance in CSP consists of variables and some constraints, and the task of the constraint solver is then to find out whether there are some values for the variables so that all the constraints are satisfied Now the domain of a variable x is a finite set D(x) of values that can be assigned to it An assignment τ to a set of variables X is a function that assigns each variable x to a value τ(x) D(x) Example In MiniZinc, one can declare integer variables and constants as shown below. var int: x; % An integer variable var 1..10: y; % An integer variable with the domain {1,2,...,10} int: c = 3; % An integer constant The domain of the variable declared with var int: x depends on the underlying solver: it can be unbounded or restricted, for instance, to the finite range [ 2 31,2 31 1]. Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

5 Constraints Mathematically, a constraint is just a relation that restricts the values that a set of variables can have Definition: Constraint A constraint C over a set of variables {y 1,...,y k } X is a subset of D(y 1 )... D(y k ). A tuple (v 1,...,v k ) C is called a solution to C. An assignment τ to X satisfies C if (τ(y 1 ),...,τ(y k )) C. However, as the explicit relation presentation can contain up to k i=1 D(y i ) tuples, constraints are usually given more concisely by some symbolic notation Example The standard binary less-or-equal constraint between two integer-valued variables, x 1 x 2, corresponds to the set {(v 1,v 2 ) v 1 D(x 1 ) v 2 D(x 2 ) v 1 v 2 }. For instance, if D(x) = {1,2,3,6} and D(y) = {1,4,5,9}, then x y means the set {(1,1),(1,4),(1,5),(1,9),(2,4),(2,5),(2,9),(3,4),(3,5),(3,9),(6,9)}. Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

6 Definition: Constraint satisfaction problem A constraint satisfaction problem (CSP) consists of a finite set X of variables with domains, and a finite set of constraints, each over a subset of X. A solution to a CSP is an assignment to X so that all the constraints are satisfied. A CSP is satisfiable if it has at least one solution, otherwise it is unsatisfiable. Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

7 Example Consider the verbal arithmetic problem s e n d + m o r e = m o n e y requiring us to find distinct digits for the variables so that the equation holds. We can model this with a simple CSP consisting of 31 constraints 1000s + 100e + 10n + d m + 100o + 10r + e = 10000m o + 100n + 10e + y s 0 m 0 x y for all x,y {s,e,n,d,m,o,r,y} and the domains D(d) = D(e) = D(m) = D(n) = D(o) = D(r) = D(s) = D(y) = {0,1,2,3,4,5,6,7,8,9}. After this, we can use a CSP solver to find whether it is satisfiable or not. Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

8 Example The CSP instance in the previous example can be declared in the MiniZinc language as shown below right. Note that the requirements D(m) 0 and D(r) 0 are modelled by removing 0 from the domains of m and r. Similarly, the digit distinctness requirement is handled by a global constraint ALLDIFFERENT. Executing a MiniZinc solver gives us the solution = include alldifferent.mzn ; var 1..9: s; var 0..9: e; var 0..9: n; var 0..9: d; var 1..9: m; var 0..9: o; var 0..9: r; var 0..9: y; constraint 1000 * s * e + 10 * n + d * m * o + 10 * r + e = * m * o * n + 10 * e + y; constraint alldifferent([s,e,n,d,m,o,r,y]); solve satisfy; output [ \(s)\(e)\(n)\(d)\n, + \(m)\(o)\(r)\(e)\n, = \(m)\(o)\(n)\(e)\(y)\n ]; Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

9 Global constraints Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

10 A global constraint is a constraint that captures a relation between a non-fixed number of variables [vhk06] For instance, an all-different global constraint ALLDIFFERENT(y 1,...,y n ) requires that the values assigned to the variables y 1,...,y n are pairwise distinct Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

11 In many cases, global constraints are semantically redundant as they can be expressed with some simpler constraints. For instance, ALLDIFFERENT(y 1,...,y n ) could be expressed 1 with n(n 1) 2 disequalities: (y i y j ) 1 i<j n However, having higher-level shorthands like ALLDIFFERENT(y 1,...,y n ) 1 makes the problem description task easier, and 2 allows the constraint solver to have a higher-level view of the structure of the problem and potentially use better constraint propagation techniques Hundreds of global constraints have been defined, see e.g. the global constraints catalog In the following, we 1 introduce a few commonly used global constraints, and 2 describe how some of them can be solved and propagated algorithmically 1 In fact, some solvers transform all-different constraints to this form internally Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

12 The all-different constraint As our first global constraint, let us study the all-different constraint ALLDIFFERENT(y 1,...,y n ) requires that the values assigned to the variables y 1,...,y n are mutually distinct Formally, ALLDIFFERENT(y 1,...,y n ) corresponds to the set {(v 1,...,v n ) D(y 1 )... D(y n ) v i v j for all 1 i < j n} Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

13 As an application example, let s see how Sudokus can be modelled and solved with the MiniZinc language The model file sudoku.mzn describes the variable types and the constraints include alldifferent.mzn ; int: D; % Grid dimension constant, from an external data file int: N = D * D; array [1..N,1..N] of var 1..N: grid; % A 2-dimensional array array [1..N,1..N] of 0..N: clues; % 0 = empty constraint forall (row in 1..N, col in 1..N) (clues[row,col] > 0 -> grid[row,col] == clues[row,col]); constraint forall (row in 1..N) (alldifferent([grid[row,col] col in 1..N])); constraint forall (col in 1..N) (alldifferent([grid[row,col] row in 1..N])); constraint forall (subrow, subcol in 1..D)( alldifferent([grid[(subrow-1) * D + rowd, (subcol-1) * D + cold] rowd,cold in 1..D])); % Solve the problem solve satisfy; % Solution output int: digits = ceil(log(10.0,int2float(n))); output [ show int(digits,grid[row,col]) if col mod D == 0 then else endif ++ if col == N /\ row!= N then if row mod D == 0 then \n\n else \n endif else endif row,col in 1..N ] ++ [ \n ]; Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

14 In MiniZinc, the problem instance data can be given in a separate data file so that the same model can be used for different instances For the previous sudoku model we could have The data file sudoku-royle.dzn: D = 3; clues = [ 0,0,0,0,0,0,0,1,0 4,0,0,0,0,0,0,0,0 0,2,0,0,0,0,0,0,0 0,0,0,0,5,0,4,0,7 0,0,8,0,0,0,3,0,0 0,0,1,0,9,0,0,0,0 3,0,0,4,0,0,2,0,0 0,5,0,1,0,0,0,0,0 0,0,0,8,0,6,0,0,0 ]; The corresponding sudoku puzzle: Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

15 Solving the model and data file with the gecode solver (bundled in the MiniZinc distribution) produces a solution for the sudoku grid: cs 167 % mzn gecode sudoku. mzn sudoku royle. dzn Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

16 The sum constraint A very common requirement in many problems is that the values of some integer variables should sum up to some value This can be captured with the sum global constraint c 1 x c n x n = z, where the c i s are integer constants and x 1,...,x n,z are integer-valued variables More formally, such a sum can be seen as the constraint SUM(y 1,...,y n, c,z), where c is a vector of n integer constants, corresponding to the set {(v 1,...,v n,w) D(y 1 )... D(y n ) D(z) c 1 v c n v n = w} Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

17 In MiniZinc, sums over some fixed set of variables can be written in the usual infix form (recall the verbal arithmetic example) Sums over the values in an array can be computed with the sum construct. For instance, if a is an array of integers such as array [1..N] of var 1..K: a; then the sum of its elements can be computed with sum(i in 1..N)(a[i]) Multi-dimensional arrays and filtering are also supported, e.g. sum(i in 1..N, j in 1..M where b[i,j] >= 4)(b[i,j]) computes the sum of all elements whose value is at least 4 in a 2-dimensional N M-array b. Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

18 The cumulative constraint Used for describing cumulative resourse usage For n tasks, the constraint is satisfied if each task i CUMULATIVE([s 1,...,s n ],[d 1,...,d n ],[r 1,...,r n ],b) is started at time s i, runs d i time units, and uses r i resourses, and the tasks running at the same time use at most b resourses at any time point. Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

19 Example In MiniZinc, the following model finds the shortest time in which we can run 4 tasks: the first runs for 3 units and uses 2 resourses, the second runs for 2 units and uses 1 resourses, and so on include cumulative.mzn ; int: n = 4; set of int: TASKS = 1..n; int: max time = 20; int: max resources = 3; var 0..max time: end; array[tasks] of int: dur = [3,2,1,2]; array[tasks] of int: resources = [2,1,3,2]; array[tasks] of var 0..max time: start; constraint cumulative(start, dur, resources, max resources); constraint forall(t in TASKS)(start[t]+dur[t] <= end); solve minimize end; output [ start=\(start)\n, end=\(end)\n ]; Solving this gives us: s t a r t =[0, 0, 5, 3] end=6 An illustration of a solution with minimal total time use: r Task 2 Task 1 Task 4 Task t Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

20 Backtracking Search Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

21 When the domains are finite, CSP instances could be solved by reducing the CSP instance to a SAT instance, and then solving the SAT instance with a SAT solver However, performing a backtracking search and constraint propagation on the global constraints level can result in better performance as 1 the expansion of non-binary domains and global constraints to the Boolean level can be quite large, and 2 one can use efficient custom algorithms for propagating global constraints Below is a very simple backtracking search procedure that first performs constraint propagation, and if the solution is not yet found, selects a variable and recursively searches a solution in which the variable has a fixed value from its domain def solve(c,d): D propagate(c,d) if C has a constraint C that is inconsistent under D : return unsat if D (x) = 1 for all the variables x: return sat choose a variable x with D (x) = {v 1,...,v k } and k 2 for each v {v 1,...,v k }: r solve(c,d x {v} ) if r = sat: return sat return unsat Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

22 Example Consider a simple ARM-like architecture assembly program with symbolic register names below left. If we perform a liveness analysis for the registers, we get a register-inference graph a shown below right: there is an edge between register nodes iff there is a line in which one register is written to and the other can be read later without being written to in between. The graph is k-colorable iff the program can be implemented by using only k hardware registers and no spills to the memory. LDR a, a addr / / a i s the address of the array a MOV i, #0 / / i = 0 MOV s, #0 / / s = 0 loop : CMP i, #10 / / i f i >= 10, goto end BGE end LDR t, [ a, i, LSL#2] / / t = a [ i ] MUL v, t, t / / v = t * t ADD s, s, v / / s = s + v ADD i, i, #1 B loop end : LDR b, b addr / / save s to the memory l o c a t i o n b addr STR s, [ b ] a i s t v b a See e.g. Aho, Sethi, and Ullman: Compilers: Principles, Techniques, and Tools Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

23 Example: (continues) The graph coloring problem can be easily expressed as a CSP problem by taking a variable for each vertex and adding the constraint x y for each edge between x and y in the graph. In our simple example, the constraints are a i a s a t a t a v i s i t i v s t s v s b a i s t v b The domains of the variables are some set of k distinct colors. Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

24 Example: (continues) A search tree for our instance when three colors are allowed is shown below: each node describes the domains either when entering the solve call or after constraint propagation. The instance has no solutions as all the branches end in a situation where the domain of some variable is empty. a = {,, } i = {,, } s = {,, } t = {,, } v = {,, } b = {,, } a = { } a = { } a = { } a = { } i = {,, } s = {,, } t = {,, } v = {,, } b = {,, } a = { } i = {,, } s = {,, } t = {,, } v = {,, } b = {,, } a = { } i = {,, } s = {,, } t = {,, } v = {,, } b = {,, } Propagate a i, a s, a t, a v a = { } i = {, } s = {, } t = {, } v = {, } b = {,, } s = { } s = { } Propagate a i, a s, a t, a v Symmetric to the leftmost case Propagate a i, a s, a t, a v Symmetric to the leftmost case a = { } i = {, } s = { } t = {, } v = {, } b = {,, } Propagate s i, s t, s v, s b, i v a = { } i = { } s = { } t = { } v = {} b = {, } a = { } i = {, } s = { } t = {, } v = {, } b = {,, } Propagate s i, s t, s v, s b, i v Symmetric to the leftmost case Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

25 Example: (continues) Our example graph is colorable with 4 colors and thus the program can be implemented with 4 registers: LDR R0, a addr / / a i s the address of the array a MOV R1, #0 / / i = 0 MOV R2, #0 / / s = 0 loop : CMP R1, #10 / / i f i >= 10, goto end BGE end LDR R3, [ R0, R1, LSL#2] / / t = a [ i ] MUL R3, R3, R3 / / v = t * t ADD R2, R2, R3 / / s = s + v ADD R1, R1, #1 B loop end : LDR R3, b addr / / save s to the memory l o c a t i o n b addr STR R2, [ R3 ] Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

26 The above description of the backtracking search scheme is simplified and omits many details The variable selection heuristic, i.e. how one chooses the variable x whose domain {v 1,...,v k } is split into {v 1 },...,{v k }, is important but not discussed further in this course And one could also split the domain {v 1,...,v k } of the branching variable x differently, for instance into {v 1,...,v k/2 } and {v k/2+1,...,v k } if k is large Some solvers allow the user to control these aspects and thus tune the solver for specific problem types Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

27 Constraint Propagation Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

28 The goal of constraint propagation (also called filtering ) is to reduce the domains of variables by removing values that cannot occur in any solution Corresponds to unit propagation in SAT solvers but is more complex (and usually more efficient) because the domains are larger and the constraints more complex Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

29 Arc consistency Definition: Arc consistency A constraint C D(y 1 )... D(y k ) is generalized arc consistent if, for every i {1,...,k} and every v D(y i ), there exists a tuple (v 1,...,v k ) C such that v i = v. A CSP is generalized arc consistent if every constraint in it is. Example We usually omit generalized and just use the term arc consistent 2 When D(x) = {1,2,4} and D(y) = {1,2,5}, the constraint x = y is not arc consistent as 4 D(x) but 4 / D(y). Similarly, 5 D(y) but 5 / D(x). the constraint x y is arc consistent as for every v x D(x), there is a v y D(y) such that v x v y, and for every v y D(y), there is a v x D(x) such that v x v y. 2 the term arc consistency is sometimes used for generalized arc consistency when the constraint is binary (i.e., over two variables) Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

30 Note If a CSP is arc consistent and the domains of the variables are non-empty, then the individual constraints in the CSP have solutions. But this does not mean that the CSP as a whole has solutions. Example Consider the CSP consisting of the constraints x y, x z and y z. When D(x) = {1,2}, D(y) = {1,2} and D(z) = {1,2}, the CSP is arc consistent but does not have any solutions. Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

31 Constraint propagation (aka filtering) The aim of constraint propagation is to reduce the domains of the variables so that all the solutions to the constraint are preserved That is, we are given a constraint C D(y 1 )... D(y k ) and our goal is to produce new domains D (y i ) D(y i ) for all 1 i k such that C (D (y 1 )... D (y k )) = C Whenever feasible, our goal is to reduce the domains so that the constraint in question becomes arc-consistent Example When D(x) = {1,2,4} and D(y) = {1,2,5}, propagating the constraint x = y to be arc-consistent gives to domains D (x) = {1,2} and D (y) = {1,2}. Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

32 Usually, global constraints propagate better than a (possibly large) corresponding set of primitive binary constraints. Example When D(x) = {1,2}, D(y) = {1,2} and D(z) = {1,2,3}, propagating the disequality constraints x y, x z and y z to be arc-consistent results in the domains D (x) = {1,2}, D (y) = {1,2} and D (z) = {1,2,3}. Example When D(x) = {1,2}, D(y) = {1,2} and D(z) = {1,2,3}, propagating the constraint ALLDIFFERENT(x, y, z) to arc-consistency yields the domains D (x) = {1,2}, D (y) = {1,2} and D (z) = {3}. Of course, propagating complex global constraints is algoritmically more difficult Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

33 Consistency checking Propagating an inconsistent constraint to arc-consistency results in empty domains However, just checking the consistency can be easier for some constraints Consistency checking: given a constraint over y i,...,y k and some domains D(y i ),...,D(y k ), does it hold that C (D(y 1 )... D(y k )) /0 Testing consistency of binary equality and disequality constraints is easy For equality, check whether the domains contain at least one common element For disequality, check whether the domains are not empty and not equal to a common singleton set Testing consistency of more complex global constraints is algoritmically more involved Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

34 The sum constraint: consistency checking Recall that a sum global constraint is of form c 1 x c n x n = z, where the c i s are integer constants and x 1,...,x n,z are integer-valued variables Consistency checking and propagation of sum constraints is NP-hard in general (the NP-complete subset sum problem reduces to it in a straighforward way) However, one obtains pseudo-polynomial time algorithms by using dynamic programming [Tri03] We can define a predicate p(i,t), where i [0,n], that evaluates to true if and only if the sum i j=1 c jx j can evaluate to t, recursively as follows: p(0,0) = T for t = 0, F otherwise p(i,t) = d D(x i ) p(i 1,t c id) for 1 i n If p(n,v) = T for some v D(z), then x 1,...,x n can have values so that c 1 x c n x n = v and the constraint is consistent. Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

35 Example Consider the sum constraint 2x 1 + 2x 2 + 2x 3 + x 4 + x 5 = z under the domains D(x 1 ) = {0,2,3}, D(x 2 ) = {0,3}, D(x 3 ) = {0,3}, D(x 4 ) = {2,3}, D(x 5 ) = {2,3}, and D(z) = {4,7,9}. The figure on the right illustrates the computation of p: the dot at (i,v) is filled iff p([x 1,...,x i ],v) = T, there is an edge from (i,v i ) to (i + 1,v i+1 ) iff p([x 1,...,x i ],v i ) = T and v i+1 = v i + c i+1 d for some d D(x i+1 ). We see that p(5,4) and p(5,9) are true, therefore the constraint is consistent Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

36 The sum constraint: propagation The graph representation shown above allows us to find all the solutions: they correspond to the paths from the node (0,0) to the nodes (n,v) with v D(z) If (0,0),(1,v 1 ),...,(n,v n ) is such a path, then the solution is x 1 = (v 1 0)/c 1, x 2 = (v 2 v 1 )/c 2,..., x n = (v n v n 1 )/c n Propagation is thus also easy 1 v D(z) iff v D(z) and there is a path from the node (0,0) to (n,v) 2 v D(x i ) iff there is a path (0,0),(1,v 1 ),...,(n,v n ) such that v n D(z) and x i = (v i v i 1 )/c i. Finding all the edges that take part in some of the paths above is easy: just follow the edges backwards from the nodes (n,v) with v D(z) Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

37 Example Consider again the sum constraint 2x 1 + 2x 2 + 2x 3 + x 4 + x 5 = z under the domains D(x 1 ) = {0,2,3}, D(x 2 ) = {0,3}, D(x 3 ) = {0,3}, D(x 4 ) = {2,3}, D(x 5 ) = {2,3}, and D(z) = {4,7,9}. From the highlighted edges we see that the constraint has three solutions: x 1 = 0,x 2 = 0,x 3 = 0,x 4 = 2,x 5 = 2 x 1 = 2,x 2 = 0,x 3 = 0,x 4 = 2,x 5 = 2, and x 1 = 2,x 2 = 0,x 3 = 0,x 4 = 3,x 5 = 3. We can thus reduce the domains to D(x 1 ) = {0,2}, D(x 2 ) = {0}, D(x 3 ) = {0}, D(x 4 ) = {2,3}, D(x 5 ) = {2,3}, and D(z) = {4,9} x 1 x 2 x 3 x 4 x 5 Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

38 When implemented with arrays, the dynamic programming approach only works well if the constants and domain values are reasonably small When implemented with dynamic sets, the approach works well if the number of possible values of i j=1 c jx j for each i is manageable For the other cases (large domains etc), one can use weaker propagation that does not enforce arc-consistency. For instance, for each i one can compute the sum m i = j {1,...,i 1,i+1,...,n} c j mind(x j ) and remove the values v from D(x i ) for which m i + c i v > maxd(z) Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

39 Consistency checking for ALLDIFFERENT constraints We can reduce the consistency problem of ALLDIFFERENT constraints to the matching problem in unweighted bipartite graphs [vhk06] There are efficient algorithms for solving the matching problem the consistency problem can be solved efficiently ALLDIFFERENT(x 1,x 2,x 3,x 4 ) D(x 1 ) = {1,4} D(x 2 ) = {2,3,5} D(x 3 ) = {1,4} D(x 4 ) = {1,2,3,4,5} x 1 x 2 x 3 x Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

40 An unweighted bipartite graph is a triple (U,W,E), where U and W are two disjoint, finite and non-empty sets of vertices, and E U W is a set of edges. A matching in such a graph is a set M E such that for all disjoint (u 1,w 1 ),(u 2,w 2 ) M, u 1 u 2 and w 1 w 2 A matching M covers a vertex u U if (u,w) M for some w W Example The bipartite graph (U,W,E) with U = {x 1,x 2,x 3,x 4 } W = {1,2,3,4,5} E = {(x 1,1),(x 1,4),(x 2,2),(x 2,3),(x 2,5),(x 3,1),(x 3,4), (x 4,1),(x 4,2),(x 4,3),(x 4,4),(x 4,5)} is shown below right. The matching {(x 1,4),(x 2,3),(x 4,1)} is shown with the highlighted edges. It covers the vertex x 1 but not the vertex x 3. x 1 x 2 x 3 x Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

41 Definition: Value graphs Assume an all-different constraint ALLDIFFERENT(y 1,...,y k ) and some domains D(y 1 ),...,D(y k ). The value graph of the constraint under the domains is the undirected bipartite graph ({y 1,...,y k }, k i=1 D(y i),e), where E = {(y i,v) 1 i k v D(y i )}. The vertices in {y 1,...,y k } are called variable vertices and the ones in k i=1 D(y i) value vertices. Example The value graph of the constraint and domains shown on the left below is shown on the right. ALLDIFFERENT(x 1,x 2,x 3,x 4 ) D(x 1 ) = {1,4} D(x 2 ) = {2,3,5} D(x 3 ) = {1,4} D(x 4 ) = {1,2,3,4,5} x 1 x 2 x 3 x Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

42 Each solution to the constraint corresponds to a matching that covers all the variable vertices of the value graph Each matching that covers all the variable vertices of the value graph corresponds to a solution to the constraint The constraint is consistent if the value graph has a matching that covers all variable vertices Example The matching corresponding to the solution {x 1 1,x 2 3,x 3 4,x 4 2} of the constraint and domains shown on the left below is shown on the right with highlighted edges. ALLDIFFERENT(x 1,x 2,x 3,x 4 ) D(x 1 ) = {1,4} D(x 2 ) = {2,3,5} D(x 3 ) = {1,4} D(x 4 ) = {1,2,3,4,5} x 1 x 2 x 3 x Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

43 Whether a value graph has a matching covering all variable vertices can be found by computing a maximum matching, a matching having largest possible number of edges, for the graph and checking whether it covers all the variable vertices A maximum matching can be found, e.g., with the Hopcroft-Karp algorithm A simplified version is presented next Assume a bipartite graph G = (U,W,E) and a matching M E A vertex is M-free if it does not occur in any edge in M An augmenting path for M is a path in G that starts and ends in an M-free vertex and alternates between edges not in M and in M Property: a matching is maximum if there are no augmenting paths for it If M has an augmenting path p, a larger matching can be obtained by taking the symmetric difference of M and the edges in p Finding maximum matchings: 1 Start with an empty matching M 2 Search for an augmenting path p If none is found, return M Otherwise, assign M to the symmetric difference of M and the edges in p and repeat Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

44 Example The value graph for the constraint ALLDIFFERENT(x 1,x 2,x 3 ) with the domains D(x 1 ) = {1,2,3,4}, D(x 2 ) = {1,3}, and D(x 3 ) = {1,3} is shown in Fig. (a) We start with the empty matching: M = /0 We may first find the augmenting path [x 1,1] After this, the matching is M = {(x 1,1)}, see Fig. (b) The next the augmenting path could be [x 2,3] After this, the matching is M = {(x 1,1),(x 2,3)}, see Fig. (c) The next the augmenting path could be [x 3,1,x 1,2] After this, the matching is M = {(x 1,2),(x 2,3),(x 3,1)}, which is shown in Fig. (d) The are no more augmenting paths All variable vertices are covered and a solution is {x 1 2,x 2 3,x 3 1} x 1 x 2 x (a) x 1 x 2 x (b) x 1 x 2 x (c) x 1 x 2 x (d) Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

45 Propagating ALLDIFFERENT constraints All-different constraints can be propagated to arc-consistency in polynomial time As stated earlier, each solution to the constraint corresponds to a value vertex covering matching of the value graph, and each value vertex covering matching of the value graph corresponds to a solution to the constraint. Thus if an edge (x,v) in the value graph does not appear in any value vertex covering matching, the element v can be removed from the domain D(x). Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

46 Once one maximum matching is found, we can find all edges that appear in some maximum matching [Tas12, vhk06] Assume a bipartite graph G = (U,W,E) and a maximum matching M E Build the directed graph G M = (U W,{(u,w ) (u,w ) M} {(w,u ) (u,w ) E \ M}) An edge (u, w) belongs to some maximum matching if 1 (u,w) M 2 (u,w) is an edge inside a strongly connected component of G M 3 (u,w) appears in a path of G M that starts from an M-free vertex Strongly connected components can be computed efficiently with Tarjan s algorithm or with Kosaraju s algorithm Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

47 Example Consider again our running example having the value graph G and maximum matching M shown on left below. The directed graph G M is shown below right. x 1 x 2 x 3 x 1 x 2 x The edges (x 1,2), (x 2,3) and (x 3,1) in M belong to some maximum matching The directed graph has only one non-singleton strongly connected component, {x 2,3,x 3,1}. Thus the edges (x 2,1) and (x 3,3) belong to some maximum matching. As [4,x 1 ] is a path of the form required by the third case, (x 1,4) belongs to some maximum matching The edge (x 1,1) cannot be included with any one 4 cases above. Therefore, the value 1 can be removed from the domain of x 1. Indeed, the constraint has the solutions {x 1 2,x 2 1,x 3 3}, {x 1 4,x 2 1,x 3 3}, {x 1 2,x 2 3,x 3 1}, and {x 1 4,x 2 3,x 3 1}. Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

48 References Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

49 References I [RvBW06] Francesca Rossi, Peter van Beek, and Toby Walsh (eds.), Handbook of Constraint Programming, Foundations of Artificial Intelligence, vol. 2, Elsevier, [Tas12] [Tri03] [vhk06] Tamir Tassa, Finding all maximally-matchable edges in a bipartite graph, Theoretical Computer Science 423 (2012), Michael A. Trick, A Dynamic Programming Approach for Consistency and Propagation for Knapsack Constraints, Annals of Operations Research 118 (2003), Willem-Jan van Hoeve and Irit Katriel, Global Constraints, in Rossi et al. [RvBW06], pp Tommi Junttila (Aalto University) Round 4: CSP CS-E3220 DP / Spring / 49

PART II: Local Consistency & Constraint Propagation

PART II: Local Consistency & Constraint Propagation PART II: Local Consistency & Constraint Propagation Solving CSPs Search algorithm. Usually backtracking search performing a depth-first traversal of a search tree. Local consistency and constraint propagation.

More information

Constraint Propagation: The Heart of Constraint Programming

Constraint Propagation: The Heart of Constraint Programming Constraint Propagation: The Heart of Constraint Programming Zeynep KIZILTAN Department of Computer Science University of Bologna Email: zeynep@cs.unibo.it URL: http://zeynep.web.cs.unibo.it/ What is it

More information

Propagating separable equalities in an MDD store

Propagating separable equalities in an MDD store Propagating separable equalities in an MDD store T. Hadzic 1, J. N. Hooker 2, and P. Tiedemann 3 1 University College Cork t.hadzic@4c.ucc.ie 2 Carnegie Mellon University john@hooker.tepper.cmu.edu 3 IT

More information

An Alldifferent Constraint Solver in SMT

An Alldifferent Constraint Solver in SMT An Alldifferent Constraint Solver in SMT Milan Banković and Filip Marić Faculty of Mathematics, University of Belgrade (milan filip)@matf.bg.ac.rs May 16, 2010 Abstract The finite domain alldifferent constraint,

More information

Chapter 3: Finite Constraint Domains

Chapter 3: Finite Constraint Domains 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 Finite Constraint Domains Constraint Satisfaction

More information

Constraint (Logic) Programming

Constraint (Logic) Programming Constraint (Logic) Programming Roman Barták Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic bartak@ktiml.mff.cuni.cz Sudoku Combinatorial puzzle, whose goal is to enter

More information

Constraint Programming. Global Constraints. Amira Zaki Prof. Dr. Thom Frühwirth. University of Ulm WS 2012/2013

Constraint Programming. Global Constraints. Amira Zaki Prof. Dr. Thom Frühwirth. University of Ulm WS 2012/2013 Global Constraints Amira Zaki Prof. Dr. Thom Frühwirth University of Ulm WS 2012/2013 Amira Zaki & Thom Frühwirth University of Ulm Page 1 WS 2012/2013 Overview Classes of Constraints Global Constraints

More information

Constraint satisfaction problems. CS171, Winter 2018 Introduction to Artificial Intelligence Prof. Richard Lathrop

Constraint satisfaction problems. CS171, Winter 2018 Introduction to Artificial Intelligence Prof. Richard Lathrop Constraint satisfaction problems CS171, Winter 2018 Introduction to Artificial Intelligence Prof. Richard Lathrop Constraint Satisfaction Problems What is a CSP? Finite set of variables, X 1, X 2,, X n

More information

Course Summary! What have we learned and what are we expected to know?

Course Summary! What have we learned and what are we expected to know? Course Summary! What have we learned and what are we expected to know? Overview! Introduction Modelling in MiniZinc Finite Domain Constraint Solving Search Linear Programming and Network Flow Mixed Integer

More information

Constraint Programming. Marco Kuhlmann & Guido Tack Lecture 1

Constraint Programming. Marco Kuhlmann & Guido Tack Lecture 1 Constraint Programming Marco Kuhlmann & Guido Tack Lecture 1 Welcome! Where am I? Constraint Programming advanced course in Computer Science 6 credit points lecture (2 hours) + lab (2 hours) http://www.ps.uni-sb.de/courses/cp-ss07/

More information

Constraint Modeling. with MiniZinc. Jakub Bulín. Department of CU Prague

Constraint Modeling. with MiniZinc. Jakub Bulín. Department of CU Prague Constraint Modeling with MiniZinc Jakub Bulín Department of Algebra @ CU Prague Table of contents 1. Intro & the theory part 2. An overview of MinZinc 3. Examples of constraint models 4. Learn more 1 In

More information

Bound Consistency for Binary Length-Lex Set Constraints

Bound Consistency for Binary Length-Lex Set Constraints Bound Consistency for Binary Length-Lex Set Constraints Pascal Van Hentenryck and Justin Yip Brown University, Box 1910 Carmen Gervet Boston University, Providence, RI 02912 808 Commonwealth Av. Boston,

More information

MTH4410 Constraint Programming. Merci à Willem-Jan van Hoeve, CMU.

MTH4410 Constraint Programming. Merci à Willem-Jan van Hoeve, CMU. MTH4410 Constraint Programming Merci à Willem-Jan van Hoeve, CMU. Outline Successful Applications Modeling Solving Some details global constraints scheduling Integrated methods (MIP+CP) Constraint Programming

More information

Integer Programming! Using linear programming to solve discrete problems

Integer Programming! Using linear programming to solve discrete problems Integer Programming! Using linear programming to solve discrete problems Solving Discrete Problems Linear programming solves continuous problem! problems over the reai numbers.! For the remainder of the

More information

A CSP Search Algorithm with Reduced Branching Factor

A CSP Search Algorithm with Reduced Branching Factor A CSP Search Algorithm with Reduced Branching Factor Igor Razgon and Amnon Meisels Department of Computer Science, Ben-Gurion University of the Negev, Beer-Sheva, 84-105, Israel {irazgon,am}@cs.bgu.ac.il

More information

Lecture 18. Questions? Monday, February 20 CS 430 Artificial Intelligence - Lecture 18 1

Lecture 18. Questions? Monday, February 20 CS 430 Artificial Intelligence - Lecture 18 1 Lecture 18 Questions? Monday, February 20 CS 430 Artificial Intelligence - Lecture 18 1 Outline Chapter 6 - Constraint Satisfaction Problems Path Consistency & Global Constraints Sudoku Example Backtracking

More information

Constraint Satisfaction Problems. Chapter 6

Constraint Satisfaction Problems. Chapter 6 Constraint Satisfaction Problems Chapter 6 Constraint Satisfaction Problems A constraint satisfaction problem consists of three components, X, D, and C: X is a set of variables, {X 1,..., X n }. D is a

More information

PROPAGATION-BASED CONSTRAINT SOLVER IN IMS Igor Ol. Blynov Kherson State University

PROPAGATION-BASED CONSTRAINT SOLVER IN IMS Igor Ol. Blynov Kherson State University Інформаційні технології в освіті UDC 0044:37 PROPAGATION-BASED CONSTRAINT SOLVER IN IMS Igor Ol Blynov Kherson State University Abstracts Article compiling the main ideas of creating propagation-based

More information

Validating Plans with Durative Actions via Integrating Boolean and Numerical Constraints

Validating Plans with Durative Actions via Integrating Boolean and Numerical Constraints Validating Plans with Durative Actions via Integrating Boolean and Numerical Constraints Roman Barták Charles University in Prague, Faculty of Mathematics and Physics Institute for Theoretical Computer

More information

Foundations of Artificial Intelligence

Foundations of Artificial Intelligence Foundations of Artificial Intelligence 5. Constraint Satisfaction Problems CSPs as Search Problems, Solving CSPs, Problem Structure Wolfram Burgard, Bernhard Nebel, and Martin Riedmiller Albert-Ludwigs-Universität

More information

MiniZinc Tutorial. Ralph Becket 18 June The G12 project defines three closely related modelling languages:

MiniZinc Tutorial. Ralph Becket 18 June The G12 project defines three closely related modelling languages: MiniZinc Tutorial Ralph Becket rafe@csse.unimelb.edu.au 18 June 2007 1 Modelling in MiniZinc The G12 project defines three closely related modelling languages: Zinc is a very high level modelling language;

More information

Solving XCSP problems by using Gecode

Solving XCSP problems by using Gecode Solving XCSP problems by using Gecode Massimo Morara, Jacopo Mauro, and Maurizio Gabbrielli University of Bologna. morara jmauro gabbri@cs.unibo.it Abstract. Gecode is one of the most efficient libraries

More information

Greedy Algorithms 1. For large values of d, brute force search is not feasible because there are 2 d

Greedy Algorithms 1. For large values of d, brute force search is not feasible because there are 2 d Greedy Algorithms 1 Simple Knapsack Problem Greedy Algorithms form an important class of algorithmic techniques. We illustrate the idea by applying it to a simplified version of the Knapsack Problem. Informally,

More information

Introduction to Constraint Programming

Introduction to Constraint Programming DM841 Discrete Optimization Part II Lecture 1 Introduction to Constraint Programming Marco Chiarandini Department of Mathematics & Computer Science University of Southern Denmark Outline Course Introduction

More information

Constraint Satisfaction Problems

Constraint Satisfaction Problems Constraint Satisfaction Problems Tuomas Sandholm Carnegie Mellon University Computer Science Department [Read Chapter 6 of Russell & Norvig] Constraint satisfaction problems (CSPs) Standard search problem:

More information

Constraint Satisfaction Problems (CSPs) Introduction and Backtracking Search

Constraint Satisfaction Problems (CSPs) Introduction and Backtracking Search Constraint Satisfaction Problems (CSPs) Introduction and Backtracking Search This lecture topic (two lectures) Chapter 6.1 6.4, except 6.3.3 Next lecture topic (two lectures) Chapter 7.1 7.5 (Please read

More information

Solving Constraint Problems in Constraint Programming

Solving Constraint Problems in Constraint Programming Solving Constraint Problems in Constraint Programming Zeynep KIZILTAN Department of Computer Science University of Bologna Email: zeynep@cs.unibo.it What is it about? 10 hour lectures about the core of

More information

{SETS} A LIGHTWEIGHT CONSTRAINT PROGRAMMING LANGUAGE BASED ON ROBDDS

{SETS} A LIGHTWEIGHT CONSTRAINT PROGRAMMING LANGUAGE BASED ON ROBDDS {SETS A LIGHTWEIGHT CONSTRAINT PROGRAMMING LANGUAGE BASED ON ROBDDS Haim Cohen Columbia University City of New York, NY, The United States hc2311@columbia.edu Stephen A. Edwards Columbia University City

More information

Constraint Satisfaction Problems

Constraint Satisfaction Problems Constraint Satisfaction Problems Bernhard Nebel, Julien Hué, and Stefan Wölfl Albert-Ludwigs-Universität Freiburg April 23, 2012 Nebel, Hué and Wölfl (Universität Freiburg) Constraint Satisfaction Problems

More information

Constraint Satisfaction Problems

Constraint Satisfaction Problems Constraint Satisfaction Problems CE417: Introduction to Artificial Intelligence Sharif University of Technology Spring 2013 Soleymani Course material: Artificial Intelligence: A Modern Approach, 3 rd Edition,

More information

Constraint Programming

Constraint Programming Constraint Programming - An overview Examples, Satisfaction vs. Optimization Different Domains Constraint Propagation» Kinds of Consistencies Global Constraints Heuristics Symmetries 7 November 0 Advanced

More information

3 No-Wait Job Shops with Variable Processing Times

3 No-Wait Job Shops with Variable Processing Times 3 No-Wait Job Shops with Variable Processing Times In this chapter we assume that, on top of the classical no-wait job shop setting, we are given a set of processing times for each operation. We may select

More information

IV/IV B.Tech (Regular) DEGREE EXAMINATION. Design and Analysis of Algorithms (CS/IT 414) Scheme of Evaluation

IV/IV B.Tech (Regular) DEGREE EXAMINATION. Design and Analysis of Algorithms (CS/IT 414) Scheme of Evaluation IV/IV B.Tech (Regular) DEGREE EXAMINATION Design and Analysis of Algorithms (CS/IT 414) Scheme of Evaluation Maximum: 60 Marks 1. Write briefly about the following 1*12= 12 Marks a) Give the characteristics

More information

2. Modeling AEA 2018/2019. Based on Algorithm Engineering: Bridging the Gap Between Algorithm Theory and Practice - ch. 2

2. Modeling AEA 2018/2019. Based on Algorithm Engineering: Bridging the Gap Between Algorithm Theory and Practice - ch. 2 2. Modeling AEA 2018/2019 Based on Algorithm Engineering: Bridging the Gap Between Algorithm Theory and Practice - ch. 2 Content Introduction Modeling phases Modeling Frameworks Graph Based Models Mixed

More information

Introduction. Bernhard Nebel, Julien Hué, and Stefan Wölfl. April 23, 2012

Introduction. Bernhard Nebel, Julien Hué, and Stefan Wölfl. April 23, 2012 Bernhard Nebel, Julien Hué, and Stefan Wölfl Albert-Ludwigs-Universität Freiburg April 23, 2012 s s What is a constraint? 1 a: the act of constraining b: the state of being checked, restricted, or compelled

More information

Global Constraints. Combinatorial Problem Solving (CPS) Enric Rodríguez-Carbonell (based on materials by Javier Larrosa) February 22, 2019

Global Constraints. Combinatorial Problem Solving (CPS) Enric Rodríguez-Carbonell (based on materials by Javier Larrosa) February 22, 2019 Global Constraints Combinatorial Problem Solving (CPS) Enric Rodríguez-Carbonell (based on materials by Javier Larrosa) February 22, 2019 Global Constraints Global constraints are classes o constraints

More information

Chapter 10 Part 1: Reduction

Chapter 10 Part 1: Reduction //06 Polynomial-Time Reduction Suppose we could solve Y in polynomial-time. What else could we solve in polynomial time? don't confuse with reduces from Chapter 0 Part : Reduction Reduction. Problem X

More information

CS 188: Artificial Intelligence. What is Search For? Constraint Satisfaction Problems. Constraint Satisfaction Problems

CS 188: Artificial Intelligence. What is Search For? Constraint Satisfaction Problems. Constraint Satisfaction Problems CS 188: Artificial Intelligence Constraint Satisfaction Problems Constraint Satisfaction Problems N variables domain D constraints x 1 x 2 Instructor: Marco Alvarez University of Rhode Island (These slides

More information

Outline. Best-first search

Outline. Best-first search Outline Best-first search Greedy best-first search A* search Heuristics Local search algorithms Hill-climbing search Beam search Simulated annealing search Genetic algorithms Constraint Satisfaction Problems

More information

Outline. Best-first search

Outline. Best-first search Outline Best-first search Greedy best-first search A* search Heuristics Local search algorithms Hill-climbing search Beam search Simulated annealing search Genetic algorithms Constraint Satisfaction Problems

More information

CS 771 Artificial Intelligence. Constraint Satisfaction Problem

CS 771 Artificial Intelligence. Constraint Satisfaction Problem CS 771 Artificial Intelligence Constraint Satisfaction Problem Constraint Satisfaction Problems So far we have seen a problem can be solved by searching in space of states These states can be evaluated

More information

CS 188: Artificial Intelligence Fall 2011

CS 188: Artificial Intelligence Fall 2011 Announcements Project 1: Search is due next week Written 1: Search and CSPs out soon Piazza: check it out if you haven t CS 188: Artificial Intelligence Fall 2011 Lecture 4: Constraint Satisfaction 9/6/2011

More information

Logic, Programming and Prolog (Supplement)

Logic, Programming and Prolog (Supplement) Logic, Programming and Prolog (Supplement) Ulf Nilsson Dept of Computer and Information Science Linköping University ulfni@ida.liu.se http://www.ida.liu.se/labs/logpro/ulfni c Ulf Nilsson, November 26,

More information

The Tractability of Global Constraints

The Tractability of Global Constraints The Tractability of Global Constraints Christian Bessiere ½, Emmanuel Hebrard ¾, Brahim Hnich ¾, and Toby Walsh ¾ ¾ ½ LIRMM-CNRS, Montpelier, France. bessiere@lirmm.fr Cork Constraint Computation Center,

More information

Principles of Optimization Techniques to Combinatorial Optimization Problems and Decomposition [1]

Principles of Optimization Techniques to Combinatorial Optimization Problems and Decomposition [1] International Journal of scientific research and management (IJSRM) Volume 3 Issue 4 Pages 2582-2588 2015 \ Website: www.ijsrm.in ISSN (e): 2321-3418 Principles of Optimization Techniques to Combinatorial

More information

Announcements. Homework 4. Project 3. Due tonight at 11:59pm. Due 3/8 at 4:00pm

Announcements. Homework 4. Project 3. Due tonight at 11:59pm. Due 3/8 at 4:00pm Announcements Homework 4 Due tonight at 11:59pm Project 3 Due 3/8 at 4:00pm CS 188: Artificial Intelligence Constraint Satisfaction Problems Instructor: Stuart Russell & Sergey Levine, University of California,

More information

Boolean Representations and Combinatorial Equivalence

Boolean Representations and Combinatorial Equivalence Chapter 2 Boolean Representations and Combinatorial Equivalence This chapter introduces different representations of Boolean functions. It then discusses the applications of these representations for proving

More information

Handbook of Constraint Programming

Handbook of Constraint Programming Handbook of Constraint Programming Francesca Rossi, Peter van Beek, Toby Walsh Elsevier Contents Contents v I First part 1 1 Modelling 3 Barbara M. Smith 1.1 Preliminaries... 4 1.2 Representing a Problem.....

More information

CS 343: Artificial Intelligence

CS 343: Artificial Intelligence CS 343: Artificial Intelligence Constraint Satisfaction Problems Prof. Scott Niekum The University of Texas at Austin [These slides are based on those of Dan Klein and Pieter Abbeel for CS188 Intro to

More information

Search Strategy Simulation in Constraint Booleanization

Search Strategy Simulation in Constraint Booleanization Search Strategy Simulation in Constraint Booleanization Jinbo Huang Optimisation Research Group, NICTA and Research School of Computer Science, Australian National University Abstract Within the recently

More information

Lecture 6: Constraint Satisfaction Problems (CSPs)

Lecture 6: Constraint Satisfaction Problems (CSPs) Lecture 6: Constraint Satisfaction Problems (CSPs) CS 580 (001) - Spring 2018 Amarda Shehu Department of Computer Science George Mason University, Fairfax, VA, USA February 28, 2018 Amarda Shehu (580)

More information

CS W4701 Artificial Intelligence

CS W4701 Artificial Intelligence CS W4701 Artificial Intelligence Fall 2013 Chapter 6: Constraint Satisfaction Problems Jonathan Voris (based on slides by Sal Stolfo) Assignment 3 Go Encircling Game Ancient Chinese game Dates back At

More information

10/11/2017. Constraint Satisfaction Problems II. Review: CSP Representations. Heuristic 1: Most constrained variable

10/11/2017. Constraint Satisfaction Problems II. Review: CSP Representations. Heuristic 1: Most constrained variable //7 Review: Constraint Satisfaction Problems Constraint Satisfaction Problems II AIMA: Chapter 6 A CSP consists of: Finite set of X, X,, X n Nonempty domain of possible values for each variable D, D, D

More information

The Extended Global Cardinality Constraint: An Empirical Survey

The Extended Global Cardinality Constraint: An Empirical Survey The Extended Global Cardinality Constraint: An Empirical Survey Peter Nightingale a a School of Computer Science University of St Andrews St Andrews Fife KY16 9SX United Kingdom Abstract The Extended Global

More information

Range and Roots: Two Common Patterns for Specifying and Propagating Counting and Occurrence Constraints

Range and Roots: Two Common Patterns for Specifying and Propagating Counting and Occurrence Constraints Range and Roots: Two Common Patterns for Specifying and Propagating Counting and Occurrence Constraints Christian Bessiere LIRMM, CNRS and U. Montpellier Montpellier, France bessiere@lirmm.fr Brahim Hnich

More information

CMPSCI611: The SUBSET-SUM Problem Lecture 18

CMPSCI611: The SUBSET-SUM Problem Lecture 18 CMPSCI611: The SUBSET-SUM Problem Lecture 18 We begin today with the problem we didn t get to at the end of last lecture the SUBSET-SUM problem, which we also saw back in Lecture 8. The input to SUBSET-

More information

Announcements. Homework 1: Search. Project 1: Search. Midterm date and time has been set:

Announcements. Homework 1: Search. Project 1: Search. Midterm date and time has been set: Announcements Homework 1: Search Has been released! Due Monday, 2/1, at 11:59pm. On edx online, instant grading, submit as often as you like. Project 1: Search Has been released! Due Friday 2/5 at 5pm.

More information

CS473-Algorithms I. Lecture 13-A. Graphs. Cevdet Aykanat - Bilkent University Computer Engineering Department

CS473-Algorithms I. Lecture 13-A. Graphs. Cevdet Aykanat - Bilkent University Computer Engineering Department CS473-Algorithms I Lecture 3-A Graphs Graphs A directed graph (or digraph) G is a pair (V, E), where V is a finite set, and E is a binary relation on V The set V: Vertex set of G The set E: Edge set of

More information

Two Set-Constraints for Modeling and Efficiency

Two Set-Constraints for Modeling and Efficiency Two Set-Constraints for Modeling and Efficiency Willem-Jan van Hoeve 1 and Ashish Sabharwal 2 1 Tepper School of Business, Carnegie Mellon University 5000 Forbes Avenue, Pittsburgh, PA 15213, U.S.A. vanhoeve@andrew.cmu.edu

More information

The All Different and Global Cardinality Constraints on Set, Multiset and Tuple Variables

The All Different and Global Cardinality Constraints on Set, Multiset and Tuple Variables The All Different and Global Cardinality Constraints on Set, Multiset and Tuple Variables Claude-Guy Quimper 1 and Toby Walsh 2 1 School of Computer Science, University of Waterloo, Canada, cquimper@math.uwaterloo.ca

More information

Artificial Intelligence Constraint Satisfaction Problems

Artificial Intelligence Constraint Satisfaction Problems Artificial Intelligence Constraint Satisfaction Problems Recall Search problems: Find the sequence of actions that leads to the goal. Sequence of actions means a path in the search space. Paths come with

More information

Modelling for Constraint Programming

Modelling for Constraint Programming Modelling for Constraint Programming Barbara M. Smith Cork Constraint Computation Centre, University College Cork, Ireland September 2005 1 Introduction Constraint programming can be a successful technology

More information

Combining forces to solve Combinatorial Problems, a preliminary approach

Combining forces to solve Combinatorial Problems, a preliminary approach Combining forces to solve Combinatorial Problems, a preliminary approach Mohamed Siala, Emmanuel Hebrard, and Christian Artigues Tarbes, France Mohamed SIALA April 2013 EDSYS Congress 1 / 19 Outline Context

More information

Announcements. CS 188: Artificial Intelligence Fall 2010

Announcements. CS 188: Artificial Intelligence Fall 2010 Announcements Project 1: Search is due Monday Looking for partners? After class or newsgroup Written 1: Search and CSPs out soon Newsgroup: check it out CS 188: Artificial Intelligence Fall 2010 Lecture

More information

Constraint Satisfaction Problems

Constraint Satisfaction Problems Constraint Satisfaction Problems Chapter 5 Section 1 3 Constraint Satisfaction 1 Outline Constraint Satisfaction Problems (CSP) Backtracking search for CSPs Local search for CSPs Constraint Satisfaction

More information

Constraint Satisfaction Problems

Constraint Satisfaction Problems Constraint Satisfaction Problems In which we see how treating states as more than just little black boxes leads to the invention of a range of powerful new search methods and a deeper understanding of

More information

Module 4. Constraint satisfaction problems. Version 2 CSE IIT, Kharagpur

Module 4. Constraint satisfaction problems. Version 2 CSE IIT, Kharagpur Module 4 Constraint satisfaction problems Lesson 10 Constraint satisfaction problems - II 4.5 Variable and Value Ordering A search algorithm for constraint satisfaction requires the order in which variables

More information

What is Search For? CS 188: Artificial Intelligence. Constraint Satisfaction Problems

What is Search For? CS 188: Artificial Intelligence. Constraint Satisfaction Problems CS 188: Artificial Intelligence Constraint Satisfaction Problems What is Search For? Assumptions about the world: a single agent, deterministic actions, fully observed state, discrete state space Planning:

More information

Rapid Prototyping of a Structured Domain through Indexical Compilation

Rapid Prototyping of a Structured Domain through Indexical Compilation Rapid Prototyping of a Structured Domain through Indexical Compilation Joseph D. Scott Uppsala University Abstract. We report on our experience with rapid prototyping for a new structured domain of bounded-length

More information

CS 4100 // artificial intelligence

CS 4100 // artificial intelligence CS 4100 // artificial intelligence instructor: byron wallace Constraint Satisfaction Problems Attribution: many of these slides are modified versions of those distributed with the UC Berkeley CS188 materials

More information

Constraint Satisfaction Problems Part 2

Constraint Satisfaction Problems Part 2 Constraint Satisfaction Problems Part 2 Deepak Kumar October 2017 CSP Formulation (as a special case of search) State is defined by n variables x 1, x 2,, x n Variables can take on values from a domain

More information

CMU-Q Lecture 7: Searching in solution space Constraint Satisfaction Problems (CSPs) Teacher: Gianni A. Di Caro

CMU-Q Lecture 7: Searching in solution space Constraint Satisfaction Problems (CSPs) Teacher: Gianni A. Di Caro CMU-Q 15-381 Lecture 7: Searching in solution space Constraint Satisfaction Problems (CSPs) Teacher: Gianni A. Di Caro AI PLANNING APPROACHES SO FAR Goal: Find the (best) sequence of actions that take

More information

Constraint Satisfaction Problems

Constraint Satisfaction Problems Constraint Satisfaction Problems Robert Platt Northeastern University Some images and slides are used from: 1. AIMA What is a CSP? The space of all search problems states and actions are atomic goals are

More information

3rd CHR Summer School Topics: Introduction to Constraint Programming

3rd CHR Summer School Topics: Introduction to Constraint Programming 3rd CHR Summer School Topics: Introduction to Constraint Programming Prof. Dr. Slim Abdennadher 8.7.2013 c S.Abdennadher 1 Constraint Programming: Much Quoted Sentence Constraint Programming represents

More information

A Fast Arc Consistency Algorithm for n-ary Constraints

A Fast Arc Consistency Algorithm for n-ary Constraints A Fast Arc Consistency Algorithm for n-ary Constraints Olivier Lhomme 1 and Jean-Charles Régin 2 1 ILOG, 1681, route des Dolines, 06560 Valbonne, FRANCE 2 Computing and Information Science, Cornell University,

More information

6.034 Notes: Section 3.1

6.034 Notes: Section 3.1 6.034 Notes: Section 3.1 Slide 3.1.1 In this presentation, we'll take a look at the class of problems called Constraint Satisfaction Problems (CSPs). CSPs arise in many application areas: they can be used

More information

Lecture 9: Group Communication Operations. Shantanu Dutt ECE Dept. UIC

Lecture 9: Group Communication Operations. Shantanu Dutt ECE Dept. UIC Lecture 9: Group Communication Operations Shantanu Dutt ECE Dept. UIC Acknowledgement Adapted from Chapter 4 slides of the text, by A. Grama w/ a few changes, augmentations and corrections Topic Overview

More information

Constraint Satisfaction Problems. Chapter 6

Constraint Satisfaction Problems. Chapter 6 Constraint Satisfaction Problems Chapter 6 Office hours Office hours for Assignment 1 (ASB9810 in CSIL): Sep 29th(Fri) 12:00 to 13:30 Oct 3rd(Tue) 11:30 to 13:00 Late homework policy You get four late

More information

arxiv: v1 [cs.dm] 21 Dec 2015

arxiv: v1 [cs.dm] 21 Dec 2015 The Maximum Cardinality Cut Problem is Polynomial in Proper Interval Graphs Arman Boyacı 1, Tinaz Ekim 1, and Mordechai Shalom 1 Department of Industrial Engineering, Boğaziçi University, Istanbul, Turkey

More information

Treewidth and graph minors

Treewidth and graph minors Treewidth and graph minors Lectures 9 and 10, December 29, 2011, January 5, 2012 We shall touch upon the theory of Graph Minors by Robertson and Seymour. This theory gives a very general condition under

More information

Chapter 9: Constraint Logic Programming

Chapter 9: Constraint Logic Programming 9. Constraint Logic Programming 9-1 Deductive Databases and Logic Programming (Winter 2007/2008) Chapter 9: Constraint Logic Programming Introduction, Examples Basic Query Evaluation Finite Domain Constraint

More information

CS388C: Combinatorics and Graph Theory

CS388C: Combinatorics and Graph Theory CS388C: Combinatorics and Graph Theory David Zuckerman Review Sheet 2003 TA: Ned Dimitrov updated: September 19, 2007 These are some of the concepts we assume in the class. If you have never learned them

More information

Lecture 9 Arc Consistency

Lecture 9 Arc Consistency Computer Science CPSC 322 Lecture 9 Arc Consistency (4.5, 4.6) Slide 1 Lecture Overview Recap of Lecture 8 Arc Consistency for CSP Domain Splitting 2 Problem Type Static Sequential Constraint Satisfaction

More information

Contents. Index... 33

Contents. Index... 33 Contents Semidefinite Programming and Constraint Programming Willem-Jan van Hoeve... 1 1 Introduction.................................................... 1 2 Constraint Programming..........................................

More information

Consistency and Set Intersection

Consistency and Set Intersection Consistency and Set Intersection Yuanlin Zhang and Roland H.C. Yap National University of Singapore 3 Science Drive 2, Singapore {zhangyl,ryap}@comp.nus.edu.sg Abstract We propose a new framework to study

More information

Boolean Satisfiability: The Central Problem of Computation

Boolean Satisfiability: The Central Problem of Computation Boolean Satisfiability: The Central Problem of Computation Peter Kogge SAT Notre Dame CSE 34151: Theory of Computing: Fall 2017 Slide 1 (p. 299) SAT: Boolean Satisfiability wff: well-formed-formula constructed

More information

Relational Database: The Relational Data Model; Operations on Database Relations

Relational Database: The Relational Data Model; Operations on Database Relations Relational Database: The Relational Data Model; Operations on Database Relations Greg Plaxton Theory in Programming Practice, Spring 2005 Department of Computer Science University of Texas at Austin Overview

More information

Constraint Satisfaction Problems. A Quick Overview (based on AIMA book slides)

Constraint Satisfaction Problems. A Quick Overview (based on AIMA book slides) Constraint Satisfaction Problems A Quick Overview (based on AIMA book slides) Constraint satisfaction problems What is a CSP? Finite set of variables V, V 2,, V n Nonempty domain of possible values for

More information

Chapter 6 Constraint Satisfaction Problems

Chapter 6 Constraint Satisfaction Problems Chapter 6 Constraint Satisfaction Problems CS5811 - Artificial Intelligence Nilufer Onder Department of Computer Science Michigan Technological University Outline CSP problem definition Backtracking search

More information

Artificial Intelligence

Artificial Intelligence Contents Artificial Intelligence 5. Constraint Satisfaction Problems CSPs as Search Problems, Solving CSPs, Problem Structure Wolfram Burgard, Andreas Karwath, Bernhard Nebel, and Martin Riedmiller What

More information

Artificial Intelligence

Artificial Intelligence Artificial Intelligence 5. Constraint Satisfaction Problems CSPs as Search Problems, Solving CSPs, Problem Structure Wolfram Burgard, Andreas Karwath, Bernhard Nebel, and Martin Riedmiller SA-1 Contents

More information

CSE 417 Network Flows (pt 3) Modeling with Min Cuts

CSE 417 Network Flows (pt 3) Modeling with Min Cuts CSE 417 Network Flows (pt 3) Modeling with Min Cuts Reminders > HW6 is due on Friday start early bug fixed on line 33 of OptimalLineup.java: > change true to false Review of last two lectures > Defined

More information

Lagrangian Relaxation in CP

Lagrangian Relaxation in CP Lagrangian Relaxation in CP Willem-Jan van Hoeve CPAIOR 016 Master Class Overview 1. Motivation for using Lagrangian Relaxations in CP. Lagrangian-based domain filtering Example: Traveling Salesman Problem.

More information

There are no CNF problems. Peter J. Stuckey and countless others!

There are no CNF problems. Peter J. Stuckey and countless others! There are no CNF problems Peter J. Stuckey and countless others! Conspirators Ignasi Abio, Ralph Becket, Sebastian Brand, Geoffrey Chu, Michael Codish, Greg Duck, Nick Downing, Thibaut Feydy, Graeme Gange,

More information

Constraint Satisfaction

Constraint Satisfaction Constraint Satisfaction Philipp Koehn 1 October 2015 Outline 1 Constraint satisfaction problems (CSP) examples Backtracking search for CSPs Problem structure and problem decomposition Local search for

More information

CS 473: Algorithms. Ruta Mehta. Spring University of Illinois, Urbana-Champaign. Ruta (UIUC) CS473 1 Spring / 36

CS 473: Algorithms. Ruta Mehta. Spring University of Illinois, Urbana-Champaign. Ruta (UIUC) CS473 1 Spring / 36 CS 473: Algorithms Ruta Mehta University of Illinois, Urbana-Champaign Spring 2018 Ruta (UIUC) CS473 1 Spring 2018 1 / 36 CS 473: Algorithms, Spring 2018 LP Duality Lecture 20 April 3, 2018 Some of the

More information

AUTOMATED REASONING. Agostino Dovier. Udine, October 1, Università di Udine CLPLAB

AUTOMATED REASONING. Agostino Dovier. Udine, October 1, Università di Udine CLPLAB AUTOMATED REASONING Agostino Dovier Università di Udine CLPLAB Udine, October 1, 2018 AGOSTINO DOVIER (CLPLAB) AUTOMATED REASONING UDINE, OCTOBER 1, 2018 1 / 28 COURSE PLACEMENT International Master Degree

More information

Theorem 2.9: nearest addition algorithm

Theorem 2.9: nearest addition algorithm There are severe limits on our ability to compute near-optimal tours It is NP-complete to decide whether a given undirected =(,)has a Hamiltonian cycle An approximation algorithm for the TSP can be used

More information

Round 3: Trees. Tommi Junttila. Aalto University School of Science Department of Computer Science. CS-A1140 Data Structures and Algorithms Autumn 2017

Round 3: Trees. Tommi Junttila. Aalto University School of Science Department of Computer Science. CS-A1140 Data Structures and Algorithms Autumn 2017 Round 3: Trees Tommi Junttila Aalto University School of Science Department of Computer Science CS-A1140 Data Structures and Algorithms Autumn 2017 Tommi Junttila (Aalto University) Round 3 CS-A1140 /

More information

Reducing Directed Max Flow to Undirected Max Flow and Bipartite Matching

Reducing Directed Max Flow to Undirected Max Flow and Bipartite Matching Reducing Directed Max Flow to Undirected Max Flow and Bipartite Matching Henry Lin Division of Computer Science University of California, Berkeley Berkeley, CA 94720 Email: henrylin@eecs.berkeley.edu Abstract

More information