Update warehouse digital twin and robot fleet optimization
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
"""Unit tests for intelligent, distributed charging station placement and layout planner."""
|
||||
|
||||
import pytest
|
||||
from warehouse_twin.domain.warehouse import Position3D, StorageLocation
|
||||
from warehouse_twin.layout.charging_planner import ChargingPlannerConfig, ChargingStationPlanner
|
||||
|
||||
|
||||
def test_charging_planner_distributed_placement():
|
||||
"""Verify charging planner distributes stations across perimeter alcoves without rack collision."""
|
||||
planner = ChargingStationPlanner(
|
||||
ChargingPlannerConfig(
|
||||
num_stations=4,
|
||||
charging_rates_kw=[25.0, 25.0, 50.0, 50.0],
|
||||
min_station_separation=3.0,
|
||||
approach_clearance=1.0,
|
||||
)
|
||||
)
|
||||
|
||||
# Sample storage locations in warehouse center
|
||||
storage_locs = [
|
||||
StorageLocation(
|
||||
location_id=f"rack_{i}",
|
||||
zone="zone_a",
|
||||
position=Position3D(10.0 + (i % 3) * 4.0, 10.0 + (i // 3) * 3.0, 0.0),
|
||||
rack_dimensions=(2.4, 1.0, 3.0),
|
||||
)
|
||||
for i in range(6)
|
||||
]
|
||||
|
||||
stations = planner.plan_charging_stations(
|
||||
warehouse_width=40.0,
|
||||
warehouse_depth=30.0,
|
||||
storage_locations=storage_locs,
|
||||
)
|
||||
|
||||
# 1. Count and capacity assertions
|
||||
assert len(stations) == 4
|
||||
for st in stations:
|
||||
assert st.capacity == 1 # Single berth only
|
||||
assert st.charging_rate_kw in (25.0, 50.0)
|
||||
|
||||
# 2. Minimum separation assertion
|
||||
for i in range(len(stations)):
|
||||
for j in range(i + 1, len(stations)):
|
||||
dist = stations[i].position.distance_to(stations[j].position)
|
||||
assert dist >= 2.8, f"Stations {stations[i].station_id} and {stations[j].station_id} too close ({dist:.2f}m)"
|
||||
|
||||
# 3. Not inside any rack footprint
|
||||
for st in stations:
|
||||
for r in storage_locs:
|
||||
half_w = r.rack_dimensions[0] / 2.0
|
||||
half_d = r.rack_dimensions[1] / 2.0
|
||||
inside_x = (r.position.x - half_w <= st.position.x <= r.position.x + half_w)
|
||||
inside_y = (r.position.y - half_d <= st.position.y <= r.position.y + half_d)
|
||||
assert not (inside_x and inside_y), f"Station {st.station_id} inside rack {r.location_id}"
|
||||
Reference in New Issue
Block a user