eflips-depot 4.13.1__py3-none-any.whl → 4.13.2__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/api/__init__.py +56 -23
- {eflips_depot-4.13.1.dist-info → eflips_depot-4.13.2.dist-info}/METADATA +1 -1
- {eflips_depot-4.13.1.dist-info → eflips_depot-4.13.2.dist-info}/RECORD +5 -5
- {eflips_depot-4.13.1.dist-info → eflips_depot-4.13.2.dist-info}/LICENSE.md +0 -0
- {eflips_depot-4.13.1.dist-info → eflips_depot-4.13.2.dist-info}/WHEEL +0 -0
eflips/depot/api/__init__.py
CHANGED
|
@@ -32,7 +32,7 @@ from collections import OrderedDict
|
|
|
32
32
|
from datetime import timedelta, datetime
|
|
33
33
|
from enum import Enum
|
|
34
34
|
from math import ceil
|
|
35
|
-
from typing import Any, Dict, Optional, Union
|
|
35
|
+
from typing import Any, Dict, Optional, Union
|
|
36
36
|
|
|
37
37
|
import sqlalchemy.orm
|
|
38
38
|
from eflips.model import (
|
|
@@ -51,6 +51,7 @@ from eflips.model import (
|
|
|
51
51
|
ConsistencyWarning,
|
|
52
52
|
Station,
|
|
53
53
|
)
|
|
54
|
+
from sqlalchemy import func
|
|
54
55
|
from sqlalchemy.orm import Session
|
|
55
56
|
|
|
56
57
|
import eflips.depot
|
|
@@ -761,28 +762,15 @@ def init_simulation(
|
|
|
761
762
|
.all()
|
|
762
763
|
]
|
|
763
764
|
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
# We take first arrival time as simulation start
|
|
772
|
-
total_duration = (last_arrival_time - first_departure_time).total_seconds()
|
|
773
|
-
schedule_duration_days = ceil(total_duration / (24 * 60 * 60))
|
|
774
|
-
|
|
775
|
-
if repetition_period is None and schedule_duration_days in [1, 2]:
|
|
776
|
-
repetition_period = timedelta(days=1)
|
|
777
|
-
elif repetition_period is None and schedule_duration_days in [7, 8]:
|
|
778
|
-
repetition_period = timedelta(weeks=1)
|
|
779
|
-
elif repetition_period is None:
|
|
780
|
-
raise ValueError(
|
|
781
|
-
"Could not automatically detect repetition period. Please specify manually."
|
|
782
|
-
)
|
|
765
|
+
if repetition_period is None:
|
|
766
|
+
repetition_period = schedule_duration_days(scenario)
|
|
767
|
+
if repetition_period not in (timedelta(days=1), timedelta(days=7)):
|
|
768
|
+
warnings.warn(
|
|
769
|
+
f"Non-standard schedule duration of {repetition_period}. Please make sure this is intended.",
|
|
770
|
+
UserWarning,
|
|
771
|
+
)
|
|
783
772
|
|
|
784
773
|
# Now, we need to repeat the vehicle schedules
|
|
785
|
-
|
|
786
774
|
vehicle_schedules = repeat_vehicle_schedules(vehicle_schedules, repetition_period)
|
|
787
775
|
|
|
788
776
|
sim_start_stime, total_duration_seconds = start_and_end_times(vehicle_schedules)
|
|
@@ -1129,7 +1117,9 @@ def generate_depot_optimal_size(
|
|
|
1129
1117
|
repetition_period: Optional[timedelta] = None,
|
|
1130
1118
|
) -> None:
|
|
1131
1119
|
"""
|
|
1132
|
-
Generates an optimal depot layout with the smallest possible size for each depot in the scenario.
|
|
1120
|
+
Generates an optimal depot layout with the smallest possible size for each depot in the scenario.
|
|
1121
|
+
|
|
1122
|
+
Line charging areas
|
|
1133
1123
|
with given block length area preferred. The existing depot will be deleted if `delete_existing_depot` is set to True.
|
|
1134
1124
|
|
|
1135
1125
|
:param scenario: Either a :class:`eflips.model.Scenario` object containing the input data for the simulation. Or
|
|
@@ -1148,7 +1138,6 @@ def generate_depot_optimal_size(
|
|
|
1148
1138
|
value as in the simulation.
|
|
1149
1139
|
|
|
1150
1140
|
:return: None. The depot layout will be added to the database.
|
|
1151
|
-
|
|
1152
1141
|
"""
|
|
1153
1142
|
|
|
1154
1143
|
logger = logging.getLogger(__name__)
|
|
@@ -1309,3 +1298,47 @@ def generate_depot_optimal_size(
|
|
|
1309
1298
|
num_shunting_slots=int(max(time_range)),
|
|
1310
1299
|
num_cleaning_slots=int(max(time_range)),
|
|
1311
1300
|
)
|
|
1301
|
+
|
|
1302
|
+
|
|
1303
|
+
def schedule_duration_days(
|
|
1304
|
+
scenario: Union[Scenario, int, Any], database_url: Optional[str] = None
|
|
1305
|
+
) -> timedelta:
|
|
1306
|
+
"""
|
|
1307
|
+
This method calculates the duration of a given scenario in days.
|
|
1308
|
+
|
|
1309
|
+
This is the duration
|
|
1310
|
+
between the first departure of the first day, and the last departure on the last day, rounded up to full days.
|
|
1311
|
+
|
|
1312
|
+
Most of the time, this is the "natural" repetition period of the scenario. We are simulating one full period, and
|
|
1313
|
+
this period – continuously repeated – is what happens in reality.
|
|
1314
|
+
|
|
1315
|
+
This method can be used to show the user what the detected repetition period is and to auto-set the repetition
|
|
1316
|
+
period if none is provided.
|
|
1317
|
+
|
|
1318
|
+
:param scenario: Either a :class:`eflips.model.Scenario` object containing the input data for the simulation. Or
|
|
1319
|
+
an integer specifying the ID of a scenario in the database. Or any other object that has an attribute "id"
|
|
1320
|
+
containing an integer pointing to a unique scenario id.
|
|
1321
|
+
:param database_url: An optional database URL. Used if no database url is given by the environment variable.
|
|
1322
|
+
:return: a timedelta object representing the duration in days.
|
|
1323
|
+
"""
|
|
1324
|
+
with create_session(scenario, database_url) as (session, scenario):
|
|
1325
|
+
first_departure = (
|
|
1326
|
+
session.query(func.min(Trip.departure_time))
|
|
1327
|
+
.filter(Trip.scenario_id == scenario.id)
|
|
1328
|
+
.scalar()
|
|
1329
|
+
)
|
|
1330
|
+
if first_departure is None:
|
|
1331
|
+
raise ValueError("No trips found in the scenario.")
|
|
1332
|
+
|
|
1333
|
+
last_departure = (
|
|
1334
|
+
session.query(func.max(Trip.departure_time))
|
|
1335
|
+
.filter(Trip.scenario_id == scenario.id)
|
|
1336
|
+
.scalar()
|
|
1337
|
+
)
|
|
1338
|
+
if last_departure is None:
|
|
1339
|
+
raise ValueError("No trips found in the scenario.")
|
|
1340
|
+
|
|
1341
|
+
duration = last_departure - first_departure
|
|
1342
|
+
duration_days = ceil(duration.total_seconds() / (24 * 60 * 60))
|
|
1343
|
+
|
|
1344
|
+
return timedelta(days=duration_days)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
eflips/depot/__init__.py,sha256=p-oqm1LmTuIk5PRiWDyychBhwAsr-9Rw7dKmRCZ58wc,2968
|
|
2
|
-
eflips/depot/api/__init__.py,sha256=
|
|
2
|
+
eflips/depot/api/__init__.py,sha256=a3hA8iiogTenthVkEd-u4H2hwCz3725Qm_LujgGSHPw,58898
|
|
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
|
|
@@ -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.
|
|
40
|
-
eflips_depot-4.13.
|
|
41
|
-
eflips_depot-4.13.
|
|
42
|
-
eflips_depot-4.13.
|
|
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,,
|
|
File without changes
|
|
File without changes
|