Content uploaded by Parfait Atchadé

Author content

All content in this area was uploaded by Parfait Atchadé on Oct 26, 2021

Content may be subject to copyright.

Available via license: CC BY 4.0

Content may be subject to copyright.

GPS: Improvement in the formulation of the TSP for its generalizations type QUBO

Sa´ul Gonz´alez-Bermejo,1Guillermo Alonso-Linaje,1and Parfait Atchade-Adelomou2, 3

1Universidad de Valladolid C/Plaza de Santa Cruz, 8, 47002 Valladolid (Spain) ∗

2Engineering Department Research Group on Data Science for the Digital Society La Salle -

Universitat Ramon Llull Carrer de Sant Joan de La Salle, 42 08022 Barcelona (Spain) †

3Lighthouse Disruptive Innovation Group, LLC 7 Broadway Terrace,

Apt 1 Cambridge MA 02139 Middlesex County, Massachusetts (USA) ‡

(Dated: Oct 2021)

We propose a new binary formulation of the Travelling Salesman Problem (TSP), with which

we overcame the best formulation of the Vehicle Routing Problem (VRP) in terms of the minimum

number of necessary variables. Furthermore, we present a detailed study of the constraints used and

compare our model (GPS) with other frequent formulations (MTZ and native formulation). Finally,

we have carried out a coherence and eﬃciency check of the proposed formulation by running it on

a quantum annealing computer, D-Wave 2000Q6.

KeyWords: Quantum Computing, Quantum Annealing, Optimizaci´on combinatoria, QUBO,

TSP, VRP

I. INTRODUCCI ´

ON

It is known that the best current QUBO formulation

of the Traveling Salesman Problem (TSP) requires N2

binary variables (IXA)). However, when this formula-

tion is extended to more general problems such as Vehi-

cle Routing Problem (VRP), its modelling is no longer

eﬃcient in terms of the number of variables because it re-

quires the use of new variables to transform it into QUBO

formulation. The number of the qubits, are crucial in to-

day’s quantum computing, so it is necessary to develop

models focused on reducing the number of required vari-

ables.

The VRP encompasses two diﬀerent problems: one in

which the distance travelled by vehicles subject to capac-

ity restrictions is minimized [1–4] and another, in which

the time spent it takes vehicles to complete their routes

is minimized. In this article, everything related to the

VRP will optimize the time to complete these routes.

When modelling this problem, it is necessary to estab-

lish relationships between the distances travelled by the

vehicles. For this reason, it is required that the distance

calculation function between journeys has to be a linear

function if we want to reduce the number of auxiliary

variables used.

The best QUBO models of the TSP that can represent

distance linearly use more than N3variables (native TSP

formulation). There is indeed a formulation that uses

N2log2(N) variables (MTZ [5]), but its results are not as

satisfactory when applying the annealing algorithms on

it.

Our purpose in this work is to present a new QUBO

model of the TSP whose the travelled distance’s calcula-

tion is linear, and that uses only 3N2variables, consid-

erably improving the existing TSP models (both of N3

∗saul.gonzalez.bermejo@alumnos.uva.es

†parfait.atchade@salle.url.edu

‡parfait.atchade@lighthouse-dig.com

and N2log2(N) variables). Furthermore, this new formu-

lation of the TSP will be generalized to deﬁne the most

eﬃcient formulation in terms of the number of variables

of the VRP.

The document is organized as follows. Section (II)

shows previous work on the TSP algorithm and its deriva-

tives. Section (III) will explore adiabatic computation.

In the section (IV), the general formulations of TSP and

MTZ will be explored. Section (V) presents our TSP

proposal with the improvements in numbers of qubits for

quantum projects of this NISQ era and beyond. A gener-

alization of our contribution is seen in Section (VI) where

we propose an optimal VRP at the qubit level. In Section

(VII), we present the results of the entire study carried

out. In the section (VIII), we discuss the results and con-

trast the contributions. Finally, Section (IX) concludes

the work carried out, and we open ourselves to some lines

of the future of the proposed model.

II. RELATED WORK

In the mid-1920s, these two references, [6, 7] were the

ﬁrst articles to provide a solution to the minimal span-

ning tree (MST) problem. Based on these works, the

mathematical researcher, Joseph B. Kruskal Jr, applied

these solutions to the TSP [8], giving life to some of the

ﬁrst solutions to this problem that will arise during the

next decades.

Almost at the end of the sixties, this work [9] oﬀered a

compilation and synthesis of the research on the travel-

ling salesman problem. Its authors began by deﬁning the

problem and presenting several relevant theorems. They

also classiﬁed and detailed the solution techniques and

computational results. Before that, in the mid-1960s,

the TSP started to emerge in many diﬀerent contexts.

This article [10] highlights some applications that began

to gain space in everyday life, such as vehicle routing or

job shop scheduling problems. Other applications such

as planning, logistics and the manufacture of electronic

arXiv:2110.12158v1 [quant-ph] 23 Oct 2021

2

circuits became of particular interest.

By making a few small modiﬁcations to the original

TSP, we could apply it in many ﬁelds such as SWP [11]

and DNA sequencing [12, 13] among others. In this last

application, the concept of ‘city’ would come to be frag-

ments of DNA and the idea of ‘distance’, a measure of

similarity between the pieces of DNA. In many applica-

tions, additional restrictions such as resource limits or

time windows make the problem considerably diﬃcult.

Computationally, the TSP [14] is an NP-Hard prob-

lem within combinatorial optimization. As an NP-Hard

problem, it is computationally complex, and heuristics

are continually being developed to get as close as possible

to the optimal solution. However, considering the com-

putational complexity nature of these problems, the new

approach that quantum computing takes is very promis-

ing.

Many works are related to the standard/native TSP

or some related variant in a quantum environment within

this new approach. For example, in this work [15], the au-

thors introduced a diﬀerent quantum annealing scheme

based on a path-integral Monte Carlo processes to ad-

dress the symmetric version of the Travelling Salesman

Problem (sTSP). In these other articles [16, 17], the au-

thors did a comparative study using the D-Wave platform

to evaluate and compare the eﬃciency of quantum an-

nealing with classical methods for solving standard TSP.

In this reference, [18] several comparisons of heuris-

tic techniques were made for some TSPLIB problems,

both symmetric and asymmetric, and their results have

been compared to other methods such as Self Organizing

Maps and Simulated Annealing. In both cases, the local

search technique was applied to the results found with

Wang’s Recurrent Neural Network with ”Winner Takes

All”. The computational complexity of their heuristics

method got O(n2+n) [19], considered competitive when

compared to Self Organizing Maps, which has a com-

plexity of O(n2) [20]. The authors went on to show that

the CAN technique has a computational complexity of

O(n2log(n)) [21], while the Simulated Annealing tech-

nique has a complexity of O(n4log(n)) [22]. Results that

are quite far from what we propose in this article.

One of the generalizations of the TSP, known as the

VRP, was studied on the D-Wave platform [23, 24]. In

tasks where routing and planning capacity (time) is re-

quired, the TSP with time windows (TSPTW) was gen-

eralized [25, 26], and has high inherent complexity and

presents enormous resolution diﬃculties. In these refer-

ences [11, 27, 28], the authors modelled combinatorial

optimization problems in which social workers visit their

patients at their respective homes and attend to them at

a speciﬁc time, called Social Workers’ Problem (SWP).

SWP is a signiﬁcant problem because additional time

constraints allow more realistic scenarios to be modelled

than native TSP. The optimal or near-optimal solution

for such issues is important in minimizing distance and

time and environmental problems such as reducing fuel

consumption.

The generalization of the TSP that we will use in work

will be the VRP. However, there are other TSP deriva-

tives, such as the Job Shop Scheduling Problem (JSSP)

[29] that are not included in the study of this work.

During state of the art carried out, we have found sev-

eral articles [23, 24, 30] that solve the TSP and VRP

(focusing on minimizing distance and not time) for an-

nealing computers. However, the number of variables

is still intractable for the current size of quantum com-

puters. For this reason, we propose a new TSP formu-

lation with a representation of the linear distance that

uses only 3N2variables, which we will use to outperform

the current best VRP modelling in terms of the number

of required variables.

III. ADIABATIC QUANTUM COMPUTERS

Adiabatic computation was born from the use of the

adiabatic theorem [31, 32] to perform the calculations.

Using the tunnel eﬀect to go from the global mini-

mum of a simple Hamiltonian to the global minimum

of the problem of interest. One of the market leaders

for this type of computing is D-Wave, which roughly

solves the quadratic unconstrained binary optimization

problem (QUBO). The QUBO formulation (1) is suitable

for running a D-Wave architecture; however, QUBO can

be mapped to the Ising [33] model and thus be used in

computers based on quantum gates, for example, IBMQ,

Rigetti, Xanadu (strawberryﬁelds), etc.

The problems that D-Wave quantum computers are

prepared to solve are those that consist in ﬁnding the

minimum of a function of the following form:

n

X

i=1

bixi+

n

X

i=1

n

X

j=1

qi,j xixj,(1)

where the variables xi∈ {0,1}and the coeﬃcients

bi, qi,j ∈R.

We have then that, given a problem, we need to model

it with the above structure where the variables that form

the solution will only take the values 0 or 1. Let us

observe that, by taking the variables xithe values 0 or

1, it is true that x2

i=xi. Therefore, we can group the

linear terms with the quadratic terms and express the

above equation in matrix format:

xtQx, (2)

with x∈ {0,1}nand Q∈Mn×nwhich is compactly

representing the QUBO formulation.

IV. TSP FORMULATION

As discussed in the introduction, we will develop the

QUBO model of the TSP in which we have worked and

3

which improves the number of variables required from

the previous models whose distance calculation function

is linear. To do this, ﬁrst, we will present the models

that we will improve by analyzing their strengths and

weaknesses.

A. Native Formulation

In this section, we will recall the formulation of the

native TSP [30] to analyze it in detail. This modelling,

which has been deﬁned in [34], despite appearing in a very

natural way which facilitates its understanding, requires

N3variables to be implemented. For today’s quantum

computers, due to qubit number limitations, we could

hardly solve cases with several cities less than 15.

The variables that appear in this model are the

variables xi,j,t such that i, j ∈ {0, ..., N + 1}and

t∈ {0, ..., N }. Let us consider that the variables xi,i,t do

not exist in this model.

The interpretation of the variables xi,j,t is simple, since

xi,j,t = 1 if at instant twe traverse the edge that

connects the cities iand j, and xi,j,t = 0 for all other

cases.

We can deﬁne the objective function of the native (Na-

tive in the sense of general, the most used) TSP[30] as:

N+1

X

u=0

N+1

X

v=0

N

X

t=0

xu,v,tdu,v .(3)

where du,v represents the distance between nodes u

and v. This objective function is subject to a series of

restrictions:

•Constraint 1. The salesman must leave each city

once.

For each u∈ {0, ..., N}:

N+1

X

v=1

N

X

t=0

xu,v,t = 1.(4)

•Constraint 2. Each city must be reached once.

For each v∈ {1, .., N + 1}:

N

X

u=0

N

X

t=0

xu,v,t = 1.(5)

•Constraint 3. If the salesman leave a city, he cannot

return to it later. This constraint ensures that no

unconnected cycles are formed as a solution. There

are two ways of posing this constraint.

–Imposing that once he leaves a city he cannot

return to it.

For each u∈ {1, ..., N + 1}:

N+1

X

v=0

N

X

t=0

N+1

X

w=0

N

X

j=t+1

xu,v,txw ,u,j = 0.(6)

–Imposing that once he arrives in a city, at the

next moment, he must leave it.

For each t∈ {0, ..., N −1},u, v ∈ {0, ..., N }:

xu,v,t(1 −

N+1

X

w=1

xv,w,t+1 ) = 0.(7)

This formulation requires N3variables. Next, we will

analyze another model used to deﬁne the TSP, which,

although it uses fewer variables, oﬀers worse results when

working with annealing.

B. MTZ formulation.

The idea of this formulation is to consider the vari-

ables xi,j = 1 if the edge that connects the cities iand

jappears in the solution path, where xi,j = 0 for all

other cases. Once we have these variables, we can es-

tablish order on the route employing a set of variables

that will represent the moment the salesman arrives at

that city (the variable uiexpressed in binary format, will

take the integer value tif the city iis reached in the t

-th position.). This model requires N2log2(N), greatly

improving the number of variables in the general formu-

lation. However, when implemented using annealing it

presents surprisingly bad results. This is because the an-

nealing algorithm gets stuck trying to minimize the part

of the objective function generated by the constraint of

the equation (11), since the representation of integers in

their binary format has the disadvantage that close num-

bers such as 2n−1 and 2ndiﬀer by a large number of

qubits, so from the annealing they are perceived as very

diﬀerent solutions.

Next, let us deﬁne the variables needed for this model.

•xi,j such that i, j ∈ {0, ..., N + 1}. They will repre-

sent the edges that appear in the route.

•Let H:= blog2(N+ 1)c+ 1 and then deﬁne ui:=

PH

h=0 ui,h such that i∈ {0, ..., N +1}. As discussed

in the previous paragraph, these variables represent

the order in which the cities are travelled.

•To be able to handle the previous variables, it

is necessary to include the following variables:

slacki,j,h such that i, j ∈ {0, ..., N + 1}and h∈

{0, ..., H1}with H1:= blog2(N+ 1)c+ 2. These

auxiliary variables will work as slack variables to

transform inequalities into equalities.

Once the model variables have been deﬁned, let us ana-

lyze the constraints that must be met.

Similar to the native TSP, we can deﬁne the MTZ ob-

jective function as follows:

N+1

X

i=0

N+1

X

j=0

xi,j di,j ,(8)

4

where di,j represents the distance between cities iand j.

In this case, the restrictions to be satisﬁed are as follows:

•Constraint 1 : The salesman must leave each city

once.

For each i∈ {0, ..., N}:

N+1

X

j=1

xi,j = 1.(9)

•Constraint 2 : Each city must be reached once.

For each j∈ {1, ..., N + 1}:

N

X

i=1

xi,j = 1.(10)

•Constraint 3 : There must be an order between

the cities so that there is a single cycle that

runs through all of them. Then, for each i, j ∈

{0, ..., N + 1}:

ui−uj+ (N+ 2)xi,j +

H1

X

h=0

2hslacki,j,h =N+ 1.(11)

This restriction guarantees that if xi,j = 1, what

means, from city iwe travel to city j, then the

value of ujmust be greater than ui. This ensures

that the uivariables provide a meaningful order.

Once the two most common QUBO models of the TSP

have been presented, let us analyze the formulation with

which we improve the number of variables of the previous

two.

V. GPS FORMULATION

To develop this model, we take the variables xi,j,r with

i, j ∈ {0, ..., N +1}and r∈ {0,1,2}. In all the modelling,

the variables xi,j,r such that i=jare not considered. We

work with directional edges, that is, if in the model the

edge (i, j) appears, we will understand that ﬁrst we go

through node iand immediately after that we go to j.

Let us analyze what each variable represents:

•xi,j,0= 1 means that the edge (i, j ) does not appear

in the path and the node iis reached earlier than

the j.

•xi,j,1= 1 means that the edge (i, j) appears in the

path, so the node iis reached earlier than the j.

•xi,j,2= 1 means that the edge (i, j ) does not appear

in the path, and the node jis reached earlier than

the i.

From the deﬁnition of our variables, we can deﬁne the

distance travelled through the following objective func-

tion as:

N+1

X

i=0

N+1

X

j=0

di,j xi,j,1.(12)

The constraints that must be met are:

•Constraint 1 : For each i, j one and only one of the

3 cases of rmust be given, so

For all i, j:

2

X

r=0

xi,j,r = 1.(13)

•Constraint 2 : Each node must be exited once.

For each i∈ {0, ..., N}:

N+1

X

j=0

xi,j,1= 1.(14)

•Constraint 3 : Each node must be reached once.

For each j∈ {1, ..., N + 1}:

N

X

i=0

xi,j,1= 1.(15)

•Constraint 4 : If node iis reached before j,

then node jis reached after i, so, for all i, j ∈

{0, ..., N + 1}such that i6=j:

xi,j,2= 1 −xj,i,2.(16)

It would also have to be speciﬁed for r= 0 and

r= 1, however this restriction is suﬃcient since by

(13) it is implicit.

•Constraint 5 : If node iis reached before node j

and node jis reached before node k, then node i

must be reached before k. This condition will pre-

vent the route from returning to a node from which

it had already exited, thus preventing cycles from

forming. We then arrive at the penalty function

equation (17).

N

X

i=1

N

X

j=1

N

X

k=1

(xj,i,2xk,j,2−xj,i,2xk,i,2−xk,j,2xk,i,2+xk,i,2).

(17)

With only the cases in which i6=j,i6=kand j6=k

will be taken in the summation and in the annex

(X) we will provide the approach followed to arrive

at it.

The following is deduced from the equation (17).

We have xi,j,2= 0 if iis reached before jand

xi,j,2= 1 in the case where jis reached before i.

Thus, with the previous equation we penalize these

5

following cases in which xi,j,2= 0, xj,k,2= 0 and

xi,k,2= 1 and xi,j,2= 1, xj,k,2= 1 and xi,k,2= 0

which lead to cases in which it would be forming

cycles (for these two situations we have that the

value of the parentheses is 1 and for the rest 0). In

(31) we have a similar situation for our VRP formu-

lation, where we oﬀer more details. For this condi-

tion, we must have directly constructed a penalty

function that avoids erroneous cases without ﬁrst

posing linear conditions through which to generate

its corresponding penalty function.

Formulated in this way we have managed to reduce

the number of variables required from N2log2Nto 3N2,

achieving very noticeable reductions when working with

large problems. Once we have this formulation, let us see

how we can generalize it to the VRP.

VI. VRP FORMULATION

As discussed in the introduction, this model is ori-

ented to be optimal concerning the number of qubits

used. However, this generalization does not appear as

naturally as expected because it requires a delicate step

to get the constraints of the equation (31). To do this,

we will detail each step and explain each constraint step

by step.

A. Original formulation 5N2Q

For this VRP, we will consider that Nis the number

of cities and Qis the number of available vehicles. We

ﬁrst present the variables that will form the problem. We

then take the following set of variables.

xi,j,r,q with i, j ∈ {0, ..., N + 1},

r∈ {0,1,2,3,4}and q∈ {1, ..., Q}(18)

In all the modelling, the variables xi,j,r such that i=j

are not considered. The variables i,jrefer to the cities

must travel to, and the variable qrefers to the vehicle.

The nodes 0 and N+ 1 correspond to the starting and

ending points. Note that they may be the same node but

we will separate them for convenience in the formulation.

The values di,j with i, j ∈ {0, ..., N + 1}correspond to

the distance between node iand j. Let us dive into the

interpretation of each variable:

•xi,j,0,q = 1 means that the vehicle qtravels to the

cities iand j, does not travel across the edge (i, j)

and arrives at the city ibefore the j.

•xi,j,1,q = 1 means that the vehicle qtravels to the

cities iand jtravels across the edge (i, j) (that is,

once it passes through the city ithe next city it

reaches is the j) and therefore the city iis reached

earlier than the city j.

•xi,j,2,q = 1 means that the vehicle qtravels through

the cities iand jand arrives at the city jearlier

than at the i.

•xi,j,3,q = 1 means that the vehicle qdoes not go

through the cities iand j, and the city iis reached

earlier than the city j. Note that xi,j,3,q can take

the value 1 whether the vehicle qpasses through

one of both cities or neither of them.

•xi,j,4,q = 1 means that the vehicle qdoes not travel

to the cities iand j, and the city jis reached earlier

than the city i.

Even if no vehicle passes through the objects iand j,

the formulation must establish an order between them.

However, this restriction does not make the modelling

meaningless, since we can assume that if the vehicles are

ordered in the order of {1, ..., Q}, then iwill be reached

before jif the vehicle that passes through node ihas a

lower number than the one that passes through node j.

Once the interpretation of each variable is explained, let

us analyse the constraints that must be met.

•Constraint 1: For each i, j, q, one and only one of

the possibilities must be met for r, so:

For all i, j, q:

4

X

r=0

xi,j,r,q = 1,(19)

•Constraint 2: Each vehicle has to fulﬁll that it

leaves the starting position. For this situation, we

are going to impose that:

For all q:

N+1

X

j=1

x0,j,1,q = 1,(20)

No vehicle can return to the starting position from

a city, so:

For all q:

N+1

X

i=0

xi,0,1,q = 0,(21)

•Constraint 3: Every vehicle must ﬁnish in the ﬁnal

position. For this, it must be fulﬁlled that:

For all q:

N

X

i=0

xi,N+1,1,q = 1,(22)

No vehicle can leave the ﬁnal position. We then

have that:

For all q:

N+1

X

j=0

xN+1,j,1,q = 0.(23)

Vehicles that do not travel on any road will

meet all constraints when taking the following con-

dition:

x0,N+1,1,q = 1.

6

•Constraint 4: The vehicle must leave once and only

once from each city, then:

For each i∈ {1, ..., N}:

Q

X

q=1

N+1

X

j=1

xi,j,1,q = 1.(24)

•Constraint 5: The vehicle must arrive once and

only once to each city, then:

For each j∈ {1, ..., N}:

Q

X

q=1

N

X

i=0

xi,j,1,q = 1.(25)

•Constraint 6: The city iis reached before the city j

does not depend on each vehicle. Therefore, for all

the vehicles that either arrive at city iearlier than

j, or arrive at city jearlier than i. Introducing

the auxiliary variables ai,j, we have the following

constraint. For all i, j ∈ {1, ..., N}:

Q

X

q=1

xi,j,0,q +xi,j,1,q +xi,j,3,q =ai,j Q. (26)

It will then be true that for each i, j or ai,j = 1,

which means that the city iis reached earlier than

the city jand therefore for each qwe will have

xi,j,r,q = 1 for any value of the rin which iis

reached before j, or ai,j = 0, and, we will have

xi,j,r,q = 0 for all the vehicles and for values rwhere

iis reached before j.

•Constraint 7: If the vehicle qarrives in the

city j, then the vehicle qmust leave the city

j. For this we impose the constraint that

for i∈ {0, ..., N },j∈ {1, ..., N}and q∈

{1, ..., Q}:

xi,j,1,q(1 −

N+1

X

k=1

xj,k,1,q ) = 0.(27)

Let us now impose the conditions that make vehicles

run on a tour.

•Constraint 8: It must be fulﬁlled that either the

vehicle pass through the city ibefore the jor ar-

rive before to the city jthan the i. Therefore,

it must be veriﬁed that, for i∈ {0, ..., N},j∈

{1, ..., N }and q∈ {1, ..., Q}:

xi,j,0,q +xi,j,1,q +xi,j,3,q = 1 −(xj,i,0,q +xj,i,1,q +xj,i,3,q).

(28)

•Constraint 9: If city iis reached before jand city j

is reached before city k, then city imust be reached

before city k. This condition will prevent the ve-

hicle from returning to a city it has already passed

through and therefore prevents a cycle from form-

ing.

To introduce this constraint, we will directly calcu-

late a penalty function worth 0 in the correct cases

and 1 in those that are not. To facilitate the un-

derstanding of the penalty function, we are going

to take, for i, j, k, q, the following variables:

ai,j =xi,j,0,1+xi,j,1,1+xi,j,3,1

aj,k =xj,k,0,1+xj,k,1,1+xj,k,3,1

ai,k =xi,k,0,1+xi,k,1,1+xi,k,3,1.

(29)

Remember that it is not necessary to introduce

these conditions because the constraint (26)

establishes the correct values of the variables ai,j.

Therefore, ai,j = 1 means that the city iis reached

before the city jand the same with jand k. Also,

it is very important to remember that due to

the same constraint (26), we can take any of the

vehicles as a reference. In this case, we have taken

the ﬁrst vehicle as a reference.

In this way, ﬁxed i, j, k, we have the 3 variables

ai,j , aj,k, ai,k . Remember that ai,j , aj,k , ai,k only

take the values 0 or 1. Also, let us note that

the cases that lead to values of the variables

for which cycles can be formed and that we

must discard are (ai,j, aj,k , ai,k ) = (0,0,1) and

(ai,j , aj,k, ai,k ) = (1,1,0).

In the case (0,0,1) we would have that the city

jis reached after the i, the kafter the j, and

yet the city kis reached rather than i, which

is absurd. The case (1,1,0) cannot be given ei-

ther, since it reaches ibefore jand jbefore k, so

it cannot be that we also reach kbefore i. We

therefore must construct a penalty function so that

for f(ai,j , aj,k, ai,k ) it holds that f(0,0,1) >0,

f(1,1,0) >0 y f(ai,j , aj,k, ai,k ) = 0 for all other

cases. A function that satisﬁes these conditions is

from the equation (30).

f(ai,j , aj,k, ai,k ) := ai,j aj,k −ai,jai,k −aj,k ai,k+a2

i,k.(30)

then, adding to the cost function the equation (31)

λ

N

X

i=1

N

X

j=1

N

X

k=1

(ai,j aj,k −ai,j ai,k −aj,kai,k +a2

i,k),(31)

we will have that the best solutions will be those

that comply with this constraint.

•Constraint 10: The objective we seek is to mini-

mize vehicle travel time. What we could do is to see

how long each vehicle takes to complete the route

and try to minimize as much of the time as possi-

ble. However, this function soon becomes complex

7

so we have decided to develop a diﬀerent idea that

simpliﬁes the process and smoothes the objective

function. If we impose the condition that all vehi-

cles travel less distance than the distance travelled

by vehicle number 1, we will have that minimizing

the maximum of the distances will be equivalent to

minimizing the distance travelled by the ﬁrst ve-

hicle. We then have the following condition. For

each q∈ {2, ..., Q}:

N+1

X

i=0

N+1

X

j=0

di,j xi,j,1,q ≤

N+1

X

i=0

N+1

X

j=0

di,j xi,j,1,1.(32)

We transform this inequality into equality by tak-

ing once again Dmax := Pn

i=0 maxj{di,j }and the

variables bh,q (the variables bh,q are like in (11)

slack variables and they are in their binary expres-

sion) in:

N+1

X

i=0

N+1

X

j=0

di,j xi,j,1,q +

hmax

X

h=0

2hbh,q −

N+1

X

i=0

N+1

X

j=0

di,j xi,j,1,1= 0.

(33)

Under these conditions the function to be mini-

mized corresponds to:

N+1

X

i=0

N+1

X

j=0

di,j xi,j,1,1.(34)

This condition has the disadvantage that we are

eliminating solutions where it is another vehicle

that travels the longest distance. Let us explore

how to avoid this problem and get more ﬂexibility

in the model to make it easier for the Quantum

Annealing to ﬁnd the optimum one. We can es-

tablish an auxiliary variable Dand we set that the

distance travelled by each vehicle must be less than

this variable, that is to say:

N+1

X

i=0

N+1

X

j=0

di,j xi,j,1,q ≤D, for all q∈ {1, ..., Q}.(35)

The variable Dis an integer, so we must treat it in

some way in order to include it in the model. As

we explained in the introduction of the section ded-

icated to the formulation of the MTZ model (IV B),

it is convenient to try to avoid the binary represen-

tation of integer variables. To do so, we can ex-

press Das a combination of the distances between

edges by taking D=PN+1

i=0 PN+1

j=0 xi,j bi,j . Thus

after imposing the constraint (35) we have that the

function to minimize is D.

Thanks to this modelling of the VRP we have been able

to reduce the number of variables required to the order

of 5N2Q. However, we have managed to reduce it even

further to 3N2Q, which is detailed in (IX B). However,

we have preferred to present this other model due to its

easy understanding.

VII. RESULTS

Before analyzing the results, we are pleased with our

GPS formulation’s positive results achieved.

Let us observe in the diﬀerent tables the comparison of

the number of qubits, time during which the D-Wave

Quantum Annealing simulator has been executed, and

the length of the path found. The sign ”-” represents

that the algorithm did not ﬁnd a possible way during the

elapsed time (in minutes). In this examples, the cities

which form the TSP to solve are the vertex of the regular

polygon with these number of vertex.

GPS General MTZ

Number of qubits 75 100 140

Elapsed Time (min) 0.332 0.08 0.569

Path Length (m) 5.65 5.65 5.65

Table I. In this scenario of 4 cities, we set comparison with

the 3 models, MTZ, native TSP and GPS. The comparison

is based on the number of times to ﬁnd the solution, the dis-

tance travelled, and the number of qubits. We can appreciate

the good performance of our GPS model, and above all the

savings it oﬀers us in the number of qubits.

GPS General MTZ

Number of qubits 147 294 266

Elapsed Time (min) 0.337 0.39 1.338

Path Length (m) 6.00 6.00 8.46

Table II. In this scenario of 6 cities, we set comparison with

the 3 models, MTZ, native TSP and GPS. The comparison

is based on the number of times to ﬁnd the solution, the dis-

tance travelled, and the number of qubits. We can appreciate

the good performance of our GPS model, and above all the

savings it oﬀers us in the number of qubits.

These results have been obtained using a simulator be-

cause we would require access to a quantum computer

for a time similar to that needed to perform the simula-

tions (in some cases more than an hour). However, it is

the beneﬁts of modeling with few qubits (such as GPS

modelling) will be much more notable when these prob-

lems are implemented in real quantum computers. Other

studies that did not require many hours of the quantum

computer were carried out on the DW 2000Q 6. In the

discussion section, we detail some interesting cases.

8

GPS General MTZ

Number of qubits 243 648 522

Elapsed Time (min) 1.209 1.177 2.676

Path Length (m) 6.122 9.58 11.46

Table III. In this scenario of 8 cities, we set comparison with

the 3 models, MTZ, native TSP and GPS. The comparison

is based on the number of times to ﬁnd the solution, the dis-

tance travelled, and the number of qubits. We can appreciate

the good performance of our GPS model, and above all the

savings it oﬀers us in the number of qubits.

GPS General MTZ

Number of qubits 363 1210 770

Elapsed Time (min) 3.316 3.087 4.175

Path Length (m) 12.51 10.978 -

Table IV. In this scenario of 10 cities, we set comparison with

the 3 models, MTZ, native TSP and GPS. The comparison

is based on the number of times to ﬁnd the solution, the dis-

tance travelled, and the number of qubits. We can appreciate

the good performance of our GPS model, and above all the

savings it oﬀers us in the number of qubits.

GPS General MTZ

Number of qubits 507 2028 1066

Elapsed Time (min) 7.992 9.677 10.578

Path Length (m) 14.286 12.28 -

Table V. In this scenario of 12 cities, we set comparison with

the 3 models, MTZ, native TSP and GPS. The comparison is

based on the number of times to ﬁnd the solution, the distance

travelled, and the number of qubits.

VIII. DISCUSSIONS

Once the diﬀerent models had been implemented, we

achieved the following results. Through the results of the

ﬁgure (1) up to the ﬁgure (4), the good performance of

our formulation compared to the general TSP [30] can

be observed. An almost identical operation is seen with

the generic TSP, except that we are improving at least

the number of qubits for the same cases in our proposal.

Although the time diﬀerence is not signiﬁcant again, the

diﬀerence between path lengths is. Let us remember that

the advantage of the formulation in which we have worked

is based on improving the number of qubits used. We

then have that the larger the problems we are working

on, the better this diﬀerence will be appreciated in the

number of variables.

The MTZ model does not oﬀer positive results. This

is since Annealing presents many diﬃculties to ﬁnd

minimum expressions in which the representation of

integers appears in their binary format. This is because

although the numbers 2k−1 and 2kare close, they

are not close in their binary form since they diﬀer in k

variables, so the annealing tends to present bad results.

Apart from that adjusting, the Lagrange coeﬃcient of

this type of constraint is also a complicated task.

General and GPS modelling show better results. While

it is true that general modelling gives slightly better re-

sults, it requires the use of a higher number of qubits.

This may be since the function to be optimized for this

model has a smaller number of local minima where the

Annealing can get stuck or to a bad ﬁt of the Lagrange

coeﬃcients.

The problem on which the simulations are carried out

consists in ﬁnding the optimal path when the points are

placed on the vertices of the regular polygons that have

the same number of vertices as nodes in our problem.

Figure 1. Path length comparison for N = 9. In this graph,

we see how the length of the solution paths for the case of 9

cities is very similar so that both models give good results.

One of the behaviours and results that we believe is

important to mention is the following. We realized that

it is even more important to consider the number of edges

that our model generates. The vertex/connections in

a quantum computer are limited and deﬁne our quan-

tum computer’s typology and quality for error mitiga-

tion. Thus, a model that produces many edges (direct

links) may request more from a computer than another

generates few. The ﬁgure (5) oﬀers us a comparative

study between our GPS model and the native TSP. This

ﬁgure shows the exponential behaviour and the number

of interconnections that each model oﬀers. Our model

improves the number of qubits and gives us a great re-

sult reducing the number of connections a lot. The native

TSP behaves as 0.8(N+ 2)5while the GPS as 2(N+ 2)3.

9

Figure 2. Time comparison for N = 9. This graph shows

the time taken to carry out the executions in the case of 9

cities. Although it seems that there is a lot of diﬀerence, it

only represents 10% of the total time, which, as we have seen

in other experiences, is not signiﬁcant.

Figure 3. Path length comparison for N = 11. For the exam-

ple of 11 cities, we can observe that the outcomes are quite

similar. Although the time diﬀerence is not signiﬁcant again,

the diﬀerence between path lengths is. Let us remember that

the advantage of the modelling we have worked is based on

improving the number of qubits used. We then have that

the larger the problems we are working on, the better that

diﬀerence will be appreciated in the number of variables.

One aspect of GPS worth commenting on here is

to generalize it also to be used for the Cutting-plane

method. We must change the current constraint (17)

since this methodology only works with linear con-

straints. The way to do this is as follows. For each i, j, k:

•xj,i,2+xk,j,2≤2xk,i,2+w1

i,j,k

•xj,i,2+xk,j,2≥2xk,i,2−w2

i,j,k.

In these equations, the variables wp

i,j,k are auxiliaries.

The purpose of these variables is to satisfy the said con-

strains. These two restrictions are satisﬁed by all cases of

Figure 4. Time comparison for N = 11. For the example of

11 cities, we can observe that the outcomes are quite similar

because although there is a mean diﬀerence of about 20 sec-

onds between the results of both simulations, the experience

with this problem and other similar ones is that this very

small diﬀerence does not aﬀect the results on the length of

the solution path.

Figure 5. In this ﬁgure we can appreciate the exponential be-

haviour and the number of interconnections that each model

oﬀers. Our model (GPS) improves the number of qubits and

gives us a great result reducing the number of connections a

lot. The Native TSP behaves as 0.8(N+ 2)5while the GPS

as 2(N+ 2)3.

(xj,i,2, xk,j,2, xk,i,2) except for (0,0,1) (because it doesn’t

satisfy the second constraint) and (1,1,0) (because it

doesn’t satisfy the ﬁrst constraint).

IX. CONCLUSIONS AND FURTHER WORK

The modelling of both the TSP and the VRP de-

veloped in this work has given outstanding results to

be used to solve both problems and the tasks that

derive from them. We have improved the number of

variables over other similar ones that provide good

results in the condition of having a linear distance

calculation function. The improvement in our models

represents a fairly signiﬁcant order of magnitude be-

cause we went from N3variables to 3N2. The ﬁgure (6)

and (7) summarizes the major contribution of this article.

10

Figure 6. Comparison of the diﬀerent models based on the

number of qubits. This graph shows the behaviour and evo-

lution of the numbers of qubits for each model. We see the

best performance of our GPS model compared to the other

models.

Figure 7. Benchmark between MTZ and GPS model based

on the number of qubits. We can appreciate that for 30 cities,

GPS model needs 2700 qubits while the MTZ 4458.

The results obtained from our VRP formulation and

all the experiments carried out maintain the number of

variables QN2and allow us to oﬀer the community new

formulations that minimize the time it takes for vehicles

to travel.

Future work will apply the ideas developed in the

QUBO model of these problems to similar ones. In

particular, we will look for other variants of the TSP to

use the modelling of this that we have carried out.

Compliance with Ethics Guidelines

Funding: This research received no external funding.

Institutional review: This article does not contain any

studies with human or animal subjects.

Informed consent: Informed consent was obtained from

all individual participants included in the study.

Data availability: Data sharing not applicable. No new

data were created or analyzed in this study. Data sharing

is not applicable to this article.

APPENDIX

A. TSP formulation N2.

There is a TSP modeling that requires N2variables,

where these are the following:

xi,t such as i∈ {0, ..., N +1}and t∈ {0, ..., N +1}.(36)

Under this formulation xi,t = 1 denotes that the city iis

reached at position t. The distance calculation function

with this formulation is as follows

N+1

X

i=0

N+1

X

j=0

N

X

t=0

di,j xi,txj,t+1 ,(37)

where di,j represents the distance between the node iand

the node j. This expression has the problem that the

distance formulation has terms of degree two and when

trying to generalize this idea to other types of problems

such as the VRP it will become a 4 degree constraint

making use of a large number of auxiliary variables to

convert it to QUBO type format.

B. Improved model 3N2Q

In the previous modelling, we can improve the number

of variables used from 5N2Qto 3N2Qsince certain vari-

ables are redundant. Let us see how we can do this. Let

us take the set of variables as follows:

xi,j,r,q with i<j∈ {0, .., N +1}, r ∈ {0,1,2}and q∈ {1, .., Q}

In all the modelling, the variables xi,j,r such that i=j

are not considered. Let us analyze the interpretation of

each variable. For each edge (i, j), diﬀerent cases de-

pending on whether a vehicle passes through both cities,

which city is visited before the other and whether the

edge is travelled or not.

•xi,j,0,q = 1 means that the city iis reached earlier

than the jand the edge (i, j) is not travelled.

•xi,j,1,q = 1 means that the vehicle qtravels the

cities iand j, it reaches the city ibefore the jand

it travels the edge (i, j).

•xi,j,2,q = 1 means that the city jis reached earlier

than the iand the edge (j, i) is not travelled.

This new simpliﬁcation keeps constraints (20), (22),

(24), (25), (27) and (32) deﬁned in the same way as the

ﬁrst proposal of the VRP formulation, so we will only

focus on the changes of the remaining constraints:

•Constraint 1: For each i, j, q, one and only one of

the possibilities must be met for r, so:

For all i, j, q:

2

X

r=0

xi,j,r,q = 1,(38)

11

•Constraint 6: That the city iis reached before the

city jdoes not depend on each vehicle. Therefore,

for all the vehicles that either arrive at city iearlier

than j, or arrive at city jearlier than i. Introducing

the auxiliary variables ai,j, we have the following

constraint. For all i, j ∈ {1, ..., N}:

Q

X

q=1

xi,j,0,q +xi,j,1,q =ai,j Q. (39)

•Constraint 8: It must be fulﬁlled that either the

vehicle pass through the city ibefore the jor ar-

rive before to the city jthan the i. Therefore,

it must be veriﬁed that, for i∈ {0, ..., N},j∈

{1, ..., N }and q∈ {1, ..., Q}:

xi,j,0,q +xi,j,1,q = 1 −(xj,i,0,q +xj,i,1,q ).(40)

•Constraint 9: If the city iis reached before jand

the city jis reached before the city k, then the city

imust be reached before the city k. This condition

will prevent the vehicle from returning to a city it

has already passed through and therefore prevents

a cycle from forming.

λ

N

X

i=1

N

X

j=1

N

X

k=1

(ai,j aj,k −ai,j ai,k −aj,kai,k +a2

i,k),(41)

X. RESTRICTION PENALTY

Let us analyze the system that must be solved

to build the penalty function from the equation

(17). Our penalty function P(ai,j , aj,k, ai,k ) must

satisfy that P(0,0,1) = 1, P(1,1,0) = 1 and

P(ai,j , aj,k, ai,k ) = 0 for the rest of the cases. Let

us call the variables ai,j =x,aj,k =y,ai,k =z

to simplify the notation. Then, we arrive at the

quadratic function P, as is shown as follows:

P(x, y, z) = c1x2+c2xy +c3xz +c4y2+c5yz +c6z2

Imposing the previous restrictions, we have the fol-

lowing system of equations.

–P(0,0,1) = 1 So that c6= 1.

–P(0,1,0) = 0 So that c4= 0.

–P(0,1,1) = 0 So that c5+c6= 1 ⇒c5=−1.

–P(1,0,0) = 0 So that c1= 0.

–P(1,0,1) = 0 So that c1+c3+c6= 0 ⇒c3=

−1

–P(1,1,0) = 1 So that c2= 1.

So far, we have a system of 6 equations with

six certain compatible unknowns. First, how-

ever, an additional restriction must be veri-

ﬁed. Let us verify if it is met.

–P(1,1,1) = 0. P6

i=1 ci= 1 −1−1 + 1 = 0.

So that indeed all the requirements are met.

We then have that the following function which is

a penalty function for the constraint (17).

P(ai,j , aj,k, ai,k ) = ai,j aj,k −ai,j ai,k −aj,k ai,k +a2

i,k

12

[1] P. Toth and D. Vigo, The vehicle routing problem (SIAM,

2002).

[2] P. Toth and D. Vigo, Models, relaxations and exact ap-

proaches for the capacitated vehicle routing problem,

Discrete Applied Mathematics 123, 487 (2002).

[3] T. K. Ralphs, L. Kopman, W. R. Pulleyblank, and L. E.

Trotter, On the capacitated vehicle routing problem,

Mathematical programming 94, 343 (2003).

[4] P. Atchade-Adelomou, G. Alonso-Linaje, J. Albo-

Canals, and D. Casado-Fauli, qrobot: A quantum com-

puting approach in mobile robot order picking and

batching problem solver optimization, Algorithms 14,

10.3390/a14070194 (2021).

[5] C. E. Miller, A. W. Tucker, and R. A. Zemlin, Inte-

ger programming formulation of traveling salesman prob-

lems, Journal of the ACM (JACM) 7, 326 (1960).

[6] O. Boruvka, On a minimal problem, Pr´ace Moravsk´e Pri-

dovedeck´e Spolecnosti 3, 37 (1926).

[7] O. Boruvka, Prıspevek k reˇsenı ot´azky ekonomick´e stavby

elektrovodnıch sıtı (contribution to the solution of a prob-

lem of economical construction of electrical networks),

Elektronick`y obzor 15, 153 (1926).

[8] J. B. Kruskal, On the shortest spanning subtree of a

graph and the traveling salesman problem, Proceedings

of the American Mathematical society 7, 48 (1956).

[9] M. Bellmore and G. L. Nemhauser, The traveling sales-

man problem: A survey, Operations Research 16, 538

(1968).

[10] J. K. Lenstra and A. H. G. R. Kan, Some simple applica-

tions of the travelling salesman problem, Journal of the

Operational Research Society 26, 717 (1975).

[11] A. P. Adelomou, E. G. Rib´e, and X. V. Cardona, For-

mulation of the social workers’ problem in quadratic un-

constrained binary optimization form and solve it on a

quantum computer, Journal of Computer and Commu-

nications 8, 44 (2020).

[12] J. Y. Lee, S.-Y. Shin, T. H. Park, and B.-T. Zhang, Solv-

ing traveling salesman problems with DNA molecules en-

coding numerical values, Biosystems 78, 39 (2004).

[13] P. Ball, DNA computer helps travelling salesman, Nature

10.1038/news000113-10 (2000).

[14] G. Pataki, Teaching integer programming formulations

using the traveling salesman problem, SIAM review 45,

116 (2003).

[15] R. Martoˇn´ak, G. E. Santoro, and E. Tosatti, Quantum

annealing of the traveling-salesman problem, Physical

Review E 70, 057701 (2004).

[16] R. H. Warren, Adapting the traveling salesman problem

to an adiabatic quantum computer, Quantum informa-

tion processing 12, 1781 (2013).

[17] R. H. Warren, Small traveling salesman problems, Jour-

nal of Advances in Applied Mathematics 2(2017).

[18] F. Greco, Traveling salesman problem (BoD–Books on

Demand, 2008).

[19] J. Wang, Primal and dual assignment networks, IEEE

Transactions on Neural Networks 8, 784 (1997).

[20] K.-S. Leung, H.-D. Jin, and Z.-B. Xu, An expanding

self-organizing neural network for the traveling salesman

problem, Neurocomputing 62, 267 (2004).

[21] E. Cochrane and J. E. Beasley, The co-adaptive neural

network approach to the euclidean travelling salesman

problem, Neural Networks 16, 1499 (2003).

[22] G.-y. Liu, Y. He, Y. Fang, and Y. Qiu, A novel adap-

tive search strategy of intensiﬁcation and diversiﬁcation

in tabu search, in International Conference on Neural

Networks and Signal Processing, 2003. Proceedings of the

2003, Vol. 1 (IEEE, 2003) pp. 428–431.

[23] S. Feld, C. Roch, T. Gabor, C. Seidel, F. Neukart, I. Gal-

ter, W. Mauerer, and C. Linnhoﬀ-Popien, A hybrid solu-

tion method for the capacitated vehicle routing problem

using a quantum annealer, Frontiers in ICT 6, 13 (2019).

[24] H. Irie, G. Wongpaisarnsin, M. Terabe, A. Miki, and

S. Taguchi, Quantum annealing of vehicle routing prob-

lem with time, state and capacity, in International Work-

shop on Quantum Technology and Optimization Problems

(Springer, 2019) pp. 145–156.

[25] F. Focacci, A. Lodi, and M. Milano, A hybrid exact al-

gorithm for the tsptw, INFORMS journal on Computing

14, 403 (2002).

[26] S. Edelkamp, M. Gath, T. Cazenave, and F. Teytaud, Al-

gorithm and knowledge engineering for the tsptw prob-

lem, in 2013 IEEE Symposium on Computational Intel-

ligence in Scheduling (CISched) (IEEE, 2013) pp. 44–51.

[27] P. Atchade-Adelomou, E. Golobardes-Rib´e, and

X. Vilas´ıs-Cardona, Using the variational-quantum-

eigensolver (VQE) to create an intelligent social workers

schedule problem solver, in Lecture Notes in Computer

Science (Springer International Publishing, 2020) pp.

245–260.

[28] P. Atchade-Adelomou, E. Golobardes-Ribe, and

X. Vilasis-Cardona, Using the parameterized quantum

circuit combined with variational-quantum-eigensolver

(vqe) to create an intelligent social workers’ schedule

problem solver (2020), arXiv:2010.05863 [quant-ph].

[29] D. Applegate and W. Cook, A computational study of the

job-shop scheduling problem, ORSA Journal on comput-

ing 3, 149 (1991).

[30] C. Papalitsas, T. Andronikos, K. Giannakis,

G. Theocharopoulou, and S. Fanarioti, A qubo model

for the traveling salesman problem with time windows,

Algorithms 12, 224 (2019).

[31] M. Born and V. Fock, Beweis des adiabatensatzes,

Zeitschrift f¨ur Physik 51, 165 (1928).

[32] E. Farhi, J. Goldstone, S. Gutmann, and M. Sipser,

Quantum computation by adiabatic evolution, arXiv

preprint quant-ph/0001106 (2000).

[33] C. C. McGeoch, Adiabatic quantum computation and

quantum annealing: Theory and practice, Synthesis Lec-

tures on Quantum Computing 5, 1 (2014).

[34] A. Lucas, Ising formulations of many np problems, Fron-

tiers in physics 2, 5 (2014).