Fiveleapers a-leaping - INFORMS PubsOnline

2 downloads 0 Views 223KB Size Report
The problem of finding knight's tours on a chessboard ... zi variables for sub-tour breaking constraints .... Marlow, T.W. and Jelliss G.P. (2002), Knight's Tour.
CHLOND & DANIEL & HEIPCKE Fiveleapers a-leaping

Fiveleapers a-leaping Martin J.Chlond Lancashire Business School University Of Central Lancashire [email protected]

Robert C. Daniel Dash Optimization Blisworth House [email protected]

Susanne Heipcke Dash Optimization Blisworth House [email protected]

Editor's note: This is a pdf copy of an html document which resides at http://ite.pubs.informs.org/Vol4No1/ ChlondDanielHeipcke/ The problem of finding knight's tours on a chessboard is well documented in the literature of Recreational Mathematics and is also known in ORMS circles as an instance of the Traveling Salesperson Problem (TSP). A similar but much lesser known puzzle taken from the whimsical world of Fairy Chess is that of identifying fiveleaper tours. A knight move may be described as having coordinates {1,2} meaning in a single move it travels one square in a particular direction and two squares in an orthogonal direction. Using this notation the legal moves for a fiveleaper have coordinates {0,5} or {3,4}. In either event the Euclidean distance traveled is five squares.

We begin the formulation for a closed tour by defining s as the number of squares per side of a square board and n=s2 as the number of squares on the board. Also N = 1, ..., n.

A brief introduction to fiveleapers is at Math Puzzle(1) and further background together with an impressive array of results is at Fiveleaper Tours(2).

tour, 0 otherwise

A tour requires that the fiveleaper visits every square on a board once and once only using legal moves. The fiveleaper tours come in two varieties, that is, open and closed tours. In an open tour there is no restriction on where the tour begins and ends. In a closed tour the start and finish squares must be separated by a legal move and the fiveleaper could close the tour by making this final move.

The objective is merely to fulfil the conditions of the tour so any arbitrary objective function may be chosen. It is useful to select a simple expression in order to avoid unnecessay computations. The complete formulation for the closed tour is as follows.

Aij = 1 if square i to square j is a legal move, 0 otherwise An Xpress-Mosel code fragment to generate this table of legal moves is here(3) Decision variables required are xij = 1 if move from square i to square j forms part of

zi variables for sub-tour breaking constraints

Minimize: x11 s.t.

(1) (2) (3)

http://www.mathpuzzle.com/26Mar03.html http://www.ktn.freeuk.com/9f.htm http://ite.pubs.informs.org/Vol4No1/ChlondDanielHeipcke/legal.php

INFORMS Transcations on Education 4:1 (78-82)

78

© INFORMS ISSN: 1532-0545

CHLOND & DANIEL & HEIPCKE Fiveleapers a-leaping

Each square is preceded by one other

Legal moves only Each square precedes one other Total moves required Legal moves only Exclude tourlets Exclude tourlets Finally Finally and and complete the formulation complete the formulation

Mosel code to implement the open tour model is here(5).

Mosel code to implement the closed tour model is here(4).

An interesting property of the 8x8 board is that a fiveleaper on any square has exactly four legal moves available. This was first noted by G.P.Jellis who realised that, as a consequence, any closed tour would involve two unused moves at every square and wondered whether a second closed tour could be identified linking these unused moves. The question was answered by Tom Marlow in 1991 and his solution is presented at Math Puzzle(6). The closed tour formulation may be easily modified to identify such a dual tour by defining variables yij and wi for the second tour which are equivalent to xij and zi. The precedence and subtour-breaking constraints for the second tour are added to the model and the constraints ensuring only legal moves are replaced by

The open tour requires identical variable definitions and a couple of modifications to the above giving the following model: Minimize: x11 s.t. Each square is preceded by no more than one other

Each square precedes no more than one other

(4) (5) (6)

http://ite.pubs.informs.org/Vol4No1/ChlondDanielHeipcke/leaper8c.php http://ite.pubs.informs.org/Vol4No1/ChlondDanielHeipcke/leaper8o.php http://www.mathpuzzle.com/26Mar03.html

INFORMS Transcations on Education 4:1 (78-82)

79

© INFORMS ISSN: 1532-0545

CHLOND & DANIEL & HEIPCKE Fiveleapers a-leaping

2. initially stating only a subset of the constraints and adding iteratively those that are violated of the remaining ones until a solution is found

Mosel code to implement the dual tour model is here.(7)

We shall first take a look at the variables: on an 8x8 board there are four permissible moves per square but for every square i we have defined variables xij for

Larger board sizes, rectangular boards The model implementations referred to above for a standard chessboard (s=8) can be solved within seconds or at most a few minutes on a PC. There are no solutions to the fiveleaper tour problem for smaller boards, but we may well try to solve it for larger ones. Unfortunately, with increasing board sizes, the models described above quickly grow too large to be solvable within a reasonable amount of time (see the table with an overview of solution times below). However, it is possible to reformulate these models reducing them to a more managable size by

moving to all 64 squares of the board, that means, 16 times more than we need. Most of these variables get immediately fixed to 0 by the value of Aij . We now only define those variables that represent permissible moves as shown in this Mosel code(8) fragment. This formulation also has the advantage that much less terms are summed up in the predecessor and successor constraints. A visualisation of the spasity pattern of the permissible moves matrix is below (Mosel code(9) to produce this graphical output).

1. removing unnecessary variables

We now state the model as follows:

Each square precedes one other

minimise sum(i,j in N | move i->j is permissible ) x_{i,j}

forall(i in N): sum(j in N | move i->j is permissible ) x_{i,j} = 1

(7) (8) (9)

http://ite.pubs.informs.org/Vol4No1/ChlondDanielHeipcke/leaperd.php http://ite.pubs.informs.org/Vol4No1/ChlondDanielHeipcke/dynvar.php http://ite.pubs.informs.org/Vol4No1/ChlondDanielHeipcke/matrixA.php

INFORMS Transcations on Education 4:1 (78-82)

80

© INFORMS ISSN: 1532-0545

CHLOND & DANIEL & HEIPCKE Fiveleapers a-leaping

Each cell is preceded by one other



forall(j in N): sum(i in N | move i->j is permissible ) x_{i,j} = 1 forall(i,j in N | move i->j is permissible ): x_{i,j} in {0,1} The objective function in this model is the sum of all variables (x11 is not a permissible move and hence not

°

defined). Another possibility would be to use simply the value 0.

if problem is feasible:



call procedure 'break_subtour': °

construct the tour starting at square 1

°

if this tour is not the complete tour: *

add a subtour breaking constraint for this subtour

*

add all squares of this tour to the set of visited squares

*

for all squares not yet visited: •

construct the subtour starting at this square



add a subtour breaking constraint for this subtour

*

iteratively call 'break_subtour'

again

procedure

else: a solution is found

where size(T) denotes the number of squares forming the tour T.

implement the following subtour breaking algorithm:



re-solve the problem

sum(i,j in N | move i->j in T) x_{i,j}

Suggest Documents