A-SW Hub / Repositories
Local Gitea · READ ONLY
← 저장소 Repositories
REPOSITORY

ontariotech/task-allocation Private

[참조 MVP] 다중 농기계 작업 배분 A-SW — 농기계 용량을 고려해 작업구역을 예상 완료시간이 최소가 되도록 배분합니다.

https://git.agrithing.ai/ontariotech/task-allocation.git
7 commits
2 items · main
·/ asw_component/component.py
python · 897 B · 1e634fc Download
from __future__ import annotationsdef execute(payload: dict) -> dict:    machines = [{**item, "assigned_workload": 0.0, "tasks": []} for item in payload.get("machines", [])]    if not machines or any(float(m["capacity"]) <= 0 for m in machines):        raise ValueError("positive-capacity machines are required")    for task in sorted(payload.get("tasks", []), key=lambda item: float(item["workload"]), reverse=True):        machine = min(machines, key=lambda item: item["assigned_workload"] / float(item["capacity"]))        machine["tasks"].append(task["id"])        machine["assigned_workload"] += float(task["workload"])    allocations = [{"machine_id": m["id"], "tasks": m["tasks"], "estimated_time": round(m["assigned_workload"] / float(m["capacity"]), 3)} for m in machines]    return {"allocations": allocations, "makespan": max(item["estimated_time"] for item in allocations)}