- server/: FastAPI 협상 엔진 (5라운드, Q-Table/UCB, 페르소나 계측, :53117) - frontend/: 데모 콘솔 (React+Tailwind → nginx, /api 프록시) - eval/·testdata/: 지표 8종 측정 하네스 + 재현 가능 테스트셋 - results/: 측정 증빙 (지표별 result+provenance, raw 원본 동결+SHA256) ① 86.0 · ② 76.0 · ③ 5.99% · ⑥ p95 3.61ms · ⑦ 611만/년 · ⑧ 91/100 · ⑨ 99.71 · ⑩ 97.99 - docker-compose.yml + run.sh: backend+frontend 일괄 기동 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0112XUWF4bc3gGrEt8vsYCzy
57 lines
1.9 KiB
Python
57 lines
1.9 KiB
Python
"""Action-Card 매핑 — Q-Table action_id ↔ 협상 카드 card_id."""
|
|
|
|
import json
|
|
from pathlib import Path
|
|
from typing import Dict, Optional
|
|
|
|
from common.paths import RESOURCES_DIR
|
|
|
|
|
|
class ActionCardMapper:
|
|
"""
|
|
action_id (0, 1, 2, ...) ↔ card_id ("NC26-000", ...)
|
|
|
|
Q_Table은 추상적인 action_id만 다루고, 카드 저장소는 card_id만 다룬다.
|
|
매핑은 resources/policy/action_card_mapping.json 에서 로드된다.
|
|
"""
|
|
|
|
def __init__(self, mapping_file: Optional[str] = None):
|
|
if mapping_file is None:
|
|
mapping_file = RESOURCES_DIR / "policy" / "action_card_mapping.json"
|
|
|
|
self.mapping_file = Path(mapping_file)
|
|
self.action_to_card: Dict[int, str] = {}
|
|
self.card_to_action: Dict[str, int] = {}
|
|
self._load_mapping()
|
|
|
|
def _load_mapping(self):
|
|
if not self.mapping_file.exists():
|
|
raise FileNotFoundError(f"Mapping file not found: {self.mapping_file}")
|
|
|
|
with open(self.mapping_file, "r", encoding="utf-8") as f:
|
|
data = json.load(f)
|
|
|
|
self.action_to_card = {int(k): v for k, v in data["action_to_card"].items()}
|
|
self.card_to_action = {v: int(k) for k, v in data["action_to_card"].items()}
|
|
|
|
def get_card_id(self, action_id: int) -> Optional[str]:
|
|
return self.action_to_card.get(action_id)
|
|
|
|
def get_action_id(self, card_id: str) -> Optional[int]:
|
|
return self.card_to_action.get(card_id)
|
|
|
|
def get_action_space_size(self) -> int:
|
|
return len(self.action_to_card)
|
|
|
|
def get_all_card_ids(self) -> list:
|
|
return [self.action_to_card[i] for i in sorted(self.action_to_card.keys())]
|
|
|
|
def reload(self):
|
|
self._load_mapping()
|
|
|
|
def __repr__(self) -> str:
|
|
return (
|
|
f"ActionCardMapper(action_space_size={self.get_action_space_size()}, "
|
|
f"mapping_file={self.mapping_file})"
|
|
)
|