eflips-depot 4.11.0__py3-none-any.whl → 4.12.1__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.

@@ -124,7 +124,8 @@ def generate_consumption_result(scenario):
124
124
  Generate consumption information for the scenario.
125
125
 
126
126
  This function retrieves the consumption LUT and vehicle classes from the database and returns a dictionary
127
- containing the consumption information for each vehicle type in the scenario.
127
+ containing the consumption information for each vehicle type in the scenario. If a trip has no corresponding
128
+ consumption LUT, it won't be included in the results.
128
129
 
129
130
  :param scenario: A :class:`eflips.model.Scenario` object containing the input data for the simulation.
130
131
 
@@ -135,10 +136,18 @@ def generate_consumption_result(scenario):
135
136
  trips = session.query(Trip).filter(Trip.scenario_id == scenario.id).all()
136
137
  consumption_results = {}
137
138
  for trip in trips:
138
- consumption_info = extract_trip_information(
139
- trip.id,
140
- scenario,
141
- )
139
+ try:
140
+ consumption_info = extract_trip_information(
141
+ trip.id,
142
+ scenario,
143
+ )
144
+ except ValueError as e:
145
+ # If the trip has no consumption information, skip it
146
+ logging.warning(
147
+ f"Skipping trip {trip.id} due to missing consumption information: {e}"
148
+ )
149
+ continue
150
+
142
151
  battery_capacity_current_vt = trip.rotation.vehicle_type.battery_capacity
143
152
  consumption_result = consumption_info.generate_consumption_result(
144
153
  battery_capacity_current_vt
@@ -1097,25 +1106,27 @@ def add_evaluation_to_database(
1097
1106
 
1098
1107
 
1099
1108
  def generate_depot_optimal_size(
1100
- scenario: Scenario,
1109
+ scenario: Union[Scenario, int, Any],
1101
1110
  standard_block_length: int = 6,
1102
1111
  charging_power: float = 90,
1103
1112
  database_url: Optional[str] = None,
1104
1113
  delete_existing_depot: bool = False,
1105
- consumption_results: Optional[Dict[int, ConsumptionResult]] = None,
1114
+ use_consumption_lut: bool = False,
1106
1115
  ) -> None:
1107
1116
  """
1108
1117
  Generates an optimal depot layout with the smallest possible size for each depot in the scenario. Line charging areas
1109
1118
  with given block length area preferred. The existing depot will be deleted if `delete_existing_depot` is set to True.
1110
1119
 
1111
- :param scenario: A :class:`eflips.model.Scenario` object containing the input data for the simulation.
1120
+ :param scenario: Either a :class:`eflips.model.Scenario` object containing the input data for the simulation. Or
1121
+ an integer specifying the ID of a scenario in the database. Or any other object that has an attribute "id" containing
1122
+ an integer pointing to a unique scenario id.
1112
1123
  :param standard_block_length: The standard block length for the depot layout in meters. Default is 6.
1113
1124
  :param charging_power: The charging power of the charging area in kW. Default is 90.
1114
1125
  :param database_url: An optional database URL. Used if no database url is given by the environment variable.
1115
1126
  :param delete_existing_depot: If there is already a depot existing in this scenario, set True to delete this
1116
1127
  existing depot. Set to False and a ValueError will be raised if there is a depot in this scenario.
1117
- :param consumption_results: A dictionary of consumption results for each vehicle type. It is used to simulate the consumption with
1118
- given look-up tables. If not given, the constant consumption will be used in the simulation.
1128
+ :param using_consumption_lut: If True, the depot layout will be generated based on the consumption lookup table.
1129
+ If False, constant consumption stored in VehicleType table will be used.
1119
1130
 
1120
1131
  :return: None. The depot layout will be added to the database.
1121
1132
 
@@ -1133,15 +1144,26 @@ def generate_depot_optimal_size(
1133
1144
  # Handles existing depot
1134
1145
  if session.query(Depot).filter(Depot.scenario_id == scenario.id).count() != 0:
1135
1146
  if delete_existing_depot is False:
1136
- raise ValueError("Depot already exists.")
1147
+ raise ValueError(
1148
+ "Depot already exists. Set delete_existing_depot to True to delete it."
1149
+ )
1137
1150
 
1138
1151
  delete_depots(scenario, session)
1139
1152
 
1140
1153
  ##### Step 0: Consumption Simulation #####
1141
1154
  # Run the consumption simulation for all depots
1142
- simple_consumption_simulation(
1143
- scenario, initialize_vehicles=True, consumption_result=consumption_results
1144
- )
1155
+
1156
+ if use_consumption_lut:
1157
+ # If using the consumption lookup table, we need to calculate the consumption results
1158
+ consumption_results = generate_consumption_result(scenario)
1159
+ simple_consumption_simulation(
1160
+ scenario,
1161
+ initialize_vehicles=True,
1162
+ consumption_result=consumption_results,
1163
+ )
1164
+ else:
1165
+ # If not using the consumption lookup table, we need to initialize the vehicles with the constant consumption
1166
+ simple_consumption_simulation(scenario, initialize_vehicles=True)
1145
1167
 
1146
1168
  ##### Step 1: Find all potential depots #####
1147
1169
  # These are all the spots where a rotation starts and end
@@ -1208,9 +1230,8 @@ def generate_depot_optimal_size(
1208
1230
  finally:
1209
1231
  savepoint.rollback()
1210
1232
 
1211
- # create depot with the calculated area sizes
1233
+ # Create depot using the calculated capacities
1212
1234
 
1213
- with create_session(scenario, database_url) as (session, scenario):
1214
1235
  for depot_station, capacities in depot_capacities_for_scenario.items():
1215
1236
  generate_depot(
1216
1237
  capacities,
@@ -28,6 +28,10 @@ from sqlalchemy import or_
28
28
  from sqlalchemy.orm import Session
29
29
 
30
30
 
31
+ class MissingVehicleDimensionError(ValueError):
32
+ pass
33
+
34
+
31
35
  def delete_depots(scenario: Scenario, session: Session) -> None:
32
36
  """This function deletes all depot-related data from the database for a given scenario.
33
37
 
@@ -676,7 +680,10 @@ def area_needed_for_vehicle_parking(
676
680
  width = vehicle_type.width
677
681
 
678
682
  if length is None or width is None:
679
- raise ValueError(f"No length or width found for VehicleType {vehicle_type}")
683
+ raise MissingVehicleDimensionError(
684
+ f"No length or width found for VehicleType {vehicle_type}. VehicleType dimensions are required to "
685
+ f"calculate the area needed for parking."
686
+ )
680
687
 
681
688
  # This is the angle the vehicles are parked at in direct areas
682
689
  # zero is equivalent to the direction they would be parked in a line area
@@ -1070,6 +1077,9 @@ def depot_smallest_possible_size(
1070
1077
  logger.debug(
1071
1078
  f"Vehicle count for {vt.name} in {amount_of_line_areas} line areas configuration: {vehicle_count_q}. This is > than the all-direct configuration ({vehicle_counts_all_direct[vt]})."
1072
1079
  )
1080
+
1081
+ except MissingVehicleDimensionError as e:
1082
+ raise e
1073
1083
  except Exception as e:
1074
1084
  # This change is made after Unstable exception and delay exceptions are introduced
1075
1085
  if (
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: eflips-depot
3
- Version: 4.11.0
3
+ Version: 4.12.1
4
4
  Summary: Depot Simulation for eFLIPS
5
5
  License: AGPL-3.0-or-later
6
6
  Author: Enrico Lauth
@@ -13,8 +13,8 @@ Classifier: Programming Language :: Python :: 3.11
13
13
  Classifier: Programming Language :: Python :: 3.12
14
14
  Classifier: Programming Language :: Python :: 3.13
15
15
  Requires-Dist: eflips (>=0.1.3,<0.2.0)
16
- Requires-Dist: eflips-model (>=8.1.0,<9.0.0)
17
- Requires-Dist: eflips-opt (>=0.3.0,<0.4.0)
16
+ Requires-Dist: eflips-model (>8.1.0,<10.0.0)
17
+ Requires-Dist: eflips-opt (>=0.3.3,<0.4.0)
18
18
  Requires-Dist: pandas (>=2.2.0,<3.0.0)
19
19
  Requires-Dist: scipy (>=1.14.0,<2.0.0)
20
20
  Requires-Dist: simpy (>=4.0.1,<5.0.0)
@@ -1,9 +1,9 @@
1
1
  eflips/depot/__init__.py,sha256=06GUem0JIEunIyJ0_P_MLAGfibGEnNqcPPY0OBpO2NQ,1662
2
- eflips/depot/api/__init__.py,sha256=19lwuX7KlvfKwyvbpxGSo4E9DSasVm8bNnw6k-Pz-_g,54158
2
+ eflips/depot/api/__init__.py,sha256=t5BsJIheFF9B2732j0bbWGo0dUE7gF5cxuIveJDICIU,55170
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
5
  eflips/depot/api/private/consumption.py,sha256=nImegyhKrZlEwKTNdmAmDxjTQCvwfPgxA588e0M_F9o,27282
6
- eflips/depot/api/private/depot.py,sha256=-LpLeEi3ctjsLzWbBGDBTic_aKrb6S35ii5wt-7QTmI,43359
6
+ eflips/depot/api/private/depot.py,sha256=YyC_jMDGkg8yOAiYkKzb5HboFM1P4x-GTJSfD8srdvE,43640
7
7
  eflips/depot/api/private/results_to_database.py,sha256=_qXB9046dWHek4ys669J3IojJt4xlZRkW1HxT7OTLFo,25524
8
8
  eflips/depot/api/private/util.py,sha256=rDqVuB4sllFZmNvXuDktIsFRoR9l-AWc4QM00e1Quvw,17966
9
9
  eflips/depot/configuration.py,sha256=Op3hlir-dEN7yHr0kTqbYANoCBKFWK6uKOv3NJl8w_w,35678
@@ -36,7 +36,7 @@ eflips/depot/simulation.py,sha256=ee0qTzOzG-8ybN36ie_NJallXfC7jUaS9JZvaYFziLs,10
36
36
  eflips/depot/smart_charging.py,sha256=C3BYqzn2-OYY4ipXm0ETtavbAM9QXZMYULBpVoChf0E,54311
37
37
  eflips/depot/standalone.py,sha256=8O01zEXghFG9zZBu0fUD0sXvbHQ-AXw6RB5M750a_sM,22419
38
38
  eflips/depot/validation.py,sha256=TIuY7cQtEJI4H2VVMSuY5IIVkacEEZ67weeMuY3NSAM,7097
39
- eflips_depot-4.11.0.dist-info/LICENSE.md,sha256=KB4XTk1fPHjtZCYDyPyreu6h1LVJVZXYg-5vePcWZAc,34143
40
- eflips_depot-4.11.0.dist-info/METADATA,sha256=av_PasTBBigxFeKbjYQ1PT2pXXx3qp6p5HzSpQF1-JA,5985
41
- eflips_depot-4.11.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
42
- eflips_depot-4.11.0.dist-info/RECORD,,
39
+ eflips_depot-4.12.1.dist-info/LICENSE.md,sha256=KB4XTk1fPHjtZCYDyPyreu6h1LVJVZXYg-5vePcWZAc,34143
40
+ eflips_depot-4.12.1.dist-info/METADATA,sha256=1txE-lc2o62p-gf7CLKUVQ4PWzDfn1-7axYKXeV1gGA,5985
41
+ eflips_depot-4.12.1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
42
+ eflips_depot-4.12.1.dist-info/RECORD,,