<<

Examensarbete

Computation of Mileage Limits for Traveling Salesmen by Means of Optimization Techniques Johan Torstensson

LiTH - MAT - EX - - 2008 / 08 - - SE

Computation of Mileage Limits for Traveling Salesmen by Means of Optimization Techniques

Division of Optimization, Department of Mathematics Linköpings Universitet

Johan Torstensson

LiTH - MAT - EX - - 2008 / 08 - - SE

Examensarbete: 30 hp Level: D Examiner: Kaj Holmberg, Division of Optimization, Department of Mathematics Linköpings Universitet Supervisor: Kaj Holmberg, Professor, Linköpings Universitet Co-supervisor: Maria Mehlin, Scantech Sverige Linköping: June 2008

Abstract

Many companies have traveling salesmen that market and sell their products. This results in much traveling by car due to the daily customer visits. This causes costs for the company, in form of travel expenses compensation, and en- vironmental effects, in form of carbon dioxide pollution. As many companies are certified according to environmental management systems, such as ISO 14001, the environmental work becomes more and more important as the environmen- tal consciousness increases every day for companies, authorities and public.

The main task of this thesis is to compute reasonable limits on the mileage of the salesmen; these limits are based on specific conditions for each salesman’s district. The objective is to implement a heuristic algorithm that optimizes the customer tours for an arbitrary chosen month, which will represent a “standard” month. The output of the algorithm, the computed distances, will constitute a mileage limit for the salesman.

The algorithm consists of a constructive heuristic that builds an initial solution, which is modified if infeasible. This solution is then improved by a local search algorithm preceding a genetic algorithm, which task is to improve the tours separately.

This method for computing mileage limits for traveling salesmen generates good solutions in form of realistic tours. The mileage limits could be improved if the input data were more accurate and adjusted to each district, but the suggested method does what it is supposed to do. Keywords: Period Traveling Salesman Problem, Periodic, Travelling Salesman Problem, PTSP, TSP, Heuristic Algorithm, mileage limit, business trips, travel expenses compensation.

i ii Abstract Acknowledgements

I would like to thank my supervisor Professor Kaj Holmberg for his assistance and guidance. I would also like to thank my co-supervisor at Scantech Sverige, Maria Mehlin, for her help, engagement and encouragement throughout the whole period.

I also would like to thank the rest of the staff at Scantech Sverige for their help with understanding the salesmen’s work situation and for compilation of data material.

I would also like to thank my opponent Emelie Raba for her comments and criticism of the report.

Finally, I would like to thank family and friends for their support.

iii iv Acknowledgements Contents

Abstract i

Acknowledgements iii

1 Introduction 1 1.1 Background ...... 1 1.2 Purpose ...... 1 1.3 Delimitations ...... 2 1.4 Outline of the Thesis ...... 2

2 Background 3 2.1 Scantech - The Company ...... 3 2.1.1 Products and Business Idea ...... 3 2.2 The Environmental Work ...... 4 2.2.1 ISO Certification ...... 4 2.2.2 Reasons for Certification ...... 5 2.2.3 Scantech’s Environmental Work ...... 5 2.3 Business Trips ...... 6 2.3.1 The Salesmen’s Working Situation ...... 7 2.4 Problem Data ...... 7 2.4.1 Adjustment of Data ...... 8 2.4.2 Computation of Distances ...... 10

3 Theoretical Background 11 3.1 TSP ...... 11 3.2 PTSP ...... 12 3.2.1 Formulation in Terms of Graph Theory ...... 12 3.3 Heuristic Algorithms ...... 13 3.3.1 Genetic Algorithms ...... 13 3.4 Literature on the PTSP ...... 14 3.4.1 A Study in the PTSP Literature ...... 14 3.4.2 Mathematical Formulation of the PTSP ...... 15

v vi CONTENTS

4 Mathematical Formulation 17 4.1 Description of the Problem ...... 17 4.2 Parameters ...... 17 4.3 Sets ...... 18 4.4 Variables ...... 18 4.5 Mathematical Model ...... 18 4.5.1 Explanation of the Model ...... 19 4.6 Commentary on the Mathematical Model ...... 19

5 Solution Method 21 5.1 The Algorithm ...... 21 5.2 Description of the Algorithm ...... 21 5.2.1 Initial Tour ...... 23 5.2.2 Tour Construction ...... 23 5.2.3 Extra Improvement Procedure ...... 23 5.2.4 Empty Tours ...... 24 5.2.5 Improvement Procedure ...... 25 5.2.6 Tour Improvement ...... 25 5.2.7 Insertion Rule ...... 25 5.2.7.1 Check Feasibility ...... 26 5.2.8 Removal Rule ...... 27 5.3 Example of Algorithm Progress ...... 28 5.4 Alternative Solution Techniques ...... 32

6 Results 33 6.1 Runs and Parameters ...... 33 6.2 Computational Results ...... 33 6.2.1 An Illustration of the Tours ...... 35 6.3 Customization to Budgeted Sales ...... 35

7 Analysis 39 7.1 Computation of a Lower Boundary ...... 39 7.2 Analysis of Computational Results ...... 39 7.3 Analysis of the Algorithm ...... 40 7.3.1 Algorithm Fluctuation ...... 40 7.3.2 Running Times ...... 40 7.3.3 Essential Procedures ...... 41

8 Demarcation of New District Boundaries 43 8.1 Reason for Proposal of New Boundaries ...... 43 8.2 The Proposal ...... 43 CONTENTS vii

9 Conclusions and Further Research 47 9.1 Conclusions ...... 47 9.2 Further Research ...... 48

A More Illustrations of Tours 49

B Detailed Maps 53

Bibliography 59 viii CONTENTS List of Figures

2.1 Map of Scandinavia, with the sales offices marked ...... 4

2.2 Pollution of carbon dioxide (CO2) due to business trips . . . . .6 2.3 Average monthly mileages for the districts ...... 7 2.4 Map of the current district boundaries ...... 9

3.1 Solutions to a TSP and a PTSP (the square represents the home- town) ...... 12

5.1 An overview of the algorithm progress ...... 22 5.2 Insertion Rule: Inserting customer s into a non-empty tour . . . 26 5.3 Insertion Rule: Inserting customer s into an empty tour . . . . . 26 5.4 An axis that illustrates the punishment intervals ...... 27 5.5 Removal Rule: Removing customer r ...... 28 5.6 Initial Tour after insertion of customer 2...... 29 5.7 Tour Construction after insertion of customer 6...... 29 5.8 Tour Construction after insertion of customer 5...... 29 5.9 Tour Construction after insertion of all six customers...... 30 5.10 The tours after the extension of one day and two customers. . . . 30 5.11 Empty Tour after moving customer 8 to the empty tour on day 3. 31 5.12 Improvement Procedure after moving customer 7 to the tour on day3...... 31

6.1 Mileage limits (green striped) and mileage means (black) . . . . . 34 6.2 The tours of district 15, Skaraborg ...... 37

7.1 The result of all 30 runs for district 2 ...... 40

8.1 Map of the proposed district boundaries ...... 45

A.1 The tours of district 7, Västmanland/Närke ...... 50 A.2 The tours of district 14, Bohuslän ...... 51 A.3 The tours of district 24, East Skåne ...... 52

ix x LIST OF FIGURES

B.1 Map of the districts in southern Sweden ...... 54 B.2 Map of the districts in southern-central Sweden ...... 55 B.3 Map of the districts in northern-central Sweden ...... 56 B.4 Map of the districts in northern Sweden ...... 57 List of Tables

2.1 Information concerning the districts (a star (*) implies that no mileage limit will be computed for that district) ...... 8

6.1 Mileage limits ...... 34 6.2 Results for the tours on district 15, Skaraborg ...... 35 6.3 Budgeted mileage limits ...... 36

xi xii LIST OF TABLES Chapter 1

Introduction

This chapter gives a description of the problem background and the purpose and delimitations of the thesis.

1.1 Background

Almost every company has salesmen that market and sell their products. A traveling salesman visits customers every day and does spend much time in the car. The more traveling the more increases the cost for the company, in the form of travel expenses compensation to the salesmen, and the effects on the environment. To keep down the traveled distance is therefore essential both in the perspective of cost and environmental considerations.

On account of that, it is important to get an idea of whether a traveling sales- man’s mileage1 is reasonable, with respect to the customers’ geographical lo- cations in relation to the salesman’s hometown. Taking an arbitrary “normal” month for a specific salesman and optimizing on which day and in which order the customers should be visited, that distance will constitute a mileage limit. The problem will be a periodic variant of the well-known Traveling Salesman Problem. This thesis concentrates on finding a minimal travel distance for every salesman, with the help of a heuristic algorithm.

1.2 Purpose

The main purpose of this thesis is to solve the periodic Traveling Salesman Problem with a heuristic algorithm that consists of a constructive heuristic, a local search algorithm and a metaheuristic. A subproblem in this thesis is also to look at the boundaries of the districts and to demarcate these in order to reduce the environmental effetcs.

1mileage refers to the traveled distance in consequence of business trips

1 2 1.4. Outline of the Thesis

1.3 Delimitations

Because the number of customers is huge for every district, it would be very time-consuming to compute the exact road distance between all of them. There- fore the distances are approximated with the air distances, with an addition to compensate the error. An estimation of how often the customers are visited are also done, where the basis is the order statistics.

1.4 Outline of the Thesis

In Chapter 2 the background of the company and their business trips is pre- sented. Chapter 3 gives a theoretical background to the periodic variant of the Traveling Salesman Problem and the heuristics that are used. A mathematical formulation of the problem is given in Chapter 4 and in Chapter 5 a solution method is presented. Chapter 6 deals with the results from the algorithm and they are analyzed in Chapter 7. A proposal of new district boundaries is given in Chapter 8. Conclusions and suggestions for future research are presented in Chapter 9. In Appendix A additional illustrations of tours are given, while Appendix B presents detailed maps of the proposed district boundaries. Chapter 2

Background

The following chapter deals with the background of the company and the com- pany’s way of dealing with the business trips.

2.1 Scantech - The Company

The company Scantech Sverige AB markets chemical products. It was founded in 1990 and has its head office and inventory in Göteborg. There are also sales offices in Ski (near Oslo), Norway and in Jyväskylä, Finland, see Figure 2.1. Scantech Sverige is a part of the Norden Holding group that in turn is a part of the American ITW group, a global producer of engineered fasteners and compo- nents. The head office and the production unit of the Norden Holding group are located in Hadsund, Denmark. Some of the company’s products are produced in the factory in Denmark, while the rest of the products are bought in from without. Scantech Sverige AB will be called just Scantech in the rest of this thesis.

2.1.1 Products and Business Idea The company provides technical adhesives as cyanoacrylates, anaerobics, epox- ies, MS-polymers, silicone sealants and gasketing materials. They also supply aerosol products and epoxy based engineering materials. Scantech’s business idea is to “meet the requirements of our customers within the areas of bond- ing, retaining, thread locking, gasketing, sealing and industrial products.” Their concept also includes “offering the customer a tailor-made product range that covers a diversity of applications within the fields of maintenance, service and manufacturing. Through ongoing customer training we ensure a high quality, reliability and a safe working environment.”

They also say “we should be cognized as a concept and as a natural first choice of Nordic industry within bonding, retaining, thread locking, gasketing and seal- ing. We are aware that key issues like “knowledge, quality and engagement” must pervade all our work. In order to constantly guarantee this we secure our

3 4 2.2. The Environmental Work

Figure 2.1: Map of Scandinavia, with the sales offices marked production and our work with quality and environmental management systems.”

2.2 The Environmental Work 2.2.1 ISO Certification ISO, the International Organization for Standardization, is an international standard-setting organ. It is the world’s largest developer and publisher of international standards [1]. ISO consists of a network of 157 member countries, where each country is represented by a national standard institute. Sweden is represented by SIS, Swedish Standards Institute [2].

There is an enormous amount of ISO standards and below follows a few exam- ples: 2.2. The Environmental Work 5

• Paper sizes, e.g. A4

• ISBN numbers on books

• Screw threads

• Credit cards

ISO also have standards for management systems. The ISO 9000 and ISO 14000 families are among ISO’s best known standards and they cover quality manage- ment and environmental management. ISO 14001 is a member of the ISO 14000 family and it is an environmental management system that is a tool in order to continuously improve the environmental work by companies and organizations. It implies requirements with guidance for use and the environmental issues are integrated systematically in the daily work.

2.2.2 Reasons for Certification That a company is certified according to a management system is done espe- cially for businesslike reasons. It is often profitable to certificate the company and it can be a competitive advantage in purchasing. The communication with customers and suppliers are eased and a management system gives a better control and knowledge of the company itself but also increased goodwill and credibility.

It is more common these days that companies have claims to be certified accord- ing to environmental and/or quality management systems. It is not only the authorities, but also the company’s customers, employees and financiers that these claims can come from. Hence, a certification can be both an advantage and a necessity.

2.2.3 Scantech’s Environmental Work Scantech is certified according to the environmental management system ISO 14001. The company is certified since April 2001.

The environmental influence that the company causes, make up of three differ- ent parts. It is the products that they sell, their own waste and pollution of climate-influencing gases. The latter consists of pollution from transports and the consumption of power and heat. Their transports consist of business trips, transportation of goods and travels to and from work.

The company has achieved much in its continuing environmental work, but one item that has been neglected is the carbon dioxide pollution in consequence of business trips. Before 2006, Scantech had these environmental objectives concerning this:

• Increase the traveling by train, instead of by car or by plane, with 10%

• Develop a model for a long-term decreasing of the salesmen’s mileages 6 2.3. Business Trips

Neither of these objectives has been accomplished during 2006. It is the second point above that is the main task in this thesis.

2.3 Business Trips

Scantech has divided Sweden into 25 districts and each district corresponds to one salesman. Three of these salesmen are sales managers and one is product manager, which mean that they have other assignments than just selling, e.g. training new salesmen. For detailed information, see Table 2.1. A map of the districts is given in Figure 2.4, where a red filled circle denotes the hometown of that district.

For Scantech, the business trips stand for the greatest part of the company’s environmental pollution. The carbon dioxide pollution has increased in the past years, see Figure 2.2, and this is a consequence of that the salesmen’s mileages also have increased. Hence, with respect for the environment and the ISO 14001 certification, the goal to keep the mileage of the salesmen down is of utmost im- portance.

Figure 2.2: Pollution of carbon dioxide (CO2) due to business trips

The fact that the salesmen plan their trips in a strategically way is important to avoid unnecessary travels. Reduced traveling makes the pollution decrease, which results in decreasing costs and environmental effects. Scantech wants to get an idea of whether a salesman’s mileage is reasonable. This makes the preparation of a model, which output is a limit for the mileage, an important step in the company’s environmental policy. This limit is a maximal number of kilometers that a salesman is allowed to cover for a specified time period. The limit is unique for every salesman and district and is dependent on the customers’ geographical locations in relation to the salesman’s hometown. 2.4. Problem Data 7

2.3.1 The Salesmen’s Working Situation

A salesman normally works five days a week with an 8-hour working-day. In- cluding travels yet a working day tends to be 9-10 hours long. During that time, normally 4-10 customers are visited and a customer visit lasts between 30 and 60 minutes in general. Some salesmen have large districts and sometimes they stay overnight to continue traveling the next day, but no respect will be taken to this in the model.

The salesmen normally works approximately 220 days per year and each sales- man has about 200 active customers, which means customers that have placed an order the last year. The time between two consecutive visits for a customer is normally at least , while some customers are visited just once a year.

2.4 Problem Data

Data, in form of customer and order data, is always taken from the same salesman and as a standard approach from the year 2007. For some dis- tricts/salesmen, data are missing for 2007 and are then replaced with data from 2006 or from the beginning of 2008. Some districts have data for only a few months, which makes the basis becomes poor for those districts. Mileage data for each district are given in Figure 2.3.

Figure 2.3: Average monthly mileages for the districts

For some districts no mileage limits will be computed and there are different reasons for that. The salesmen for districts Uppland and Halmstad/Helsingborg are sales managers and the salesman for district Södermanland is product man- ager. Their business trips consist of more than customer visits, hence a mileage limit for these districts would be of no use for the company. The district Dalarna has been empty the most recent years, since it has not been able to recruit a salesman. Therefore there are no statistics for that district, but the salesman 8 2.4. Problem Data in the district Västmanland/Närke has covered some customers in Dalarna.

As in ordinary workplaces, employees quit and new ones begin and this makes the data concerning sell and mileage to halt. Sometimes it also implies that occasional districts remain empty.

2.4.1 Adjustment of Data It can be assumed that a salesman works eleven months a year, excluding July. Another assumption is that each month consists of 20 working days. How many times each customer is visited is unknown so estimation is done; an explanation is given below. The visits, for the whole period that data is available, are evenly distributed among the months and then one month is chosen to represent an arbitrary month. That month and its customer visits are then used to solve the problem and this is done for every district that is concerned.

Code Area Hometown Commentary 1 Norrbotten/Lappland Skellefteå 2 Västerbotten/Örnsköldsvik Holmsund 3 Jämtland/Västernorrland Timrå 4 Gävleborg Bollnäs 5 Dalarna∗ - Empty 6 Värmland Karlstad Sales manager 7 Västmanland/Närke Västerås 8 Uppland∗ Uppsala Sales manager 9 Stockholm North Stockholm 10 Stockholm South∗ - Empty 11 Södermanland∗ Katrineholm Product manager 12 Östergötland/Södermanland Norrköping 13 Östergötland Linköping 14 Bohuslän Uddevalla 15 Skaraborg Stenstorp 16 Göteborg North Göteborg 17 Göteborg South Stenungsund 18 Älvsborg/Halland Borås 19 Jönköping Jönköping 20 Kronoberg/Kalmar Älmhult 21 Kalmar/Blekinge/Öland Kalmar 22 Halmstad/Helsingborg∗ Viken Sales manager 23 NW Skåne Helsingborg 24 East Skåne Malmö 25 SW Skåne Kävlinge

Table 2.1: Information concerning the districts (a star (*) implies that no mileage limit will be computed for that district)

The order data do not tell how often a customer actually is visited. Every cus- tomer visit do not lead to a sell and this figure remains unknown because the salesmen do not keep statistics on it. Therefore, how many times each customer is visited, is estimated by a given rule, which has been developed in discussion 2.4. Problem Data 9

Figure 2.4: Map of the current district boundaries 10 2.4. Problem Data with the company. The rule works like this:

In general, approximately one-fifth of the customer visits lead to a sell. Hence, the number of visits is estimated to be five times the number of orders, but maximally once a month, for customers that order less than five times the last year. The customers that order five times per year or more are presumed to visit the customers these number of times and no more.

The rule could also be formulated like this: Let fvisits denote the number of visits, let forders denote the number of orders and let fmonths denote the number of months that there are order statistics for (normally 11), then  forders if forders ≥ 5 fvisits = . min(5 · forders, fmonths) if forders < 5

2.4.2 Computation of Distances The distances between the customers (and the salesman) are computed by means of the customers’ geographical coordinates. This method gives the air distance, which always will be shorter than the road distance. To compensate this, a factor between 20–40% is added to the air distance, depending on the road structure of the actual district. These percentages were chosen according to Bjelmrot [3]. A comparison between the road distances and the air distance was also done, to verify that the percentages were reasonable. This approach does not give the correct distances, but data for the real road distances are not available. To assemble this for around 100 customers per district and 20 districts totally would take plenty of time and therefore this method seems to be an acceptable compromise. Chapter 3

Theoretical Background

This chapter explains the theory behind the problem types and the solution meth- ods used in this thesis.

3.1 TSP

The Traveling Salesman Problem (TSP) is a very well-known optimization prob- lem that can be applied in many kinds of situations, especially in the transport sector. It can be described as follows: Given n cities and costs of traveling between them, the purpose is for the traveling salesman, starting out from his hometown, to visit all the cities exactly once and then return home, and to do this in the most cost-effective way. Instead of using costs of traveling between cities, distance or time can be used. Similarly, customers can be used instead of cities. An example of a solution to a TSP is given in Figure 3.1(a).

Let I be the set of all cities, including the hometown, and let cij be the cost for traveling between city i and city j. Also let the binary variable xij be 1 if city j is visited immediately after city i, or 0 otherwise. Then the Traveling Salesman Problem mathematically can be formulated like this: X X min cijxij i∈I j∈I X xij = 1 i ∈ I j∈I X xij = 1 j ∈ I i∈I X X xij ≤ |S| − 1 S ⊂ I, |S| ≥ 2 i∈S j∈S

xij ∈ {0, 1} i ∈ I, j ∈ I

The objective function minimizes the total distance traveled. The first two constraints ensure that the salesman arrives and leaves each city exactly once. The third constraint assures that there are no subtours, i.e. the route must be coherent. The last constraint secures that the variables are binary.

11 12 3.2. PTSP

(a) A solution to a TSP (b) A solution to a three-day PTSP (two customers require two visits)

Figure 3.1: Solutions to a TSP and a PTSP (the square represents the home- town)

3.2 PTSP

An extension of the TSP is the Period Traveling Salesman Problem (PTSP), where the planning horizon consists of several days. In this formulation, cus- tomers are chosen instead of cities. In this problem, the traveling salesman must leave home, visit at least one customer and then return home, and do this for every day in the period. The PTSP consists of designing a tour for every day so that each customer’s visit requirement is fulfilled and at the same time min- imizing the distance traveled over the whole period. An example of a solution to a PTSP is given in Figure 3.1(b).

Let ri denote how many times customer i must be visited over the period of m days. Each customer must be visited at least once and at most daily, i.e.

1 ≤ ri ≤ m. For each customer there is a set V (i) = {C1,C2,...,Cni } that consists of possible combinations of visit days. Each combination Ck ∈ V (i) is composed of ri days and ni denotes how many different visit combinations cus- tomer i has. The problem is to choose the visit combination for each customer that minimizes the total distance traveled.

For example, if ri = 3 and V (i) = {{1, 3, 5}, {2, 4, 6}} in a 6-day period (m = 6), then customer i must be visited three times, either on days 1, 3 and 5 or on days 2, 4 and 6. The sets of visit combinations are constructed in a way that spread the visit days evenly over the planning horizon. It means that in the example above, days 1,2 and 3 would not be an allowed visit combination, because the customer is visited three days in a row and that is too close in time.

3.2.1 Formulation in Terms of Graph Theory The PTSP can be formulated as a network optimization model [4]. Let I be the set of nodes consisting of all customers and the salesman’s hometown, and let E be the set of edges between every node in I. Each edge (i, j) ∈ E has a weight cij connected to it, which represents the distance between node i and node j. The graph G = (I,E) is then a complete graph. The goal is to construct m tours so that each customer is visited the required number of times and to 3.3. Heuristic Algorithms 13 simultaneously minimize the total distance traveled over the whole period.

3.3 Heuristic Algorithms

The word heuristic comes of the Greek word heuriskein that means “to find”. The task of a heuristic is to find a solution to an optimization problem. The method produces a good solution in some way, but the quality of the solution is unknown, unless it is compared with other solutions or if the optimal value is known. The solution often is near-optimal, but it is hard to determine how close to optimum it is or if an optimal solution actually is reached. Some types of optimization algorithms can ensure that optimum is found, but heuristic al- gorithms cannot do that. The facts in this section are taken from the book Optimeringslära [5] by Lundgren et al.

There are several reasons for using a heuristic instead of other solutions methods. Here follow four possible reasons:

• An optimizing method is too time-consuming.

• An optimizing method is too memory requiring.

• Input data to the problem is uncertain and a near-optimal solution is acceptable.

• A simple heuristic is often more understandable for a non-expert. This makes it easier to describe what happens in the method.

There are different types of heuristics. Constructive heuristics, local search al- gorithms and metaheuristics are the types that are used in the solution method in this thesis. A constructive heuristic successively builds a feasible solution. The local search algorithm is a method that iteratively improves a feasible solu- tion through changes and modifications of the the solution; this tends to a local optimum. A metaheuristic is an extension of a local search algorithm and the advantage with this method is that the algorithm can go from a local optimum to another one and that increases the possibility to find a better solution. A well-known metaheuristic is tabu search.

3.3.1 Genetic Algorithms A genetic algorithm (GA) is a search technique used to find good solutions to optimization problems and is a part of the evolutionary algorithms. They are in turn a part of the metaheuristic algorithms. The evolutionary algorithms try to simulate the evolution in nature, hence its name. Genetic algorithms are often used to solve problems that other algorithms and solution methods fail to solve, due to the unreasonable long computation time. An overview of how genetic algorithms work is done by Beasley et al. [6].

Here follows a brief description of a genetic algorithm, see Dizdarevic et al. [7] for details. space of the problem consists of a number of individ- uals. An individual is a possible solution to the problem. Every individual is 14 3.4. Literature on the PTSP represented by a chromosome, which consists of a character string or a matrix. The chromosome describes how a solution is stored in the algorithm. An indi- vidual’s fitness score measures how good the solution of that individual is. A population consists of several individuals and is the part of the search space that the algorithm currently looks at.

At first, an initial population is selected. Then parents are chosen from the pop- ulation and they produce children. This procedure is called crossover. These children are added to the population, while the weakest individuals are removed from it. After a crossover, the individuals could be affected by mutation, but this happen with a very low possibility. The steps just described are then ex- ecuted iteratively until the algorithms stops. One iteration of the algorithm is called generation.

3.4 Literature on the PTSP

The periodicity of the PTSP adds an extra dimension to the TSP and does make it more useable in real world practice. Examples of occasions when problems of this type arise are in mail delivery and lawn-care services (see Cordeau et al. [8]).

3.4.1 A Study in the PTSP Literature The PTSP is an NP-hard optimization problem and is a generalization of the Traveling Salesman Problem (TSP). The TSP is a classic and very well-studied problem and a great work is the book by Lawler et al. [9]. Bodin et al. [10] deal with the TSP and many other similar problem types. It also includes several algorithms. However, the literature on periodic variants of the TSP is not that extensive.

The first approach of solving a periodic routing problem is done by Christofides and Beasley in 1984 [11]. The problem in their article is the Period Vehicle Routing Problem (PVRP). The PTSP is a special case of the PVRP, in case there is only one vehicle available. They formulate the problem mathematically but the problem is solved heuristically since the PVRP is NP-hard. The idea of their heuristic algorithm is that minimizing the distance for every day inde- pendently, also results in a minimization of the total distance of the PVRP.

In addition, different methods in order to solve the PTSP have been developed by Paletta [12, 13], Cordeau et al. [8], Bertazzi et al. [14] and Paletta and Triki [15]. The heuristic algorithms in these articles but [8] are similar to each other because they are constructed in the same way.

In the article by Paletta in 1992 [12], two almost identical heuristic algorithms are presented. In the first step, that is common for the both algorithms, a non-visited customer is assigned to one of its visit combinations. This proce- dure continues until all days have been given a tour. Secondly, the remaining customers (they that are not inserted in the solution yet) are inserted in the 3.4. Literature on the PTSP 15 solution in the most cost-effective way.

In 1995, Chao et al. [4] present a new technique for solving the PTSP. An initial solution is produced by balancing the number of customers that are serviced on each day of the planning period. After that, different improvement procedures are used in order to get the best possible solution.

A tabu search heuristic for periodic and multi-depot vehicle routing problems is presented by Cordeau et al. [8] in 1997. The problems in question are the PVRP, the PTSP and the MDVRP (Multi-Depot Vehicle Routing Problem). The first step is to find an initial solution, but this solution may be infeasible. Therefore, the GENI heuristic [16] is used to for insertions and removals in order to reach feasibility. Then a tabu heuristic is used to improve the solution as much as possible and that in turn uses 4-opt and cheapest-insertion techniques.

Again, in 2002 Paletta [13] introduces a new heuristic algorithm for the PTSP. Starting with all tours empty, the customers are inserted one by one into the tours. If a tour remains empty, a procedure that fixes this is performed until all days of the planning period have non-empty tours. Now having a feasible solution, an improvement procedure is performed in order to possibly find a better solution than the current one.

In 2004 Bertazzi, Paletta and Speranza [14] present an improved heuristic al- gorithm with respect to the one proposed by Paletta [13]. The difference is in the improvement phase and computational results indicate this algorithm to be better than the previous one.

In the same year, Paletta and Triki [15] propose a heuristic algorithm that tries to solve the PTSP, but now with the assumption that the distances may be asymmetric. This algorithm is similar to the ones described in [13] and [14]. What differs this from the other two is that possible occurrences of days with empty tours is not taken into account, a slightly modified improvement procedure and that the procedures that handles insertions and removals are updated with more possible options.

3.4.2 Mathematical Formulation of the PTSP Most of the articles that deal with the PTSP do not include a mathematical formulation. Caglar and Matta [17] use a formulation with minimum frequency constraints and prevention of too frequent visits, which handles the periodicity in the problem. Constraints that limit the length of a working day are also included in their formulation.

Another type of formulation is presented by Cordeau et al. [8]. They first for- mulate the PVRP but then show how a slight modification can transform this problem into a PTSP. To solve the periodicity in the problem they introduce visit combinations. A visit combination consists of a set of days and the cus- tomer will be visited these days, if this combination is chosen. A customer can have several such combinations and they are all given beforehand. 16 3.4. Literature on the PTSP

A mathematical formulation is presented in 2007 by Basetto and Mason [18], for the special case when the length of the planning period is just two days. This circumstance makes the formulation a little bit different in comparison to the other formulations described above. Their formulation aslo includes constraints regarding the maximum number of customers visited per day.

All these three types of mathematical formulations have great similarities with each other, because they all are built on the formulation of the TSP. The dif- ferences are in how to handle the periodicity in the PTSP and this of course affects how many types of variables and constraints there are and how the con- straints are formulated. The model and the algorithm described in [8] involve visit combinations and so do the algorithms described in [13, 14, 15]. Chapter 4

Mathematical Formulation

The problem of this thesis is mathematically formulated in this chapter.

4.1 Description of the Problem

The problem that is used to compute the mileage limits is a modified version of the Period Traveling Salesman Problem (PTSP), formerly described in section 3.2. The salesman’s task is to start out from his home, visit customers and then return home again in the end of the day. This must be done for each day of the planning period and the objective is to do this in a way that minimizes the total distance traveled. No tour is allowed to be empty, even if it would reduce the traveled distance. This is because the salesman must have the option to avoid working overtime, if this is not ordered by the company.

What differs between the formulation that follows in this chapter, from the original PTSP, is additional constraints regarding the length of a working day, the daily distance traveled and the daily number of customer visits. These constraints are added because otherwise the generated tours may be unrealistic, with a few tours that has almost all customer visits and the remaining tours just a few visits each.

4.2 Parameters

The following parameters are used and they are of either scalar, vector or matrix form. Customer 0 represents the salesman’s home.

17 18 4.5. Mathematical Model

n = number of customers m = length of the planning horizon [days]

cij = symmetric distance between customer i and customer j [km]

τi = approximate duration of a customer visit (τ0 = 0; τi = constant, i ∈ N) [h] v = approximate average speed [km/h]

tij = traveling time from customer i to customer j (tij = cij/v) [h] L = threshold value for the length of a working day [h] D = threshold value for the distance traveled per day [km] K = threshold value for the number of visited customers per day  1 if day d belongs to visit combination k a = kd 0 otherwise

ni = number of visit combinations for customer i

4.3 Sets

The sets below are used in the formulation. N = {1, 2, . . . , n}, the set of all customers A = {(i, j): i, j ∈ {0} ∪ N, i 6= j}, the set of all arcs P = {1, 2, . . . , m}, the set of all days in the planning period

Ck = a visit combination of days

V (i) = {C1,C2,...,Cni }, the set of visit combinations for customer i

4.4 Variables

Two variables are used in the formulation, the binary variables xijd and yik. Note that the distances are symmetric, so it is equivalent if xijd or xjid is equal to 1 on an arbitrary day d.

 1 if customer j follows directly on customer i on day d x = ijd 0 otherwise  1 if visit combination k ∈ V (i) is assigned to customer i y = ik 0 otherwise

4.5 Mathematical Model

The mathematical model in this thesis is a variant of the PTSP and is mainly based on the formulation by Cordeau et al. in [8]. What make this formulation unique is the additional constraints regarding the daily limitations of the length of a working day, the distance traveled and the number of visited customers.

X X min cijxijd (4.1) d∈P (i,j)∈A 4.6. Commentary on the Mathematical Model 19

X yik = 1 i ∈ N (4.2) k∈V (i) X X xijd − akdyik = 0 i ∈ N d ∈ P (4.3) j:(i,j)∈A k∈V (i) X (tij + τi)xijd ≤ L d ∈ P (4.4) (i,j)∈A X cijxijd ≤ D d ∈ P (4.5) (i,j)∈A X xijd − 1 ≤ K d ∈ P (4.6) (i,j)∈A X X xhjd − xihd = 0 h ∈ N ∪ {0} d ∈ P (4.7) j:(h,j)∈A i:(i,h)∈A X x0jd = 1 d ∈ P (4.8) j∈N X xijd ≤ 1 i ∈ N d ∈ P (4.9) j:(i,j)∈A X xijd ≤ 1 j ∈ N d ∈ P (4.10) i:(i,j)∈A X X xijd ≤ |S| − 1 S ⊆ N |S| ≥ 3 d ∈ P (4.11) i∈S j∈S

xijd ∈ {0, 1} (i, j) ∈ A d ∈ P (4.12)

yik ∈ {0, 1} i ∈ N k ∈ V (i) (4.13)

4.5.1 Explanation of the Model The objective function (4.1) minimizes the total distance traveled during the whole time period. Constraint (4.2) assures that one visit combination is as- signed to each customer. That each customer is visited only on the days corre- sponding to the assigned combination is ensured in constraint (4.3). The length of a working day is limited by (4.4), the total distance traveled per day is lim- ited by (4.5) and the number of visited customers per day is limited by (4.6). Constraint (4.7) guarantees that if the salesman enters a customer, then he also must leave the customer, while (4.8) ensures that the salesman leaves home every day. Constraints (4.9) and (4.10) secure that the salesman leaves respectively arrives at a particular customer maximally once daily. Constraint (4.11) assures that subtours is eliminated, i.e. that the daily routes are coherent. The last two constraints (4.12) and (4.13) are binary constraints for the two variables x and y.

4.6 Commentary on the Mathematical Model

At first, an attempt to use the model by Caglar and Matta [17], presented in subsection 3.4.2, was made, as it seemed easier to implement in AMPL [19] and 20 4.6. Commentary on the Mathematical Model solve with CPLEX [20]. But when the execution time for solving this type and size of problems this way tended to be very long, this approach was abandoned. Also the approach to solve the problem in AMPL at all was forsaken, with re- spect to expected long execution times.

Though the mathematical model is not used to solve the problem in thesis, a model can be useful to have. For example, the model describes the problem in straight way and the model could be used for a future implementation in e.g. AMPL. Another possible use of it could be to solve the LP1 relaxation and in that way get a lower bound of the optimal value. Unfortunately the lack of memory, due to too many subtour elimination constraints, made this impossible.

1Linear Programming Chapter 5

Solution Method

This chapter describes the solution method used to solve the problem described in the previous chapter. It also includes a small example that gives an overview of how the method works. A discussion about advantages and disadvantages concerning other solution methods is also included.

5.1 The Algorithm

The heuristic algorithm that is used in this thesis is principally based upon the algorithms proposed by Paletta [13] and Paletta and Triki [15]. The first arti- cle describes a solution method for the symmetric PTSP with no allowance of empty tours, while the latter article has a method for the asymmetric PTSP, but empty tours are permitted. This thesis’ algorithm is a mixture of them both with modifications to fit this problem and the extra constraints regarding time, distance and the number of customers.

The algorithm that is described in this chapter, including the genetic algorithm that is used at the end of the algorithm, has been implemented in Matlab. Matlab is a numerical computing environment and programming language that is widely used in the industry and academia. The program has been run on an Intel R CoreTM2 Duo T7250 with CPU 2.00 GHz and 2.00 GB RAM.

5.2 Description of the Algorithm

The program progress is visualized in Figure 5.1 and below follows a short overview of the algorithm and the most important procedures are explained.

1. Initial Tour: Picks one customer and forms an initial solution 2. Tour Construction∗: Inserts all customers into the solution 2.1 Extra Improvement Procedure∗∗: Improves current solution 3. Empty Tours∗∗: Eliminates empty tours, if any. 4. Improvement Procedure∗∗: Improves the current feasible solution

21 22 5.2. Description of the Algorithm

Figure 5.1: An overview of the algorithm progress

5. Tour Improvement: Improves the tour of each day, if possible.

The algorithm begins with Initial Tour, where a random customer is inserted into the solution on the days of a randomly chosen visit combination. Then Tour Construction continues to insert customers, one by one, on the combi- nation that has the lowest insertion cost. Tour Construction is interrupted occasionally by Extra Improvement Procedure, to check if the current solution can be improved. When all customers are inserted, the program checks if there are days with empty tours. If any, Empty Tours is applied and customers are assigned to the empty tours in the most cost-effective way. Then Improve- ment Procedure tries to better the current solution even more. After that Tour Improvement improves the tours separately, using a genetic algorithm. The procedures that are marked with star (*) in above use Insertion Rule and the ones marked with two stars (**) also use Removal Rule.

Before a detailed description of the procedures in the algorithm, some notations are explained. Let Ht represent the tour currently designed for day t ∈ P . Initially, let Ht = ∅, ∀t ∈ P , which means that all days consist of empty tours. The notation (i, j) ∈ Ht (arc (i, j) belongs to tour Ht), means that customer i ∈ N ∪ {0} immediately follows customer j ∈ N ∪ {0} in tour Ht. As denoted earlier, customer 0 represents the salesman’s hometown. At last, the ceiling function dpe returns the smallest integer not less than p.

The main part of the algorithm is described in subsection 5.2.1–5.2.6, while the insertion and removal procedures are described in subsection 5.2.7–5.2.8. 5.2. Description of the Algorithm 23

5.2.1 Initial Tour The Initial Tour procedure randomly selects a customer and one of that cus- tomer’s visit combinations. Arcs from the salesman’s home to the selected customer are then established for the days in the chosen combination.

• Select a random customer i ∈ N. • Select a random visit combination k ∈ V (i).

• Let Ht := {(0, i), (i, 0)} for all days t in visit combination k.

5.2.2 Tour Construction The Tour Construction procedure selects a yet unvisited customer and assigns it to the visit combination that minimizes the total insertion cost. Then the selected customer is inserted in the tour that consists of the days of the actual combination. When all customers are inserted the procedure is terminated.

Define the set Z as the customers that have not been inserted in the solution yet and the set W as the customers that already is inserted. Consequently, N = Z ∪ W .

Repeat

• Select a customer s such that s = arg maxi∈Z {ri · minj∈W {cij}}.

• Compute the total insertion cost ick(s) for each combination k ∈ V (s), using Insertion Rule. • Assign to s the combination with the lowest total insertion cost ic(s) = mink∈V (s){ick(s)}.

• Insert s in the tour Ht for each day t in the assigned combination. • Consider s as a processed customer and update Z and W . Set Z := Z\{s} and W := W ∪ {s}. • If |W | = α, perform the Extra Improvement Procedure, let l := l + 1 and update α. Until Z is empty

5.2.3 Extra Improvement Procedure The Tour Construction procedure is interrupted when |W | = α. The parameter α changes its value each time the Extra Improvement Procedure has been run. The first α is computed like this:

α = d(3/5) × (n + 1)/me.

Henceforth α is updated with the following formula, where l stands for how many times the Tour Construction procedure has been interrupted:

α := α + d(3/4) × (l + 1) × (n + 1 − α)/me.

The procedure works like this: 24 5.2. Description of the Algorithm

For each j ∈ W

• Calculate the total removal cost rc(j) for removing customer j from its tours, using Removal Rule. • For each visit combination k ∈ V (j), compute the total insertion cost ick(j), using Insertion Rule.

• Compute the lowest total insertion cost ic(j) = mink∈V (j){ick(j)}. • If rc(j) + ic(j) < 0 then – Remove customer j from its tours and assign it to the combina- tion that corresponds to the lowest total insertion cost ic(j). – Insert customer j in the tours of the selected combination.

End for j

5.2.4 Empty Tours

If the solution contains days with empty tours after the Tour Construction pro- cedure, this procedure is used to fix this. A customer, which belongs to tours that contains at least two customers, is selected. The customers are then re- moved from its current tours and then the visit combination that contains the most number of empty tours is chosen. The selected customer is then inserted in the tours that correspond to the newly selected combination. This procedure is repeated until no days contain empty tours.

Define the set N2 as follows: N2 = {i : i ∈ N and i belongs to days which tours contain at least 2 customers of N}. The definition of N2 secures that no new empty tours can be generated by the algorithm.

Repeat

• For each j ∈ N2 – Evaluate the total removal cost rc(j), using Removal Rule. – Evaluate the lowest insertion cost ic(j) among the combinations of customer j involving the greatest number of tours, using In- sertion Rule.

• Select the customer v = arg minj∈N2 {rc(j) + ic(j)} – Remove v from its current tours. – Assign to v the combination that corresponds to the lowest total insertion cost among the combinations of customer v involving the greatest number of empty tours. – Insert v into the tours designed for the days of the new assigned combination.

Until no tour is empty 5.2. Description of the Algorithm 25

5.2.5 Improvement Procedure Then, the Improvement Procedure is performed and its purpose is to improve the current solution. By successively removing a customer belonging to N2 from the tours it belongs to and computing the cost for inserting it into another combination of days/tours, the solution will be changed if this change is cheaper. The current customer is then inserted into the tours of the new combination.

For each j ∈ N2 • Calculate the total removal cost rc(j) for removing customer j from its tours, using Removal Rule. • For each visit combination k ∈ V (j), compute the total insertion cost ick(j), using Insertion Rule.

• Compute the lowest total insertion cost ic(j) = mink∈V (j){ick(j)}. • If rc(j) + ic(j) < 0 then – Remove customer j from its tours and assign it to the combina- tion that corresponds to the lowest total insertion cost ic(j). – Insert customer j in the tours of the selected combination. End for j

5.2.6 Tour Improvement Tour Improvement finds a near-optimal solution for every day separately. Be- cause the number of nodes in a tour in this problem rarely is more than ten to twelve, the probability of that an optimal solution to the TSP is generated is relatively great. This procedure uses a genetic algorithm that is developed by Joseph Kirk [21] and it is slightly modified to fit this problem.

5.2.7 Insertion Rule The function of this procedure is to compute the cost for inserting a specific customer into the solution. It finds the cheapest way to do this, i.e. in between which customers the actual customer should be inserted. The procedure does not perform any changes to the solution, but computes costs that direct which changes that are to take place. Let s be the customer that will be inserted in the tour Ht.

There are two cases:

• If tour t is non-empty (Ht 6= ∅), remove the arc (i, j) ∈ Ht and replace it with the arcs (i, s) and (s, j), see Figure 5.2. Nodes i and j are found in computing the lowest insertion cost:

ic(s, t) = min {cis + csj − cij}. (i,j)∈Ht

• If tour t is empty (Ht = ∅), the arcs (0, s) and (s, 0) are added to the actual tour, see Figure 5.3. The cost for this is:

ic(s, t) = c0s + cs0. 26 5.2. Description of the Algorithm

Figure 5.2: Insertion Rule: Inserting customer s into a non-empty tour

Figure 5.3: Insertion Rule: Inserting customer s into an empty tour

The total insertion cost ick(s), is the sum of all costs for inserting customer s into the tours corresponding to the days of the combination k ∈ V (s). Mathe- matically this can be formulated as: X ick(s) = ic(s, t). t∈k

5.2.7.1 Check Feasibility When computing the insertion cost for an arbitrary customer, it may be that the insertion could make the solution infeasible, i.e. the tour does not satisfy the daily restrictions regarding time, distance and number of customers. Such unallowed insertion is prevented by means of punishing the insertion cost. This results in very high costs for combinations that contain such an unallowable tour, which makes the tendency for choosing that combination very low.

The restrictions for time and distance are the same for all districts, but this is not the case with the number of customers. Since the number of customers differs between the districts, having the same limit would cause some troubles. A too high limit would result in an uneven spread of the visits for districts with few customer visits. For example, if several tours only have one visit per day, while the rest have ten visits. Therefore, the districts have individual limits regarding the allowed number of visits.

There are no beforehand given threshold values that constraint the length of a working day, the distance traveled for a day and the number of visited customers for a day. Consequently, it is difficult to draw the line at a particular number. 5.2. Description of the Algorithm 27

Therefore, there is an interval that only punishes the solution moderately and an other interval that results in a huge punishment, see Figure 5.4.

Let M be a huge number, used for great punishment, and let β > 1 regulate how great a moderate punishment is. For an insertion of customer s into the tour on day t, also let time be the length of day t, dist be the traveled distance on day t and cust be the number of visited customers on day t. There is one axis for time, dist and cust respectively. Let the upper threshold values L, D and K be defined as in section 4.2. Let the parameters λ, δ and κ define the corresponding lower threshold values. This is exemplified in Figure 5.4.

Figure 5.4: An axis that illustrates the punishment intervals

Here follows an overview of how the procedure works:

If either time, dist or cust belong to the Infeasible interval, then

ic(s, t) := M · ic(s, t) + M.

Else if either time, dist or cust belong to the Half-feasible interval then

ic(s, t) := β · ic(s, t).

Else the insertion is feasible and there is no punishment.

5.2.8 Removal Rule The function of this procedure is to compute the cost for removing a customer from the current solution. This procedure does not perform any changes to the solution, but does compute the costs that direct which changes that are to take place.

Let rc(r, t) be the cost for removing customer r from tour Ht. The customers i and j are immediately before and after customer r. Therefore, the arcs (i, r) and (r, j), both belonging to Ht, are removed and replaced with the arc (i, j), see Figure 5.5. The cost for this removal is

rc(r, t) = cij − cir − crj. 28 5.3. Example of Algorithm Progress

Figure 5.5: Removal Rule: Removing customer r

The total removal cost rc(r), is the sum of all costs for removing customer r from the tours corresponding to the days of the combination currently assigned to customer r. If k is the combination assigned to customer r, the mathematical formulation of the total removal cost is: X rc(r) = rc(r, t). t∈k

5.3 Example of Algorithm Progress

In this section a small example will show how the algorithm works. In this intial example, the planning period consist of only two days, the number of customers is six and every customer only needs one visit, i.e. m = 2, n = 6, ri = 1,V (i) = {{1}, {2}}, ∀i = 1, . . . , n. In the illustrations that follow, the hometown is represented by a square and the customers by circles.

Initial Tour

A random customer is chosen, in this case customer 2. Then a random visit combination is chosen, either day 1 or day 2, in this case it was day 1. The current tours now look like in Figure 5.6.

Tour Construction

Now to Tour Construction and customer 6 is chosen according to the selection rule. It is inserted into the solution on day 2, because this insertion is the cheapest possible, see Figure 5.7.

In the same way, customer 5 is inserted into the solution, in between the home- town and customer 6, see Figure 5.8.

After all customers have been inserted into the solution, the tours look like in Figure 5.9. 5.3. Example of Algorithm Progress 29

Figure 5.6: Initial Tour after insertion of customer 2.

Figure 5.7: Tour Construction after insertion of customer 6.

Figure 5.8: Tour Construction after insertion of customer 5. 30 5.3. Example of Algorithm Progress

Figure 5.9: Tour Construction after insertion of all six customers.

Empty Tours

Let now imagine that the recently described example is extended to a third day and two more customers, in mathematic notation m = 3, n = 8, ri = 1,V (i) = {{1}, {2}, {3}}, ∀i = 1, . . . , n. After the first two procedures, the solution looks like in Figure 5.10. As can be seen, the tour of day 3 is empty and therefore the Empty Tour procedure is applied.

Figure 5.10: The tours after the extension of one day and two customers.

According to the selection rule, customer 8 is chosen to be moved to day 3. This insertion is the simplest possible, because customer 8 is the only visited customer on day 3. See Figure 5.11.

As can be seen in Figure 5.11, no day contains an empty tour, which means that Empty Tour is finished and Tour Improvement begins. 5.3. Example of Algorithm Progress 31

Figure 5.11: Empty Tour after moving customer 8 to the empty tour on day 3.

Improvement Procedure

The updated example described in Empty Tour now continues with this proce- dure. The tour on day 3 cannot remain empty again, because only customers that belong to tours that contain two or more customers can be moved. All customers, except for customer 8, are examined for a possible move to another day. The only move that shorten the total distance is when customer 7 moves to day 3, see Figure 5.12.

Figure 5.12: Improvement Procedure after moving customer 7 to the tour on day 3.

Tour Improvement

In this small example, Tour Improvement does not improve the tours at all, because the tour of each day is already optimal. It can be seen with the naked eye that no improvement can be done. 32 5.4. Alternative Solution Techniques

5.4 Alternative Solution Techniques

There are several possible methods that can be used for solving this problem. One is to solve the problem exactly with AMPL/CPLEX using the mathemati- cal model directly. The advantage with this is that an optimal solution could be generated. But a great disadvantage with this approach is that the execution time may be unreasonable long, especially when the same problem type must be solved several times, one for each district. One other aspect could be that there are so many variables and constraints that lack of memory could be a problem that makes this approach impossible.

Another possibility is column generation. Columns/variables could be repre- sented by routes and these routes must satisfy the constraints regarding time, distance and the number of customers. Before the column generation could begin, starting columns must be initiated. Because the number of customers is large and hence the number of combinations of routes could be large, this tends to be a huge problem as well. Both an LP problem and a subproblem for gen- erating new routes must be solved. In addition to this, an ILP1 problem must be solved when the column generation is finished and these problems are often NP-hard. This problem could be solved heuristically though, but the complex- ity of using column generation could make the solving time for this approach extremely unpredictable.

1Integer Linear Programming Chapter 6

Results

This chapter deals with the computational results generated by the algorithm, previously described in Chapter 5.

6.1 Runs and Parameters

The algorithm has been run on 20 districts that vary in size. For each district the algorithm has been run 30 times, where the first procedure includes a ran- dom factor, making the runs different.

The number of work days in one month is 20 (m = 20) and the length of a customer visit was presumed to be 45 minutes (τi = 45/60, ∀i ∈ N). The aver- age speed was estimated to 70 km/h (v = 70). The upper limits for time and distance were set to 10 h and 350 km (L = 10 and D = 350), while the lower limits were set to 9 h and 300 km (λ = 9 and δ = 300). The limits for the number of customers per day, K and κ, depend on the situation of each district and are not presented here.

6.2 Computational Results

Here follows some notations for the computational results, used in the Table 6.1.

• Code - the code of the district

• Area - the geographical area of the district

• Heur - heuristic solution, i.e. the mileage limit [km]

• Mean - the mean mileage actually traveled [km]

• Visits - total number of visits

• Time - total computational time for all 30 runs [seconds]

33 34 6.2. Computational Results

Code Area Heur Mean Visits Time 1 Norrbotten/Lappland 4065 4089 82 4008 2 Västerbotten/Örnsköldsvik 3381 3840 77 3323 3 Jämtland/Västernorrland 3008 3808 86 3927 4 Gävleborg 2507 1906 61 3283 6 Värmland 2994 2865 137 12135 7 Västmanland/Närke 3525 3366 83 1199 9 Stockholm North 1035 1673 92 5329 12 Östergötland/Södermanland 3460 4173 122 2125 13 Östergötland 2116 1995 112 8317 14 Bohuslän 2014 2716 110 7283 15 Skaraborg 2308 3057 90 4842 16 Göteborg North 902 1948 96 4320 17 Göteborg South 757 3283 103 6850 18 Älvsborg/Halland 2266 1886 97 1560 19 Jönköping 2999 3430 117 2206 20 Kronoberg/Kalmar 4155 4868 151 15457 21 Kalmar/Blekinge/Öland 2275 2020 70 2661 23 NW Skåne 1744 2599 136 2876 24 East Skåne 2700 3714 109 7521 25 SW Skåne 1508 2532 110 7298

Table 6.1: Mileage limits

Figure 6.1: Mileage limits (green striped) and mileage means (black)

The computational results are presented in Table 6.1 and the mileage limit and the mean mileage are compared in Figure 6.1.

As expected, the most computed mileages are lower than the real mileages. It is reasonable that the algorithm generates better routes, because it has more freedom than the salesmen have. For example, it may not be possible to visit all customers within an area in the same day, due to different customer conditions. 6.3. Customization to Budgeted Sales 35

But for six of the districts, the heuristic gave a higher value than the real ones. A much likely cause could be that the number of customer visits is overesti- mated, and thus the mileage becomes too high. Another possibility could be that just these salesmen plan their trips better than these that the algorithm generates.

6.2.1 An Illustration of the Tours This subsection presents the results that the algorithm generated for district 15, which represents the area of Skaraborg. Table 6.2 shows the number of customer visit, the distance and the time for the tours for each day. Figure 6.2 visualizes the different tours graphically; the tours are separated by different colors and the number next to each tour represents which day the tour belongs to. More examples of how the routes, that the algorithm generated, look graphically, are given in Appendix A.

Day Customers Distance [km] Time [hh:mm] 1 5 134 5:39 2 3 158 4:30 3 5 171 6:11 4 5 73 4:47 5 6 237 7:52 6 5 36 4:15 7 5 113 5:21 8 3 41 2:49 9 4 98 4:24 10 3 79 3:22 11 6 207 7:27 12 5 102 5:12 13 3 153 4:26 14 5 132 5:38 15 6 109 6:03 16 6 120 6:12 17 4 41 3:34 18 4 145 5:04 19 3 38 2:47 20 4 122 4:44

Table 6.2: Results for the tours on district 15, Skaraborg

6.3 Customization to Budgeted Sales

The mileage limits presented above are computed with respect to the sales that actually have taken place, i.e. to the orders that lead to visits. These limits are now justified to how they could have been, if the budgeted sales were reached exactly. The mileage is related to the ratio between the budgeted sales and the real sales and the result is presented in Table 6.3. The budgeted mileage is computed like this: 36 6.3. Customization to Budgeted Sales

budget sales budgeted mileage = ×mileage limit. real sales | {z } ρ

Code Ratio, ρ Mileage [km] Budgeted computed real mileage [km] 1 0.97 4065 4089 3945 2 1.07 3381 3840 3601 3 0.44 3008 3808 1333 4 0.89 2507 1906 2224 6 0.93 2994 2865 2782 7 1.02 3525 3366 3578 9 1.03 1035 1673 1067 12 0.96 3460 4173 3310 13 0.99 2116 1995 2088 14 1.09 2014 2716 2187 15 0.98 2308 3057 2256 16 0.96 902 1948 863 17 1.26 757 3283 954 18 1.15 2266 1886 2614 19 0.92 2999 3430 2749 20 1.00 4155 4868 4166 21 1.12 2275 2020 2551 23 0.96 1744 2599 1669 24 1.04 2700 3714 2810 25 0.90 1508 2532 1359

Table 6.3: Budgeted mileage limits 6.3. Customization to Budgeted Sales 37

(a) The tours on day 1–10

(b) The tours on day 11–20

Figure 6.2: The tours of district 15, Skaraborg 38 6.3. Customization to Budgeted Sales Chapter 7

Analysis

In this chapter the results of the algorithm are analyzed as well as the algorithm itself.

7.1 Computation of a Lower Boundary

To find out the quality of a generated solution, efforts have been made to get a lower boundary. Unfortunately, the lack of time and memory has made it impossible to get a valid lower boundary. An LP relaxation of the problem, using the formerly described mathematical formulation, is too hard to solve with CPLEX within a reasonable time. When attempts were done to also relax the subtour elimination constraints, the objective value became too poor to use as a lower boundary.

7.2 Analysis of Computational Results

As seen in Table 6.1, the computed mileages for the districts 9, 16, 17, 25 are much lower than the real ones. A possible cause for this may be that the traffic situation is different comparing to the other districts because these districts are located in Sweden’s three biggest cities, i.e. Stockholm, Göteborg and Malmö. There may be more traffic congestions and the availability therefore becomes more difficult; the average speed may therefore be lower than the estimated one is. Another possible cause could be the salesmen’s lack of selling skills, i.e. much time driving car but low sales.

Looking at Table 6.2, the number of customer visits per day is between 3 and 6, which is reasonable considering the average on 4.5 visits per day for that district. Both the distance and the time for every tour are within the allowed limits and they also seem reasonable.

As seen in Figure 6.2 and in the figures in Appendix A, the algorithm produces good solutions, with tours that are realistic. Tours that visit customers that are far away from the hometown, also includes customers that are along the way or in the same area. There are no occurrences of tours that seem strange or bad. That the solution may not be optimal does not matter so much because if the

39 40 7.3. Analysis of the Algorithm difference not is huge, a heuristic solution is acceptable. Of course an optimal value is always preferred, but in this case a good near-optimal solution that can act as a mileage limit is good enough.

7.3 Analysis of the Algorithm 7.3.1 Algorithm Fluctuation A weakness with the algorithm is that once it reaches a local optimum, it stays there. A local optimum can be a good one but also a very bad one. This is the reason for running the algorithm several times. The randomness in the al- gorithm is in the first procedure, Initial Tour, where a customer and one of its visit combinations are randomly chosen. The rest of the algorithm contains no randomness. In the test phase, it was obvious that the algorithm could give results that fluctuated much, and this is illustrated in Figure 7.1 that presents the results of all runs for district 2. Therefore it was not enough with just a few runs but 30 runs where chosen, where the best result among them was taken.

Figure 7.1: The result of all 30 runs for district 2

7.3.2 Running Times The running time for just one run is between a half and nine minutes, depending on which district it is. The algorithm was implemented in Matlab and contains 7.3. Analysis of the Algorithm 41 several nested loops, which may slow down the running time. An implementa- tion of the most demanding computations in some other program language, e.g. C++, could speed-up the running time.

7.3.3 Essential Procedures The procedures that are the most essential are Tour Construction and Improve- ment Procedure. Tour Construction builds up the solution successive and Tour Improvement better the solution, in moving customers to other days. In between these procedures, Empty Tours are used to eliminate possible empty tours. It is important because it is first after Empty Tours that it is for sure that the solution is feasible. 42 7.3. Analysis of the Algorithm Chapter 8

Demarcation of New District Boundaries

In this chapter a proposal about how to change the district boundaries is pre- sented, in order to reduce the costs and the environmental effects.

8.1 Reason for Proposal of New Boundaries

With the passing of years, salesmen begin and quit, new customers are gained while others are lost. When a salesman quits and not immediately replaced, some neighboring salesmen may take over some of the former salesman’s cus- tomers. A salesman can gain customers that is closer another salesman, but does not want lose them because then he also loses commission. Over the years, districts may reduce and increase in size, which can lead to unwanted effects in the extension. That a district increases very much in size can lead to increasing costs as a result of fuel consumption and with that increasing carbon dioxide pollution.

8.2 The Proposal

There was no district boundaries given, but they had to be found out when looking at the location of the customers. In that way the boundaries could be clarified. This proposal is based only on changes that can be seen intuitively. The proposal is presented in Figure 8.1; red filled circles denote the hometown of that district, green lines denote the newly proposed boundaries and dotted lines the removed boundaries. More detailed maps are available in Appendix B. The district boundaries have changed at seven places, as can be seen in the figure; these changes are commented from north to south below:

• District 3 is expanded slightly to the south, at the expense of district 4.

• District 7 loses its eastern part, including Karlskoga, to district 6.

• District 7 is extended to the southeast, taking Eskilstuna and Strängnäs from districts 11 and 12.

43 44 8.2. The Proposal

• District 13 expands in an area to the southeast, including Västervik. Dis- trict 19 and 20 are hence reduced in size.

• District 20 loses its northern part to district 19. • District 21 is expanded, taking the eastern part of district 20. • District 20 expands to the south, at the expense of districts 21 and 24. 8.2. The Proposal 45

Figure 8.1: Map of the proposed district boundaries 46 8.2. The Proposal Chapter 9

Conclusions and Further Research

This chapter concludes the thesis and suggestions for future research are pre- sented.

9.1 Conclusions

This thesis focuses on computing reasonable mileage limits for traveling sales- men, in computing realistic routes for a period of 20 days. It includes a mathe- matical formulation and a heuristic solution method, which has been modified and implemented. The algorithm includes a constructive heuristic, a local search algorithm and at the end a genetic algorithm.

The algorithm produced good solutions that work as approximate limits for the salesmen’s mileages. The generated tours are plausible in sense of length and customer visits. There are also some demarcations of the district boundaries that could be made to decrease the costs and the environmental effects.

One thing that has taken plenty of time is the data handling for the problem. To get the order data in a manageable form, data have first been copied from PDF documents to spreadsheets in Microsoft Office Excel. The data have then been compiled with help of several procedures coded in Visual Basic for Appli- cations (VBA). VBA is an event driven programming language and associated integrated development environment that is built into Excel. Totally, nearly two thousand geographical coordinates have been assembled, and these coordi- nates are taken from Eniro’s web page [22]. Every salesman and every customer corresponds to one coordinate.

The data handling had been eased very much if the data were stored in a more accessible file format, such as an Excel spreadsheet. Another thing that could have helped is if the data material had been more extensive, e.g. statistics on actual customer visit had been kept. The same data handling was done with all twenty districts, which contributed much to the amount of work.

47 48 9.2. Further Research

9.2 Further Research

Several improvements could be done to get a better output from this solution method. One essential thing is to get better and more reliable input data, e.g. in form of more accurate visit information.

To reduce the size of the problem, customers that are similar, in ways of visiting frequency and location, could be aggregated. This could speed up the compu- tation time as well as it is increases the possibility to get a lower boundary if solving the LP relaxation. But an aggregation could also worsen the accuracy, which makes this approach questionable.

Another thing is to improve the algorithm itself. There is one method by Bertazzi et al. [14], which is an extension and an improvement of the one described by Paletta [13], which is used in this thesis. Neither of the heuristic methods, but [8], studied in this thesis have any additional constraints, e.g. regarding time or distance; the punishing method chosen may not be the best one. Appendix A

More Illustrations of Tours

This appendix contains more examples of tours that the algorithm has generated, than the tours presented in subsection 6.2.1.

The tours that the algorithm generated for district 7, 14 and 24 are presented graphically in Figures A.1, A.2 and A.3, where the tours are separated by dif- ferent colors.

49 50 APPENDIX A. MORE ILLUSTRATIONS OF TOURS

(a) The tours on day 1–10

(b) The tours on day 11–20

Figure A.1: The tours of district 7, Västmanland/Närke APPENDIX A. MORE ILLUSTRATIONS OF TOURS 51

(a) The tours on day 1–10

(b) The tours on day 11–20

Figure A.2: The tours of district 14, Bohuslän 52 APPENDIX A. MORE ILLUSTRATIONS OF TOURS

(a) The tours on day 1–10

(b) The tours on day 11–20

Figure A.3: The tours of district 24, East Skåne Appendix B

Detailed Maps

This appendix contains more detailed maps of the proposal of new district bound- aries, than the map in Figure 8.1.

The maps in Figures B.1, B.2, B.3 and B.4 contain the locations of the customers and customers from different salesmen are distinguished by different colors. A square represents the hometown of that district’s salesman and a town with only customers is represented by a circle. There are four sizes of the circles/squares; the bigger size the more customers are in that town.

Sometimes different salesmen have customers in the same town or area, which makes the districts overlap each other in many areas. In those areas there may not exist an explicit boundary in reality. This is the case with district 16 and 17, which both is in the area surrounding Göteborg and to the west. The same holds for district 9 and 10, but right now the latter is empty. The districts 11 and 12 do overlap each other as well, but district 12 belongs to the product manager and his role is freer compared to a common salesman.

53 54 APPENDIX B. DETAILED MAPS

Figure B.1: Map of the districts in southern Sweden APPENDIX B. DETAILED MAPS 55

Figure B.2: Map of the districts in southern-central Sweden 56 APPENDIX B. DETAILED MAPS

Figure B.3: Map of the districts in northern-central Sweden APPENDIX B. DETAILED MAPS 57

Figure B.4: Map of the districts in northern Sweden 58 APPENDIX B. DETAILED MAPS Bibliography

[1] ISO, International Organization for Standardization. http://www.iso. org, April 2008.

[2] SIS, Swedish Standards Institute. http://www.sis.se, April 2008.

[3] Erik Bjelmrot. Lokaliseringsfaktorer för resecentra - en gis-analys av solna station. Master’s thesis, Luleå tekniska universitet, 2006.

[4] I-Ming Chao, Bruce L. Golden, and Edward A. Wasil. A new heuristic for the period traveling salesman problem. Computers & Operations Research, 22(5):553–565, 1995.

[5] Jan Lundgren, Mikael Rönnqvist, and Peter Värbrand. Optimeringslära. Studentlitteratur, 2nd edition, 2003.

[6] David Beasley, David R. Bull, and Ralph R. Martin. An overview of genetic algorithms: Part 1, Fundamentals. University Computing, 15(2):58–69, 1993.

[7] S. Dizdarevic, I. Inza, C.M.H. Kuijpers, P. Larrañaga, and R.H. Murga. Genetic Algorithms for the Travelling Salesman Problem: A Review of Representations and Operators. Artificial Intelligence Review, 13:129–170, 1999.

[8] Jean-François Cordeau, Michel Gendreau, and Gilbert Laporte. A tabu search heuristic for periodic and multi-depot vehicle routing problems. Net- works, 30:105–119, 1997.

[9] E.L. Lawler, J.K. Lenstra, H.G. Rinnooy Kan, and D.B. Shmoys. The traveling salesman problem: a guided tour of combinatorial optimization. Wiley, New York, 1985.

[10] Lawrence Bodin, Bruce Golden, Arjang Assad, and Michael Ball. Routing and scheduling of vehicles and crews. The state of the art. Computers & Operations Research, 10(2):63–211, 1983.

[11] N. Christofides and J.E. Beasley. The period routing problem. Networks, 14:237–256, 1984.

[12] Giuseppe Paletta. A multiperiod traveling salesman problem: heuristic algorithm. Computers & Operations Research, 19(8):789–795, 1992.

59 60 BIBLIOGRAPHY

[13] Giuseppe Paletta. The period traveling salesman problem: a new heuristic algorithm. Computers & Operations Research, 29(10):1343–1352, 2002.

[14] Luca Bertazzi, Giuseppe Paletta, and M. Grazia Speranza. An improved heuristic for the traveling salesman problem. Computers & Operations Research, 31:1215–1222, 2004. [15] Giuseppe Paletta and Chefi Triki. Solving the asymmetric traveling sales- man problem with periodic constraints. Networks, 44(1):31–37, 2004.

[16] François-Xavier Le Louarn, Michel Gendreau, and Jean-Yves Potvin. GENI ants for the traveling salesman problem. Annals of Operations Research, 131:187–201, 2004. [17] Toros Caglar and Marie Matta. Modeling the period traveling salesman problem with visit frequency constraints and a geriatric homecare applica- tion. Working paper at the George Washington University, 2006. [18] Tatiana Bassetto and Francesco Mason. The 2-period balanced traveling salesman problem. Working Papers 154, Department of Applied Mathe- matics, University of Venice, 2007.

[19] Robert Fourer, David M. Gay, and Brian W. Kernighan. A Modeling Language for Mathematical Programming. Management Science, 36:519– 554, 1990. [20] ILOG CPLEX: High-performance sofware for mathematical programming and optimization. http://www.ilog.com/products/cplex/index.cfm, April 2008.

[21] Joseph Kirk. Traveling Salesman Problem - Genetic Algorithm. http:// www.mathworks.com/matlabcentral/files/13680/tsp_ga.m, May 2007. Matlab program, Release 1.2; [email protected]. [22] Eniro. http://www.eniro.se, April 2008. LINKÖPING UNIVERSITY ELECTRONIC PRESS

Copyright The publishers will keep this document online on the Internet - or its possible replacement - for a period of 25 years from the date of publication barring ex- ceptional circumstances. The online availability of the document implies a per- manent permission for anyone to read, to download, to print out single copies for your own use and to use it unchanged for any non-commercial research and educational purpose. Subsequent transfers of copyright cannot revoke this per- mission. All other uses of the document are conditional on the consent of the copyright owner. The publisher has taken technical and administrative mea- sures to assure authenticity, security and accessibility. According to intellectual property law the author has the right to be mentioned when his/her work is accessed as described above and to be protected against infringement. For ad- ditional information about the Linköping University Electronic Press and its procedures for publication and for assurance of document integrity, please refer to its WWW home page: http://www.ep.liu.se/

Upphovsrätt Detta dokument hålls tillgängligt på Internet - eller dess framtida ersättare - under 25 år från publiceringsdatum under förutsättning att inga extraordinära omständigheter uppstår. Tillgång till dokumentet innebär tillstånd för var och en att läsa, ladda ner, skriva ut enstaka kopior för enskilt bruk och att använda det oförändrat för ickekommersiell forskning och för undervisning. Överföring av upphovsrätten vid en senare tidpunkt kan inte upphäva detta tillstånd. All annan användning av dokumentet kräver upphovsmannens medgivande. För att garantera äktheten, säkerheten och tillgängligheten finns det lösningar av teknisk och administrativ art. Upphovsmannens ideella rätt innefattar rätt att bli nämnd som upphovsman i den omfattning som god sed kräver vid användning av dokumentet på ovan beskrivna sätt samt skydd mot att dokumentet ändras eller presenteras i sådan form eller i sådant sammanhang som är kränkande för upphovsmannens litterära eller konstnärliga anseende eller egenart. För ytterligare information om Linköping University Electronic Press se förlagets hemsida http://www.ep.liu.se/ c 2008, Johan Torstensson

61