f8b21af4be
10_Wiki/Topics 대규모 정리: - 오류 캡처/미완성 stub 문서 227개 제거 - 교차폴더 중복 43클러스터 병합 (63파일 → redirect) - 링크명 정규화: 깨진 링크 수정·redirect 직결·개념 매핑 ~2,400건 - 카테고리 MOC 6개 신규 생성 - Graph 섹션 미해결 related-keyword 링크 10,058건 제거 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
156 lines
5.3 KiB
Markdown
156 lines
5.3 KiB
Markdown
---
|
||
id: wiki-2026-0508-search-space
|
||
title: Search Space
|
||
category: 10_Wiki/Topics
|
||
status: verified
|
||
canonical_id: self
|
||
aliases: [State Space, Solution Space, Hypothesis Space]
|
||
duplicate_of: none
|
||
source_trust_level: A
|
||
confidence_score: 0.9
|
||
verification_status: applied
|
||
tags: [algorithms, search, optimization, ai, planning]
|
||
raw_sources: []
|
||
last_reinforced: 2026-05-10
|
||
github_commit: pending
|
||
tech_stack:
|
||
language: python
|
||
framework: algorithms
|
||
---
|
||
|
||
# Search Space
|
||
|
||
## 매 한 줄
|
||
> **"매 search space = 매 algorithm 의 매 explore-able 모든 candidate 의 set"**. 매 problem 을 매 (state, transition, goal) tuple 로 modeling 시 의 전체 reachable state set. 매 search 의 효율 = 매 1) space 의 size 줄이기 + 2) 매 promising region 의 priorit ize.
|
||
|
||
## 매 핵심
|
||
|
||
### 매 정의 components
|
||
- **State**: 매 partial / full solution candidate.
|
||
- **Initial state**: 매 search 시작 점.
|
||
- **Successor function**: 매 state → 매 reachable next states.
|
||
- **Goal test**: 매 state 가 매 valid solution 인지.
|
||
- **Path cost**: 매 path 의 매 quality metric.
|
||
|
||
### 매 size scaling
|
||
- **Combinatorial explosion**: 매 N-queens 의 N=8 → 매 16M state. N=20 → 매 effectively infinite.
|
||
- **Branching factor (b)** × **depth (d)** → b^d.
|
||
- **Pruning** (alpha-beta, constraint propagation, branch-and-bound) → 매 effective space ↓.
|
||
|
||
### 매 응용
|
||
1. **Pathfinding**: 매 grid/graph 의 매 cell/node space.
|
||
2. **Game AI**: 매 chess/go 의 매 game tree.
|
||
3. **Planning**: 매 STRIPS, PDDL 의 매 action sequence space.
|
||
4. **NAS**: 매 neural architecture 의 매 hyperparameter space.
|
||
5. **LLM reasoning**: 매 chain-of-thought / tree-of-thought 의 매 reasoning tree.
|
||
|
||
## 💻 패턴
|
||
|
||
### Pattern 1: Generic search space (BFS)
|
||
```python
|
||
from collections import deque
|
||
|
||
def bfs(initial, successors, is_goal):
|
||
frontier = deque([(initial, [])])
|
||
visited = {initial}
|
||
while frontier:
|
||
state, path = frontier.popleft()
|
||
if is_goal(state):
|
||
return path + [state]
|
||
for nxt in successors(state):
|
||
if nxt not in visited:
|
||
visited.add(nxt)
|
||
frontier.append((nxt, path + [state]))
|
||
return None
|
||
```
|
||
|
||
### Pattern 2: A* with admissible heuristic (search space reduction)
|
||
```python
|
||
import heapq
|
||
|
||
def astar(initial, successors, is_goal, heuristic, cost):
|
||
pq = [(heuristic(initial), 0, initial, [])]
|
||
seen = {}
|
||
while pq:
|
||
_, g, s, path = heapq.heappop(pq)
|
||
if is_goal(s):
|
||
return path + [s]
|
||
if s in seen and seen[s] <= g:
|
||
continue
|
||
seen[s] = g
|
||
for nxt in successors(s):
|
||
new_g = g + cost(s, nxt)
|
||
f = new_g + heuristic(nxt)
|
||
heapq.heappush(pq, (f, new_g, nxt, path + [s]))
|
||
```
|
||
|
||
### Pattern 3: Constraint propagation (CSP)
|
||
```python
|
||
# 매 search space 의 매 prune via 매 arc-consistency.
|
||
def ac3(domains, constraints):
|
||
queue = [(x, y) for x in domains for y in constraints.get(x, [])]
|
||
while queue:
|
||
x, y = queue.pop(0)
|
||
if revise(domains, x, y, constraints):
|
||
if not domains[x]:
|
||
return False # 매 inconsistent
|
||
for z in constraints.get(x, []) - {y}:
|
||
queue.append((z, x))
|
||
return True
|
||
```
|
||
|
||
### Pattern 4: Tree-of-Thoughts (LLM reasoning space)
|
||
```python
|
||
# 매 LLM 의 매 reasoning step 을 매 search node 로.
|
||
async def tot_search(problem, max_depth=5, beam=3):
|
||
frontier = [{"state": problem, "trace": []}]
|
||
for d in range(max_depth):
|
||
cands = []
|
||
for node in frontier:
|
||
thoughts = await llm.expand(node["state"], k=beam)
|
||
for t in thoughts:
|
||
cands.append({"state": t, "trace": node["trace"] + [t]})
|
||
# 매 evaluator (LLM-as-judge) 가 매 top-beam pick.
|
||
scored = await llm.evaluate(cands)
|
||
frontier = sorted(scored, key=lambda x: -x["score"])[:beam]
|
||
if any(is_goal(n["state"]) for n in frontier):
|
||
break
|
||
return frontier[0]["trace"]
|
||
```
|
||
|
||
## 매 결정 기준
|
||
| 상황 | Approach |
|
||
|---|---|
|
||
| 매 small finite space | BFS / DFS — 매 complete |
|
||
| 매 large but heuristic-able | A* / IDA* |
|
||
| 매 huge stochastic | MCTS (UCT) |
|
||
| 매 continuous space | gradient-based / Bayesian opt |
|
||
| 매 LLM reasoning | Tree-of-Thoughts / Graph-of-Thoughts |
|
||
| 매 constraint-rich | CSP solver (Z3, OR-Tools) |
|
||
|
||
**기본값**: 매 first 매 reformulate problem 으로 매 space 의 size ↓ — 매 algorithm choice 보다 효과 큼.
|
||
|
||
## 🔗 Graph
|
||
- 부모: [[Combinatorial Optimization]]
|
||
- 변형: [[State Space]] · [[Hypothesis Space]]
|
||
- 응용: [[MCTS]]
|
||
|
||
## 🤖 LLM 활용
|
||
**언제**: 매 problem 의 매 search space modeling 의 매 design 도움.
|
||
**언제 X**: 매 매우 narrow domain (chess engine 등) — specialized solver 가 우위.
|
||
|
||
## ❌ 안티패턴
|
||
- **No pruning**: 매 brute-force on b^d=10^15 — 매 wall-clock 의 절망.
|
||
- **Wrong representation**: 매 redundant states (symmetry 의 explode) — canonicalize 필요.
|
||
- **Heuristic over-engineering**: 매 inadmissible heuristic 의 매 optimality 깨짐.
|
||
|
||
## 🧪 검증 / 중복
|
||
- Verified (Russell & Norvig *AIMA* 4th ed; Yao et al. ToT 2023).
|
||
- 신뢰도 A.
|
||
|
||
## 🕓 Changelog
|
||
| 날짜 | 변경 |
|
||
|---|---|
|
||
| 2026-05-08 | Phase 1 |
|
||
| 2026-05-10 | Manual cleanup — Search Space components/scaling/BFS/A*/CSP/ToT 정리 |
|