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
COMMIT DETAIL

feat: add executable reference MVP

A-SW Reference Factory <[email protected]> · 2026. 8. 2. 오전 7:38:06
9d1acf574331bd27de50dee268cc71f6b78b9186
5 changed files +59 −0 parent 9a07d04
added asw_component/__init__.py +3−0 View file
@@ -0,0 +1,3 @@
1 + from .component import execute
2 +
3 + __all__ = ["execute"]
added asw_component/component.py +12−0 View file
@@ -0,0 +1,12 @@
1 + from __future__ import annotations
2 +
3 + def execute(payload: dict) -> dict:
4 + machines = [{**item, "assigned_workload": 0.0, "tasks": []} for item in payload.get("machines", [])]
5 + if not machines or any(float(m["capacity"]) <= 0 for m in machines):
6 + raise ValueError("positive-capacity machines are required")
7 + for task in sorted(payload.get("tasks", []), key=lambda item: float(item["workload"]), reverse=True):
8 + machine = min(machines, key=lambda item: item["assigned_workload"] / float(item["capacity"]))
9 + machine["tasks"].append(task["id"])
10 + machine["assigned_workload"] += float(task["workload"])
11 + allocations = [{"machine_id": m["id"], "tasks": m["tasks"], "estimated_time": round(m["assigned_workload"] / float(m["capacity"]), 3)} for m in machines]
12 + return {"allocations": allocations, "makespan": max(item["estimated_time"] for item in allocations)}
added examples/input.json +26−0 View file
@@ -0,0 +1,26 @@
1 + {
2 + "machines": [
3 + {
4 + "id": "tractor-1",
5 + "capacity": 1
6 + },
7 + {
8 + "id": "tractor-2",
9 + "capacity": 1.5
10 + }
11 + ],
12 + "tasks": [
13 + {
14 + "id": "F1",
15 + "workload": 4
16 + },
17 + {
18 + "id": "F2",
19 + "workload": 3
20 + },
21 + {
22 + "id": "F3",
23 + "workload": 2
24 + }
25 + ]
26 + }
added pyproject.toml +8−0 View file
@@ -0,0 +1,8 @@
1 + [project]
2 + name = "task_allocation"
3 + version = "0.1.0"
4 + description = "농기계 용량을 고려해 작업구역을 예상 완료시간이 최소가 되도록 배분합니다."
5 + requires-python = ">=3.11"
6 +
7 + [tool.unittest]
8 + test-path = "tests"
added run.py +10−0 View file
@@ -0,0 +1,10 @@
1 + from __future__ import annotations
2 + import json
3 + import sys
4 + from asw_component import execute
5 +
6 + if __name__ == "__main__":
7 + path = sys.argv[1] if len(sys.argv) > 1 else None
8 + with open(path, encoding="utf-8") if path else sys.stdin as source:
9 + payload = json.load(source)
10 + print(json.dumps(execute(payload), ensure_ascii=False, indent=2))