eflips-depot 4.7.0__py3-none-any.whl → 4.8.0__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.
@@ -576,7 +576,7 @@ def simulate_scenario(
576
576
  scenario: Union[Scenario, int, Any],
577
577
  repetition_period: Optional[timedelta] = None,
578
578
  database_url: Optional[str] = None,
579
- smart_charging_strategy: SmartChargingStrategy = SmartChargingStrategy.EVEN,
579
+ smart_charging_strategy: SmartChargingStrategy = SmartChargingStrategy.NONE,
580
580
  ignore_unstable_simulation: bool = False,
581
581
  ignore_delayed_trips: bool = False,
582
582
  ) -> None:
@@ -812,7 +812,11 @@ def init_simulation(
812
812
  # The areas allow either one type, or all vehicle types
813
813
  for p in area.processes:
814
814
  if p.electric_power is not None and p.duration is None:
815
- vehicle_count += area.capacity
815
+ row_count = (
816
+ area.row_count if area.row_count is not None else 1
817
+ )
818
+
819
+ vehicle_count += area.capacity * row_count
816
820
 
817
821
  assert (
818
822
  vehicle_count > 0
@@ -90,6 +90,7 @@ def depot_to_template(depot: Depot) -> Dict[str, str | Dict[str, str | int]]:
90
90
  list_of_processes = []
91
91
 
92
92
  # Get dictionary of each area
93
+ # For line areas, generate an dictionary item for total areas, later it will be split into individual lines
93
94
  for area in depot.areas:
94
95
  area_name = str(area.id)
95
96
  template["areas"][area_name] = {
@@ -101,6 +102,8 @@ def depot_to_template(depot: Depot) -> Dict[str, str | Dict[str, str | int]]:
101
102
  "issink": False,
102
103
  "entry_filter": None,
103
104
  }
105
+ if area.area_type == AreaType.LINE:
106
+ template["areas"][area_name]["row_count"] = area.row_count
104
107
 
105
108
  # Fill in vehicle_filter.
106
109
  # If the vehicle type id is set, the area is only for this vehicle type
@@ -142,6 +145,33 @@ def depot_to_template(depot: Depot) -> Dict[str, str | Dict[str, str | int]]:
142
145
  if process_type(process) == ProcessType.STANDBY_DEPARTURE:
143
146
  template["areas"][area_name]["issink"] = True
144
147
 
148
+ # Generate line areas in the unit of a single line for the simulation core and assigning charging interfaces
149
+ area_template = template["areas"]
150
+
151
+ line_area_template = {}
152
+ line_areas_to_delete = []
153
+ for name, area in area_template.items():
154
+ if area["typename"] == "LineArea":
155
+ line_areas_to_delete.append(name)
156
+ capacity_per_line = int(area["capacity"] / area["row_count"])
157
+ for i in range(area["row_count"]):
158
+ area_name = name + "_row_" + str(i)
159
+ line_area_template[area_name] = {
160
+ "typename": "LineArea",
161
+ "capacity": capacity_per_line,
162
+ "available_processes": area["available_processes"],
163
+ "issink": area["issink"],
164
+ "entry_filter": area["entry_filter"],
165
+ "charging_interfaces": area["charging_interfaces"][
166
+ i * capacity_per_line : (i + 1) * capacity_per_line
167
+ ],
168
+ }
169
+ area_template.update(line_area_template)
170
+
171
+ for name in line_areas_to_delete:
172
+ del area_template[name]
173
+
174
+ # Fill in the dictionary of processess
145
175
  for process in list_of_processes:
146
176
  process_name = str(process.id)
147
177
  # Shared template for all processes
@@ -240,11 +270,27 @@ def depot_to_template(depot: Depot) -> Dict[str, str | Dict[str, str | int]]:
240
270
  group_name = str(process.name) + "_group"
241
271
  template["groups"][group_name] = {
242
272
  "typename": "AreaGroup",
243
- "stores": [str(area.id) for area in process.areas],
273
+ "stores": [
274
+ str(area.id)
275
+ for area in process.areas
276
+ if area.area_type != AreaType.LINE
277
+ ],
244
278
  }
245
- if process_type(process) == ProcessType.CHARGING:
246
- template["groups"][group_name]["typename"] = "ParkingAreaGroup"
247
- template["groups"][group_name]["parking_strategy_name"] = "FIRST"
279
+ if (
280
+ process_type(process) == ProcessType.CHARGING
281
+ or process_type(process) == ProcessType.STANDBY_DEPARTURE
282
+ ):
283
+ areas_this_process = process.areas
284
+ for area in areas_this_process:
285
+ if area.area_type == AreaType.LINE:
286
+ for i in range(area.row_count):
287
+ template["groups"][group_name]["stores"].append(
288
+ str(area.id) + "_row_" + str(i)
289
+ )
290
+
291
+ if process_type(process) == ProcessType.CHARGING:
292
+ template["groups"][group_name]["typename"] = "ParkingAreaGroup"
293
+ template["groups"][group_name]["parking_strategy_name"] = "FIRST"
248
294
 
249
295
  # Fill in locations of the plan
250
296
  template["plans"]["default"]["locations"].append(group_name)
@@ -547,19 +593,20 @@ def generate_depot(
547
593
  capacities: Dict[AreaType, None | int]
548
594
  if capacities[AreaType.LINE] is not None and capacities[AreaType.LINE] > 0:
549
595
  # Create a number of LINE areas
550
- number_of_areas = capacities[AreaType.LINE] // standard_block_length
551
- for i in range(number_of_areas):
552
- area = Area(
553
- scenario=scenario,
554
- name=f"Line Area {i + 1} for {vehicle_type.name_short}",
555
- depot=depot,
556
- area_type=AreaType.LINE,
557
- vehicle_type=vehicle_type,
558
- capacity=standard_block_length,
559
- )
560
- area.processes.append(charging)
561
- area.processes.append(standby_departure)
562
- session.add(area)
596
+ number_of_rows = capacities[AreaType.LINE] // standard_block_length
597
+
598
+ area = Area(
599
+ scenario=scenario,
600
+ name=f"Line Area for {vehicle_type.name_short}",
601
+ depot=depot,
602
+ area_type=AreaType.LINE,
603
+ vehicle_type=vehicle_type,
604
+ capacity=capacities[AreaType.LINE],
605
+ row_count=number_of_rows,
606
+ )
607
+ area.processes.append(charging)
608
+ area.processes.append(standby_departure)
609
+ session.add(area)
563
610
  if (
564
611
  capacities[AreaType.DIRECT_ONESIDE] is not None
565
612
  and capacities[AreaType.DIRECT_ONESIDE] > 0
@@ -410,18 +410,29 @@ def add_events_into_database(
410
410
 
411
411
  # Get station_id of the current depot through area
412
412
 
413
- current_area = session.query(Area).filter(Area.id == process_dict["area"]).one()
413
+ # TODO needs better implementation
414
+ if type(process_dict["area"]) == str and "_" in process_dict["area"]:
415
+ area_name = process_dict["area"].split("_")
416
+ area_id = int(area_name[0])
417
+ row = int(area_name[-1])
418
+
419
+ else:
420
+ area_id = int(process_dict["area"])
421
+
422
+ current_area = session.query(Area).filter(Area.id == area_id).one()
414
423
  station_id = current_area.depot.station_id
415
424
 
425
+ if current_area.area_type == AreaType.LINE:
426
+ capacity_per_line = int(current_area.capacity / current_area.row_count)
427
+ process_dict["slot"] = capacity_per_line * row + process_dict["slot"] - 1
428
+
416
429
  current_event = Event(
417
430
  scenario=scenario,
418
431
  vehicle_type_id=db_vehicle.vehicle_type_id,
419
432
  vehicle=db_vehicle,
420
433
  station_id=station_id,
421
- area_id=int(process_dict["area"]),
422
- subloc_no=int(process_dict["slot"]) - 1
423
- if "slot" in process_dict.keys()
424
- else 00,
434
+ area_id=area_id,
435
+ subloc_no=process_dict["slot"] if "slot" in process_dict.keys() else 00,
425
436
  trip_id=None,
426
437
  time_start=timedelta(seconds=start_time) + simulation_start_time,
427
438
  time_end=timedelta(seconds=process_dict["end"]) + simulation_start_time,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: eflips-depot
3
- Version: 4.7.0
3
+ Version: 4.8.0
4
4
  Summary: Depot Simulation for eFLIPS
5
5
  License: AGPL-3.0-or-later
6
6
  Author: Enrico Lauth
@@ -13,7 +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 (>=6.0.6,<7.0.0)
16
+ Requires-Dist: eflips-model (>=7.0.0,<8.0.0)
17
+ Requires-Dist: eflips-opt (>=0.3.0,<0.4.0)
17
18
  Requires-Dist: pandas (>=2.2.0,<3.0.0)
18
19
  Requires-Dist: scipy (>=1.14.0,<2.0.0)
19
20
  Requires-Dist: simpy (>=4.0.1,<5.0.0)
@@ -1,10 +1,10 @@
1
1
  eflips/depot/__init__.py,sha256=06GUem0JIEunIyJ0_P_MLAGfibGEnNqcPPY0OBpO2NQ,1662
2
- eflips/depot/api/__init__.py,sha256=9hSopelEhFIPj7Y9gc50oZgDvh5z_NKfwNtYV2Menik,47906
2
+ eflips/depot/api/__init__.py,sha256=-yosp-qSCtaL7ezITTvR3B-CJbz9YIZqxIo5eeqA1JM,48087
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=FTF_E-DsbvJNWZJKQy_CPoHQpLz--pWY-inJYg8lsjM,16453
6
- eflips/depot/api/private/depot.py,sha256=2teoo4Yzqa5KpYMIiTTlO8uC1TCYFz9YoK6eoNOGg_s,41274
7
- eflips/depot/api/private/results_to_database.py,sha256=R3wwGuaEsof2sW_fFv5Y9K0cl2K8W0JKe5VoN2elXTQ,25037
6
+ eflips/depot/api/private/depot.py,sha256=vJgafDMYA9rjgH21E2DOLZbFU3mnQ8MA_MHWVeE4ywQ,43253
7
+ eflips/depot/api/private/results_to_database.py,sha256=rSwBAjwiThE8_B8e0rrIGFhrEjo8kPiHM5NPwAEGdEI,25514
8
8
  eflips/depot/api/private/util.py,sha256=YcvjKikgdquYXx61pbDiB3Naa1FTEvEfiEcWbnFGNH8,16841
9
9
  eflips/depot/configuration.py,sha256=Op3hlir-dEN7yHr0kTqbYANoCBKFWK6uKOv3NJl8w_w,35678
10
10
  eflips/depot/depot.py,sha256=35P1P3jMBbfq9jevmZVI46oM82osEoDL_B6C65drww0,105711
@@ -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.7.0.dist-info/LICENSE.md,sha256=KB4XTk1fPHjtZCYDyPyreu6h1LVJVZXYg-5vePcWZAc,34143
40
- eflips_depot-4.7.0.dist-info/METADATA,sha256=1La8tjP82xF3JLiVyB8tVnXeA2EniNtrZWE1FyloXQE,5941
41
- eflips_depot-4.7.0.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
42
- eflips_depot-4.7.0.dist-info/RECORD,,
39
+ eflips_depot-4.8.0.dist-info/LICENSE.md,sha256=KB4XTk1fPHjtZCYDyPyreu6h1LVJVZXYg-5vePcWZAc,34143
40
+ eflips_depot-4.8.0.dist-info/METADATA,sha256=LXhYJTNCjt1H7L9u539UjV1KTAGQ9VUd4im1NVNFYCM,5984
41
+ eflips_depot-4.8.0.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
42
+ eflips_depot-4.8.0.dist-info/RECORD,,