Omega 35 (2007) 541 – 552 www.elsevier.com/locate/omega

QAP—not so hard in spreadsheets

Rasmus Rasmussen

Molde University College, P.O. Box 2110, 6402 Molde, Norway

Received 13 January 2005; accepted 12 October 2005

Available online 28 November 2005

Processed by B. Lev

Abstract

Quadratic assignment problems (QAP) are rarely mentioned in introductory textbooks in management science and other relevant areas. Even in advanced textbooks, only very small examples are used, because of the complexity of the cost function.

This article shows that alternative formulations of the cost function reduce the complexity. The cost function is still quadratic and the variables are still integers (binary variables), so the computational difficulties are the same as with the traditional approach.

But new solvers for spreadsheets seem to be quite efficient using the matrix representation of the cost function. This approach turns out to be very simple to implement in spreadsheets. Another formulation directly representing the permutation by integers is even easier to implement, and has shown very promising results using heuristic solvers. In fact spreadsheet solvers could very well be the preferred software solving QAP, compared to other general purpose optimization software.

2005 Elsevier Ltd. All rights reserved.

Keywords: Quadratic programming; Assignment; Distribution; Spreadsheets; Education

1. Introduction 2. A facility location problem

Quadratic assignment problems (QAP) are easy to describe, not so easy to formulate, and very hard to solve. The examples in the literature are all very small in size for obvious reasons, i.e., large problems become extremely difficult to solve to optimality. Most of the examples in this text are taken from [1,2] . First, two small examples are used to introduce alternative implementations in spreadsheets, demonstrating that different formulations require different solvers. Second, a larger test problem is used to test alternative spreadsheet solver engines, and compares them to several solvers available at NEOS. Finally, the solvers are tested against selected problem instances from QAPLIB.

A layout planning problem, formulated as a QAP problem is described as follows: four university facilities 1–4 are to be located in four existing areas

(For practical reasons I have “reversed” the use of letters and numbers for the facilities and areas, compared to how they are defined in

3. scientific staff;

4. computer and library.

[1]

1. administrative personnel;

.) The facilities are:

2. canteen and recreational facilities; a – d

Tel.: +47 71 21 42 42; fax: +47 71 21 41 00.

E-mail address: Rasmus.Rasmussen@hiMolde.no

.

0305-0483/$ - see front matter

2005 Elsevier Ltd. All rights reserved.

doi:10.1016/j.omega.2005.10.002

The interaction among the facilities is described with a connection matrix B

= { b ij metric matrix). Thus b

23

= b

}

32 where b ij

= b j i

(symrepresents the aspects of “connection” between the staff and canteen (coffee breaks, lunch, etc.) The diagonal is undefined but can

.

542 be set to zero. It represents the connections within a facility and is supposed to be unrelated to the location of the facility. Each facility is both a “facility” performing services; and also a “client”, receiving services.

1

1

2

7

3

8

4

4

2

3

4

7

8

4

7

0

7 0

5

5

−⎟⎠

⎟⎟ =

B

The four existing equally sized areas for housing the facilities are located as follows: a b c d

R. Rasmussen / Omega 35 (2007) 541 – 552

The (rectangular) distances between each pair of areas is defined in the symmetric distance matrix A

={ a c d a b a b c d

0 1 2 4

1 0 1 3

2 1 0 2

4 3 2 0

⎟⎠

⎟⎟

=

A

3. A simple spreadsheet for assignments ij

}

Assuming that each area can only house exactly one of the four facilities, the problem then is to assign each facility to one area in an optimal manner.

If facilities 3 and 4 are assigned to areas b and d , respectively, then the resulting “cost” would be b

34

· a bd

. This “cost” of 5 · 3 = 15 represents the distance of 3 performed 5 times. With all 4 facilities placed, the total cost will be the sum of

4

2

=

6 such individual contributions. There exist a total of 4

! =

24 different layouts for this example.

In general, a problem with n different facilities has n

!

possible layouts, and the cost function will be the sum of n

2 elements if the square matrixes of distances and interactions are symmetric (assuming the diagonal of the distance matrix is 0). If the distances and/or the interactions are non-symmetric, the complete cost matrix will consist of n

2 individual contributions.

In the spreadsheet ( Fig. 1 ) the symmetric matrix of

distances is named A. The matrix of interactions (named

B) also includes the indexes in spreadsheet row 9. The

.

actual allocation (named F in the spreadsheet) is to assign a facility to each area. In

Fig. 1

facilities 2 , 1 , 3 and 4 have been assigned to the areas a, b, c and d , respectively.

We then have to compute the 6 corresponding cost elements. This is done in the cost matrix for the entries below (or above) the diagonal. The total cost is simply the sum of the cost matrix.

Finding the optimum solution then requires to systematically testing all the 24 different layouts, keeping track of the layout and the corresponding cost. Instead of manually performing a complete enumeration,

Solver

1

in Excel can be used. The Solver settings would be:

Minimize $L$6 (Total costs)

By changing F ($I$3:$I$6)

Subject to F = alldifferent

Such a formulation however has a non-smooth objective function (due to the INDEX and HLOOKUP functions calculating the cost), with 4 integer variables with values between 1 and 4 (generally n) , all with a different value. This formulation therefore requires the Evolutionary Solver Engine, or alternatively the

OptQuest add-in solver. (The other spreadsheet solvers rely on derivatives, and therefore require smooth functions.) Optimization tools like this are heuristics, as they find good solutions quickly, but cannot prove optimality.

In this example the Evolutionary Solver finds the optimum solution almost instantly (arbitrary starting with the infeasible allocation 1 , 1 , 1 , 1), but spends considerable time (several minutes) before it settles with the message “ Solver cannot improve the current solution.

All constraints are satisfied .” Of course, when the user sees that the solution does no longer improve, he can stop Solver by pressing Esc.

A limitation of this type of formulation is that the number of facilities m and the number of areas n has to be equal i.e., m

= n . Otherwise we cannot use the all different constraint. This limitation can easily be overcome by adding dummy facilities with no interactions in cases where m < n . If m > n the problem is infeasible, unless the areas can house more than one facility.

If so, we no longer can use the approach in

Fig. 1 .

For non-symmetric data, the complete cost matrix must be computed. This is in fact simplifying the spreadsheet, since the cost formula is copied to the whole cost matrix in just one copy operation, instead of carefully selecting where to copy. This simplification can

1

Developed by Frontline Systems; http://www.Solver.com

.

R. Rasmussen / Omega 35 (2007) 541 – 552 543

Fig. 1. Assignment of 4 facilities to 4 areas.

also be done for symmetric data. Just keep in mind that the actual cost is half of what has been computed.

Non-symmetric data occur rarely, but typewriting is an example: the sequence of the letters “ab” may not occur with the same average frequency as the opposite sequence “ba”.

4. A quadratic formulation

In the general case, we have the symmetric matrix

B [ m

× m

] of interactions between facilities i and j , with a total of m facilities. And as before we have the symmetric matrix A [ n

× n

] of distances between areas k and l , with a total of n areas.

Let i, j

∈ { 1 , . . . , m

} be indexes for the facilities, and k, l

∈ {

1 , . . . , n

} be indexes for the areas. Finally, define the matrix of decision variables if facility i is located in area k

U [ m

; otherwise

× u n

] ik as u

=

0.

ik

=

1

If a pair

{ i, j

} of facilities are assigned to areas

{ k, l

}

, respectively, the frequency of interaction between i and j is b ij

, and the distance between the facilities is a kl

Thus, the cost of interaction between the facilities i and

.

j , if they are located in areas k and l , will be b

This will only occur if product u ik u j l u ik

=

1 and u j l ij a kl

=

1, i.e., if the

=

1. The total cost to be minimized can

.

therefore be written as min S

= m m n n i

=

1 j

=

1 k

=

1 l

=

1 b ij a kl u ik u j l

.

(1)

The product u ik u j l makes this a quadratic function. The computational difficulties regarding optimality are made complex by the fact that the variables are binary variables. The quadratic assignment problem is a genuine integer programming problem, and often very difficult to solve.

This standard representation of the QAP will however double count the cost if the data are symmetric (it will include the costs both above and below the diagonal in the cost matrix). Unless the data are asymmetric the cost function in Eq. (1) either has to restrict the summation to only include k > l , or be divided by 2.

The constraints in a standard quadratic assignment model are fairly simple. Each facility must be assigned to exactly one area, represented by n k

= 1 u ik

= 1 , i

= 1 , 2 , . . . , m .

(2)

At the same time each area can accommodate at most one facility: m i

=

1 u ik

1 , k

=

1 , 2 , . . . , n .

(3)

For this problem to be feasible, we must have m n .

5. A simpler cost function

The computation of the costs as described in Eq. (1) can be a bit “tricky” in spreadsheets. However, there is a simpler way of representing the total cost S

:

min S

= tr

[

B

·

U

] · [

U

·

A

] T

2

.

(4a)

2

2

Thanks to my colleague Halvard Arntzen who helped me with this transformation. See also

[4]

for other examples.

544 R. Rasmussen / Omega 35 (2007) 541 – 552

Here

[

B

·

U

] is the matrix produced by multiplication of the matrixes B and U , and

[

U

·

A

] T is the transposed matrix of the multiplication of the matrixes U and A .

The matrixes [

B

·

U

] and [

U

·

A

] T are then multiplied, and the trace (sum of the elements in the diagonal) of the resulting matrix is computed. This matrix is an m

× m matrix, so the sum S will consist of m elements. To correct for double counting the costs in Eq. (1) this sum is divided by 2. (If the data are asymmetric we must not divide by 2.)

Spreadsheets are in essence a “free form” formulation tool. Therefore, it is sometimes convenient to represent the matrix U [ m

× n

] as U

2

[ n

× m

] , where U

2

=

U

T

. In that case the formula should be written as min S

= tr

[

A

·

U

2

] T · [

U

2

·

B

]

2

.

(4b)

This sum will be of dimension m too.

If we have two matrixes D [ n

× m

] and E [ m

× n

] then

{

D

·

E

}

[ n

× n

]

, so the trace will be of dimension n .

However, if we reverse the sequence of multiplication to be

{

E

·

D

}

[ m

× m

]

, this trace will be of dimension m .

Fortunately, tr

{

D

·

E

} = tr

{

E

·

D

}

. Therefore, we can also write the cost function as min S

= tr

[

U

·

A

] T · [

B

·

U

]

2

.

(4c)

This sum will be of dimension n , which also will be the case for the following version: min S

= tr [

U

2

·

B

] · [

A

·

U

2

] T

2

.

(4d)

One of these 4 alternative cost representations should fit the preferred layout of the spreadsheet.

Because Excel

4

does not have a built in function to compute the trace of a matrix, a dummy identity matrix of proper dimension is manually entered, defined as T in the spreadsheet. A SUMPRODUCT function is then used to compute the trace, by referring to the matrix we want to compute the trace of, and the dummy matrix T .

A somewhat different example, problem 12 .

10 from

[2] , describes a case of decentralization. Five depart-

ments (a, b, c, d, e) are considered moved out of London, which will save costs. No city (including London) can be the location of more than three of the departments. The benefits of moving to Bristol or Brighton are computed as shown in

Table 1 .

There will however be costs associated with the relocating of departments, since there is some communi-

cation between the departments ( Table 2 ).

Let A [

3 , 3

] be the symmetric matrix of distances. In this case there are costs of communications between the cities, as indicated by

Table 3 . (Observe that there

are also costs associated with communications within a city.) And as before, let B [

5 , 5

] be the symmetric matrix of interactions, as indicated by

Table 2 . In addition,

we define the matrix D [

3 , 5

] to be the benefits from decentralization as indicated by

Table 1 . (The third row,

benefits from staying in London, is set to 0.) Finally, we define U [

3 , 5

] to be the binary matrix where u ki

=

1 implies that department i is moved to city k .

The decentralization problem can then be formulated as (using version 4d):

Max

S. to.

3 k

=

1

3

5 i

=

1 d ki u ki

− tr

[

U

·

B

] · [

A

·

U

] T

2 k

=

1 u ki

=

1 , i

=

1 , 2 , ..., 5.

(5)

(6)

6. QAP made simple in spreadsheets

The spreadsheet in belled zero

3

F in

Fig. 1

Fig. 2

is using the binary representation of a QAP, where we have replaced the assignment represented by the all different integers laby the binary matrix engine. When starting with a null U

U . The quadratic cost function from Eq. (4a) is implemented, and we therefore can use the Standard LP/Quadratic Solver matrix (all entries

) this solver instantly reports: “

Solver found a solution. All constraints and optimality conditions are satisfied ”.

5 i

=

1 u ki

3 , k

=

1 , 2 , 3 (7)

Eq. (6) assures that each department is located somewhere; and Eq. (7) restricts at most 3 departments in a city.

This time the matrix U was left empty as a starting point, and the Standard LP/Quadratic Solver engine once again finds the optimum solution instantly (Fig.

3 ).

3

The MMULT function in Excel returns an #VALUE! error if any cells are empty. Numbers have to be entered in all cells represented by U .

4

Note that array functions in Excel has to be entered pressing

CTRL/Shift/Enter simultaneously. This will insert the parentheses

{=

. . .

} automatically, and they must not be entered manually.

R. Rasmussen / Omega 35 (2007) 541 – 552 545

Fig. 2. QAP of 4 facilities to 4 areas.

Table 1

Benefits of decentralization a b

Bristol

Brighton

10

10

15

20 c d a b

Table 2

Quantities of communication a b

0,0 c

1,0

1,4 c

10

15

Table 3

Cost per unit of communication

Bristol

5 Bristol

Brighton

London

Brighton

14

5 d

1,5

1,2

0,0 d

20

15

London

13

9

10 e

0,0

0,0

2,0

0,7 e

5

15

25 areas (with a capacity of 1) was made in

Fig. 4 ,

using randomly generated integer numbers between 0 and 99. This time the Standard LP/Quadratic Solver engine takes more than an hour to solve the problem, and the solution cannot be the global optimum solution, as we shall see in the next few paragraphs, in spite of the message: “ Solver found a solution. All constraints and optimality conditions are satisfied ”. The solution found has an objective function value of

39 215.

5

However, there are several installable Solver engines which are more suitable for large quadratic problems with integer variables.

6

The Large-Scale SQP Solver stopped after just a few minutes with the message:

“ Solver has converged to the current solution. All constraints are satisfied ”. and the objective function of

− 38 972.

A rerun (starting with U empty) using other Solver options resulted in the diagnosis “ Solver found an integer solution within tolerance. All constraints are satisfied .”, and the objective function value of

38 583.

Continuing from this solution resulted in “ Solver has converged to the current solution. All constraints are

7. A larger test example

To test this approach on larger problems, an escalation of the previous example to m

= 20 facilities and n

=

5

This is a maximization problem where costs (entered as positive numbers) exceed benefits. All examples at QAPLIB are minimization problems, with positive objective function values for all feasible solutions.

6

The Premium Solver Platform V5.5 was initially used in this article. This allows for installable Solver engines.

546 R. Rasmussen / Omega 35 (2007) 541 – 552

Fig. 3. Decentralization.

satisfied ”. without any change in the objective function value.

For this maximization problem, the best value of the objective function found using the Large-scale SQP

Solver is

38 342, by altering solver options and initial values (Fig.

5 ). A general characteristic of QAP is

that the relative difference between the worst and the best value of the objective function becomes arbitrary small with a probability that tends to 1 as the size of the problem tends to infinity, see

[1, Section 9.8] . The

minimum solution appears to be around

61 598, indicating that the problem size has to be quite large before the situation predicted by

[1]

manifests itself.

8. A comparison of optimization solvers

One of the other Solver engines available for the Premium Solver Platform in Excel, XPRESS from Dash

Associates was also tested. This solver failed on all problems ( Figs. 2–4) , for various reasons. The problem in

Fig. 2

returned “Global search incomplete—no integer solution was found”.

Fig. 3

gave the error “The Set

Cell value does not converge”. The problem in

Fig. 4

resulted in the error “The linearity conditions required by this Solver engine are not satisfied” even though the option Assume Quadratic Objective was selected. However, the problem in

Fig. 3

solved correctly with the

PreSolve option turned off. When Dash Associates was asked about this situation, their answer was:

The Q matrix for this problem is not positive semidefinite (nor is it negative semi-definite). This means that the problem is not convex and so the results are unpredictable. As the problem has all binary rows it’s possible to add a term to the diagonal of the Q matrix and subtract twice the term from the linear cost coefficient so as to make the matrix positive semi-definite without changing the optimal solution value. We are looking to do this automatically in a future version. As the problem is not convex, Xpress will not necessary find the optimal solution and can stop in a local optimum (or not converge at all). It just happens that when PreSolve is turned off the local optimum that Xpress finds is the global optimum.

A similar test of the Knitro solver engine resulted in the error “Solver could not find a feasible solution” for the problem in

Fig. 2 . The same error occurred even

though a feasible solution was given as initial values.

The same error occurred also for the problem in

Fig. 4 ,

whereas the problem in

Fig. 3

was correctly solved by

Knitro.

R. Rasmussen / Omega 35 (2007) 541 – 552 547

Fig. 4. Selected data for escalated decentralization problem.

Fig. 5. Best solution found for problem in

Fig. 4 .

The LGO Solver engine found an inferior local optimum solution for the problem in

Fig. 2 . Select-

ing global solver options resulted in the error “Solver could not find a feasible solution” even though it was starting from the local optimum solution. The problem in

Fig. 3

was correctly solved. For the

548 R. Rasmussen / Omega 35 (2007) 541 – 552

Benchmark AMPL runs

Solver

BLMVM

DONLP2

FILTERSQP

FORTMP

KNITRO 3.1

(Performed 2004.04.16)

Objective Time (sec)

-42 711.14

38 819.66

libtao.so: openfailed:No such file ordirectory max variables = 110

222.01 Optimality error 7,905723E-2 numerical problem - suspect Q-matrix indefinite

192.35

L-BFGS-B

LOQO

MINLP

MINOS 5.5

MOSEK

PENNON 1.0

SNOPT 6.2-2

XPRESS

1 462.00

-38 621.60

-40 006.22

39 327.07

256.15

212.95

Not listed in the Benchmark

81.45

The feature 'MIXEDINT' in not in licence file.

672.02

Error evaluating nonlinear expressions libxprs.so.14.10: open failed: No such file or directory

Single AMPL runs

BLMVM

DONLP2

FORTMP

KNITRO 3.1

LANCELOT

L-BFGS-B

(Performed 2004.09.27-28)

Error: No results were produced

Not listed independently

38 819.66

180.91

-40 139.60

1154.14

SUSPECT Q-MATRIX INDEFINITE

Returned model errors

MINOS 5.5

MOSEK

PENNON 1.0

SNOP 6.2-2

XPRESS

-40 006.22

75.39

Returned same model errors as L-BFGS-B

Returned same model errors as L-BFGS-B

Returned same model errors as L-BFGS-B

Not accepting AMPL input.

Fig. 6. NEOS results for the problem in

Fig. 4 .

problem in

Fig. 4 , the LGO Solver could not find a

feasible solution.

A comparison with CPLEX using AMPL input of the data in

Fig. 4

was made. The following message completed an over-night run: “ CPLEX 9.0.0: unrecoverable failure with integer solution : objective

39 567. 18 074 103 MIP simplex iterations , 4 867 655 branch-and-bound nodes .” Adding the solver options

“nodeselect

=

0 integrality

=

0” seem to avoid this problem. Patience ran out after 26 days and the process was ended manually. Since there are no options to halt the solution process and retrieve the best solution so far, no solution from that run was available. Apparently,

CPLEX does not converge on this problem. It just confirms that QAP is NP -hard. (See

[1]

for a discussion and definition, and why QAP is NP -hard.) This means that there has not yet been developed a polynomial algorithm that will find and prove the globally optimum solution.

A test was also made using solvers accepting AMPL input on the NEOS

7 web site. A benchmark running

several solvers successively was done. Only 7 out of 13 solvers produced a numerical result, the rest only returned an error message. However, the objective function value from one of the solvers produced a numerical result completely out of line with the rest (L-BFGS-

B gave a value of 1462), and two solvers apparently returned the wrong sign (KNITRO 3.1 and PENNON

1.0). The output was not tested for feasibility, but clearly none of the solvers accepted integers, since they all produced fractional values for the objective function.

(The coefficients in the objective function were all integers.) Typically “ignoring integrality of 500 variables” was listed for most of the solvers, but not for Knitro,

LANCELOT and PENNON, which all produced fractional values for the values of the objective function.

7 http://www-neos.mcs.anl.gov/

R. Rasmussen / Omega 35 (2007) 541 – 552

Testing each solver independently revealed that for one solver the result was better than in the benchmark test (FILTERSQP, still ignoring integrality, but this time returned an integer solution). Another solver in the benchmark was not listed independently (DONLP2), and MINLP was not included in the benchmark. LOQO gave the best objective function value of

38621 .

76, but clearly ignoring the integer requirements. Five of the solvers in the benchmark run gave model errors when running independently. See

Fig. 6

for a summary of the NEOS results. The automatic benchmark test is no longer available at NEOS, and the new web page layout has reduced the confusion of which solvers accept integers.

A specially designed software for GQAP

8 using

heuristics has found a solution of

38 025 for the problem in

Fig. 4 . The corresponding permutation is:

9 , 24 , 20 , 5 , 4 , 19 , 1 , 6 , 16 , 11 , 3 , 15 , 23 , 22 , 8 , 17 , 13,

21 , 14 , 10. This solution is not proved to be the optimum solution.

9

General purpose spreadsheet solvers

come quite close to this solution found by special designed solvers.

Generally speaking most of the difficulties for the solvers are caused by the fact that QAP usually have many local optimum solutions and are quite often nonconvex. However, the ability to return meaningful messages regarding the causes of the difficulties is not always satisfactory. Some of the spreadsheet solvers have a multistart search option to try to avoid being trapped by locally optimum solutions. This option is missing in their LP solvers. But as these LP solvers also accept quadratic objectives of non-convex problems, it seems to be handy with a multistart search option in these LP solvers too.

9. A software note

Optimization software is constantly improved. As with most software there are bugs fixed in new versions, unfortunately sometimes replaced by new bugs.

When reporting the problems with the Xpress solver engine in Excel, Frontline Systems discovered a bug in their software regarding treatment of the TRANS-

POSE function in Excel, which is used in the QAP spreadsheet models. Apparently, this bug has not seriously affected the Large Scale SQP Solver engine in a

549 negative way. However, Frontline claims this bug caused the problems with the Xpress solver engine.

A new version of the spreadsheet solver (Premium

Solver Platform V6) was introduced when completing this paper. A quick test reveals that the Knitro solver now works very well on all problems previously tested, but settles with

39 238 for the problem in

Fig. 4 . The

Xpress solver also works well, except for the problem instance represented in

Fig. 4 , which is still not solv-

able; claiming the linearity conditions are not satisfied, even when Assume Quadratic Option is set. This seems a bit odd, since the problem has the same structure as in

Fig. 3 , which is solved by Xpress. The same hap-

pens with the Large Scale LP/QP Solver. The standard

LP/Quadratic solver has no such problems, and returns

39 140 as the solution for

Fig. 4 . The LGO Global

Solver, however, still performs poorly on all these problems, and worse with the new release on the problem instance of

Fig. 3 . Unfortunately, a bug has been in-

troduced with the Large Scale SQP Solver, which now ignores the binary constraints and returns fractional values if the Multistart Search option is selected. If not using this option a solution of

38 870 is found very quickly. A few new solver engines were added to the new version, but none of them are capable of solving the QAP examples in this article. (The new Mosek solver can solve quadratic constrained problems, but only if they are convex.)

10. QAPLIB

The Quadratic Assignment Problem Library

(QAPLIB)

10 has a wealth of resources for QAP, both

numerical test problems and references. A total of 135 different test problems are available. Just recently all

50 problems up to (square) size 20 have been solved to optimality. Of the remaining 85 problems, 41 have not been solved to optimality yet. These problems are listed with the best known solution and bounds for the objective function.

Typically, these test problems are solved using specially designed software for QAP, and utilizing large amount of computer power,

[4] : “For the solution of

nug30 an average of 650 worker machines were utilized over a one-week period, providing the equivalent of

8

GQAP, generalized QAP. “standard” QAP is usually limited to instances of QAP minimizing the objective function value, and where m

= n , and with all constraints restricted to equal 1.

9

Thanks to Luigi Moccia

[3] .

10 http://www.seas.upenn.edu/qaplib/ . Peter M. Hahn is maintaining the web-pages of QAPLIB. He was very helpful and encouraging reading an early draft of this paper. His insightful comments truly improved this article. He also involved Luigi Moccia, thus helped finding a better solution to the problem instance represented in

Fig. 4 .

550 R. Rasmussen / Omega 35 (2007) 541 – 552 almost 7 years of computation on a single HP9000

C3000 workstation”. To challenge these test problems

(or any QAP model with size > 10) using general purpose optimization software on a laptop is therefore rather optimistic. A list of 365 references for the QAP can be found in

[5] .

To compare the spreadsheet solvers

11

with the solvers at NEOS, 20 cases were selected from QAPLIB, half of them being greater than 20 in size, and half of those again are not yet solved to optimality. From the list of more than 50 solvers available at NEOS, only two seem to be capable of solving (Mixed) Integer

Nonlinearly Constrained Optimization—MINLP and

SBB—accepting AMPL and GAMS input, respectively

(two solvers listed under Global Optimization failed to satisfy the model constraints.) As only AMPL input was used, the comparison is to MINLP alone.

Since the matrix of decision variables ( U ) is square

( m

= n) for all the cases at QAPLIB, both the integer permutation formulation (from

Fig. 1 ) and the binary

formulation (from

Fig. 2 ) was tested in the spreadsheets.

All cases at QAPLIB except the 7 cases by Burkard and Offermann are symmetric, but the objective function values are calculated for the complete cost matrix for all cases (thus double counting the cost in the symmetric cases). Therefore, the cost matrix corresponding to

Fig. 1

was filled for all cells in the cost area in the new spreadsheets, to make the cost function correspond to the reported values at QAPLIB. This actually also simplifies the spreadsheets.

It turned out that the heuristic solvers needed to solve

Fig. 1

formulation proved to find very quickly good solutions. For the smallest problems (size n < 16–18) they actually found the optimum solution within a lunch break or so. An overnight run almost always produced the optimum solution. The problem with these heuristic solvers is that it is never clear when to stop (except when you already know the optimum solution and do not need to run the solvers). For the largest problems (still size n 20) they therefore were left to run over a weekend.

The design of the comparison was as follows: as a start the

Fig. 1

formulation was run, using the permutation 1 , 2 , 3 , . . . , n as default initial solution. The

OptQuest solver was run first. If this solver failed to find the optimum solution (within a weekend’s time), the solution from OptQuest was used as initial solution for the Standard Evolutionary Solver. If OptQuest did find the optimum solution, the default initial solution was used also for the Standard Evolutionary Solver. This

11

Version 6.0 of the Premium Solver Platform was used in testing the QAPLIB examples.

will of course favor the Standard Evolutionary Solver in cases where OptQuest failed to find the optimum solution.

For the 10 problems of size n 20 this occurred only twice, and for the other eight cases the Standard Evolutionary Solver failed to find the optimum global solution three times when OptQuest succeeded. Thus, OptQuest found the optimum solution in eight cases and the Standard Evolutionary Solver in five. Even so, the average score was better for the Standard Evolutionary Solver, with an average of 0.26% deviation of the optimum objective function value compared to 0.32% for OptQuest.

Quite often these solvers found individually alternative optimum solutions to those listed at QAPLIB. The results are listed in

Fig. 7 .

After the heuristic solvers were run, the “traditional” optimization solvers were tested. Xpress, the most expensive add-in solver, is capable of solving mixed integer problems with a quadratic objective function, but failed on every test problem from QAPLIB. It requires positive definite quadratic objectives (when minimizing). Only the following four spreadsheet solvers proved useful in solving QAP; Knitro, Large Scale

SQP Solver, Large Scale LP Solver and the Standard

LP Solver (the LP solvers accept quadratic objective functions).

The planned strategy was to use the best solutions found by the heuristic solvers as initial solution for the

“traditional” solvers, unless this already was the optimum solution, then the default initial solution would be applied. However, it sometimes happened that the solution found by the traditional solvers were inferior to the initial solution given to them by the heuristic solvers.

This was of course quite disappointing, and a re-run using the default initial solution very often improved the solution. The reason for this bizarre behavior is that for problems including integers, the initial solution is

“lost” for these traditional solvers. This indicates that a good initial solution is of little relevance for the final solution. Therefore, only experimenting with the different solver options was mostly used to try to “tune” the solvers to the problem at hand, not so often altering the initial solution.

Interestingly the “traditional” optimization solvers were outperformed by the heuristic solvers. And disregarding the two smallest cases, the Standard

12

LP

Solver was in fact performing best (but slowest) among

12

The Standard solvers (Standard LP/QP, Standard non-linear and Standard Evolutionary, as well as Interval Global Solver and

SOCP Barrier Solver) are included in the Premium Solver Platform; the other solvers are add-ins at an extra cost.

R. Rasmussen / Omega 35 (2007) 541 – 552

Problem QAPLIB Chr12c Tai12b Had14 Nug15 Esc16h Tai17a Had18 Els19 Rou20 Scr20

Status OPT OPT OPT OPT OPT OPT OPT OPT OPT OPT # times

Objective 11156 39464925 2724 1150 996 5358 17212548 725522 110030 “best”

OptQuest 11156 39464925 2724 1150 996 499468 5358 17212548 737614 110030

Standard Evolutionary 11156 39464925 2724 1152 996 496906 5358 17367328 726812

8

110352 6

Knitro 11156 39464925

Standard LP/QP 12322 43001081

2746

Large Scale SQP Solver 11566 39464925 2744 1152 996 502650 5358 17284692 739182 112882

Large Scale LP Solver 11840 42207910 2746 1152

2744

1150 996

1152

996 502240

996 496330

5360 17241628 731444 112660

5360 18589622 730180 116138

5358 731498 110868

4

4

1

4

Relative Gap

Best spreadsheet solver

Chr12c Tai12b Had14 Nug15 Esc16h Tai17a Had18 Els19 Rou20 Scr20 Average

0.00 % 0.00 % 0.00 % 0.00 % 0.00 % 0.92 % 0.00 % 0.00 % 0.18 % 0.00 % 0.11 %

NEOS Chr12c Tai12b Had14 Nug15 Esc16h Tai17a Had18 Els19 Rou20 Scr20

MINLP 13082 42512310 2724 1160 996 500460 5366 17938112 728512 113516

# times

“best”

2

Date of run on WEB 05-04-14 05-04-14 05-04-14 05-04-14 05-04-18 05-04-21 05-04-23 05-05-02 05-05-18 05-05-19 Average

Relative gap 17.26 % 7.72 % 0.00 % 0.87 % 0.00 % 1.76 % 0.15 % 4.22 % 0.41 % 3.17 % 3.56 %

551

Fig. 7. Comparison of 10 cases from QAPLIB, n 20.

the traditional solvers. Looking at the whole sample shows that Knitro was the best “traditional” solver, with an average deviation of 0.54%, and the Large Scale

LP Solver was the worst with an average deviation of

3.04%.

However, all spreadsheet solvers performed better than the MINLP solver at NEOS, which had an average deviation of 3.56%. Always selecting the best spreadsheet solver would make an average deviation of 0.11%, missing the optimum solution only twice. (Referring to the 10 smallest cases, in

Fig. 7 .)

The heuristic spreadsheet solvers OptQuest and Standard Evolutionary Solver seem to have quite similar performance on the integer formulation. Given enough time both would find the optimum solution (not necessarily in our lifetime), and there were no clear pattern which of them improved the solution quickest. The

OptQuest Solver also performs well on the binary formulation, whereas the Evolutionary Solver is rather poor on this binary type of model, likely caused by the “large” number of constraints.

The heuristic solvers will never stop unless they are instructed to, but the “traditional” solvers all seem to stop premature. This is likely caused by the non-convex type of problems, and the non-convexity also explains why different initial values return different final solutions. Trying to improve the performance of the traditional solvers by using the Integer Cutoff option in

Solver however did not work. I got this clarifying reply by Frontline:

It is not advisable to use an “integer cutoff” for a nonconvex model. The reason is that for a non-convex model, the solver normally can find only a locally optimal solution, not necessarily the globally optimal solution. When the Branch & Bound algorithm is applied to a non-convex model, the subproblems may yield locally optimal solutions that do not necessarily get “worse” as the algorithm proceeds more deeply in the Branch & Bound tree. The integer cutoff is used to save time by cutting off search of a “subtree” when the objective value at the root of that subtree is worse than the cutoff value. But for a non-convex model, this could cut off search of a subtree that includes a better, even globally optimal integer solution.

For the 10 largest problems all solvers were run us-

ing the default initial solution ( Fig. 8 ).

13

As the problem size grew, the solution time increased dramatically.

For the spreadsheet solvers it was a matter of days and not hours before they completed running the largest of these problems. The solution time also increased for the

NEOS solver, but the solution time was usually within a few minutes.

Again the Standard LP/QP Solver performed surprisingly well, except for two of the largest cases this

13

For the problems Tai35b and Ste36a in

Fig. 8 , the Premium

Solver Platform V6.5 was used.

552 R. Rasmussen / Omega 35 (2007) 541 – 552

Problem QAPLIB Chr22a Tai25b Bur26a Kra30a Tai30b Esc32a Esc32c Tai35b Ste36a Sko42

Objective 6156 344355646 88900 637117113 283315445 9526 15812 “best”

OptQuest 6450 345626201 90260 651247567 138

Standard Evolutionary 6402 344355646 5435076 93710 651247567 142

Knitro 6676 351581288 90460 706148872 130

642 297841263 10186 16176

654 286103632

3

3

16026 3

Large Scale SQP Solver 6518 345917665 5436728 90160 693956807 132 644

Large Scale LP Solver 6644 383758371 5440375 109200 665221946 372

Standard LP/QP 6278 347360879 5436492 90160 654344880 132

642 303347024 10522 17614

1

1

642 327006983 11238 16030 3

Relative Gap Chr22a Tai25b Bur26a Kra30a Tai30b Esc32a Esc32c Tai35b Ste36a Sko42 Average

Best spreadsheet solver 1.98 % 0.00 % 0.12 % 1.42 % 2.22 % 0.00 % 0.00 % 0.21 % 2.90% 1.33 % 1.02%

# times

NEOS Chr22a Tai25b Bur26a Kra30a Tai30b Esc32a Esc32c Tai35b Ste36a Sko42 “best”

MINLP 6532 345626201 5437538 91850 653927006

Date of run on WEB 05-05-23 05-04-01 05-05-23 05-05-24

142 642

05-05-25 05-05-27 05-05-27

288544254 10038 15886

05-05-29 05-06-01 05-06-01

2

Average

Relative gap 6.11 % 0.37 % 0.20 % 3.32 % 2.64 % 9.23 % 0.00 % 1.85 % 5.37 % 0.47 % 2.96 % time. Best is the heuristic Solver OptQuest with an average relative gap of 2.24%. The second best solver was MINLP at NEOS, with an average relative gap of

2.96%. However, except for the largest problem (Sko42) there was always at least one spreadsheet solver that performed better than the solver at NEOS.

As expected the variation in the performance (relative gap) increased for every solver, compared to the

smaller cases. For the smaller cases ( Fig. 7 ) all solvers

either found the optimum or a solution quite close to the

optimum solution. For the larger cases ( Fig. 8 ) a solver

found the optimum/best solution usually in just one of the problems, and sometimes they were rather far away.

(The best “worse” departure was 6.15%, again achieved by the heuristic solver OptQuest.)

Fig. 8. Comparison of 10 cases from QAPLIB, n 20.

The implementation of the matrix formula formulation of the objective function of QAP presented in this paper makes these problems easily adapted to spreadsheets. Once the data have been entered (or loaded from a database), just a few formulas have to be typed into the spreadsheet to make the QAP model ready for solving. If the matrix of the decision variables ( U ) is square

( m

= n) , the direct permutation approach using (all different) integers is even simpler to apply. For non-convex problems there are no solvers that always find the global optimum solution, and we usually must settle with a good locally optimum solution. As the available solvers for spreadsheets seem to compete very well with other general purpose solvers, then the QAP is not so hard in spreadsheets anymore.

11. Conclusion

QAP problems prove to be very hard to solve to optimality, and alternative solvers often stop prematurely at different local optimum solutions. Using other initial values and tuning the solver options may improve the solution. This was not done with the NEOS solvers. But it proved very helpful with the Premium Solver Platform solvers in Excel, which so far found the best solution among the general purpose solvers, with an objective function value of

38 342, by using the Large

Scale SQP Solver V5.5 engine on the problem in

Fig. 4 .

(Version 6.0 and 6.5 could not find as good a solution, due to the integer bug introduced in that solver engine.)

References

[1] Mirchandani PB, Francis RL. Discrete location theory. Wiley-

Interscience series in discrete mathematics and optimization.

New York: Wiley; 1990.

[2] Williams HP. Model building in mathematical programming.

Chichester: Wiley; 1999.

[3] Cordeau J-F, Gaudioso M, Laporte G, Moccia L. A memetic heuristic for the generalized quadratic assignment problem.

Décembre 2003, Centre de recherche sur les transports, Montréal,

CRT-2003-40.

[4] Anstreicher KM, Brixius NW, Goux J-P, Linderoth J. Solving large quadratic assignment problems on computational grids.

Mathematical Programming 2002;91(3):563–88.

[5] Eliane ML, Nair MM de Abreu, Paulo Oswaldo B-N, Peter

H, Tania Q. An analytical survey for the quadratic assignment problem. European Journal of Operational Research, accepted for publication.