[
     {
          "problem": "Problem B8 involves integrating a multi-criteria decision-making approach to account for factors such as travel time, customer priority, and vehicle capacity in formulating routing solutions.",
          "algorithm": "The algorithm uses a greedy approach to iteratively select the next customer based on the lowest travel time and priority while ensuring vehicle capacity is not exceeded, forming routes until all customers are served.",
          "code": "\nfrom typing import Tuple, List\nimport numpy as np\n\ndef solve_B(input_B: Tuple[np.ndarray, np.ndarray, np.ndarray, int]) -> List[np.ndarray]:\n    customer_coords, distance_matrix, demands, capacity = input_B\n    num_customers = len(demands)\n    visited = np.zeros(num_customers, dtype=bool)\n    routes = []\n    \n    while not np.all(visited):\n        route = []\n        total_demand = 0\n        current_location = 0  # Starting from the depot\n        \n        while True:\n            next_customer = None\n            min_travel_time = np.inf\n            \n            for i in range(num_customers):\n                if not visited[i] and total_demand + demands[i] <= capacity:\n                    travel_time = distance_matrix[current_location][i]\n                    if travel_time < min_travel_time:\n                        min_travel_time = travel_time\n                        next_customer = i\n            \n            if next_customer is None:\n                break\n            \n            route.append(next_customer + 1)  # +1 to start customer IDs from 1\n            visited[next_customer] = True\n            total_demand += demands[next_customer]\n            current_location = next_customer  # Move to next customer\n        \n        routes.append(np.array(route))\n    \n    return routes\n",
          "objective": -10.93289,
          "runtime": 0.03631,
          "other_inf": null,
          "op": "i1"
     },
     {
          "problem": "Problem B9 involves studying the flow-shop scheduling problem to schedule deliveries while considering vehicle availability times to minimize delays in servicing customers.",
          "algorithm": "The algorithm uses a greedy heuristic approach to first filter the customers based on their availability and demand, then constructs routes respecting the vehicle's capacity while minimizing delays by scheduling the most urgent deliveries first.",
          "code": "import numpy as np\nfrom typing import Tuple, List\n\ndef solve_B(input_B: Tuple[np.ndarray, np.ndarray, np.ndarray, List[int], np.ndarray, int]) -> List[List[int]]:\n    depot_coords, customer_coords, distance_matrix, demands, job_availability, capacity = input_B\n    \n    n_customers = len(demands)\n    routes = []\n    visited = [False] * n_customers\n    \n    # Create a list of customers with their indices, availability, and demand\n    customers = [(i, job_availability[i], demands[i]) for i in range(n_customers) if demands[i] > 0]\n\n    # Sort customers based on availability time\n    customers.sort(key=lambda x: x[1])  # Sort by availability time\n\n    while customers:\n        route = []\n        current_capacity = capacity\n        \n        for index, availability, demand in customers:\n            if visited[index] or demand > current_capacity:\n                continue\n            \n            if len(route) == 0 or (availability <= job_availability[route[-1]]):  # Check timing constraint\n                route.append(index)\n                current_capacity -= demand\n                visited[index] = True\n        \n        if route:\n            routes.append(route)\n        # Remove serviced customers from the list\n        customers = [(i, a, d) for i, a, d in customers if not visited[i]]\n    \n    return routes\n",
          "objective": -27.04355,
          "runtime": 0.01269,
          "other_inf": null,
          "op": "i1"
     },
     {
          "problem": "Problem B8 involves integrating a multi-criteria decision-making approach to account for factors such as travel time, customer priority, and vehicle capacity in formulating routing solutions.",
          "algorithm": "The algorithm applies a greedy method to prioritize customers based on their demands and the overall travel time, incrementally building routes that respect vehicle capacity and customer priority.",
          "code": "\nfrom typing import Tuple, List\nimport numpy as np\n\ndef solve_B(input_B: Tuple[np.ndarray, np.ndarray, np.ndarray, int]) -> List[np.ndarray]:\n    customer_coords, distance_matrix, demands, capacity = input_B\n    num_customers = len(demands)\n    routes = []\n    visited = np.zeros(num_customers, dtype=bool)\n\n    def sorted_customers():\n        customer_priority = sorted(range(num_customers), key=lambda x: (demands[x], distance_matrix[0][x]), reverse=True)\n        return customer_priority\n\n    while not all(visited):\n        current_route = []\n        current_load = 0\n        customer_order = sorted_customers()\n\n        for customer in customer_order:\n            if not visited[customer] and current_load + demands[customer] <= capacity:\n                current_route.append(customer + 1)  # +1 for 1-based indexing\n                current_load += demands[customer]\n                visited[customer] = True\n        \n        if current_route:\n            routes.append(np.array(current_route))\n\n    return routes\n",
          "objective": -25.55602,
          "runtime": 0.01917,
          "other_inf": null,
          "op": "i1"
     },
     {
          "problem": "Problem B6 involves utilizing a nearest neighbor heuristic to develop initial routes, followed by a local search algorithm to refine those routes for reduced travel distance.",
          "algorithm": "The algorithm first generates initial routes using the nearest neighbor heuristic, then refines those routes using a local search optimization technique to minimize total travel distance.",
          "code": "import numpy as np\nfrom typing import Tuple, List\n\ndef solve_B(input_B: Tuple[np.ndarray, np.ndarray, np.ndarray, int]) -> List[np.ndarray]:\n    coord_matrix, distance_matrix, demands, capacity = input_B\n    num_customers = len(demands)\n    routes = []\n    \n    # Nearest Neighbor Heuristic\n    unvisited = set(range(1, num_customers + 1))\n    \n    while unvisited:\n        route = []\n        current_capacity = capacity\n        current_node = 0  # starting from the depot\n        \n        while True:\n            if current_capacity <= 0 or not unvisited:\n                break\n            \n            # Find the nearest neighbor\n            nearest = None\n            nearest_distance = float('inf')\n            for customer in unvisited:\n                if distance_matrix[current_node][customer] < nearest_distance:\n                    nearest_distance = distance_matrix[current_node][customer]\n                    nearest = customer\n            \n            # If a nearest neighbor is found and capacity allows, visit it\n            if nearest is not None and current_capacity >= demands[nearest - 1]:\n                route.append(nearest)\n                current_capacity -= demands[nearest - 1]\n                unvisited.remove(nearest)\n                current_node = nearest\n            else:\n                break\n        \n        routes.append(np.array(route))\n    \n    # Local Search Refinement (2-opt)\n    def two_opt(route):\n        best_route = route.copy()\n        improved = True\n        \n        while improved:\n            improved = False\n            for i in range(len(best_route) - 1):\n                for j in range(i + 1, len(best_route)):\n                    if j - i == 1: continue  # Skip adjacent nodes\n                    new_route = best_route[i:j + 1][::-1]\n                    candidate_route = np.concatenate([best_route[:i], new_route, best_route[j + 1:]])\n                    if calculate_distance(candidate_route) < calculate_distance(best_route):\n                        best_route = candidate_route\n                        improved = True\n        return best_route\n    \n    def calculate_distance(route):\n        total_distance = 0\n        current_node = 0  # starting from depot\n        for customer in route:\n            total_distance += distance_matrix[current_node][customer]\n            current_node = customer\n        total_distance += distance_matrix[current_node][0]  # return to depot\n        return total_distance\n    \n    optimized_routes = [two_opt(route) for route in routes]\n    \n    return optimized_routes\n",
          "objective": -9.57157,
          "runtime": 0.15405,
          "other_inf": null,
          "op": "i1"
     },
     {
          "problem": "Problem B9 involves studying the flow-shop scheduling problem to schedule deliveries while considering vehicle availability times to minimize delays in servicing customers.",
          "algorithm": "The algorithm employs a greedy approach that prioritizes scheduling deliveries to customers based on their availability and demand while considering vehicle capacity to minimize delay.",
          "code": "\nfrom typing import Tuple, List\nimport numpy as np\n\ndef solve_B(input_B: Tuple[np.ndarray, np.ndarray, np.ndarray, List[int], np.ndarray, int]) -> List[List[int]]:\n    depot_coords, customer_coords, distance_matrix, demands, job_availability, capacity = input_B\n    num_customers = len(demands)\n    routes = []\n    unvisited = list(range(num_customers))\n    \n    while unvisited:\n        route = []\n        current_capacity = capacity\n        current_time = 0\n        current_location = 0  # Starting at depot\n        \n        while True:\n            available_customers = [\n                i for i in unvisited \n                if demands[i] <= current_capacity and\n                job_availability[i] <= current_time + distance_matrix[current_location, i]\n            ]\n            \n            if not available_customers:\n                break\n            \n            # Select the customer based on the minimum distance (greedy choice)\n            next_customer = min(\n                available_customers, \n                key=lambda i: distance_matrix[current_location, i]\n            )\n            \n            # Update the route and parameters\n            route.append(next_customer)\n            unvisited.remove(next_customer)\n            current_capacity -= demands[next_customer]\n            travel_time = distance_matrix[current_location, next_customer]\n            current_time += travel_time\n            current_location = next_customer\n        \n        if route:\n            routes.append(route)\n\n    return routes\n",
          "objective": -10.93412,
          "runtime": 0.03497,
          "other_inf": null,
          "op": "i1"
     },
     {
          "problem": "Problem B8 involves integrating a multi-criteria decision-making approach to account for factors such as travel time, customer priority, and vehicle capacity in formulating routing solutions.",
          "algorithm": "The algorithm employs a greedy heuristic that prioritizes customers based on their demand and travel distance, iteratively assigning them to routes while respecting vehicle capacity constraints.",
          "code": "\nfrom typing import Tuple, List\nimport numpy as np\n\ndef solve_B(input_B: Tuple[np.ndarray, np.ndarray, np.ndarray, int]) -> List[np.ndarray]:\n    customer_coords, distance_matrix, demands, capacity = input_B\n    routes = []\n    visited = np.zeros(len(demands), dtype=bool)\n\n    for start in range(len(demands)):\n        if visited[start]:\n            continue\n        \n        current_route = [start + 1]  # Start from customer (1 to N)\n        current_load = demands[start]\n        visited[start] = True\n        \n        while current_load < capacity:\n            best_next_customer = -1\n            best_distance = float('inf')\n\n            for next_customer in range(len(demands)):\n                if not visited[next_customer] and current_load + demands[next_customer] <= capacity:\n                    if distance_matrix[start, next_customer] < best_distance:\n                        best_distance = distance_matrix[start, next_customer]\n                        best_next_customer = next_customer\n\n            if best_next_customer != -1:\n                current_route.append(best_next_customer + 1)  # Use 1-based index\n                current_load += demands[best_next_customer]\n                visited[best_next_customer] = True\n                start = best_next_customer\n            else:\n                break\n\n        routes.append(np.array(current_route))\n    \n    return routes\n",
          "objective": -11.4304,
          "runtime": 0.03114,
          "other_inf": null,
          "op": "i1"
     },
     {
          "problem": "Problem B6 involves utilizing a nearest neighbor heuristic to develop initial routes, followed by a local search algorithm to refine those routes for reduced travel distance.",
          "algorithm": "The new algorithm employs a random selection of customers while prioritizing those with the lowest travel time and ensuring vehicle capacity is not exceeded, iteratively forming routes until all customers are served.",
          "code": "\nfrom typing import Tuple, List\nimport numpy as np\n\ndef solve_B(input_B: Tuple[np.ndarray, np.ndarray, np.ndarray, int]) -> List[np.ndarray]:\n    customer_coords, distance_matrix, demands, capacity = input_B\n    num_customers = len(demands)\n    visited = np.zeros(num_customers, dtype=bool)\n    routes = []\n    \n    while not np.all(visited):\n        route = []\n        total_demand = 0\n        current_location = 0  # Starting from the depot\n        \n        customer_indices = np.arange(num_customers)\n        np.random.shuffle(customer_indices)  # Shuffle indices for random selection\n        \n        for i in customer_indices:\n            if not visited[i] and total_demand + demands[i] <= capacity:\n                route.append(i + 1)  # +1 to start customer IDs from 1\n                visited[i] = True\n                total_demand += demands[i]\n                current_location = i  # Move to the newly added customer\n        \n        routes.append(np.array(route))\n    \n    return routes\n",
          "objective": -27.1381,
          "runtime": 0.01621,
          "other_inf": null,
          "op": "m1"
     },
     {
          "problem": "Problem B6 involves utilizing a nearest neighbor heuristic to develop initial routes, followed by a local search algorithm to refine those routes for reduced travel distance.",
          "algorithm": "The new algorithm employs a greedy strategy where customers are visited in the order of their proximity to the last added customer, ensuring capacity constraints are respected.",
          "code": "\nfrom typing import Tuple, List\nimport numpy as np\nimport random\n\ndef solve_B(input_B: Tuple[np.ndarray, np.ndarray, np.ndarray, int]) -> List[np.ndarray]:\n    '''{The new algorithm employs a greedy strategy where customers are visited in the order of their proximity to the last added customer, ensuring capacity constraints are respected.}'''\n    \n    customer_coords, distance_matrix, demands, capacity = input_B\n    num_customers = len(demands)\n    routes = []\n    visited = np.zeros(num_customers, dtype=bool)\n\n    while not all(visited):\n        current_route = []\n        current_load = 0\n        current_customer = -1  # Start from depot (not a customer)\n\n        while True:\n            available_customers = [i for i in range(num_customers) if not visited[i] and current_load + demands[i] <= capacity]\n\n            if not available_customers:\n                break\n\n            # Select the nearest available customer to the current one\n            if current_customer == -1:\n                next_customer = available_customers[random.choice(range(len(available_customers)))]\n            else:\n                next_customer = min(available_customers, key=lambda x: distance_matrix[current_customer + 1][x + 1])\n\n            current_route.append(next_customer + 1)  # +1 for 1-based indexing\n            current_load += demands[next_customer]\n            visited[next_customer] = True\n            current_customer = next_customer\n\n        if current_route:\n            routes.append(np.array(current_route))\n\n    return routes\n",
          "objective": -11.36184,
          "runtime": 0.03503,
          "other_inf": null,
          "op": "m1"
     },
     {
          "problem": "Problem B9 involves studying the flow-shop scheduling problem to schedule deliveries while considering vehicle availability times to minimize delays in servicing customers.",
          "algorithm": "The algorithm employs a greedy approach to iteratively select the next customer that can be serviced without exceeding vehicle capacity and availability times, creating routes until all customers are scheduled.",
          "code": "\nfrom typing import Tuple, List\nimport numpy as np\n\ndef solve_B(input_B: Tuple[np.ndarray, np.ndarray, np.ndarray, List[int], np.ndarray, int]) -> List[List[int]]:\n    depot_coords, customer_coords, distance_matrix, demands, job_availability, capacity = input_B\n    num_customers = len(demands)\n    visited = [False] * num_customers\n    routes = []\n    \n    def create_route(start_customer):\n        route = [start_customer]\n        total_demand = demands[start_customer]\n        current_time = job_availability[start_customer]\n        \n        for _ in range(num_customers - 1):  # as one customer is already in route\n            next_customer = None\n            next_time = float('inf')\n            \n            for j in range(num_customers):\n                if not visited[j] and total_demand + demands[j] <= capacity:\n                    arrival_time = current_time + distance_matrix[start_customer][j]\n                    if arrival_time >= job_availability[j] and arrival_time < next_time:\n                        next_customer = j\n                        next_time = arrival_time\n            \n            if next_customer is None:\n                break\n            \n            route.append(next_customer)\n            visited[next_customer] = True\n            total_demand += demands[next_customer]\n            current_time = next_time\n            start_customer = next_customer\n        \n        return route\n    \n    for customer in range(num_customers):\n        if not visited[customer]:\n            visited[customer] = True\n            route = create_route(customer)\n            routes.append(route)\n    \n    return routes\n",
          "objective": -11.32073,
          "runtime": 0.03556,
          "other_inf": null,
          "op": "i1"
     },
     {
          "problem": "Problem B6 involves utilizing a nearest neighbor heuristic to develop initial routes, followed by a local search algorithm to refine those routes for reduced travel distance.",
          "algorithm": "This algorithm generates initial routes using a random starting customer followed by a nearest neighbor approach to build routes, then refines those routes using a local search optimization technique.",
          "code": "import numpy as np\nfrom typing import Tuple, List\n\ndef solve_B(input_B: Tuple[np.ndarray, np.ndarray, np.ndarray, int]) -> List[np.ndarray]:\n    '''{This algorithm generates initial routes using a random starting customer followed by a nearest neighbor approach to build routes, then refines those routes using a local search optimization technique.}'''\n    \n    coord_matrix, distance_matrix, demands, capacity = input_B\n    num_customers = len(demands)\n    routes = []\n    \n    # Random Starting Point for Nearest Neighbor Heuristic\n    unvisited = set(range(1, num_customers + 1))\n    \n    while unvisited:\n        route = []\n        current_capacity = capacity\n        current_node = np.random.choice(list(unvisited))  # start from a random unvisited customer\n        \n        while True:\n            if current_capacity <= 0 or not unvisited:\n                break\n            \n            # Find the nearest neighbor\n            nearest = None\n            nearest_distance = float('inf')\n            for customer in unvisited:\n                if distance_matrix[current_node][customer] < nearest_distance:\n                    nearest_distance = distance_matrix[current_node][customer]\n                    nearest = customer\n            \n            # If a nearest neighbor is found and capacity allows, visit it\n            if nearest is not None and current_capacity >= demands[nearest - 1]:\n                route.append(nearest)\n                current_capacity -= demands[nearest - 1]\n                unvisited.remove(nearest)\n                current_node = nearest\n            else:\n                break\n        \n        routes.append(np.array(route))\n    \n    # Local Search Refinement (3-opt)\n    def three_opt(route):\n        best_route = route.copy()\n        improved = True\n        \n        while improved:\n            improved = False\n            for i in range(len(best_route) - 2):\n                for j in range(i + 1, len(best_route)):\n                    for k in range(j + 1, len(best_route) + 1):\n                        if k - j == 1 or j - i == 1: continue  # Skip adjacent nodes\n                        new_route = np.concatenate([best_route[:i], best_route[i:j][::-1], best_route[j:k][::-1], best_route[k:]])\n                        if calculate_distance(new_route) < calculate_distance(best_route):\n                            best_route = new_route\n                            improved = True\n        return best_route\n    \n    def calculate_distance(route):\n        total_distance = 0\n        current_node = 0  # starting from depot\n        for customer in route:\n            total_distance += distance_matrix[current_node][customer]\n            current_node = customer\n        total_distance += distance_matrix[current_node][0]  # return to depot\n        return total_distance\n    \n    optimized_routes = [three_opt(route) for route in routes if len(route) > 0]\n    \n    return optimized_routes\n",
          "objective": -9.92784,
          "runtime": 0.31126,
          "other_inf": null,
          "op": "m1"
     },
     {
          "problem": "Problem B6 involves utilizing a nearest neighbor heuristic to develop initial routes, followed by a local search algorithm to refine those routes for reduced travel distance.",
          "algorithm": "The new algorithm utilizes a randomized approach where customers are randomly selected and added to a route if they fit within the remaining capacity, followed by a sorting phase to optimize the route distance.",
          "code": "\nfrom typing import Tuple, List\nimport numpy as np\nimport random\n\ndef solve_B(input_B: Tuple[np.ndarray, np.ndarray, np.ndarray, int]) -> List[np.ndarray]:\n    customer_coords, distance_matrix, demands, capacity = input_B\n    num_customers = len(demands)\n    routes = []\n    visited = np.zeros(num_customers, dtype=bool)\n\n    while not all(visited):\n        current_route = []\n        current_load = 0\n        available_customers = [i for i in range(num_customers) if not visited[i]]\n        random.shuffle(available_customers)\n\n        for customer in available_customers:\n            if current_load + demands[customer] <= capacity:\n                current_route.append(customer + 1)  # +1 for 1-based indexing\n                current_load += demands[customer]\n                visited[customer] = True\n        \n        if current_route:\n            current_route = sorted(current_route)  # Optimize route by sorting\n            routes.append(np.array(current_route))\n\n    return routes\n",
          "objective": -27.20339,
          "runtime": 0.01892,
          "other_inf": null,
          "op": "e2"
     },
     {
          "problem": "Problem B6 involves utilizing a nearest neighbor heuristic to develop initial routes, followed by a local search algorithm to refine those routes for reduced travel distance.",
          "algorithm": "The new algorithm employs a randomized approach that selects a subset of unvisited customers and constructs a route based on the nearest neighbor strategy, ensuring demands do not exceed vehicle capacity.",
          "code": "\nfrom typing import Tuple, List\nimport numpy as np\nimport random\n\ndef solve_B(input_B: Tuple[np.ndarray, np.ndarray, np.ndarray, int]) -> List[np.ndarray]:\n    '''{The new algorithm employs a randomized approach that selects a subset of unvisited customers and constructs a route based on the nearest neighbor strategy, ensuring demands do not exceed vehicle capacity.}'''\n    \n    customer_coords, distance_matrix, demands, capacity = input_B\n    num_customers = len(demands)\n    routes = []\n    visited = np.zeros(num_customers, dtype=bool)\n\n    while not all(visited):\n        current_route = []\n        current_load = 0\n\n        # Randomly select a starting customer from the unvisited ones\n        available_starting_customers = [i for i in range(num_customers) if not visited[i]]\n        if not available_starting_customers:\n            break\n        \n        start_customer = random.choice(available_starting_customers)\n        current_route.append(start_customer + 1)  # +1 for 1-based indexing\n        current_load += demands[start_customer]\n        visited[start_customer] = True\n\n        # Route construction based on nearest neighbor\n        current_customer = start_customer\n\n        while True:\n            available_customers = [i for i in range(num_customers) if not visited[i] and current_load + demands[i] <= capacity]\n\n            if not available_customers:\n                break\n\n            next_customer = min(available_customers, key=lambda x: distance_matrix[current_customer + 1][x + 1])\n\n            current_route.append(next_customer + 1)  # +1 for 1-based indexing\n            current_load += demands[next_customer]\n            visited[next_customer] = True\n            current_customer = next_customer\n\n        if current_route:\n            routes.append(np.array(current_route))\n\n    return routes\n",
          "objective": -11.50202,
          "runtime": 0.03547,
          "other_inf": null,
          "op": "e2"
     },
     {
          "problem": "Problem B6 involves utilizing a nearest neighbor heuristic to develop initial routes, followed by a local search algorithm to refine those routes for reduced travel distance.",
          "algorithm": "The new algorithm utilizes a modified greedy approach that prioritizes customers based on their distance from the depot, while still considering their demand, incrementally forming routes until vehicle capacity is reached.",
          "code": "\nfrom typing import Tuple, List\nimport numpy as np\n\ndef solve_B(input_B: Tuple[np.ndarray, np.ndarray, np.ndarray, int]) -> List[np.ndarray]:\n    customer_coords, distance_matrix, demands, capacity = input_B\n    num_customers = len(demands)\n    routes = []\n    visited = np.zeros(num_customers, dtype=bool)\n\n    def sorted_customers():\n        customer_priority = sorted(range(num_customers), key=lambda x: distance_matrix[0][x])\n        return customer_priority\n\n    while not all(visited):\n        current_route = []\n        current_load = 0\n        customer_order = sorted_customers()\n\n        for customer in customer_order:\n            if not visited[customer] and current_load + demands[customer] <= capacity:\n                current_route.append(customer + 1)  # +1 for 1-based indexing\n                current_load += demands[customer]\n                visited[customer] = True\n        \n        if current_route:\n            routes.append(np.array(current_route))\n\n    return routes\n",
          "objective": -27.20728,
          "runtime": 0.01909,
          "other_inf": null,
          "op": "m1"
     },
     {
          "problem": "Problem B6 involves utilizing a nearest neighbor heuristic to develop initial routes, followed by a local search algorithm to refine those routes for reduced travel distance.",
          "algorithm": "The algorithm filters customers based on their demands and starts from the depot, constructing routes by selecting the farthest unvisited customer within the vehicle's remaining capacity and iteratively optimizing routes by greedy selection.",
          "code": "import numpy as np\nfrom typing import Tuple, List\n\ndef solve_B(input_B: Tuple[np.ndarray, np.ndarray, np.ndarray, int]) -> List[np.ndarray]:\n    '''\n    Args:\n    input_B (Tuple[np.ndarray, np.ndarray, np.ndarray, int]): A tuple containing:\n        - coord_matrix (np.ndarray): A (1+50)x2 matrix storing the 2D coordinates.\n        - distance_matrix (np.ndarray): A (1+50)x(1+50) matrix of distances.\n        - demands (np.ndarray): An array of customer demands, excluding the depot.\n        - capacity (int): The capacity of each vehicle.\n\n    Returns:\n    List[np.ndarray]: A list of Numpy 1D arrays, each storing the unique customer IDs (1-50) to visit in order.\n    '''\n\n    # {The algorithm filters customers based on their demands and starts from the depot, constructing routes by selecting the farthest unvisited customer within the vehicle's remaining capacity and iteratively optimizing routes by greedy selection.}\n    \n    coord_matrix, distance_matrix, demands, capacity = input_B\n    num_customers = len(demands)\n    routes = []\n    \n    unvisited = set(range(1, num_customers + 1))\n    \n    while unvisited:\n        route = []\n        current_capacity = capacity\n        current_node = 0  # starting from the depot\n        \n        # Select the farthest customer within capacity constraints\n        while True:\n            furthest = None\n            furthest_distance = -1\n            \n            for customer in unvisited:\n                if demands[customer - 1] <= current_capacity:\n                    if distance_matrix[current_node][customer] > furthest_distance:\n                        furthest_distance = distance_matrix[current_node][customer]\n                        furthest = customer\n            \n            if furthest is not None:\n                route.append(furthest)\n                current_capacity -= demands[furthest - 1]\n                unvisited.remove(furthest)\n                current_node = furthest\n            else:\n                break\n        \n        routes.append(np.array(route))\n    \n    return routes\n",
          "objective": -36.28688,
          "runtime": 0.02811,
          "other_inf": null,
          "op": "e2"
     },
     {
          "problem": "Problem B6 involves utilizing a nearest neighbor heuristic to develop initial routes, followed by a local search algorithm to refine those routes for reduced travel distance.",
          "algorithm": "This algorithm employs a constructive approach by randomly selecting a customer to serve next, while ensuring the vehicle's capacity constraint is met, and iteratively forming routes until all customers are visited.",
          "code": "\nfrom typing import Tuple, List\nimport numpy as np\nimport random\n\ndef solve_B(input_B: Tuple[np.ndarray, np.ndarray, np.ndarray, int]) -> List[np.ndarray]:\n    customer_coords, distance_matrix, demands, capacity = input_B\n    num_customers = len(demands)\n    visited = np.zeros(num_customers, dtype=bool)\n    routes = []\n    \n    while not np.all(visited):\n        route = []\n        total_demand = 0\n        current_location = 0  # Starting from the depot\n        \n        while True:\n            available_customers = [i for i in range(num_customers) if not visited[i] and total_demand + demands[i] <= capacity]\n            \n            if not available_customers:\n                break\n            \n            next_customer = random.choice(available_customers)\n            route.append(next_customer + 1)  # +1 to start customer IDs from 1\n            visited[next_customer] = True\n            total_demand += demands[next_customer]\n            current_location = next_customer  # Move to next customer\n        \n        routes.append(np.array(route))\n    \n    return routes\n",
          "objective": -27.5747,
          "runtime": 0.02742,
          "other_inf": null,
          "op": "m1"
     },
     {
          "problem": "Problem B9 involves studying the flow-shop scheduling problem to schedule deliveries while considering vehicle availability times to minimize delays in servicing customers.",
          "algorithm": "The algorithm employs a greedy approach to schedule customer deliveries by iteratively selecting the customer with the earliest availability time and sufficient demand that can be serviced without exceeding vehicle capacity.",
          "code": "\nfrom typing import Tuple, List\nimport numpy as np\n\ndef solve_B(input_B: Tuple[np.ndarray, np.ndarray, np.ndarray, List[int], np.ndarray, int]) -> List[List[int]]:\n    depot_coords, customer_coords, distance_matrix, demands, job_availability, capacity = input_B\n    n_customers = len(demands)\n    routes = []\n    visited = [False] * n_customers\n    \n    while True:\n        route = []\n        current_capacity = capacity\n        current_time = 0\n        # Start from depot (represented by index 0)\n        \n        for _ in range(n_customers):\n            best_customer = -1\n            best_availability = float('inf')\n            \n            # Find the best customer to service next\n            for j in range(n_customers):\n                if not visited[j] and demands[j] <= current_capacity:\n                    arrival_time = current_time + distance_matrix[0][j]\n                    if arrival_time >= job_availability[j] and arrival_time < best_availability:\n                        best_availability = arrival_time\n                        best_customer = j\n            \n            if best_customer == -1:  # No customer can be serviced\n                break\n            \n            # Update route and state\n            route.append(best_customer)\n            visited[best_customer] = True\n            current_capacity -= demands[best_customer]\n            current_time += distance_matrix[0][best_customer] + distance_matrix[best_customer][0]  # Round trip to depot\n            \n        if route:\n            routes.append(route)\n        else:\n            break\n\n    return routes\n",
          "objective": -26.03931,
          "runtime": 0.03772,
          "other_inf": null,
          "op": "i1"
     },
     {
          "problem": "Problem B6 involves utilizing a nearest neighbor heuristic to develop initial routes, followed by a local search algorithm to refine those routes for reduced travel distance.",
          "algorithm": "The new algorithm uses a random insertion method for generating initial routes followed by a 3-opt local search for refinement.",
          "code": "import numpy as np\nfrom typing import Tuple, List\n\ndef solve_B(input_B: Tuple[np.ndarray, np.ndarray, np.ndarray, int]) -> List[np.ndarray]:\n    ''' \n    {The new algorithm uses a random insertion method for generating initial routes followed by a 3-opt local search for refinement.}\n    '''\n    coord_matrix, distance_matrix, demands, capacity = input_B\n    num_customers = len(demands)\n    routes = []\n    \n    # Random Insertion Method\n    unvisited = set(range(1, num_customers + 1))\n    \n    while unvisited:\n        route = []\n        current_capacity = capacity\n        current_node = 0  # starting from the depot\n        \n        while current_capacity > 0 and unvisited:\n            # Randomly select an unvisited customer\n            nearest = np.random.choice(list(unvisited))\n            if current_capacity >= demands[nearest - 1]:\n                route.append(nearest)\n                current_capacity -= demands[nearest - 1]\n                unvisited.remove(nearest)\n                current_node = nearest\n            else:\n                break\n        \n        routes.append(np.array(route))\n    \n    # Local Search Refinement (3-opt)\n    def three_opt(route):\n        best_route = route.copy()\n        improved = True\n        \n        while improved:\n            improved = False\n            for i in range(len(best_route) - 1):\n                for j in range(i + 1, len(best_route)):\n                    for k in range(j + 1, len(best_route) + 1):\n                        new_routes = [\n                            np.concatenate([best_route[:i], best_route[i:j][::-1], best_route[j:k][::-1], best_route[k:]]),  # 2-opt\n                            np.concatenate([best_route[:i], best_route[i:j], best_route[j:k][::-1], best_route[k:]]),  # 3-opt\n                            np.concatenate([best_route[:i], best_route[j:k], best_route[i:j], best_route[k:]])   # another 3-opt\n                        ]\n                        for candidate_route in new_routes:\n                            if calculate_distance(candidate_route) < calculate_distance(best_route):\n                                best_route = candidate_route\n                                improved = True\n        return best_route\n    \n    def calculate_distance(route):\n        total_distance = 0\n        current_node = 0  # starting from depot\n        for customer in route:\n            total_distance += distance_matrix[current_node][customer]\n            current_node = customer\n        total_distance += distance_matrix[current_node][0]  # return to depot\n        return total_distance\n    \n    optimized_routes = [three_opt(route) for route in routes]\n    \n    return optimized_routes\n",
          "objective": -15.64629,
          "runtime": 2.16839,
          "other_inf": null,
          "op": "m1"
     },
     {
          "problem": "Problem B6 involves utilizing a nearest neighbor heuristic to develop initial routes, followed by a local search algorithm to refine those routes for reduced travel distance.",
          "algorithm": "The algorithm utilizes a selection strategy that chooses the next customer based on a combination of travel time and demand, maintaining a priority for customers with lower demand, while also ensuring vehicle capacity is not exceeded and continues until all customers are served.",
          "code": "\nfrom typing import Tuple, List\nimport numpy as np\n\ndef solve_B(input_B: Tuple[np.ndarray, np.ndarray, np.ndarray, int]) -> List[np.ndarray]:\n    ''' \n    {The algorithm utilizes a selection strategy that chooses the next customer based on a combination of travel time and demand, maintaining a priority for customers with lower demand, while also ensuring vehicle capacity is not exceeded and continues until all customers are served.}\n    '''\n    \n    customer_coords, distance_matrix, demands, capacity = input_B\n    num_customers = len(demands)\n    visited = np.zeros(num_customers, dtype=bool)\n    routes = []\n    \n    while not np.all(visited):\n        route = []\n        total_demand = 0\n        current_location = 0  # Starting from the depot\n        \n        while True:\n            next_customer = None\n            best_score = np.inf\n            \n            for i in range(num_customers):\n                if not visited[i] and total_demand + demands[i] <= capacity:\n                    travel_time = distance_matrix[current_location][i]\n                    score = travel_time + (demands[i] / capacity)  # Prioritize lower demand\n                    \n                    if score < best_score:\n                        best_score = score\n                        next_customer = i\n            \n            if next_customer is None:\n                break\n            \n            route.append(next_customer + 1)  # +1 to start customer IDs from 1\n            visited[next_customer] = True\n            total_demand += demands[next_customer]\n            current_location = next_customer  # Move to next customer\n        \n        routes.append(np.array(route))\n    \n    return routes\n",
          "objective": -26.98778,
          "runtime": 0.04035,
          "other_inf": null,
          "op": "m1"
     },
     {
          "problem": "Problem B6 involves utilizing a nearest neighbor heuristic to develop initial routes, followed by a local search algorithm to refine those routes for reduced travel distance.",
          "algorithm": "A heuristic algorithm that prioritizes visiting customers based on both travel time and demands, forming routes while utilizing the nearest unvisited customer, and returning to the depot once capacity is reached.",
          "code": "\nfrom typing import Tuple, List\nimport numpy as np\n\ndef solve_B(input_B: Tuple[np.ndarray, np.ndarray, np.ndarray, int]) -> List[np.ndarray]:\n    customer_coords, distance_matrix, demands, capacity = input_B\n    num_customers = len(demands)\n    visited = np.zeros(num_customers, dtype=bool)\n    routes = []\n    \n    while not np.all(visited):\n        route = []\n        total_demand = 0\n        current_location = 0  # Starting from the depot\n\n        while True:\n            candidates = []\n            \n            for i in range(num_customers):\n                if not visited[i] and total_demand + demands[i] <= capacity:\n                    travel_time = distance_matrix[current_location][i]\n                    candidates.append((travel_time, i))\n\n            if not candidates:\n                break\n\n            # Sort candidates based on travel time, then by demand\n            candidates.sort(key=lambda x: (x[0], demands[x[1]]))\n            next_customer = candidates[0][1]  # Choose the best candidate\n            \n            route.append(next_customer + 1)  # +1 to start customer IDs from 1\n            visited[next_customer] = True\n            total_demand += demands[next_customer]\n            current_location = next_customer  # Move to next customer\n        \n        routes.append(np.array(route))\n\n    return routes\n",
          "objective": -27.12427,
          "runtime": 0.04558,
          "other_inf": null,
          "op": "m1"
     },
     {
          "problem": "Problem B6 involves utilizing a nearest neighbor heuristic to develop initial routes, followed by a local search algorithm to refine those routes for reduced travel distance.",
          "algorithm": "The new algorithm initializes routes by serving the nearest unvisited customer based on a combination of distance and demand, ensuring the vehicle's capacity is respected.",
          "code": "\nfrom typing import Tuple, List\nimport numpy as np\n\ndef solve_B(input_B: Tuple[np.ndarray, np.ndarray, np.ndarray, int]) -> List[np.ndarray]:\n    '''\n    Args:\n    input_B (Tuple[np.ndarray, np.ndarray, np.ndarray, int]): A tuple containing:\n        - coord_matrix (np.ndarray): A (1+50)x2 matrix storing the 2D coordinates.\n        - distance_matrix (np.ndarray): A (1+50)x(1+50) matrix of distances.\n        - demands (np.ndarray): An array of customer demands, excluding the depot.\n        - capacity (int): The capacity of each vehicle.\n\n    Returns:\n    List[np.ndarray]: A list of Numpy 1D arrays, each storing the unique customer IDs (1-50) to visit in order.\n    '''\n\n    # {The new algorithm initializes routes by serving the nearest unvisited customer based on a combination of distance and demand, ensuring the vehicle's capacity is respected.}\n    \n    customer_coords, distance_matrix, demands, capacity = input_B\n    num_customers = len(demands)\n    routes = []\n    visited = np.zeros(num_customers, dtype=bool)\n\n    while not np.all(visited):\n        route = []\n        current_capacity = capacity\n        current_location = 0  # Start from depot\n\n        while True:\n            next_customer = None\n            min_cost = np.inf\n            \n            for i in range(num_customers):\n                if not visited[i] and demands[i] <= current_capacity:\n                    travel_cost = distance_matrix[current_location][i] + (demands[i] / capacity) * 100  # Penalize based on demand\n                    if travel_cost < min_cost:\n                        min_cost = travel_cost\n                        next_customer = i\n            \n            if next_customer is None:\n                break\n            \n            route.append(next_customer + 1)  # +1 for 1-based indexing\n            visited[next_customer] = True\n            current_capacity -= demands[next_customer]\n            current_location = next_customer  # Move to next customer\n        \n        if route:\n            routes.append(np.array(route))\n\n    return routes\n",
          "objective": -27.31293,
          "runtime": 0.05604,
          "other_inf": null,
          "op": "e2"
     