[fix] agent: 보상함수를 q-table 상세 설명 v4 명세에 정합화

- 동적 가중치 W: 라운드 감쇠 → 상태 5차원 가중합 clip(Σwᵢ·Sᵢ, 0.2, 0.8) (식 12~13, 기존 w1~w5 연결)
- 종료보상에 (1−W) 적용: R = W×R_price + (1−W)×R_end − λ×round (식 8)
- R_price 3단계: P<anchor 시 1+β·(anchor−P)/anchor 초과달성 보너스 추가 (식 9~11, beta 의미 재정의)
- price zone 경계는 명세(T)와 달리 anchor 유지(우선협상 규칙이 실제 의사결정 경계) — 사유 docstring 명시
- state_calculator/config 의 낡은 반대 컨벤션(anchor≥target) 주석 정정
- RewardCalculator(RewardConfig, StateConfig) 시그니처 변경 + 호출부 5곳 갱신, 테스트 기대값 정정 (76/76 PASS)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
HyeongBaeYangandClaude Fable 5 committed 2026-07-02 14:10:44 +09:00
1 parent 43ac308a5e
commit be1b4b968f
9 files changed
+57 -33

No files matched your search

+4 -3
View File
@@ -39,9 +39,10 @@ async def test_step_tenant_divergence(client):
assert dk["state_index"] != di["state_index"]
# 응답 형태
assert dk["result"]["success"] is True
# input 9950: price_reward=(10000-9950)/(10000-9900)=0.5, round3 weight=0.2,
# penalty=0.06, end(success)=1.0 → 0.2*0.5+1.0-0.06 = 1.04
assert dk["reward"]["total"] == pytest.approx(1.04, abs=1e-6)
# input 9950: price_reward=(10000-9950)/(10000-9900)=0.5,
# W=Σ0.2·Sᵢ=0.2×(0.6+0.3+0.5+1.0+0.5)=0.58 (revenue mid, dist A, single, accept high, zone1),
# penalty=0.02×3=0.06, end(success)=1.0 → 0.58×0.5 + 0.42×1.0 − 0.06 = 0.65
assert dk["reward"]["total"] == pytest.approx(0.65, abs=1e-6)
assert dk["logged"] is False # log=false
+4 -2
View File
@@ -110,8 +110,10 @@ def test_price_zone_and_partner_buckets():
def test_reward_deterministic_and_config_driven():
snap = _snapshot(outcome=NegotiationOutcome.FAILURE, round_number=2)
kt_rc = RewardCalculator(_cfg("ktcommerce").reward) # failure_penalty -0.5
imk_rc = RewardCalculator(_cfg("imarketkorea").reward) # failure_penalty -0.7
kt = _cfg("ktcommerce")
imk = _cfg("imarketkorea")
kt_rc = RewardCalculator(kt.reward, kt.state) # failure_penalty -0.5
imk_rc = RewardCalculator(imk.reward, imk.state) # failure_penalty -0.7
r1 = kt_rc.calculate(snap)
r2 = kt_rc.calculate(snap)