Skip to content

Commit

Permalink
Update python notebook and minor formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
arnabanimesh authored Jan 30, 2025
1 parent aec831e commit 81814e6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions examples/notebook/routing/cvrp_reload.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@
" for vehicle_id in range(data[\"num_vehicles\"]):\n",
" index = routing.Start(vehicle_id)\n",
" plan_output = f\"Route for vehicle {vehicle_id}:\\n\"\n",
" load_var = 0\n",
" load_value = 0\n",
" distance = 0\n",
" while not routing.IsEnd(index):\n",
" time_var = time_dimension.CumulVar(index)\n",
Expand All @@ -416,19 +416,19 @@
" # capacity dimension TransitVar is negative at reload stations during replenishment\n",
" # don't want to consider those values when calculating the total load of the route\n",
" # hence only considering the positive values\n",
" load_var += max(0,capacity_dimension.GetTransitValue(previous_index,index,vehicle_id))\n",
" load_value += max(0, capacity_dimension.GetTransitValue(previous_index, index, vehicle_id))\n",
" time_var = time_dimension.CumulVar(index)\n",
" plan_output += (\n",
" f\" {manager.IndexToNode(index)} \"\n",
" f\"Load({assignment.Min(capacity_dimension.CumulVar(index))}) \"\n",
" f\"Time({assignment.Min(time_var)},{assignment.Max(time_var)})\\n\"\n",
" )\n",
" plan_output += f\"Distance of the route: {distance}m\\n\"\n",
" plan_output += f\"Load of the route: {load_var}\\n\"\n",
" plan_output += f\"Load of the route: {load_value}\\n\"\n",
" plan_output += f\"Time of the route: {assignment.Min(time_var)}min\\n\"\n",
" print(plan_output)\n",
" total_distance += distance\n",
" total_load += load_var\n",
" total_load += load_value\n",
" total_time += assignment.Min(time_var)\n",
" print(f\"Total Distance of all routes: {total_distance}m\")\n",
" print(f\"Total Load of all routes: {total_load}\")\n",
Expand Down
2 changes: 1 addition & 1 deletion ortools/routing/samples/cvrp_reload.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def print_solution(
# capacity dimension TransitVar is negative at reload stations during replenishment
# don't want to consider those values when calculating the total load of the route
# hence only considering the positive values
load_value += max(0,capacity_dimension.GetTransitValue(previous_index,index,vehicle_id))
load_value += max(0, capacity_dimension.GetTransitValue(previous_index, index, vehicle_id))
time_var = time_dimension.CumulVar(index)
plan_output += (
f" {manager.IndexToNode(index)} "
Expand Down

0 comments on commit 81814e6

Please sign in to comment.