**Appendix A**

*Appendix A.1. TSP Formulation N*<sup>2</sup>

> There is a TSP model that requires *N*<sup>2</sup> variables, where these are the following:

$$\mathbf{x}\_{i,t} \text{ such as } i \in \{0, \dots, N+1\} \text{ and } t \in \{0, \dots, N+1\}. \tag{A1}$$

Under this formulation *xi*,*<sup>t</sup>* = 1 denotes that the city *i* is reached at position *t*. The distance calculation function with this formulation is as follows

$$\sum\_{i=0}^{N+1} \sum\_{j=0}^{N+1} \sum\_{t=0}^{N} d\_{i,j} x\_{i,t} x\_{j,t+1,t} \tag{A2}$$

where *di*,*<sup>j</sup>* represents the distance between the node *i* and 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.

*Appendix A.2. Improved Model* 3*N*<sup>2</sup>*Q*

In the previous modelling, we can improve the number of variables used from 5*N*<sup>2</sup>*Q* to 3*N*<sup>2</sup>*Q* since certain variables are redundant. Let us see how we can do this. Let us take the set of variables

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

In all of the modelling, the variables *xi*,*j*,*<sup>r</sup>* such that *i* = *j* are not considered. Let us analyse the interpretation of each variable. For each edge (*i*, *j*), different cases depend on whether a vehicle passes through both cities, which city is visited before the other and whether the edge is travelled or not.


This new simplification keeps constraints (16), (18), (20), (21), (23) and (28) defined in the same way as the first 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:

$$\text{For all } i, j, q; \sum\_{r=0}^{2} x\_{i,j,r,q} = 1,\tag{A3}$$

• Constraint 6: That the city *i* is reached before the city *j* does not depend on each vehicle. Therefore, for all the vehicles that either arrive at city *i* earlier than *j*, or arrive at city *j* earlier than *i*. Introducing the auxiliary variables *ai*,*j*, we have the following constraint. For all *i*, *j* ∈ {1, . . . , *<sup>N</sup>*}:

$$\sum\_{q=1}^{Q} \mathbf{x}\_{i,j,0,q} + \mathbf{x}\_{i,j,1,q} = a\_{i,j} \mathbf{Q}.\tag{A4}$$

• Constraint 8: It must be fulfilled that either the vehicle pass through the city *i* before the *j* or arrive before to the city *j* than the *i*. Therefore, it must be verified that, for *i* ∈ {0, . . . , *<sup>N</sup>*}, *j* ∈ {1, . . . , *N*} and *q* ∈ {1, . . . , *Q*}:

$$
\mathbf{x}\_{i,j,0,q} + \mathbf{x}\_{i,j,1,q} = 1 - (\mathbf{x}\_{j,i,0,q} + \mathbf{x}\_{j,i,1,q}).\tag{A5}
$$

• Constraint 9: If the city *i* is reached before *j* and the city *j* is reached before the city *k*, then the city *i* must 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.

$$\lambda \sum\_{i=1}^{N} \sum\_{j=1}^{N} \sum\_{k=1}^{N} (a\_{i,j} a\_{j,k} - a\_{i,j} a\_{i,k} - a\_{j,k} a\_{i,k} + a\_{i,k}^2) \, , \tag{A6}$$

#### **Appendix B. Restriction Penalty**

Let us analyze the system that must be solved to build the penalty function from the Equation (13). Our penalty function *<sup>P</sup>*(*ai*,*j*, *aj*,*k*, *ai*,*<sup>k</sup>*) must satisfy that *P*(0, 0, 1) = 1, *P*(1, 1, 0) = 1 and *<sup>P</sup>*(*ai*,*j*, *aj*,*k*, *ai*,*<sup>k</sup>*) = 0 for the rest of the cases. Let us call the variables

*ai*,*j* = *x*, *aj*,*<sup>k</sup>* = *y*, *ai*,*<sup>k</sup>* = *z* to simplify the notation. Then, we arrive at the quadratic function *P*, as is demonstrated in the following:

$$P(x,y,z) = c\_1x^2 + c\_2xy + c\_3xz + c\_4y^2 + c\_5yz + c\_6z^2. \tag{A7}$$

Imposing the previous restrictions, we have the following system of equations.


So far, we have a system of six equations with six certain compatible unknowns. First, however, an additional restriction must be verified. Let us verify if it is met.

$$1 - \quad P(1,1,1) = 0. \,\,\Box\_{i=1}^{6} c\_{i} = 1 - 1 - 1 + 1 = 0. \,\,\text{So that indeed all the requirements are met.} $$

We then have that the following function which is a penalty function for the constraint (13).

$$P(a\_{i,j}, a\_{j,k}, a\_{i,k}) = a\_{i,j}a\_{j,k} - a\_{i,j}a\_{i,k} - a\_{j,k}a\_{i,k} + a\_{i,k}^2\tag{A8}$$
