You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
In the 'Optimally Creating and Assigning Work Orders Based on Routes' notebook there is the following code:
assignments_to_add = []
for _, row in routes.iterrows():
worker = random.choice(workers)
workers.remove(worker)
route_stops = stops.loc[(stops['RouteName'] == row["RouteName"]) & stops['globalid'].notnull()]
for _, stop in route_stops.iterrows():
assignments_to_add.append(workforce.Assignment(
project,
assignment_type="Inspection",
location=stop["name"],
status="assigned",
worker=worker,
assigned_date=datetime.now(),
due_date=stop["DepartTime"],
geometry=stop["SHAPE"]
))
assignments = project.assignments.batch_add(assignments_to_add)
I think the line workers.remove(worker) should be removed because then in assignments_to_add.append() the worker=worker will give an error of empty list. Am I wrong?
Thanks
The text was updated successfully, but these errors were encountered:
@MVAC13 In the example, we create the same number or routes as workers.
results=arcgis.features.analysis.plan_routes(breweries_layer, # Feature Layer of Stopslen(workers), # Number of routes to generate5, # Maximum stops per routedatetime.now(), # Start time of routestart_layer, # The dictionary we created to represent the start locationstop_service_time=60, # How much time in minutes to spend at each stopmax_route_time=480, # The maximum time for the worker to complete the route
)
We then iterate over each route and select a worker, and remove that worker from the possible list of workers to chose (so that a worker only is assigned one route). Then for each stop in the route we create an assignment and assign it to the selected worker.
Then after all assignments for all routes have been created, we add them to the project.
If workers.remove(worker) was removed, a worker could be assigned to multiple routes which doesn't make sense from a practical standpoint.
Hello,
In the 'Optimally Creating and Assigning Work Orders Based on Routes' notebook there is the following code:
I think the line workers.remove(worker) should be removed because then in assignments_to_add.append() the worker=worker will give an error of empty list. Am I wrong?
Thanks
The text was updated successfully, but these errors were encountered: