eflips-depot 4.6.4__py3-none-any.whl → 4.6.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of eflips-depot might be problematic. Click here for more details.

@@ -266,8 +266,18 @@ def simple_consumption_simulation(
266
266
  vehicles = (
267
267
  session.query(Vehicle).filter(Vehicle.scenario_id == scenario.id).all()
268
268
  )
269
+
270
+ # Get the event count for each vbehicle in a single query using a groub_py clause
271
+ vehicle_event_count_q = (
272
+ session.query(Event.vehicle_id, sqlalchemy.func.count(Event.id))
273
+ .join(Vehicle)
274
+ .filter(Vehicle.scenario_id == scenario.id)
275
+ .group_by(Event.vehicle_id)
276
+ )
277
+ vehicle_event_count = dict(vehicle_event_count_q.all())
278
+
269
279
  for vehicle in vehicles:
270
- if session.query(Event).filter(Event.vehicle_id == vehicle.id).count() == 0:
280
+ if vehicle.id not in vehicle_event_count.keys():
271
281
  add_initial_standby_event(vehicle, session)
272
282
 
273
283
  # Since we are doing no_autoflush blocks later, we need to flush the session once here so that unflushed stuff
@@ -794,6 +804,10 @@ def init_simulation(
794
804
  if "None" in vehicle_types_for_depot:
795
805
  vehicle_types_for_depot.remove("None")
796
806
 
807
+ # In this case, all types are allowed
808
+ if len(vehicle_types_for_depot) == 0:
809
+ vehicle_types_for_depot = set([str(vt.id) for vt in scenario.vehicle_types])
810
+
797
811
  # If we have a vehicle count dictionary, we validate and use ir
798
812
  if vehicle_count_dict is not None and depot_id in vehicle_count_dict.keys():
799
813
  if set(vehicle_count_dict[depot_id].keys()) < vehicle_types_for_depot:
@@ -809,8 +823,11 @@ def init_simulation(
809
823
  for vehicle_type in vehicle_types_for_depot:
810
824
  vehicle_count = 0
811
825
  for area in depot.areas:
812
- if area.vehicle_type_id == int(vehicle_type):
813
- # TODO potential edit if we make vehicle type of an area a list
826
+ if (
827
+ area.vehicle_type_id == int(vehicle_type)
828
+ or area.vehicle_type_id is None
829
+ ):
830
+ # The areas allow either one type, or all vehicle types
814
831
  for p in area.processes:
815
832
  if p.electric_power is not None and p.duration is None:
816
833
  vehicle_count += area.capacity
@@ -78,13 +78,14 @@ def add_initial_standby_event(
78
78
  but changes are not yet committed.
79
79
  """
80
80
 
81
- earliest_trip = (
81
+ earliest_trip_q = (
82
82
  session.query(Trip)
83
83
  .join(Rotation)
84
84
  .filter(Rotation.vehicle == vehicle)
85
85
  .order_by(Trip.departure_time)
86
- .first()
86
+ .limit(1)
87
87
  )
88
+ earliest_trip = earliest_trip_q.one_or_none()
88
89
  if earliest_trip is None:
89
90
  warnings.warn(
90
91
  f"No trips found for vehicle {vehicle.id}. Cannot add initial standby event.",
@@ -111,7 +111,13 @@ def depot_to_template(depot: Depot) -> Dict[str, str | Dict[str, str | int]]:
111
111
  }
112
112
  else:
113
113
  # If the vehicle type id is not set, the area is for all vehicle types
114
- template["areas"][area_name]["entry_filter"] = dict()
114
+ scenario = depot.scenario
115
+ all_vehicle_type_ids = [str(vt.id) for vt in scenario.vehicle_types]
116
+
117
+ template["areas"][area_name]["entry_filter"] = {
118
+ "filter_names": ["vehicle_type"],
119
+ "vehicle_types": all_vehicle_type_ids,
120
+ }
115
121
 
116
122
  for process in area.processes:
117
123
  # Add process into process list
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: eflips-depot
3
- Version: 4.6.4
3
+ Version: 4.6.6
4
4
  Summary: Depot Simulation for eFLIPS
5
5
  License: AGPL-3.0-or-later
6
6
  Author: Enrico Lauth
@@ -1,9 +1,9 @@
1
1
  eflips/depot/__init__.py,sha256=RQ_UKNrGWA6q17TZFu86ai8pC7qCpcbmAgVKh7aImwo,1613
2
- eflips/depot/api/__init__.py,sha256=4WPZoYSsOgDMI-hsZrQPx_5PRjSztogZNpu3xwwAlUk,48353
2
+ eflips/depot/api/__init__.py,sha256=4oNT-J3CB34m7cenCbx2Fi1IWFk9rfDG2-TT6EqCU64,49003
3
3
  eflips/depot/api/defaults/default_settings.json,sha256=0eUDTw_rtLQFvthP8oJL93iRXlmAOravAg-4qqGMQAY,5375
4
4
  eflips/depot/api/private/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- eflips/depot/api/private/consumption.py,sha256=vDPCogd3NPx2duCUhg_CcW9rMQWgrppfqsS4E7W9T1Y,16400
6
- eflips/depot/api/private/depot.py,sha256=v5Edb0sQP2QNIyBLvccVzAK9_kxCszar0cOu5ciFyrw,40780
5
+ eflips/depot/api/private/consumption.py,sha256=FTF_E-DsbvJNWZJKQy_CPoHQpLz--pWY-inJYg8lsjM,16453
6
+ eflips/depot/api/private/depot.py,sha256=WcCcib3NSbvoL3G06I2ajT8U5L7AkDK5qe969PHq-fg,41014
7
7
  eflips/depot/api/private/results_to_database.py,sha256=Sh2VJ3k60QJ5RGkc8sw-7XbljiMe65EHeoagKIpYlHM,24585
8
8
  eflips/depot/api/private/smart_charging.py,sha256=MQ9fXdKByHAz6RSKXYcpJXDBccdJKZ2qGReCHagVCyo,13033
9
9
  eflips/depot/api/private/util.py,sha256=gk5TJZrcvtkyrqnjR3Cq-hPRGRCovhzKz3LrBDIvN0E,16799
@@ -37,7 +37,7 @@ eflips/depot/simulation.py,sha256=ee0qTzOzG-8ybN36ie_NJallXfC7jUaS9JZvaYFziLs,10
37
37
  eflips/depot/smart_charging.py,sha256=C3BYqzn2-OYY4ipXm0ETtavbAM9QXZMYULBpVoChf0E,54311
38
38
  eflips/depot/standalone.py,sha256=VxcTzBaB67fNJUMmjPRwKXjhqTy6oQ41Coote2LvAmk,22338
39
39
  eflips/depot/validation.py,sha256=TIuY7cQtEJI4H2VVMSuY5IIVkacEEZ67weeMuY3NSAM,7097
40
- eflips_depot-4.6.4.dist-info/LICENSE.md,sha256=KB4XTk1fPHjtZCYDyPyreu6h1LVJVZXYg-5vePcWZAc,34143
41
- eflips_depot-4.6.4.dist-info/METADATA,sha256=VApUGP1NNUQLv_GLCpPCLHAyY0r629HwAv8bMtv91w4,5940
42
- eflips_depot-4.6.4.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
43
- eflips_depot-4.6.4.dist-info/RECORD,,
40
+ eflips_depot-4.6.6.dist-info/LICENSE.md,sha256=KB4XTk1fPHjtZCYDyPyreu6h1LVJVZXYg-5vePcWZAc,34143
41
+ eflips_depot-4.6.6.dist-info/METADATA,sha256=j67zcAG9Xk9dSXsmwe0HPZbTHRTlGYnUTc__Dl-ncLs,5940
42
+ eflips_depot-4.6.6.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
43
+ eflips_depot-4.6.6.dist-info/RECORD,,