- 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
60 lines
1.9 KiB
Python
60 lines
1.9 KiB
Python
"""협상 스냅샷 → Q-Table State 변환."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass
|
|
from typing import Optional
|
|
|
|
from services.policy.state import (
|
|
AcceptanceRate,
|
|
DistributionStructure,
|
|
InputPriceZone,
|
|
PartnerType,
|
|
RevenueRange,
|
|
State,
|
|
)
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class NegotiationSnapshot:
|
|
"""협상 스냅샷 — 실제 비즈니스 데이터"""
|
|
|
|
revenue_amount: float # 매출액 (원)
|
|
distribution_code: str # "M" 제조 / "W" 총판 / "R" 유통
|
|
partner_count: int
|
|
anchor_price: float
|
|
target_price: float
|
|
input_price: float
|
|
acceptance_ratio: Optional[float] = None # 0~1, 없으면 initial_price로 계산
|
|
initial_price: Optional[float] = None
|
|
|
|
|
|
def build_state(snapshot: NegotiationSnapshot) -> State:
|
|
revenue_range = RevenueRange.from_amount(snapshot.revenue_amount)
|
|
distribution = DistributionStructure.from_code(snapshot.distribution_code)
|
|
partner_type = PartnerType.from_count(snapshot.partner_count)
|
|
|
|
if snapshot.acceptance_ratio is not None:
|
|
acceptance_rate = AcceptanceRate.from_ratio(snapshot.acceptance_ratio)
|
|
elif snapshot.initial_price is not None:
|
|
if snapshot.initial_price <= 0:
|
|
raise ValueError("initial_price must be positive")
|
|
ratio = (snapshot.initial_price - snapshot.input_price) / snapshot.initial_price
|
|
acceptance_rate = AcceptanceRate.from_ratio(ratio)
|
|
else:
|
|
raise ValueError("Either acceptance_ratio or initial_price must be provided")
|
|
|
|
input_price_zone = InputPriceZone.from_prices(
|
|
input_price=snapshot.input_price,
|
|
anchor_price=snapshot.anchor_price,
|
|
target_price=snapshot.target_price,
|
|
)
|
|
|
|
return State(
|
|
revenue_range=revenue_range,
|
|
distribution=distribution,
|
|
partner_type=partner_type,
|
|
acceptance_rate=acceptance_rate,
|
|
input_price_zone=input_price_zone,
|
|
)
|