Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
Fix secondary vehicles bug
Browse files Browse the repository at this point in the history
  • Loading branch information
leonlan committed Nov 1, 2023
1 parent e5a8ab8 commit ba081b9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 5 additions & 7 deletions ddwp/Environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,24 +384,22 @@ def _next_observation(self) -> State:
# Determine the number of primary vehicles available.
capacity = self.instance.capacity
num_requests = customer_idx.size - 1
vehicle_types = []

if self.num_vehicles_per_epoch is None:
# Assume that the number of vehicles is equal to the number of
# requests in the instance.
num_vehicles = max(num_requests, 1)
vehicle_types = [VehicleType(capacity, num_vehicles)]
vehicle_types.append(VehicleType(capacity, num_vehicles))
else:
num_new = self.num_vehicles_per_epoch[self.current_epoch]
num_primary = num_new + self.num_vehicles_slack

if num_primary > 0:
vehicle_types = [VehicleType(capacity, num_primary)]
else:
vehicle_types = []
vehicle_types.append(VehicleType(capacity, num_primary))

if num_primary <= num_requests:
# If there are not enough vehicles, use secondary fleet.
num_secondary = customer_idx.size - 1 - num_primary
num_secondary = max(num_requests - num_primary, 0)
if num_secondary > 0:
vehicle_types.append(
VehicleType(
capacity,
Expand Down
2 changes: 1 addition & 1 deletion experiments/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def base_parser():
parser.add_argument("--env_seed", type=int, required=True)
parser.add_argument("--agent_config_loc", type=str, required=True)
parser.add_argument("--agent_seed", type=int, default=1)
parser.add_argument("--num_procs", type=int, default=4)
parser.add_argument("--num_procs", type=int, default=6)
parser.add_argument("--hindsight", action="store_true")
parser.add_argument("--epoch_tlim", type=float, required=True)
parser.add_argument("--strategy_tlim", type=float, default=0)
Expand Down

0 comments on commit ba081b9

Please sign in to comment.