## 4 Proposed Solution Method  
In this section, we introduce a two-phase algorithm to generate route solutions for the last-mile logistics problem. The two phases of our algorithm include: initialization phase and vehicle time violation improvement phase. The first phase initializes and predetermines vehicle times from the provided city coverage area. The second phase, which is the main part of our method, improves vehicle times to avoid vehicle time violations. Algorithm 1 presents the initialization phase. The algorithm starts by importing data inputs which include a vehicle-zone map and customer coordinates. Next, the algorithm creates mapping between customers and vehicle zones and pre-assigns the customers to vehicles according to the customer locations based on the vehicle-zone map information. Vehicle routes are generated by connecting depot to customers using the \"nearest customer rule\" in order to choose the next unvisited customer. This insertion method creates a route which always goes next to the unvisited customer with the shortest travel time (rather than distance). The process is iterated until all customers are visited. Finally, the algorithm calculates each vehicle time. ```
Data: Vehicle-zone map (city coverage area) Data: Customer coordinates Result: Initial solutions with vehicle routes and times
1 Import the vehicle-zone map and customer coordinates. 2 (Mapping customers to vehicle zones.) Pre-assign customers to vehicles according to the customers' locations using the vehicle-zone map. 3 (Generating routes.) For each vehicle, starting from the depot, insert the unserved customer using the \"nearest customer rule\" which goes next to the unvisited customer with shortest travel time. The insertion will be iterated until there is no unserved customer left in that vehicle. 4 (Calculating vehicle time.) For each route, calculate the vehicle time by summing vehicles' travel times and service time of all customers in that route. ```  
**Algorithm 1**Phase I: Initialization phase  
After Phase I, the travel time of some vehicles may exceed a pre-specified operating time limit required by the company. The goal of Phase II is to reduce the number of vehicles that violate the working time capacity, and as many as possible locations in the vehicle-zone map are retained. Algorithm 2 presents the steps of Phase II, which we refer to as the route adjustment algorithm. The algorithm takes the routes and vehicle times obtained from Phase I as algorithm inputs, and creates the list \(\mathcal{V}\) containing all customer locations in those vehicles with time violations. Each customer location in the list \(\mathcal{V}\) will be mapped to the nearest target vehicle with remaining working time left (also referred to as a non-violating vehicle). Customer locations in the list \(\mathcal{V}\) are then sorted in ascending order of the travel time to the corresponding target vehicle. Starting with the first location in \(\mathcal{V}\), if the insertion does not create a time violation in the target vehicle, the move is accepted, and the vehicle route time of both vehicles are updated. If, in addition, the updated route time of the vehicle (from which the customer location is removed) no longer exceeds vehicle working time limit, all customer locations in this vehicle will be removed from the list \(\mathcal{V}\). This process is sequentially iterated over all the customer locations in the list \(\mathcal{V}\) until all locations are examined or the list \(\mathcal{V}\) becomes empty. It is worth noting that since the insertibility has been checked before carrying out an insertion, the assignment will never create time violation in the target vehicle. Moreover, when the termination status for Phase II is failure, it means the travel time of some vehicles still exceed the required workinglimit, and most likely the provided time limit was too small. We will show later in Section 5.4 how to set appropriately the level of working time limit to avoid such failure status.