## 5 Methodology
### Development of the Two-Phase Heuristic
begin\(U\longleftarrow\) get dealerships from demand\(CT\longleftarrow\) get current timewhile\(M>0\)and\(K>0\)do  Initialization a new route \(R_{k}\)\(W_{t}\longleftarrow\) get capacity from \(k\)\(A_{k}\longleftarrow\) generate a new arrangement with capacity \(W_{t}\)\(u\longleftarrow\) get \(first\) dealership to visit from \(U\)while\(W_{t}>0\)and\(u^{*}\in U\)do while\(m_{u}\in M\)do if\(Allocation(m_{u},A_{k})\)then  Update demand \(M\), capacity \(W_{t}\) and route \(R_{k}\) end if \(u^{*}\longleftarrow\) get next dealership\((R_{k},CT)\) to visit and update \(U\) end if if\(K\leq 0\)and\(M>0\)then  Get remaining from \(M\) end if  Add to \(Solution(R_{k},A_{k})\), \(k=k+1\) end if  end while
```  
**Algorithm 1**Two-phase heuristic  
The first loop is the demand \(M\) and the auto-carriers \(K\), while there are vehicles to load and auto-carriers, a new route \(R_{k}\) is initialized with time and distance counters, the auto-carrier \(k\in K\) is obtained, assigns \(W_{t}\) according to \(k\), which is the vehicle load capacity of \(k\) for its type \(t\), then a new accommodation \(A_{k}\) based on capacity \(W_{t}\) is generated. After determining the _first dealership_ to visit \(u\), i.e., Step 0 of the heuristic, this is shown in line 8 of Algorithm 1. With the first dealership \(u\) to be selected, start the loop of the auto-carrier \(k\) with capacity \(W_{t}\) and loop of the existing demand \(M\) of the dealership \(u\), carrying out the loading of the vehicle \(m_{u}\) in the auto-carrier \(k\) in the second phase of the algorithm, _the allocation_, this is shown in line 11 of Algorithm 1. The allocation algorithm receives as parameters the vector \(A_{k}\) of the current arrangement and the vehicle \(m_{u}\) to be loaded (see Algorithm 2). If the load is successful, then update the demand \(M\) (eliminating \(m_{u}\)), the number of available spaces of the capacity \(W_{t}\) and the route \(R_{k}\). In the case that the auto-carrier \(k\) is not filled or the vehicle \(m_{u}\) does not comply with the assignment restrictions, obtain the next vehicle \(m_{u}+1\) to load, until the auto-carrier \(k\) is full. ```
Data:\(m_{u}\) (vehicle), \(A_{k}\) (arrangement). Output: The \(A_{k}\) arrangement with \(m_{u}\) assigned if it is feasible. 1 begin
2\(W_{t}\longleftarrow\) size of \(A_{k}\)
3\(level\longleftarrow\)\(\frac{W_{t}}{2}\)
4 for\(A_{k_{i}}\in A_{k}\)do
5 if\(h_{m_{u}}>2.5\) and \(i<level\) and paritythen
6 if\(A_{k_{i}}\in A_{k}\) and \(A_{k_{i+1}}\in A_{k}\) and \(A_{k_{i+level}}\in A_{k}\)then
7 Allocate \(m_{u}\) vehicle to spaces \(A_{k_{i}}\), \(A_{k_{i+1}}\) and \(A_{k_{i+level}}\)
8 else
9 if\(A_{k_{i}}\in A_{k}\) and \(A_{k_{i+(level-1)}}\in A_{k}\) and \(A_{k_{i+level}}\in A_{k}\)then
10 Allocate \(m_{u}\) vehicle to spaces \(A_{k_{i}}\), \(A_{k_{i+(level-1)}}\) and \(A_{k_{i+level}}\)
11 end if
12
13 end if
14
15 else
16 if\(A_{k_{i}}\in A_{k}\) and \(A_{k_{i+1}}\in A_{k}\) and \(A_{k_{i+(level+1)}}\in A_{k}\)then
17 Allocate \(m_{u}\) vehicle to spaces \(A_{k_{i}}\), \(A_{k_{i+1}}\) and \(A_{k_{i+(level+1)}}\)
18 else
19 if\(A_{k_{i}}\in A_{k}\) and \(A_{k_{i+level}}\in A_{k}\) and \(A_{k_{i+(level+1)}}\in A_{k}\)then
20 Allocate \(m_{u}\) vehicle to spaces \(A_{k_{i}}\), \(A_{k_{i+level}}\) and \(A_{k_{i+(level+1)}}\)
21 end if
22
23 end if
24
25 end if
26 if\(h_{m_{u}}>1.8\) and \(h_{m_{u}}<2.5\) and \(i>level\) and \(A_{k_{i}}\in A_{k}\)then
27 Allocate \(m_{u}\) vehicle in space \(A_{k_{i}}\)
28 end if
29 return\(A_{k}\)
30 end if
```  
**Algorithm 2**Allocation  
If the auto-carrier \(k\) still has available spaces \(W_{t}\), but the demand of the dealership \(u\) does not comply with the assignment restrictions, update accumulators of time and distance to obtain the next dealership \(u^{*}\) to visit, this is Step 1 of the heuristic and is observed on line 15 of Algorithm 1. To obtain \(u^{*}\) the route \(R_{k}\) built so far and the current time \(CT\) are received as parameters, finally enter the demand loop \(M\) of the dealership \(u^{*}\).