Skip to content

Commit

Permalink
fix: service vehicle depot was fetch at wrong place during input gene…
Browse files Browse the repository at this point in the history
…ration (#83)
  • Loading branch information
leo-desbureaux-tellae authored Oct 19, 2023
1 parent ab64eb8 commit 1062197
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
18 changes: 7 additions & 11 deletions starling_sim/basemodel/agent/vehicles/service_vehicle.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,28 +65,24 @@ def __init__(
depot=None,
**kwargs
):
operator = simulation_model.agentPopulation.get_agent(operator_id)
# place service vehicles at depot if provided
if depot is not None:
depot = operator.depotPoints[depot]
origin = depot.position

super().__init__(simulation_model, agent_id, origin, seats, **kwargs)

# service operator, managing the fleet
self.operator = simulation_model.agentPopulation.get_agent(operator_id)

# list of trip ids to be realised by the service vehicle (chronological order)
self.tripList = None

# id of the trip realised by the service vehicle, used to match user stops
self.tripId = trip_id

# vehicle depot
self.depot = depot

# halt duration while processing a stop
self.dwellTime = dwell_time

# service operator, managing the fleet
self.operator = operator
# vehicle depot
if depot is not None:
depot = self.operator.depotPoints[depot]
self.depot = depot

# planning of the service vehicle, consists in a list of Stop objects
self.planning = []
Expand Down
5 changes: 5 additions & 0 deletions starling_sim/basemodel/input/dynamic_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,11 @@ def add_key_operator(self, input_dict):
# get the operator
operator = self.sim.agentPopulation.get_agent(operator_id)

# get position from eventual depot
if "depot" in input_dict:
depot = operator.depotPoints[input_dict["depot"]]
input_dict["origin"] = depot.position

populations = [input_dict["agent_type"]]
if "population" in input_dict:
populations.append(input_dict["population"])
Expand Down

0 comments on commit 1062197

Please sign in to comment.