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

ontariotech/path-optimization Private

[참조 MVP] 농작업 경로 최적화 A-SW — 작업 구간을 최근접 휴리스틱으로 재정렬해 공차 이동거리를 줄입니다.

https://git.agrithing.ai/ontariotech/path-optimization.git
7 commits
COMMIT DETAIL

feat: add executable reference MVP

A-SW Reference Factory <[email protected]> · 2026. 8. 2. 오전 7:38:04
de87e6848c199c3e8ddce0896385a115ec38f7bc
5 changed files +65 −0 parent fe5cc8b
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 +15−0 View file
@@ -0,0 +1,15 @@
1 + from __future__ import annotations
2 + import math
3 +
4 + def execute(payload: dict) -> dict:
5 + current = list(payload.get("start", [0, 0]))
6 + remaining = list(payload.get("tasks", []))
7 + order, distance = [], 0.0
8 + while remaining:
9 + task = min(remaining, key=lambda item: math.dist(current, item["point"]))
10 + leg = math.dist(current, task["point"])
11 + order.append({"id": task["id"], "point": task["point"], "transfer_distance_m": round(leg, 3)})
12 + distance += leg
13 + current = task["point"]
14 + remaining.remove(task)
15 + return {"algorithm": "nearest_neighbor", "order": order, "total_transfer_distance_m": round(distance, 3)}
added examples/input.json +29−0 View file
@@ -0,0 +1,29 @@
1 + {
2 + "start": [
3 + 0,
4 + 0
5 + ],
6 + "tasks": [
7 + {
8 + "id": "A",
9 + "point": [
10 + 8,
11 + 1
12 + ]
13 + },
14 + {
15 + "id": "B",
16 + "point": [
17 + 2,
18 + 2
19 + ]
20 + },
21 + {
22 + "id": "C",
23 + "point": [
24 + 5,
25 + 5
26 + ]
27 + }
28 + ]
29 + }
added pyproject.toml +8−0 View file
@@ -0,0 +1,8 @@
1 + [project]
2 + name = "path_optimization"
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))