본문으로 건너뛰기

RL 005

· 약 7분

MDP

(S,A,P,R,γ)(\mathcal{S}, \mathcal{A}, \mathcal{P}, \mathcal{R}, \gamma)

  • At each time step tt, the agent observes state StSS_t \in \mathcal{S} and chooses action AtAA_t \in \mathcal{A}
  • Receives reward Rt+1RR_{t+1} \in \mathcal{R}
  • Transitions to a new state St+1S_{t+1}

Transition Dynamics

Transition Probability

  • How the environment responds to an action, independent of the agent's policy
  • Policy: Whether to brake or accelerate when the traffic light is yellow.
  • Transition Dynamics: How much the car decelerates after braking, and what the resulting next state is.

P(ss,a)=P(St+1=sSt=s,At=a)P(s'|s,a) = P(S_{t+1} = s'|S_t = s, A_t = a)

Policy

  • A policy is the agent’s rule for choosing actions.
  • It tells the agent what action to take in a given state.
  • It defines agent's behavior.

Deterministic Policy:π(s)=a\text{Deterministic Policy}: \pi(s) = a

  • Direct mapping, and no randomness
  • All probability on one action

Stochastic Policy:π(as)=P(At=aSt=s)\text{Stochastic Policy}: \pi(a|s) = P(A_t = a | S_t = s)

  • A probability distribution over actions.
  • More general, all four Bellman Equations are stochastic, use π(as)\pi(a|s) to represent the policy.
  • Policy is what the agent controls.

Value Functions

vπ(s)=Eπ[Rt+1+γvπ(St+1)St=s]v_\pi(s) = \mathbb{E}_\pi[R_{t+1} + \gamma v_\pi(S_{t+1}) | S_t = s]

  • How good is this state?
  • Eπ[GtSt=s]\mathbb{E}_\pi[G_t | S_t = s]

qπ(s,a)=Eπ[Rt+1+γvπ(St+1)St=s,At=a]q_\pi(s,a) = \mathbb{E}_\pi[R_{t+1} + \gamma v_\pi(S_{t+1}) | S_t = s, A_t = a]

  • How good is this action in this state?
  • Eπ[GtSt=s,At=a]\mathbb{E}_\pi[G_t | S_t = s, A_t = a]

vπ(s)=aAπ(as)qπ(s,a)v_\pi(s) = \sum_{a \in \mathcal{A}} \pi(a|s) q_\pi(s,a)

  • The average value of the actions, weighted by the probability of choosing each action.
    • a1a_1 is brake
    • a2a_2 is accelerate
    • vπ(s)=0.810+0.220=10v_\pi(s) = 0.8 * 10 + 0.2 * 20 = 10
qπ(s,a)=R(s,a)+γsSP(ss,a)vπ(s)q_\pi(s,a) = \mathcal{R}(s,a) + \gamma \sum_{s' \in \mathcal{S}} P(s'|s,a) v_\pi(s')
  • The value of taking action aa in state ss: the immediate reward plus the discounted expected value of the possible next states.

Four Types of Bellman Equations

vπ(s)=aπ(as)qπ(s,a)qπ(s,a)=R(s,a)+γsP(ss,a)vπ(s)vπ(s)=aπ(as)[R(s,a)+γsP(ss,a)vπ(s)]qπ(s,a)=R(s,a)+γsP(ss,a)aπ(as)qπ(s,a)\begin{aligned} &v_\pi(s) = \sum_{a} \pi(a|s) q_\pi(s,a) \\ &q_\pi(s,a) = \mathcal{R}(s,a) + \gamma \sum_{s'} P(s'|s,a) v_\pi(s') \\ &v_\pi(s) = \sum_{a} \pi(a|s) \left[ \mathcal{R}(s,a) + \gamma \sum_{s'} P(s'|s,a) v_\pi(s') \right] \\ &q_\pi(s,a) = \mathcal{R}(s,a) + \gamma \sum_{s'} P(s'|s,a) \sum_{a'} \pi(a'|s') q_\pi(s',a') \end{aligned}
  • Evaluate a state: vπ(s)v_\pi(s)
  • Evaluate an action: qπ(s,a)q_\pi(s,a)
  • Calculate Bellman by only vv: Third equation
  • Calculate Bellman by only qq: Fourth equation

Dynamic Programming

Optimization method for sequential problem

  • Dynamic: Sequential or Temporal component
  • Programming: Optimizing a program or policy
  • Sub Problem
  • Optimal Solution

Prediction and Control

  • Prediction: Evaluate a given policy vπ(s)v_\pi(s)
  • Control: Find the optimal policy π\pi_*

Policy Improvement

  • πvππ\pi \to v_\pi \to \pi'
  • π=greedy(vπ)\pi' = \text{greedy}(v_\pi)
  • Evaluate current policy, Improve it greedily, then get a better policy

Policy Improvement

Modified Policy Iteration

  • Policy iteration can be computationally expensive
  • MPI: cut off the policy evaluation after a few iterations kk then step to policy improvement.
    • k=1Value iterationk = 1 \Rightarrow \text{Value iteration}
    • k=3,4Modified Policy iterationk = 3,4 \Rightarrow \text{Modified Policy iteration}
    • kis large enoughPolicy iterationk \quad \text{is large enough} \Rightarrow \text{Policy iteration}

Poisson Distribution Formulation

P(X=n)=λneλn!P(X = n) = \frac{\lambda^n e^{-\lambda}}{n!}

  • How many times an event occurs within a fixed interval of time (or space) when we only know the long-term average rate (λ\lambda).
  • nn: The actual number of requests or returns (n{0,1,2,}n \in \{0, 1, 2, \ldots\})
  • λ\lambda: The expected/average number of requests or returns
  • ee: Euler's number (2.71828)
  • n!n!: Factorial of nn

Deterministic Value Iteration

v(s)=maxa(R(s,a)+γsP(ss,a)v(s))v_*(s) = \max_{a} \left( \mathcal{R}(s,a) + \gamma \sum_{s'} P(s'|s,a) v_*(s') \right)

  • If solutions to sub-problems v(s)v_*(s') are known, the optimal value v(s)v_*(s) for the current state can be computed directly.
  • Value signals propagate backwards across the state space from states with terminal rewards.

Value Iteration

vk+1(s)=maxa(R(s,a)+γsP(ss,a)vk(s))v_{k+1}(s) = \max_{a} \left( \mathcal{R}(s,a) + \gamma \sum_{s'} P(s'|s,a) v_k(s') \right)

  • Infinite (\infty) iterations are required to converge exactly to vv_*.
  • In practical implementations, iteration terminates when the maximum value change between iterations is less than a small threshold θ\theta.

Dynamic Programming ALgorithms

ProblemBellman EquationAlgorithm
PredictionBellman Expectation:
vk+1(s)=aAπ(as)(R(s,a)+γsSP(ss,a)vk(s))v_{k+1}(s) = \sum_{a \in A} \pi(a \mid s) \left( R(s, a) + \gamma \sum_{s' \in S} P(s' \mid s, a) v_k(s') \right)
Iterative Policy Evaluation
ControlBellman Expectation + Greedy Policy Improvement:
vk+1(s)=aAπ(as)(R(s,a)+γsSP(ss,a)vk(s))v_{k+1}(s) = \sum_{a \in A} \pi(a \mid s) \left( R(s, a) + \gamma \sum_{s' \in S} P(s' \mid s, a) v_k(s') \right)
π=greedy(Vπ)\pi' = \text{greedy}(V_\pi)
Policy Iteration
ControlBellman Optimality:
vk+1(s)=maxa(R(s,a)+γsSP(ss,a)vk(s))v_{k+1}(s) = \max_a \left( R(s, a) + \gamma \sum_{s' \in S} P(s' \mid s, a) v_k(s') \right)
Value Iteration

Efficiency of DP

  • Strengths:
    • A foundational and efficient framework widely used for solving MDPs.
    • Mathematically guaranteed to converge to an optimal policy in polynomial time in terms of the number of states and actions.
    • Exponentially faster than exhaustive direct search across the policy space (AS|A|^{|S|}).
  • Limitations:
    • Can become computationally impractical for extremely large or complex environments.
    • Curse of Dimensionality: As the number of state variables (dimensions) increases, the total state space size (S|S|) expands exponentially, leading to severe computational and memory bottlenecks.

Asynchronous Dynamic Programming

  • Comparison with Synchronous Methods: Standard DP methods sweep through the entire state space systematically in every iteration. Asynchronous DP backs up individual states independently in arbitrary order.
  • In-place Value Updates: Directly overwrites values in a single memory array, allowing immediate propagation of newly updated state values to subsequent calculations.
  • Computational Gain & Convergence:
    • Significantly reduces computation by avoiding exhaustive full-state sweeps.
    • Guaranteed to converge to the optimal value function vv_*, provided that all states continue to be selected and updated indefinitely.

Real-Time Dynamic Programming (RTDP)

  • Interaction-Driven Online Updates: Solves sub-problems on-the-fly by focusing updates specifically on states that are directly relevant to the agent's current trajectory.
  • Target Applications: Large-scale environments where full state-space iteration is intractable (e.g., robotics, autonomous control systems, game AI).
  • Core Characteristics:
    • Online Decision Making: Makes and refines decisions while operating directly in the environment.
    • Lazy Evaluation: Computes values only for visited or critical state subsets rather than unvisited distant states.
    • Adaptive Exploration: Guides search toward high-reward trajectories through active interaction.
    • Approximate MDP Solution: Yields near-optimal policies for relevant regions without solving the global MDP.

Approximate Dynamic Programming (ADP)

  • Motivation: Addresses the curse of dimensionality where tabular representation of states and exact value computation become computationally infeasible.
  • Function Approximation Methods: Parameterizes and estimates the value function using scalable statistical and machine learning models:
    • Linear models, deep neural networks, decision trees, and general regression techniques.
  • Error Management Mechanisms:
    • Eligibility Traces: Accelerates credit assignment and temporal consistency across multi-step transitions.
    • Experience Replay: Stores transition tuples in a replay buffer and samples them randomly to break data correlation and stabilize value approximation.