2017-09-26

Sep 27 In-Class Exercise.

Post your solutions to the Sep 27 In-Class Exercise to this thread.
Best, Chris
Post your solutions to the Sep 27 In-Class Exercise to this thread. Best, Chris
2017-09-27

-- Sep 27 In-Class Exercise
  • let the columns be represented by letters a through d and
  • let the rows be represented by numbers 1 through 4
     Variables:	 
    
  • a1,a2,a3,a4;b1,..b4;c1,..c4;d1,...d4
     Domain:	 
    
  • D = a1,a2,a3,a4;b1,..b4;c1,..c4;d1,...d4 are all integers of value 1-4
     Constraints:	 
    
  • alldif(a1,a2,a3,a4) and
  • alldif(b1,b2,b3,b4) and
  • alldif(c1,c2,c3,c4) and
  • alldif(d1,d2,d3,d4) and
  • alldif(a1,b1,c1,d1) and
  • alldif(a2,b2,c2,d2) and
  • alldif(a3,b3,c3,d3) and
  • alldif(a4,b4,c4,d4)
(Edited: 2017-09-27)
*let the columns be represented by letters a through d and *let the rows be represented by numbers 1 through 4 '''Variables:''' *a1,a2,a3,a4;b1,..b4;c1,..c4;d1,...d4 '''Domain:''' *D = a1,a2,a3,a4;b1,..b4;c1,..c4;d1,...d4 are all integers of value 1-4 '''Constraints:''' *alldif(a1,a2,a3,a4) and *alldif(b1,b2,b3,b4) and *alldif(c1,c2,c3,c4) and *alldif(d1,d2,d3,d4) and *alldif(a1,b1,c1,d1) and *alldif(a2,b2,c2,d2) and *alldif(a3,b3,c3,d3) and *alldif(a4,b4,c4,d4)

-- Sep 27 In-Class Exercise
Variable: {x[i,j] for i,j in {1,…,4}}
Domain: {x[i,j] in {1,…,4} for i,j in {1,…,4}}
Constraint:
{
	x[i,k]!=x[j,k] and x[k,i]!=x[k,j]   for all i,j,k in {1,…,4} with i<j
}
(Edited: 2017-09-27)
Variable: {x[i,j] for i,j in {1,…,4}} Domain: {x[i,j] in {1,…,4} for i,j in {1,…,4}} Constraint: { x[i,k]!=x[j,k] and x[k,i]!=x[k,j] for all i,j,k in {1,…,4} with i<j }

User Icon
-- Sep 27 In-Class Exercise
Model a matrix being a 4x4 latin square as a CSP and post your solution to the.
Variables: {x1, x2, x3, x4, ..., x16} Domains: {D(x1)={1, 2, 3, 4}, D(x2) = {1, 2, 3, 4}, D(x3)={1, 2, 3, 4}, D(x4)={1, 2, 3, 4}} Constraints: {x1 !=x2 && x1 != x3 && x1 != x4 && x2 != x3 && .... x15 != x16}
Student: Xin Yan
(Edited: 2017-09-27)
Model a matrix being a 4x4 latin square as a CSP and post your solution to the. Variables: {x1, x2, x3, x4, ..., x16} Domains: {D(x1)={1, 2, 3, 4}, D(x2) = {1, 2, 3, 4}, D(x3)={1, 2, 3, 4}, D(x4)={1, 2, 3, 4}} Constraints: {x1 !=x2 && x1 != x3 && x1 != x4 && x2 != x3 && .... x15 != x16} Student: Xin Yan

-- Sep 27 In-Class Exercise



X11|X12|X13|X14
- - - - - - - - - - - - -
X21|X22|X23|X24
- - - - - - - - - - - - -
X31|X32|X33|X34
- - - - - - - - - - - - -
X41|X42|X43|X44

CSP:
Set of variables - X:
{
X11, X12, X13, X14,
X21, X22, X23, X24,
X31, X32, X33, X34,
X41, X42, X43, X44
}
Set of domains - D(each variable has domain):
{1, 2, 3, 4}
Set of constraints - C:
{
Alldiff(X11, X12, X13, X14),
Alldiff(X21, X22, X23, X24),
Alldiff(X31, X32, X33, X34),
Alldiff(X41, X42, X43, X44),
Alldiff(X11, X21, X31, X41),
Alldiff(X12, X22, X32, X42),
Alldiff(X13, X23, X33, X43),
Alldiff(X14, X24, X34, X44)
}
(Edited: 2017-09-27)
<br><br><br> X11|X12|X13|X14<br> - - - - - - - - - - - - -<br> X21|X22|X23|X24<br> - - - - - - - - - - - - -<br> X31|X32|X33|X34<br> - - - - - - - - - - - - -<br> X41|X42|X43|X44<br> <br> CSP:<br> Set of variables - X:<br> {<br> X11, X12, X13, X14, <br> X21, X22, X23, X24, <br> X31, X32, X33, X34, <br> X41, X42, X43, X44<br> }<br> Set of domains - D(each variable has domain):<br> {1, 2, 3, 4}<br> Set of constraints - C:<br> {<br> Alldiff(X11, X12, X13, X14),<br> Alldiff(X21, X22, X23, X24),<br> Alldiff(X31, X32, X33, X34),<br> Alldiff(X41, X42, X43, X44),<br> Alldiff(X11, X21, X31, X41),<br> Alldiff(X12, X22, X32, X42),<br> Alldiff(X13, X23, X33, X43),<br> Alldiff(X14, X24, X34, X44)<br> }<br>

-- Sep 27 In-Class Exercise

x is x coordinator of each grid, y is y coordinator of each grid
Variables X = {x0y0, x0y1, x0y2, x0y3, x1y0, x1y1, x1y2, x1y3, x2y0, x2y1, x2y2, x2y3, x3x0, x3y1, x3y2, x3y3}
Domain D = {all x0y0 …. x3y3 have domain 1, 2, 3, 4}
Constrain C= {
Alldiff (x0y0, x0y1, x0y2, x0y3),
Alldiff (x1y0, x1y1, x1y2, x1y3),
Alldiff (x2y0, x2y1, x2y2, x2y3),
Alldiff(x3x0, x3y1, x3y2, x3y3),
Alldiff(x0y0, x1y0, x2y0, x3y0),
Alldiff(x0y1, x1y1, x2y1, x3y1),
Alldiff(x0y2, x1y2, x2y2, x3y2),
Alldiff(x0y3, x1y3, x2y3, x3y3),
}
(Edited: 2017-09-27)
<br> x is x coordinator of each grid, y is y coordinator of each grid Variables X = {x0y0, x0y1, x0y2, x0y3, x1y0, x1y1, x1y2, x1y3, x2y0, x2y1, x2y2, x2y3, x3x0, x3y1, x3y2, x3y3} Domain D = {all x0y0 …. x3y3 have domain 1, 2, 3, 4} Constrain C= { Alldiff (x0y0, x0y1, x0y2, x0y3), Alldiff (x1y0, x1y1, x1y2, x1y3), Alldiff (x2y0, x2y1, x2y2, x2y3), Alldiff(x3x0, x3y1, x3y2, x3y3), Alldiff(x0y0, x1y0, x2y0, x3y0), Alldiff(x0y1, x1y1, x2y1, x3y1), Alldiff(x0y2, x1y2, x2y2, x3y2), Alldiff(x0y3, x1y3, x2y3, x3y3), }

-- Sep 27 In-Class Exercise
Resource Description for Screenshot_2017-09-27_15-38-03.png
(Edited: 2017-09-27)
((resource:Screenshot_2017-09-27_15-38-03.png|Resource Description for Screenshot_2017-09-27_15-38-03.png))

-- Sep 27 In-Class Exercise
Latin Square: n = 4
Variables (Square_ij) = X_ij from i = 1, j = 1 to i = n, j= n
  • Domain D: a value from [n]
  • Constraints C- set of elements in the same column : R(X_(i-1)j, X_ij, X_(i+1)j) from i = *1 to i = n where X_ij != X_(i-1)j And X_ij != X_(i+1)j and X_ij+1 != Xij and X_ij-1 != *Xij
     
    
(Edited: 2017-09-27)
Latin Square: n = 4 Variables (Square_ij) = X_ij from i = 1, j = 1 to i = n, j= n *Domain D: a value from [n] *Constraints C- set of elements in the same column : R(X_(i-1)j, X_ij, X_(i+1)j) from i = *1 to i = n where X_ij != X_(i-1)j And X_ij != X_(i+1)j and X_ij+1 != Xij and X_ij-1 != *Xij

-- Sep 27 In-Class Exercise
 Student: Phyllis Lau
 Variables: 16 squares where X(0,0), X(0,1), X(1,0), X(1,1)…X(3,3)
 Where (rows, columns)
 Domain: For each variable, they have the same domain of {1, 2, 3, 4}
 Constraints: 
 ALLDIFF(X(0,0), X(0,1), X(0,2), X(0,3))
 ALLDIFF(X(1,0), X(1,1), X(1,2), X(1,3))
 ALLDIFF(X(2,0), X(2,1), X(2,2), X(2,3))
 ALLDIFF(X(3,0), X(3,1), X(3,2), X(3,3))
 ALLDIFF(X(0,0), X(1,0), X(2,0), X(3,0))
 ALLDIFF(X(0,1), X(1,1), X(2,1), X(3,1))
 ALLDIFF(X(0,2), X(1,2), X(2,2), X(3,2))
 ALLDIFF(X(0,3), X(1,3), X(2,3), X(3,3))
(Edited: 2017-09-27)
Student: Phyllis Lau Variables: 16 squares where X(0,0), X(0,1), X(1,0), X(1,1)…X(3,3) Where (rows, columns) Domain: For each variable, they have the same domain of {1, 2, 3, 4} Constraints: ALLDIFF(X(0,0), X(0,1), X(0,2), X(0,3)) ALLDIFF(X(1,0), X(1,1), X(1,2), X(1,3)) ALLDIFF(X(2,0), X(2,1), X(2,2), X(2,3)) ALLDIFF(X(3,0), X(3,1), X(3,2), X(3,3)) ALLDIFF(X(0,0), X(1,0), X(2,0), X(3,0)) ALLDIFF(X(0,1), X(1,1), X(2,1), X(3,1)) ALLDIFF(X(0,2), X(1,2), X(2,2), X(3,2)) ALLDIFF(X(0,3), X(1,3), X(2,3), X(3,3))

-- Sep 27 In-Class Exercise
 X = {X1, X2, ..., X16}
 Dn = {1, 2, 3, 4} for each of the variables
 Constraints = {
     Alldiff(X1, X2, X3, X4)
     Alldiff(X5, X6, X7, X8)
     Alldiff(X9, X10, X11, X12)
     Alldiff(X13, X14, X15, X16)
     Alldiff(X1, X5, X9, X13)
     Alldiff(X2, X6, X10, X14)
     Alldiff(X3, X7, X11, X15)
     Alldiff(X4, X8, X12, X16)
 }
X = {X1, X2, ..., X16} Dn = {1, 2, 3, 4} for each of the variables Constraints = { Alldiff(X1, X2, X3, X4) Alldiff(X5, X6, X7, X8) Alldiff(X9, X10, X11, X12) Alldiff(X13, X14, X15, X16) Alldiff(X1, X5, X9, X13) Alldiff(X2, X6, X10, X14) Alldiff(X3, X7, X11, X15) Alldiff(X4, X8, X12, X16) }
[ Next ]
X