The Kings Problem - NC State: WWW4 Server

The Kings Problem
1/44
Shaina Race - Clemson University
Keith Schneider - UNCA
Matthew Yancey - Virginia Tech
<
>
≪
≫

i
?
P
Overview
2/44
• Fibonacci Recurrence in 1 dimension
<
>
≪
≫

i
?
P
Overview
2/44
• Fibonacci Recurrence in 1 dimension
• Graphs and Adjacency Matrix Recurrence
<
>
≪
≫

i
?
P
Overview
2/44
• Fibonacci Recurrence in 1 dimension
• Graphs and Adjacency Matrix Recurrence
• Bounding the entropy constant
<
>
≪
≫

i
?
P
Overview
2/44
• Fibonacci Recurrence in 1 dimension
• Graphs and Adjacency Matrix Recurrence
• Bounding the entropy constant
<
• Fast Algorithms to develop An
>
≪
≫

i
?
P
Overview
2/44
• Fibonacci Recurrence in 1 dimension
• Graphs and Adjacency Matrix Recurrence
• Bounding the entropy constant
<
• Fast Algorithms to develop An
>
≪
• Computational successes and boundaries
≫

i
?
P
Introduction
3/44
The King’s Problem is easily stated: How many ways can you place an arbitrary
number of non-attacking kings on a chessboard of desired dimension? Movement of
the King: In chess, a king attacks one square in every direction.
<
>
≪
≫

Figure 1: Legal moves of the King
i
?
P
The 1-dimensional problem
4/44
In 1 dimension, the chessboard is reduced to one row/column of squares. Let F(1,m)
denote the number of configurations of Kings on a row of squares of length m.
Figure 2: F(1,1) and F(1,2)
<
>
≪
≫

i
?
P
The 1-dimensional problem
4/44
In 1 dimension, the chessboard is reduced to one row/column of squares. Let F(1,m)
denote the number of configurations of Kings on a row of squares of length m.
Figure 2: F(1,1) and F(1,2)
<
>
F (1, 0) = 1
≪
≫

i
?
P
The 1-dimensional problem
4/44
In 1 dimension, the chessboard is reduced to one row/column of squares. Let F(1,m)
denote the number of configurations of Kings on a row of squares of length m.
Figure 2: F(1,1) and F(1,2)
<
>
F (1, 0) = 1
≪
F (1, 1) = 2
≫

i
?
P
The 1-dimensional problem
4/44
In 1 dimension, the chessboard is reduced to one row/column of squares. Let F(1,m)
denote the number of configurations of Kings on a row of squares of length m.
Figure 2: F(1,1) and F(1,2)
<
>
F (1, 0) = 1
≪
F (1, 1) = 2
≫
F (1, 2) = 3

i
?
P
The 1-dimensional problem
4/44
In 1 dimension, the chessboard is reduced to one row/column of squares. Let F(1,m)
denote the number of configurations of Kings on a row of squares of length m.
Figure 2: F(1,1) and F(1,2)
<
>
F (1, 0) = 1
≪
F (1, 1) = 2
≫
F (1, 2) = 3
F (1, m) = F (1, m − 2) + F (1, m − 1).
Proof: Consider two boards of length m. Place a king in the first square on one
board and do not place a king in the first square on the second board.

i
?
P
Illustrated proof
5/44
<
>
≪
≫
Figure 3: F (1, m) = F (1, m − 2) + F (1, m − 1)
The sequence is clearly the list of fibonacci numbers, appropriately indexed. We will
denote the mth fibonacci number indexed this way as Fm .

i
?
P
Graphs and Matrices for a 2-dimensional board
6/44
We used the adjacency/transfer matrix approach to count configurations on a two
dimensional board.
The method is as follows:
<
>
≪
≫

i
?
P
Graphs and Matrices for a 2-dimensional board
6/44
We used the adjacency/transfer matrix approach to count configurations on a two
dimensional board.
The method is as follows:
• We begin with 1-dimensional slices of length m. There will be Fm slices, each
representing a legal configuration.
<
>
≪
≫

i
?
P
Graphs and Matrices for a 2-dimensional board
6/44
We used the adjacency/transfer matrix approach to count configurations on a two
dimensional board.
The method is as follows:
• We begin with 1-dimensional slices of length m. There will be Fm slices, each
representing a legal configuration.
• We then label a vertex of a graph to represent each slice.
<
>
≪
≫

i
?
P
Graphs and Matrices for a 2-dimensional board
6/44
We used the adjacency/transfer matrix approach to count configurations on a two
dimensional board.
The method is as follows:
• We begin with 1-dimensional slices of length m. There will be Fm slices, each
representing a legal configuration.
• We then label a vertex of a graph to represent each slice.
<
• If two slices can be placed next to each other in a legal configuration, we put
an edge between those vertices.
>
≪
≫

i
?
P
An example
7/44
<
>
≪
≫
Figure 4: Graph for the 3 x 2 board

i
?
P
Adjacency Matrices
8/44
We can represent these graphs using adjacency matrices, locating a 1 wherever there
is an edge between vertices and zeros otherwise. We will denote the adjacency matrix
for an n x k board as An .
<
>
≪
≫

i
?
P
Adjacency Matrices
8/44
We can represent these graphs using adjacency matrices, locating a 1 wherever there
is an edge between vertices and zeros otherwise. We will denote the adjacency matrix
for an n x k board as An .
Summing the entries in An will yield the number of walks of between two vertices
- counting the number of ways to place one slice on top of another in a legal configuration. We know from graph theory, that summing the entries of Am
n will count
the number of walks between m+1 vertices - corresponding to the number of legal
configurations on an n x (m+1) board.
<
>
≪
≫
F (n, m) = 1T Am−1
1
n

i
?
P
Recursive numbering of slices
9/44
When the slices of the board are numbered cleverly, a matrix recursion develops.
Consider the following sets of slices:
<
>
≪
≫

i
?
P
The Entropy Constant η
10/44
Definition 1.
η=
lim f (n, m)1/nm
m,n→∞
The purpose of our research is to develop and improve bounds for this entropy
constant. We are able to do so by examining the dominant eigenvalues of the
matrices An .
Let λn,1 , λn,2 , . . . , λn,n be the eigenvalues of An with |λn,1 | > |λn,2 | ≥ . . . |λn,n |.
<
>
≪
Let v n,i be the eigenvector corresponding to λn,i
≫

i
?
P
Dominant Eigenvalues of An
Fact. The following equation comes from Perron and Frobenius in their work on
Matrix algebra.
f (n, m) =
X
ci λm
n,i
where ci =
i
11/44
1T v n,i v Tn,i 1
v Tn,i v n,i
λ
n,2 m
From here we can say that f (n, m) = Cλm
n,1 (1 + O(Fn ( λn,1 ) ))
<
>
≪
As m → ∞, the big O term on the right tends to zero leaving us that
≫
f (m, n) ∼ Cλm
n,1

i
?
P
Dominant Eigenvalues of An
12/44
If f (m, n) ∼ Cλm
n,1 Then
f (n,m)
Cλm
n,1
→ 1 as m → ∞.
Raising this limit to the power of
1
m,
we have the following result:
Theorem 1.
lim f (n, m)1/m = λn,1 .
m→∞
<
From this point forward, we will refer to the largest eigenvalue of An as λn and its
corresponding eigenvector as v n .
>
≪
≫

i
?
P
Bounding η
13/44
Consider the following boards:
<
>
≪
k
F (n, mk) < F (n, m) < F (n, km + (k − 1)) < F (n, m(k + 1))
≫

i
?
P
Bounding η
Fact.
14/44
F (m, nk) < f (m, n)k < f (m, k(n + 1))
From these inequalities, we are able to produce our first bounds on η.
Corollary 2.
η is bounded from above by λ1/n
n
Proof.
f (m, nk) < f (m, n)k
<
>
f (m, nk)1/k < f (m, n)
1/km
lim f (m, nk)
m,k→∞
≤
≪
1/m
lim f (m, n)
≫
m→∞
η n ≤ λn
η ≤ λ1/n
n

i
?
P
Bounding η
Similarly, with the right side of the inequality, we have another result.
15/44
Corollary 3.
η is bounded from below by λ1/n+1
n
Proof.
f (m, n)k < f (m, k(n + 1))
f (m, n)1/m(n+1) < f (m, k(n + 1))1/mk(n+1)
1/m(n+1)
lim f (m, n)
m,k→∞
≤
<
1/mk(n+1)
lim f (m, k(n + 1))
>
m,k→∞
≪
λ1/n+1
≤ η
n
≫

i
?
P
Better Lower Bounds
16/44
Lemma 4.
f (n, m) = f (m, n)
1T Am−1
1 = 1T An−1
n
m 1
Recall the Perron-Frobenius Maximum Principle: For any matrix A that is nonnegative, symmetric, and irreducible, the largest eigenvalue of A is greater than or
T
equal to xxTAx
for any nonzero vector x. The maximum principle provides tighter
x
bounds when x is close to the eigenvector associated with the largest eigenvalue.
<
>
q
Since Aqn 1 is closer to the dominant eigenvector than Aq−1
n 1, we will set x = An 1
≪
≫

i
?
P
So we have that
T
λpn ≥
λpn ≥
λpn ≥
lim λp/n
m,n→∞ n
≥
Aqn 1 Apn Aqn 1
T
Aqn Aqn
17/44
1T Ap+2q
1
n
A2q
n
1T An−1
p+2q+1 1
An−1
2q+1
lim
m,n→∞
1
T
An−1
p+2q+1 1
An−1
2q+1
!1/n
<
λp+2q+1
η ≥
λ2q+1
1/p
λp+2q+1
η ≥
λ2q+1
p
>
≪
≫

i
?
P
So we have that
T
λpn ≥
λpn ≥
λpn ≥
lim λp/n
m,n→∞ n
≥
Aqn 1 Apn Aqn 1
T
Aqn Aqn
17/44
1T Ap+2q
1
n
A2q
n
1T An−1
p+2q+1 1
An−1
2q+1
lim
m,n→∞
1
T
An−1
p+2q+1 1
An−1
2q+1
!1/n
<
λp+2q+1
η ≥
λ2q+1
1/p
λp+2q+1
η ≥
λ2q+1
p
Theorem 5. We are left with a much tighter lower bound.
λp+2q+1 1/p
η≥
λ2q+1
>
≪
≫

i
?
P
Soon to be proven
18/44
From all of the gathered information, it appears to be true that a similar convergence
is happening from above η.
Conjecture 1.
η≤
λ2q+1
λ2q
This idea is evident in extensive calculations, but has proven very difficult to
tackle.
<
>
≪
≫

i
?
P
Calculating λn
For small n, we can use various mathematical utilities.
19/44
For larger values of n, we use the power method.
<
>
≪
≫

i
?
P
The Power Method
To use the power method we need a matrix A with k eigenvalues, λi , such that:
20/44
|λ1 | > |λ2 | ≥ |λ3 | ≥ |λ4 | . . . ≥ |λk |
Thanks to the Perron-Frobenius Theorem, we know that all our An have this eigenstructure, so we’ll continue.
<
>
≪
≫

i
?
P
The Power Method (cont.)
21/44
Define:




X0 = 



1
1
..
.
1








Then generate the sequence {Xk } recursively using:
<
Yk = AXk
Xk+1 =
1
ck+1
>
≪
Yk
≫

i
?
P
The Power Method (cont.)
Two very nice things occur as a result of this:
22/44
lim ck = λ1
k→∞
lim Xk = v1
k→∞
Where v1 is the eigenvector associated with λ1 .
<
>
≪
≫

i
?
P
The Power Method (conclusion)
Using the power method we can calculate λn up to about n = 22. We are hampered
by the fact that the dimension of An is increasing exponentially.
23/44
For example, A22 is a 46368 × 46368 matrix with 2,149,991,424 entries. If each
entry requires 1 byte of memory we need approximately 2 gigabytes of memory.
<
>
≪
≫

i
?
P
Calculating Matrix Entries On The Fly
24/44
<
>
≪
≫

Figure 5: A12
i
?
P
On The Fly (cont.)
Define a function a(i, j, n) = aij of An
25/44
It is obvious from symmetry that a(i, j, n) = a(j, i, n).
It is also obvious that a(i, j, n) = 0 when i + j > Dim(An )
Since the dimensions of these matrices are used often it us useful to define a function
D(n) = Dim(An ). Note that the dimensions of the matrices are Fibonacci numbers
so it is an easy thing to compute the values of D(n) once and store them in memory
for the purposes of our program.
<
>
≪
≫

i
?
P
On The Fly (cont.)
26/44
<
>
≪
≫

Figure 6: A12 in terms of smaller matrices
i
?
P
On The Fly (cont.)
Assume i < j, then:
27/44

 a(i, j, n − 1)
for j < D(n − 1)
a(i, j, n) =
 a(i, j − D(n − 1), n − 2) for j ≥ D(n − 1)
<
>
≪
≫

i
?
P
On The Fly (cont.)
If we define a reference matrix R = Aref Index we have everything we need to write
a recursive algorithm.
28/44
int getEntry(int i, int j, int n) {
if (i + j > D[n]) return 0;
if (i > j) return getEntry(j, i, n);
if (j < D[RefIndex]) return R[i][j];
if (j < D[n - 1]) return getEntry(i, j, n-1);
return getEntry(i, j - D[n - 1], n - 2);
<
>
≪
≫
}

i
?
P
On The Fly (conclusion)
Using the on the fly algorithm in conjunction with the power method has allowed us
to calculate λn for n as large as 27. Memory space is no longer an issue, but that
gain was at the expense of the amount of time the calculation takes.
29/44
For example, λ27 = 3264.2736 . . . was calculated in just under 201 hours.
<
>
≪
≫

i
?
P
Frankenvectors and Amateur Numerology
Recall one of the first steps in the power method:




X0 = 



1
1
..
.
1
30/44








<
Choosing an initial vector for the power method that more closely resembles vn would
be equivalent to starting the power method somewhere in the middle.
>
≪
≫

i
?
P
Frankenvectors (cont.)
31/44
1
0.9
0.8
0.7
0.6
0.5
0.4
<
0.3
>
0.2
≪
0.1
≫
0
0
10
20
30
40
50
60
70
80
90

Figure 7: v9
i
?
P
Frankenvectors (cont.)
32/44
1
0.9
0.8
0.7
0.6
0.5
0.4
<
0.3
>
0.2
≪
0.1
≫
0
0
50
100
150

Figure 8: v10
i
?
P
Frankenvectors (cont.)
33/44
1
0.9
0.8
0.7
0.6
0.5
0.4
<
0.3
>
0.2
≪
0.1
≫
0
0
50
100
150
200
250

Figure 9: v11
i
?
P
Frankenvectors (cont.)
34/44
1
0.9
0.8
0.7
0.6
0.5
0.4
<
0.3
>
0.2
≪
0.1
≫
0
0
50
100
150
200
250

Figure 10: v11 and F rank11
i
?
P
Frankenvectors (cont.)
35/44
−3
15
x 10
10
5
<
>
0
≪
≫
−5
0
50
100
150
200
250

Figure 11: Error
i
?
P
Amateur Numerology (cont.)
36/44
1
actual
first
second
third
fourth
0.9
0.8
0.7
0.6
0.5
0.4
<
0.3
>
0.2
≪
0.1
≫
0
0
10
20
30
40
50
60

Figure 12: The first four iterations on v8
i
?
P
Frankenvectors and Amateur Numerology (conclusion)
37/44
Use of a carefully chosen frankenvector and a little amateur numerology reduces the
number of iterations of the power method by ≈ 40%, and since there is very little
overhead involved in these methods, the amount of time a given calculation takes is
reduced as well.
<
>
≪
≫

i
?
P
Compressed Matrices
Since the matrices in this problem are so sparse and all entries are either zero or one,
there are ways to store the data in them that are much more efficient.
38/44
One way to do this is to compress each row of the matrix into a list of indexes of
columns which contain a one.
<
>
≪
≫

i
?
P
Compressed Matrices
For example the code to store A3 can be changed from this:
int[][] a3 =
{1, 1, 1, 1,
{1, 0, 0, 1,
{1, 0, 0, 0,
{1, 1, 0, 0,
{1, 0, 0, 0,
39/44
{
1},
0},
0},
0},
0}};
<
To this:
int[][] a3 = {
{0, 1, 2, 3, 4},
{0, 3},
{0},
{0, 1},
{0}};
>
≪
≫

i
?
P
Compressed Matrices (cont.)
These compressed matrices are still recurrent.
40/44
<
>
≪
≫

Figure 13: A12 divided into recurrence classes
i
?
P
Compressed Matrices (cont.)
Define a function Row(i, n) that returns the list of
An . Then:



Row(i, n − 1) ⊕ (Row(i, n − 2))


Row(i, n) =
Row(i, n − 1)



 Row(i − D(n − 1), n − 2)
indexes of ones in the ith row of
41/44
for i < D(n − 2)
for D(n − 2) ≤ i < D(n − 1)
for i ≥ D(n − 1)
<
>
≪
≫

i
?
P
Compressed Matrices (conclusion)
Using compressed matrices is a boon to our work in many ways.
42/44
• We can store a much larger reference matrix in memory. (A26 )
• Due to recurrence we can generate rows on the fly for matrices larger than our
reference matrix.
• Calculations go much faster. (λ27 was computed in 3 hours)
<
>
≪
≫

i
?
P
Conclusion
As a result of our calculations the best (semi-proven) bounds for η are:
43/44
λ28
λ27
≈ 1.342643944 . . . < η < 1.342643963 . . . ≈
λ27
λ26
<
>
≪
≫

i
?
P