Skip to content

Commit

Permalink
Fixed labels of skipped shipments in the merged solution in the two_s…
Browse files Browse the repository at this point in the history
…tep routing library.
  • Loading branch information
ondrasej committed Sep 20, 2023
1 parent 2330a0c commit cee8d44
Show file tree
Hide file tree
Showing 2 changed files with 814 additions and 3 deletions.
9 changes: 6 additions & 3 deletions examples/two_step_routing/two_step_routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ def make_global_request(
# global request. the only change we make is that we add the original
# shipment index to their label.
for shipment_index in self._direct_shipments:
# We"re changing only the label - no need to make a deep copy.
# We're changing only the label - no need to make a deep copy.
shipment = copy.copy(self._shipments[shipment_index])
shipment["label"] = f"s:{shipment_index} {shipment.get('label')}"
global_shipments.append(shipment)
Expand Down Expand Up @@ -789,7 +789,7 @@ def add_merged_transition(transition: cfr_json.Transition):
merged_skipped_shipments = []
for local_skipped_shipment in local_response.get("skippedShipments", ()):
shipment_index, label = local_skipped_shipment["label"].split(
" ", maxsplit=1
": ", maxsplit=1
)
merged_skipped_shipments.append({
"index": int(shipment_index),
Expand All @@ -802,7 +802,10 @@ def add_merged_transition(transition: cfr_json.Transition):
match shipment_type:
case "s":
# Shipments delivered directly can be added directly to the list.
merged_skipped_shipments.append(global_skipped_shipment)
merged_skipped_shipments.append({
"index": int(index),
"label": self._model["shipments"][index].get("label", "")
})
case "p":
# For parking locations, we need to add all shipments delivered from
# that parking location.
Expand Down
Loading

0 comments on commit cee8d44

Please sign in to comment.