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

eflips/depot/__init__.py CHANGED
@@ -95,8 +95,3 @@ class UnstableSimulationException(Exception):
95
95
  f"The following blocks/rotations require a new vehicle. This suggests an unstable "
96
96
  f" simulation result, where a repeated schedule might require more vehicles: {trip_names}"
97
97
  )
98
-
99
-
100
- class MultipleErrors(Exception):
101
- def __init__(self, errors):
102
- self.errors = errors
@@ -60,7 +60,6 @@ from eflips.depot import (
60
60
  SimulationHost,
61
61
  UnstableSimulationException,
62
62
  DelayedTripException,
63
- MultipleErrors,
64
63
  )
65
64
  from eflips.depot.api.private.consumption import ConsumptionResult
66
65
  from eflips.depot.api.private.consumption import (
@@ -640,29 +639,20 @@ def simulate_scenario(
640
639
  try:
641
640
  add_evaluation_to_database(scenario, ev, session)
642
641
 
643
- except MultipleErrors as e:
644
- if e.errors:
645
- for error in e.errors:
646
- if (
647
- isinstance(error, DelayedTripException)
648
- and not ignore_delayed_trips
649
- ):
650
- logger.error(
651
- "There are delayed trips in the simulation. "
652
- "Please check the input data and try again."
653
- )
654
- raise error
655
- if (
656
- isinstance(error, UnstableSimulationException)
657
- and not ignore_unstable_simulation
658
- ):
659
- logger.error(
660
- "Simulation became unstable. "
661
- "Please check the input data and try again."
662
- )
663
- raise error
664
-
665
- logger.warning("An error occurred during the simulation: %s", error)
642
+ except* DelayedTripException as delay_exp:
643
+ if not ignore_delayed_trips:
644
+ logger.error(
645
+ "There are delayed trips in the simulation. "
646
+ "Please check the input data and try again."
647
+ )
648
+ raise delay_exp
649
+ except* UnstableSimulationException as unstable_exp:
650
+ if not ignore_unstable_simulation:
651
+ logger.error(
652
+ "The simulation became unstable. "
653
+ "Please check the input data and try again."
654
+ )
655
+ raise unstable_exp
666
656
 
667
657
  match smart_charging_strategy:
668
658
  case SmartChargingStrategy.NONE:
@@ -1104,7 +1094,9 @@ def add_evaluation_to_database(
1104
1094
  errors.append(unstable_exp)
1105
1095
 
1106
1096
  if len(errors) > 0:
1107
- raise MultipleErrors(errors)
1097
+ raise ExceptionGroup(
1098
+ "Simulation is either unstable or including delayed blocks", errors
1099
+ )
1108
1100
 
1109
1101
 
1110
1102
  def generate_depot_optimal_size(
@@ -5,9 +5,9 @@ from datetime import timedelta, datetime
5
5
  from math import ceil
6
6
  from typing import Tuple, List
7
7
  from zoneinfo import ZoneInfo
8
- import scipy
9
8
 
10
9
  import numpy as np
10
+ import scipy
11
11
  import sqlalchemy.orm
12
12
  from eflips.model import (
13
13
  Event,
@@ -99,7 +99,9 @@ class ConsumptionInformation:
99
99
 
100
100
  def calculate(self):
101
101
  """
102
- Calculates the consumption for the trip. Returns a float in kWh.
102
+ Calculates the consumption for the trip.
103
+
104
+ Returns a float in kWh.
103
105
 
104
106
  :return: The energy consumption in kWh. This is already the consumption for the whole trip.
105
107
  """
@@ -171,12 +173,26 @@ class ConsumptionInformation:
171
173
  ConsistencyWarning,
172
174
  )
173
175
 
174
- interpolator_nn = scipy.interpolate.RegularGridInterpolator(
175
- (incline_scale, temperature_scale, level_of_loading_scale, speed_scale),
176
- consumption_lut,
177
- bounds_error=False,
178
- fill_value=None, # Fill NaN with 0.0
179
- method="nearest",
176
+ x, y, z, alpha = np.meshgrid(
177
+ incline_scale,
178
+ temperature_scale,
179
+ level_of_loading_scale,
180
+ speed_scale,
181
+ indexing="ij",
182
+ )
183
+ points_array = np.column_stack(
184
+ [x.ravel(), y.ravel(), z.ravel(), alpha.ravel()]
185
+ )
186
+ consumption_lut_flattened = consumption_lut.ravel()
187
+
188
+ # Remove the NaN entries from consumption_lut and points_array
189
+ valid_mask = ~np.isnan(consumption_lut_flattened)
190
+ points_array = points_array[valid_mask]
191
+ consumption_lut = consumption_lut_flattened[valid_mask]
192
+
193
+ interpolator_nn = scipy.interpolate.NearestNDInterpolator(
194
+ x=points_array,
195
+ y=consumption_lut.ravel(),
180
196
  )
181
197
  consumption_per_km = interpolator_nn(
182
198
  [
@@ -228,9 +244,7 @@ def extract_trip_information(
228
244
  passenger_mass=68,
229
245
  passenger_count=17.6,
230
246
  ) -> ConsumptionInformation:
231
- """
232
- Extracts the information needed for the consumption simulation from a trip.
233
- """
247
+ """Extracts the information needed for the consumption simulation from a trip."""
234
248
 
235
249
  with create_session(scenario) as (session, scenario):
236
250
  # Load the trip with its route and rotation, including vehicle type and consumption LUT
@@ -27,6 +27,8 @@ from eflips.model import (
27
27
  from sqlalchemy import or_
28
28
  from sqlalchemy.orm import Session
29
29
 
30
+ from eflips.depot import UnstableSimulationException, DelayedTripException
31
+
30
32
 
31
33
  class MissingVehicleDimensionError(ValueError):
32
34
  pass
@@ -1091,14 +1093,15 @@ def depot_smallest_possible_size(
1091
1093
 
1092
1094
  except MissingVehicleDimensionError as e:
1093
1095
  raise e
1094
- except Exception as e:
1096
+ except UnstableSimulationException as e:
1095
1097
  # This change is made after Unstable exception and delay exceptions are introduced
1096
- if (
1097
- "which suggests the fleet or the infrastructure might not be enough for the full electrification. Please add charging interfaces or increase charging power ."
1098
- in repr(e)
1099
- ):
1100
- logger.debug(f"Depot is too small.")
1101
- continue
1098
+ logger.debug(
1099
+ f"Results are unstable, suggesting depot is too small."
1100
+ )
1101
+ continue
1102
+ except DelayedTripException as e:
1103
+ logger.debug(f"Trips are delayed, suggesting depot is too small.")
1104
+ continue
1102
1105
  finally:
1103
1106
  inner_savepoint.rollback()
1104
1107
  savepoint.rollback()
@@ -1,14 +1,13 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: eflips-depot
3
- Version: 4.13.2
3
+ Version: 4.13.4
4
4
  Summary: Depot Simulation for eFLIPS
5
5
  License: AGPL-3.0-or-later
6
6
  Author: Enrico Lauth
7
7
  Author-email: enrico.lauth@tu-berlin.de
8
- Requires-Python: >=3.10,<3.14
8
+ Requires-Python: >=3.11,<3.14
9
9
  Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
10
10
  Classifier: Programming Language :: Python :: 3
11
- Classifier: Programming Language :: Python :: 3.10
12
11
  Classifier: Programming Language :: Python :: 3.11
13
12
  Classifier: Programming Language :: Python :: 3.12
14
13
  Classifier: Programming Language :: Python :: 3.13
@@ -1,9 +1,9 @@
1
- eflips/depot/__init__.py,sha256=p-oqm1LmTuIk5PRiWDyychBhwAsr-9Rw7dKmRCZ58wc,2968
2
- eflips/depot/api/__init__.py,sha256=a3hA8iiogTenthVkEd-u4H2hwCz3725Qm_LujgGSHPw,58898
1
+ eflips/depot/__init__.py,sha256=I42xmkE7GDZfoZeSn_ey85sYGI7xyGqAt6Xd4UZpHLw,2872
2
+ eflips/depot/api/__init__.py,sha256=I0KQ_lDAWWPaH4HJfNLPxkv2eFKai9by2WqX0AKNsP4,58571
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=nImegyhKrZlEwKTNdmAmDxjTQCvwfPgxA588e0M_F9o,27282
6
- eflips/depot/api/private/depot.py,sha256=uESFVBhHybDN-LzvceKHlFSfsVsBfh5gaOuTxspX6rY,44055
5
+ eflips/depot/api/private/consumption.py,sha256=ICgToPQtUBvVhTwz5_oVrNKRUnM_0HGxWrH4Tby9IQ0,27776
6
+ eflips/depot/api/private/depot.py,sha256=NLrRBjb-wq7E3hnVAiX08IzUSVjfMV_NgRqzIx53CE0,44120
7
7
  eflips/depot/api/private/results_to_database.py,sha256=FBlZRKqAIG80tFyuf5vCGHRycWKYkm53jFxJEk9t1NA,25984
8
8
  eflips/depot/api/private/util.py,sha256=DasTkuGUhlBpY_BtTFWoxSNZU_CRyM3RqEDgO07Eks8,17990
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.13.2.dist-info/LICENSE.md,sha256=KB4XTk1fPHjtZCYDyPyreu6h1LVJVZXYg-5vePcWZAc,34143
40
- eflips_depot-4.13.2.dist-info/METADATA,sha256=QBChXaVYyrSBpjGL2uA2pXcci7RnGAUKNylOWjB3w5c,5987
41
- eflips_depot-4.13.2.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
42
- eflips_depot-4.13.2.dist-info/RECORD,,
39
+ eflips_depot-4.13.4.dist-info/LICENSE.md,sha256=KB4XTk1fPHjtZCYDyPyreu6h1LVJVZXYg-5vePcWZAc,34143
40
+ eflips_depot-4.13.4.dist-info/METADATA,sha256=d6pp3rq0_9aYTEzRfdcLgaevh6GiC4BRdHrsYBHU0Po,5936
41
+ eflips_depot-4.13.4.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
42
+ eflips_depot-4.13.4.dist-info/RECORD,,