# Two-Stage Metaheuristic Algorithms for Order-Batching and Routing Problems
## 4 Proposed Algorithm
### VNS Algorithm  
Compared with the SA algorithm, the VNS algorithm involves fewer parameters, thus rendering it relatively easy to control during its application. In this algorithm, a problem is divided into two stages: batching and picking. The picking distance must be recalculated with every batching substitution. Hence, the process consistently proceeds to picking insertion and swapping. Compared with swapping, insertion can be used to search for solutions in a wider range; therefore, insertion was adopted as the first neighborhood when searching neighboring picking routes. After completing the search process in the first neighborhood, we proceeded to search the second neighborhood, adopting picking swapping. The eventual export value of the picking distance obtained from a complete search of all neighborhoods represents the objective value of batching neighboring solutions. Next, we compared the search results with the current solution until all mutated neighborhoods in the batch were searched. Subsequently, we proceeded with the search process through batch swapping. Batch mutation was applied first because it can quickly consolidate orders into batches. By contrast, batch swapping is less effective in reducing the number of batches. The VNS algorithm begins to solve the problem from the initial batching solution. With each substitution of neighboring mutation or swapping solutions, the search process must proceed to the neighboring picking solutions to calculate the objective distance value. The search process begins with picking swapping, and all solutions are calculated and compared with the optimal solutions. Subsequently, the search proceeds with picking insertion; the solutions are also calculated and compared with the optimal solutions, and an objective value representing the neighboring batching solution is exported. Batching mutation is applied to ensure that the solutions change rapidly and to eliminate local solutions. In comparison, the batch-swapping procedure is less effective. The steps of the VNS algorithm are as follows:  
Step 1: First, identify the objective function value, current optimal solution, current solution, and number of iterations. Step 2: Construct the initial batching, examine whether the construction corresponds to the vehicle capacity. If the construction corresponds to the vehicle capacity, then construct an initial picking route and proceed to the next step; otherwise, repeat the construction process. Step 3: Assuming that the iteration number \(t=t+1\), use mutation and swapping procedures to improve the current batching solution. Next, examine whether the new solution corresponds to the vehicle capacity. If yes, then the new solution is adopted as a neighboring solution of this step; otherwise, return to Step 3. If the solution is improved, then update the current solution \(B\) with \(B\_neigh\), recalculate \(count=count+1\), and re-execute Step 3; otherwise, proceed to Step 4. Step 4: Adopt the insertion or swapping procedure to improve the current solution \(P\) and assess whether the new solution corresponds to the vehicle capacity. If yes, then the new solution is adopted as a neighboring solution of this step; otherwise, return to Step 4. If the solution is improved, then update the current solution \(P\) with \(P\_neigh\), recalculate \(count=count+1\), and re-execute Step 4; otherwise, proceed to Step 5. Step 5: Examine whether count = 0. If yes, then proceed to Step 6; otherwise, return to Step 3. Step 6: Conduct a perturbation process on the current solution. Specifically, S_ratio * number of orders = number of perturbations. Proceed to other neighborhoods, apply mutation and swapping procedures to improve the current batching solution, and examine whether the current solution corresponds to vehicle capacity. If yes, then the solution after the perturbation process is derived; otherwise, repeat the perturbation process. Step 7: Examine whether the terminating condition of the solution searching time has been satisfied.