Agent 서버 구축: 멀티테넌트 협상 PoC (UCB Q-Table 학습 + /chat + 14 API + 학습검증 하네스), config 단일화(local.toml) + 빌드 경량화
This commit is contained in:
1 parent
212725e5f9
commit
951d6eab84
140 files changed
+6689
-214
No files matched your search
@@ -0,0 +1,33 @@
|
||||
"""정책 레지스트리 — 하네스에서 비교할 정책 인스턴스 팩토리 (H5).
|
||||
|
||||
현재: random / static / qtable_ucb. LinUCB(H3)·CQL(H6)은 같은 NegotiationPolicy 로 추후 등록.
|
||||
"""
|
||||
|
||||
import math
|
||||
|
||||
from eval_harness.baselines import RandomPolicy, StaticPolicy
|
||||
from negotiation.policies.qtable_policy import UCBQTablePolicy
|
||||
from negotiation.qtable.domain.model.q_table import QTable
|
||||
from tenancy.config import PolicyConfig, StateConfig
|
||||
|
||||
|
||||
def build_policy(name: str, state_cfg: StateConfig, action_space_size: int,
|
||||
policy_cfg: PolicyConfig, seed: int = 0):
|
||||
"""이름으로 새 정책 인스턴스 생성 (메모리 QTable, DB 미사용 — 시뮬 속도/격리)."""
|
||||
if name == "random":
|
||||
return RandomPolicy(seed=seed)
|
||||
if name == "static":
|
||||
return StaticPolicy(fixed_action=0)
|
||||
if name in ("qtable_ucb", "qtable", "ucb"):
|
||||
qt = QTable(state_cfg.state_space_size, action_space_size,
|
||||
learning_rate=policy_cfg.learning_rate, discount_factor=policy_cfg.gamma)
|
||||
params = policy_cfg.params or {}
|
||||
return UCBQTablePolicy(
|
||||
qt,
|
||||
exploration_constant=params.get("exploration_constant", math.sqrt(2.0)),
|
||||
epsilon=params.get("propensity_epsilon", 0.1),
|
||||
)
|
||||
raise ValueError(f"unknown policy: {name} (지원: random|static|qtable_ucb; LinUCB/CQL 은 H3/H6)")
|
||||
|
||||
|
||||
AVAILABLE = ["random", "static", "qtable_ucb"]
|
||||
Reference in new issue
Block a user