Update warehouse digital twin and robot fleet optimization
This commit is contained in:
@@ -129,3 +129,52 @@ def sample_inventory_catalog():
|
||||
"""Return an initialized InventoryCatalog instance."""
|
||||
from tests.fixtures.sample_models import create_sample_inventory_catalog
|
||||
return create_sample_inventory_catalog()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sample_warehouse_config(project_config_dir: Path) -> Dict[str, Any]:
|
||||
"""Return the raw dictionary from project warehouse.json."""
|
||||
with open(project_config_dir / "warehouse.json", "r", encoding="utf-8") as f:
|
||||
return json.load(f)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sim_env_builder(project_config_dir: Path, tmp_path: Path):
|
||||
"""Fixture builder providing initialized SimulationEnvironment instances."""
|
||||
from warehouse_twin.config.loader import ConfigLoader
|
||||
from warehouse_twin.domain.inventory import InventoryCatalog
|
||||
from warehouse_twin.domain.robot import Robot, RobotTypeSpec
|
||||
from warehouse_twin.domain.warehouse import WarehouseModel
|
||||
from warehouse_twin.simulation.dispatcher import DispatcherSettings
|
||||
from warehouse_twin.simulation.order_generator import WorkloadConfig
|
||||
from warehouse_twin.simulation.sim_engine import SimulationEnvironment
|
||||
|
||||
def _create_env(seed: int = 42, event_log: bool = False):
|
||||
loader = ConfigLoader(project_config_dir)
|
||||
bundle = loader.load_all()
|
||||
warehouse = WarehouseModel.from_config_dict(bundle.warehouse)
|
||||
catalog = InventoryCatalog.from_config_dict(bundle.inventory)
|
||||
|
||||
type_specs = {
|
||||
t_id: RobotTypeSpec.from_dict(t_id, t_data)
|
||||
for t_id, t_data in bundle.robots["robot_types"].items()
|
||||
}
|
||||
fleet = [
|
||||
Robot.from_fleet_dict(r_data, type_specs)
|
||||
for r_data in bundle.robots["fleet"]
|
||||
]
|
||||
|
||||
workload = WorkloadConfig.from_dict(bundle.simulation)
|
||||
dispatch_settings = DispatcherSettings.from_dict(bundle.dispatch_policies)
|
||||
log_file = tmp_path / f"events_seed_{seed}.jsonl" if event_log else None
|
||||
|
||||
return SimulationEnvironment(
|
||||
warehouse=warehouse,
|
||||
catalog=catalog,
|
||||
fleet=fleet,
|
||||
workload_config=workload,
|
||||
dispatcher_settings=dispatch_settings,
|
||||
event_log_path=log_file,
|
||||
seed=seed,
|
||||
)
|
||||
return _create_env
|
||||
|
||||
Reference in New Issue
Block a user