You are on page 1of 5

See

discussions, stats, and author profiles for this publication at: https://www.researchgate.net/publication/306358450

Solving the Traveling Salesman Problem with


the Alldifferent Constraint in MS Excel

Conference Paper · July 2016

CITATIONS READS

0 372

1 author:

Julian Vasilev
University of Economics - Varna
33 PUBLICATIONS 23 CITATIONS

SEE PROFILE

Some of the authors of this publication are also working on these related projects:

„Developing the innovative methodology of teaching Business Informatics View project

All content following this page was uploaded by Julian Vasilev on 22 August 2016.

The user has requested enhancement of the downloaded file.


Solving the Traveling Salesman Problem with the Alldifferent
Constraint in MS Excel

Julian Vasilev
Varna University of Economics, 9002 Varna, Bulgaria
vasilev@ue-varna.bg

Abstract: The purpose of this paper is to show how to use the Alldifferent constraint in
Solver in MS Excel to solve the traveling salesman problem (TSP). Previous research
on the topic uses the Alldifferent constraint in combination with the INDEX function in
MS Excel to select the shortest path that reaches all customers. This paper offers
another approach in solving the TSP with the MS Excel Solver tool using the
VLOOKUP function. Constraints for a minimal travel distance and visiting each place
once are satisfied. The solution of the TSP is given as a consequence of places that may
be visited. The practical implication of the proposed approach is in the sphere of
distribution and transportation logistics. The example described in this paper is
innovative. It may be used by other researchers and business organizations to extend
their software products by adapting the proposed technology.
Keywords: MS Excel, Solver, traveling salesman problem.

1. Introduction
The traveling salesman problem (TSP) is an interesting problem in economics. It has
a formal description. A lot of researchers give solutions to it. Heuristic and genetic
algorithms may be used to solve the TSP. Its practical implication is in the sphere of
distribution and transportation logistics. A distributor has to visit several towns or shops
within a town with minimal travel costs, for minimal time, without visiting a shop (or town)
twice, without using one way twice. Graphical interpretations of the solution may also be
found.
The formal description of the problem helps mathematicians in creating formulas,
describing the problem and writing a formal mathematical solution. In some cases the
adaption of the formal mathematical equation in practice is difficult. In these cases
operational managers seek for open source software solutions or try to extend their
proprietary software. Making software changes is a difficult task. That is why many
managers prefer to use the MS Excel spreadsheet to describe their dataset and use some of its
instruments to analyze the dataset.
Describing a dataset usually is an easy task. But finding the best MS Excel instrument
and using it in the appropriate way is quite difficult. Online tutorials and video clips may
help us in finding a solution to a common problem. But making a replication of the solution
within an own dataset in some cases does not lead to the expected result.
Nowadays the dilemma (to use ready-made software or to ask the software provider to
extend the used proprietary software) is also topical. Nowadays managers have little time to
make decisions. That is why in many cases they choose to analyze their data within MS
Excel. MS Excel offers a lot of instruments. One of them is Solver.

420
Solver is used to solve a great variety of tasks, concerning logistics finding the
minimal time for operations on different machines, distribution of limited resources, making
cutting plans. Solver is also used to find the minimal travel distance by solving the traveling
salesman problem.
The purpose of this paper is to show how to use the Alldifferent constraint in Solver
in MS Excel to solve the traveling salesman problem (TSP).
Previous research on the topic uses the Alldifferent constraint in combination with the
INDEX function in MS Excel to find the shortest path that reaches all customers.
This paper offers another approach in solving the TSP with the MS Excel Solver tool
using the VLOOKUP function.
Constraints for a minimal travel distance and visiting each place once are satisfied.
The solution of the TSP is given as a consequence of places that may be visited. The
practical implication of the proposed approach is in the sphere of distribution and
transportation logistics.
The example described in this paper is innovative. It may be used by other researchers
and business organizations to extend their software products by adapting the proposed
technology.

2. Literature Review
-dimensional
arrays, when each cell has a different integer meaning [1]. If the array consists of five cells,
they contain the numbers from 1 to 5 in different order. If we have a 5-element array the
possible solutions are the permutations of five elements (5! = 120). Finding the best solution
manually takes too much time.
Other researchers also tried to solve the TSP within MS Excel. A complex solution is
given by Jiang [2]. Jiang uses Solver in combination with VLOOKUP function. Jiang uses
also the Alldifferent constraint with the TRANSPOSE function.
A simple solution of the TSP using MS Excel Solver and the Alldifferent constraint is
given in [3]. The INDEX function is used to extract the traveling distance between two
objects (shops or cities). MS Excel Solver is used to find the best route. The result of the
Solver is the consequence of shops (or cities) to be visited with minimal travel distance. A
replication of the given example on a blank worksheet gives the same result as the given
example in the cited paper. A replicable example gives confidence in other researchers and
businessman in applying the given steps in solving the TSP.
Calculating Euclidian distances between each pair of nodes is a common technique
that has a mathematical representation [4]. Rasmussen gives also a graphical interpretation of
the TSP solution. A direct permutation approach is used. Rasmussen uses several MS Excel
functions to solve TSP.
Different types of optimizations using the Alldifferent constraint are given by Harmon
[5]. Optimizing minimal space and solving the TSP problem are some of the problems
described by Harmon.
Sudoku is a game that may be easily solved by the Alldifferent constraint [6]. Since
all the cells in each rectangle, in each column and in each row have to be different. Books on
Android programming show how to build the Sudoku game for Android devices.
The literature review shows that many researchers try to find the TSP using Solver.
Each researcher uses a unique approach for describing the dataset and the constraints within
MS Excel. This fact shows great innovation in solving the TSP. Even though there are a lot
of known solutions we may offer a new one.

421
3. Description of the solution of the TSP with MS Excel Solver and
Alldifferent constraint
We use this consequence of numbers (1, 2, 3, 4 and 5) to find the consequence of
visiting towns. If we succeed in making the formal description of the TSP in MS Excel, we
will try to find the solution.
An MS Excel spreadsheet is used to enter the input data.

Table 1. Distances
B C D E F
1 Table 1. Distances
2 Way 1 2 3 4
3 1 134 197 446
4 2 134 252 387
5 3 197 252 305
6 4 446 387 305

Table 2. Towns
H I
1 Table 2. Towns
2 code name
3 1 Varna
4 2 Burgas
5 3 Ruse
6 4 Sofia

Table 3. Travel route


B C
8 Table 2. Towns
9 Town Distance
10 1
11 2
12 3
13 4
14 Total

F6). This named ranged will be used later on in formulas.


We assume a round trip. The first travel distance is calculated as the distance between
the forth and the first visited town. The following formula is entered in cell C10.
=VLOOKUP(B10;distances;B13+1;FALSE)
The second travel distance is calculated as the distance between the first and the
second visited town. The following formula is entered in cell C11.
=VLOOKUP(B11;distances;B10+1;FALSE)
The last formula is pulled down until cell C13.
The total travel distance is calculated in cell C14 simply by using the SUM function.
=SUM(C10:C13)
The Solver tool is used (Data/Analysis/Solver).

422
The Solver parameters are the following.
Set objective: $C$14 (the cell with the total travel distance) to minimum.
By changing variable cells: $B$10:$B$13 (the travel route the consequence of
visiting towns or shops).
Subject to the constraints: $B$10:$B$13 = Alldifferent
Select a solving method: Evolutionary
MS Excel Solver finds a solution to the problem. The initial travel route (before using

The Solver tool uses the power of the computer processor to simulate different routes
and chooses the one with minimal travel distance. If this task is done manually, for four
towns we need to test 24 models. The count of permutations of four numbers is calculated by
the following formula 4!=24.
The increase in the number of visited places increases the complexity of the task (to
find the best travel route) exponentially.

4. Conclusion
The traveling salesman problem may be solved in different ways. One of the easiest
ways is using the Solver tool in MS Excel. Constraints for a minimal travel distance and
visiting each place once are satisfied. The solution of the TSP is given as a consequence of
places that may be visited.
The increase in the number of visited places increases the complexity of the task (to
find the best travel route) exponentially. That is why using the MS Excel Solver tool the TSP
may be solved easily without concern on the number of visited shops.
The practical implication of the proposed approach is in the sphere of distribution and
transportation logistics. The example described in this paper is innovative. It may be used by
other researchers and business organizations to extend their software products by adapting
the proposed technology.

References
1. Excel Solver how integer, binary and Alldifferent constraints affect solving. 2015
(http://www.solver.com/excel-solver-how-integer-binary-and-alldifferent-constraints-affect-
solving).
2. Jiang, C. A reliable solver of Euclidian traveling salesman problem with MS Excel add-in tools for
small-size systems. Journal of software, Vol. 5, No. 7, 2010, pp. 761-768
(http://ojs.academypublisher.com/index.php/jsw/article/viewFile/0507761768/1956).
3. Excel Solver - Using the Alldifferent Constraint and the Evolutionary Method To Select the
Shortest Path That Reaches All Customers, 2015
(http://blog.excelmasterseries.com/2014/05/solving-traveling-salesman-problem-with.html).
4. Rasmussen, R. TSP in spreadsheets a guided tour. International Review of Economic Education
(https://www.economicsnetwork.ac.uk/iree/v10n1/rasmussen.pdf).
5. Harmon, M. Step-By-Step Optimization with Excel Solver - The Excel Statistical Master. Excel
Master Series, USA, 2012 (http://dl.acm.org/citation.cfm?id=2361723).
6. Freisen, D. et. al. A Spreadsheet Optimization Model for Solving Sudoku Problems Business
Management Dynamics, Vol.2, No. 9, 2013, pp.15-22
(http://bmdynamics.com/issue_pdf/bmd110331-%2015-22.pdf).

423

View publication stats

You might also like