YOU ARE DOWNLOADING DOCUMENT

Please tick the box to continue:

Transcript
Page 1: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT?

Woof!

Page 2: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

Set Variables

using as an example

Steiner Triples

Page 3: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

Set Variables

using as an example

Steiner Triples

Steiner Kirkman

Page 4: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

… and BIBD’s, 0/1 encoding, symmetry breaking

See • choco manual 1.4.2, page 14 and 15• CSPLib prob028• choco manual 6.3, pages 64 and 65• choco manual 8.56 lex (constraint)

Page 5: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

Represented with two bounds

kernel: intersection of all possible sets

envelope: the union of all possible sets upper bound

lower bound

Page 6: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

We will do this by example, solving a problem

Page 7: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!
Page 8: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

We are given a set S of size n. Produce n.(n-1)/6 triples (subsets of S of size 3) such that given any pair of triples their intersection is of size at most 1

Equivalently, every possible pair of elements in S occurs in onlyone of the n.(n-1)/6 triples

Page 9: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

Given a set of size n, how many triples are we to produce?

Equivalently, every possible pair of elements in S occurs in onlyone of the triples

How many pairs are there? n.(n-1)/2

Every triple contains 3 pairs Therefore n.(n-1)/6 triples required

Page 10: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

We are given a set S of size n. Produce n.(n-1)/6 triples (subsets of S of size 3) such that given any pair of triples their intersection is of size at most 1

Page 11: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

A triple is also called a “block” and the entries of a block a “point”

This is then a BIBD (balanced incomplete block design)

Applications: design of experiments, testing, …

Page 12: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

Modelling the Steiner Triple problem using Set Variables

Page 13: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!
Page 14: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!
Page 15: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!
Page 16: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!
Page 17: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

Given a set of size n, how many triples are we to produce?

Equivalently, every possible pair of elements in S occurs in onlyone of the triples

How many pairs are there? n.(n-1)/2

Every triple contains 3 pairs Therefore n.(n-1)/6 triples required

Page 18: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!
Page 19: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!
Page 20: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!
Page 21: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!
Page 22: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

Compile and Run

Page 23: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

An alternative representation

Page 24: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

0/1 Array

m=7

block

point

Sum of a column = 3, intersection between two columns is at most 1

1 1 1

1 1 1

1 1 1

1 1 1

1 1 1

1 1 1

1 1 1

Page 25: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!
Page 26: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!
Page 27: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!
Page 28: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!
Page 29: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!
Page 30: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!
Page 31: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!
Page 32: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!
Page 33: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!
Page 34: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

Compile & Run

For both models try n=1, n=7, n=9

Show effect of symmetry breaking and search over only decision variable

Page 35: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!
Page 36: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!
Page 37: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

How about we do the following:

Generate all triples <i,j,k> where 0 ≤ i < j < k < m and pick the ones we want

Have a zero/one IntegerVariable for each triple, in an arrayA, such that A[i][j][k] is 1 iff we select triple <i,j,k>

Flatten the array A into a one-D vector, say v?

Constrain v such that it sums to m.(m-1)/6

For every pair of triples that match on two indices make thesum of their corresponding constrained integer variables be at most 1 (i.e. select at most 1 of these triples)

Is this dumb?

Page 38: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

Fix i and j: Sum of A[i][j][*] ≤ 1

Fix i and k: Sum of A[i][*][k] ≤ 1

Fix j and k: Sum of A[*][j][k] ≤ 1

But we need to ensure that the sum of the above sums is also at most 1

For every pair of triples that match on two indices make thesum of their corresponding constrained integer variables be at most 1 (i.e. select at most 1 of these triples)

Page 39: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

The age of stupid

Page 40: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

The age of stupid

Page 41: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

The age of stupid

Page 42: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

The age of stupid

Page 43: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

The age of stupid

Page 44: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

The age of stupid

Page 45: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

The age of stupid

Page 46: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

The age of stupid

Page 47: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

The age of stupid

Page 48: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

Compile & Run

Page 49: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!
Page 50: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

An array, m by m, where pair[i][j] is an integer

pair[i][j] = k means that pair (i,j) is in kth block

Proposed by Chris Unsworth

Location, location, location

pair[i][j] = k iff points i and j are in block[k]

The number of points in a block is 3

Page 51: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

Proposed by Chris Unsworth

Location, location, location

Constrain pair[i][j] = k iff block[k][i] = 1 and b[k][j] = 1

i and j are in the kth triple

if and only if kth triple contains i

and kth triple contains j

Page 52: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

public class SteinerTriple03 { public static void main(String[] args) {

CPModel model = new CPModel(); int m = I nteger.parseInt(args[0]); int n = m*(m- 1)/6;

I ntegerVariable[][] block = makeIntVarArray("block",n,m,0,1); / / block[i][j] = 1 <- > j is in ith block I ntegerVariable[][] pair = new IntegerVariable[m][m]; / / pair[i][j] = k <- > (i,j) is in block[k]

for (int i=0;i<m- 1;i++) for (int j=i+1;j<m;j++) pair[i][j] = makeIntVar("pair_"+ i +"_"+ j,0,n- 1);

/ / / / one variable for each pair (i,j) where i<j / /

for (int i=0;i<n;i++) model.addConstraint(eq(sum(block[i]),3));

/ / / / there are 3 points in a block / /

for (int i=0;i<m- 1;i++) for (int j=i+1;j<m;j++) for (int k=0;k<n;k++)

model.addConstraint(ifOnlyI f(eq(pair[i][j],k),and(eq(block[k][i],1),eq(block[k][j],1)))); / / / / pair[i][j] = k <- > block[k][i] = 1 && block[k][j] = 1 / /

Page 53: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

public class SteinerTriple03 { public static void main(String[] args) {

CPModel model = new CPModel(); int m = I nteger.parseInt(args[0]); int n = m*(m- 1)/6;

I ntegerVariable[][] block = makeIntVarArray("block",n,m,0,1); / / block[i][j] = 1 <- > j is in ith block I ntegerVariable[][] pair = new IntegerVariable[m][m]; / / pair[i][j] = k <- > (i,j) is in block[k]

for (int i=0;i<m- 1;i++) for (int j=i+1;j<m;j++) pair[i][j] = makeIntVar("pair_"+ i +"_"+ j,0,n- 1);

/ / / / one variable for each pair (i,j) where i<j / /

for (int i=0;i<n;i++) model.addConstraint(eq(sum(block[i]),3));

/ / / / there are 3 points in a block / /

for (int i=0;i<m- 1;i++) for (int j=i+1;j<m;j++) for (int k=0;k<n;k++)

model.addConstraint(ifOnlyI f(eq(pair[i][j],k),and(eq(block[k][i],1),eq(block[k][j],1)))); / / / / pair[i][j] = k <- > block[k][i] = 1 && block[k][j] = 1 / /

Page 54: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

public class SteinerTriple03 { public static void main(String[] args) {

CPModel model = new CPModel(); int m = I nteger.parseInt(args[0]); int n = m*(m- 1)/6;

I ntegerVariable[][] block = makeIntVarArray("block",n,m,0,1); / / block[i][j] = 1 <- > j is in ith block I ntegerVariable[][] pair = new IntegerVariable[m][m]; / / pair[i][j] = k <- > (i,j) is in block[k]

for (int i=0;i<m- 1;i++) for (int j=i+1;j<m;j++) pair[i][j] = makeIntVar("pair_"+ i +"_"+ j,0,n- 1);

/ / / / one variable for each pair (i,j) where i<j / /

for (int i=0;i<n;i++) model.addConstraint(eq(sum(block[i]),3));

/ / / / there are 3 points in a block / /

for (int i=0;i<m- 1;i++) for (int j=i+1;j<m;j++) for (int k=0;k<n;k++)

model.addConstraint(ifOnlyI f(eq(pair[i][j],k),and(eq(block[k][i],1),eq(block[k][j],1)))); / / / / pair[i][j] = k <- > block[k][i] = 1 && block[k][j] = 1 / /

Page 55: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

public class SteinerTriple03 { public static void main(String[] args) {

CPModel model = new CPModel(); int m = I nteger.parseInt(args[0]); int n = m*(m- 1)/6;

I ntegerVariable[][] block = makeIntVarArray("block",n,m,0,1); / / block[i][j] = 1 <- > j is in ith block I ntegerVariable[][] pair = new IntegerVariable[m][m]; / / pair[i][j] = k <- > (i,j) is in block[k]

for (int i=0;i<m- 1;i++) for (int j=i+1;j<m;j++) pair[i][j] = makeIntVar("pair_"+ i +"_"+ j,0,n- 1);

/ / / / one variable for each pair (i,j) where i<j / /

for (int i=0;i<n;i++) model.addConstraint(eq(sum(block[i]),3));

/ / / / there are 3 points in a block / /

for (int i=0;i<m- 1;i++) for (int j=i+1;j<m;j++) for (int k=0;k<n;k++)

model.addConstraint(ifOnlyI f(eq(pair[i][j],k),and(eq(block[k][i],1),eq(block[k][j],1)))); / / / / pair[i][j] = k <- > block[k][i] = 1 && block[k][j] = 1 / /

Page 56: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

public class SteinerTriple03 { public static void main(String[] args) {

CPModel model = new CPModel(); int m = I nteger.parseInt(args[0]); int n = m*(m- 1)/6;

I ntegerVariable[][] block = makeIntVarArray("block",n,m,0,1); / / block[i][j] = 1 <- > j is in ith block I ntegerVariable[][] pair = new IntegerVariable[m][m]; / / pair[i][j] = k <- > (i,j) is in block[k]

for (int i=0;i<m- 1;i++) for (int j=i+1;j<m;j++) pair[i][j] = makeIntVar("pair_"+ i +"_"+ j,0,n- 1);

/ / / / one variable for each pair (i,j) where i<j / /

for (int i=0;i<n;i++) model.addConstraint(eq(sum(block[i]),3));

/ / / / there are 3 points in a block / /

for (int i=0;i<m- 1;i++) for (int j=i+1;j<m;j++) for (int k=0;k<n;k++)

model.addConstraint(ifOnlyI f(eq(pair[i][j],k),and(eq(block[k][i],1),eq(block[k][j],1)))); / / / / pair[i][j] = k <- > block[k][i] = 1 && block[k][j] = 1 / /

Page 57: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

CPSolver sol = new CPSolver(); sol.read(model);

I ntDomainVar[] decision = new IntDomainVar[m*(m- 1)/2]; for (int i=0,k=0;i<m- 1;i++)

for (int j=i+1;j<m;j++,k++) decision[k] = sol.getVar(pair[i][j]);

sol.setVarIntSelector(new StaticVarOrder(decision)); / / / / decision variables are the pairs / /

System.out.println(sol.solve()); sol.printRuntimeSatistics(); for (int i=0;i<n;i++){

for (int j=0;j<m;j++) if(sol.getVar(block[i][j]).getVal() == 1) System.out.print(j +" "); for (int j=0;j<m;j++) System.out.print(sol.getVar(block[i][j]).getVal()); System.out.println();

} }

Page 58: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

CPSolver sol = new CPSolver(); sol.read(model);

I ntDomainVar[] decision = new IntDomainVar[m*(m- 1)/2]; for (int i=0,k=0;i<m- 1;i++)

for (int j=i+1;j<m;j++,k++) decision[k] = sol.getVar(pair[i][j]);

sol.setVarIntSelector(new StaticVarOrder(decision)); / / / / decision variables are the pairs / /

System.out.println(sol.solve()); sol.printRuntimeSatistics(); for (int i=0;i<n;i++){

for (int j=0;j<m;j++) if(sol.getVar(block[i][j]).getVal() == 1) System.out.print(j +" "); for (int j=0;j<m;j++) System.out.print(sol.getVar(block[i][j]).getVal()); System.out.println();

} }

Page 59: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

Compile & Run

Page 60: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

More generally Steiner Triple is a BIBD

Page 61: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!
Page 62: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!
Page 63: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!
Page 64: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

So?

1. Set variables2. Steiner triples3. Various models (four!)4. Symmetry breaking with

lex5. Dare to be stupid

Page 65: But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!

Related Documents