Skip to content
AI360Xpert
Beta

The Options Framework

The Options Framework extends reinforcement learning beyond single-step primitive actions by formalizing temporally extended subroutines with initiation sets, internal policies, and termination conditions.

The Options Framework enables temporal abstraction by formalizing macro-actions as 3-tuples of initiation sets, internal policies, and termination conditions in Semi-MDPs.
The Options Framework enables temporal abstraction by formalizing macro-actions as 3-tuples of initiation sets, internal policies, and termination conditions in Semi-MDPs.

Why Does This Exist?

In standard reinforcement learning, the agent operates in lockstep with a discrete clock: at every single timestep tt, the agent receives state sts_t, selects a single primitive action ata_t, receives reward rt+1r_{t+1}, and transitions to st+1s_{t+1}. For complex, long-horizon tasks—such as an autonomous robot navigating across an entire office building or solving an intricate manipulation puzzle—this flat, step-by-step representation introduces severe bottlenecks:

  1. Exponential Exploration Complexity: If an agent must take 10,000 primitive joint motor commands to reach a distant room, undirected random exploration (like ϵ\epsilon-greedy) requires exponential time to stumble upon the goal. The probability of randomly generating a coherent sequence of thousands of low-level motor torques is virtually zero.
  2. Diluted Credit Assignment: When a delayed reward is finally discovered after thousands of steps, Temporal Difference Learning must backpropagate that reward signal backwards across thousands of individual transitions, requiring millions of training iterations for values to propagate to initial states.
  3. Inability to Reuse Behavioral Modules: Biological intelligence does not plan at the millisecond motor-twitch level. When deciding to grab a cup of coffee, humans invoke macro-behaviors: "stand up", "walk down the hall", "open door", and "grasp cup". Flat RL forces the agent to relearn basic locomotion primitives from scratch for every new task.

The Options Framework, formalized in the seminal work of Richard Sutton, Doina Precup, and Satinder Singh (1999), resolves this by bringing temporal abstraction to reinforcement learning. Instead of restricting actions to single-step primitives, the framework formalizes macro-actions—termed options—that execute over variable temporal durations. By embedding options into the mathematics of Semi-Markov Decision Processes (SMDPs), the framework allows agents to plan, learn, and act seamlessly across multiple time scales without abandoning the rigorous convergence guarantees of dynamic programming.

Think of It Like This

Reusable Subroutines in Software Engineering

Imagine writing a complex software application in raw x86 assembly language where your only available operations are single-clock-cycle CPU instructions: bit-shifts, register increments, and jumps.

If you had to write every sorting algorithm, network socket connection, and file reading loop by copy-pasting hundreds of lines of assembly instructions directly into your main() loop, programming would be impossible. Finding bugs would be agonizing, and optimizing high-level business logic would get lost in the weeds of register allocation.

Instead, computer science relies on functions and subroutines:

  • A function like quicksort(array) has a clear entry prerequisite: the input must be an array of comparable items (the Initiation Set).
  • Once invoked, the function executes a specialized sequence of loops and swaps across hundreds or thousands of CPU cycles (the Internal Policy).
  • When the array is fully partitioned and sorted, the function reaches a return statement and exits (the Termination Condition).

At the high-level application level, your program simply calls quicksort(). The CPU still executes primitive assembly instructions underneath, but your planning logic operates across macro-level units of work.

The Options Framework does the exact same thing for reinforcement learning agents. An option is a callable behavioral subroutine: the agent invokes a high-level option like navigate_to_doorway(), the option runs its internal policy for kk environment ticks, and returns control to the high-level policy when the doorway is reached.

Where the analogy stops: Software subroutines are typically deterministic and write to clean memory addresses. In RL, options operate in stochastic, partially observable physical environments, where transitions are probabilistic and termination conditions βω(s)\beta_\omega(s) are stochastic functions evaluated at every state.

How It Actually Works

Formal 3-Tuple Definition of an Option

In the Options Framework, an option ω∈Ω\omega \in \Omega is formally defined as a 3-tuple:

ω=⟨Iω,πω,βω⟩\omega = \langle \mathcal{I}_\omega, \pi_\omega, \beta_\omega \rangle

where:

  1. Initiation Set Iω⊆S\mathcal{I}_\omega \subseteq \mathcal{S}: The subset of states in which the option can be initiated. An option ω\omega is available to be selected at state ss if and only if s∈Iωs \in \mathcal{I}_\omega. The set of available options at state ss is denoted Ω(s)={ω∈Ω∣s∈Iω}\Omega(s) = \{\omega \in \Omega \mid s \in \mathcal{I}_\omega\}.
  2. Internal Policy πω:S×A→[0,1]\pi_\omega: \mathcal{S} \times \mathcal{A} \to [0, 1]: The policy governing the agent while option ω\omega is executing. When in state ss under active option ω\omega, the agent selects primitive action aa with probability πω(a∣s)\pi_\omega(a | s).
  3. Termination Condition βω:S→[0,1]\beta_\omega: \mathcal{S} \to [0, 1]: A function giving the probability that the option terminates upon arriving in state ss. If the agent enters state ss, option ω\omega terminates with probability βω(s)\beta_\omega(s), relinquishing control back to the high-level policy. With probability 1−βω(s)1 - \beta_\omega(s), the option continues executing πω\pi_\omega.

Primitive Actions as Degenerate Options:
Every standard primitive action a∈Aa \in \mathcal{A} can be expressed as a 1-step option:

Ia=S,πa(a′∣s)=I(a′=a),βa(s)=1.0,∀s∈S\mathcal{I}_a = \mathcal{S}, \quad \pi_a(a' | s) = \mathbb{I}(a' = a), \quad \beta_a(s) = 1.0, \quad \forall s \in \mathcal{S}

Because primitive actions are valid options of duration k=1k = 1, an agent utilizing the options framework retains the full expressive capacity of the original MDP.

Semi-Markov Decision Processes (SMDPs) and Intra-Option Learning

When an agent selects among options that execute over variable temporal durations k∈{1,2,3,… }k \in \{1, 2, 3, \dots\}, the underlying discrete-time Markov Decision Process transitions to a Semi-Markov Decision Process (SMDP) at the macro level.

Primitive MDP (k = 1):s_0 ──[a_0, r_1]──► s_1 ──[a_1, r_2]──► s_2 ──[a_2, r_3]──► s_3 (Discount: gamma)
Macro SMDP (k = 3 steps):s_0 ═══════════════[ Option omega, R(s_0, omega) ]══════════════► s_3 (Discount: gamma^3)    (Executes internal policy pi_omega until beta_omega(s_3) = 1)

1. SMDP Reward and Transition Models

Let E(s,ω)\mathcal{E}(s, \omega) denote the event that option ω\omega is initiated at state ss at time tt, terminating at time t+kt+k in state s′s'.

The expected multi-step discounted reward of option ω\omega is:

R(s,ω)=E[rt+1+γrt+2+γ2rt+3+⋯+γk−1rt+k ∣ E(s,ω)]R(s, \omega) = \mathbb{E} \left[ r_{t+1} + \gamma r_{t+2} + \gamma^2 r_{t+3} + \dots + \gamma^{k-1} r_{t+k} \,\Big|\, \mathcal{E}(s, \omega) \right]

The discounted transition probability to arrive at terminal state s′s' under option ω\omega across all possible durations kk is:

P(s′∣s,ω)=∑k=1∞γkP(s′,k∣s,ω)P(s' \mid s, \omega) = \sum_{k=1}^\infty \gamma^k P(s', k \mid s, \omega)

where P(s′,k∣s,ω)P(s', k \mid s, \omega) is the joint probability that option ω\omega terminates in state s′s' after exactly kk steps.

2. Macro-Level Bellman Equations over Options

Let μ(ω∣s)\mu(\omega | s) denote the high-level policy over options, which selects which option to execute upon option termination. The action-value of executing option ω\omega in state ss satisfies the Bellman Equation:

Q(s,ω)=R(s,ω)+∑s′∈SP(s′∣s,ω)max⁡ω′∈Ω(s′)Q(s′,ω′)Q(s, \omega) = R(s, \omega) + \sum_{s' \in \mathcal{S}} P(s' \mid s, \omega) \max_{\omega' \in \Omega(s')} Q(s', \omega')

The optimal state value across all available options is:

V∗(s)=max⁡ω∈Ω(s)Q∗(s,ω)V^*(s) = \max_{\omega \in \Omega(s)} Q^*(s, \omega)

3. Intra-Option Learning

Standard SMDP Q-learning waits until an option fully terminates after kk steps before performing a single value update. If an option executes for 50 steps, nothing is learned until step 50.

Intra-Option Learning overcomes this latency by updating option values on every single primitive transition (s,a,r,s′)(s, a, r, s'):

Q(s,ω)←Q(s,ω)+α[r+γU(s′,ω)−Q(s,ω)]Q(s, \omega) \leftarrow Q(s, \omega) + \alpha \left[ r + \gamma U(s', \omega) - Q(s, \omega) \right]

where U(s′,ω)U(s', \omega) represents the expected value of arriving in state s′s':

U(s′,ω)=(1−βω(s′))Q(s′,ω)+βω(s′)max⁡ω′∈Ω(s′)Q(s′,ω′)U(s', \omega) = (1 - \beta_\omega(s')) Q(s', \omega) + \beta_\omega(s') \max_{\omega' \in \Omega(s')} Q(s', \omega')

If the option continues (βω(s′)=0\beta_\omega(s') = 0), the bootstrap target is Q(s′,ω)Q(s', \omega). If the option terminates (βω(s′)=1\beta_\omega(s') = 1), the target switches to the optimal next option value max⁡ω′Q(s′,ω′)\max_{\omega'} Q(s', \omega'). Crucially, intra-option learning enables off-option learning: an experience tuple generated by one option can simultaneously update all other options whose internal policy is consistent with action aa.

Worked numerical example

Let us trace a concrete option execution in the classic 4-room gridworld door navigation problem:

  • Environment Setup:
    • State s0s_0: Interior room position (non-terminal). Current option estimate: Q(s0,ωdoor)=5.00Q(s_0, \omega_{\text{door}}) = 5.00.
    • State s1s_1: Intermediate hallway position.
    • State s2=sdoors_2 = s_{\text{door}}: Goal doorway connecting Room 1 to Room 2.
  • Option ωdoor\omega_{\text{door}} Specification:
    • Initiation set: Idoor=Room 1 states\mathcal{I}_{\text{door}} = \text{Room 1 states}.
    • Termination condition:
      • β(s1)=0.0\beta(s_1) = 0.0 (continue).
      • β(s2)=1.0\beta(s_2) = 1.0 (terminate at doorway).
    • Discount factor: γ=0.90\gamma = 0.90.
  • Option Trajectory Rollout (k=2k = 2 primitive steps):
    • Step 1: Takes primitive action a0=Easta_0 = \text{East}, receives reward r1=0.0r_1 = 0.0, reaches s1s_1. Termination check: β(s1)=0.0\beta(s_1) = 0.0.
    • Step 2: Takes primitive action a1=Easta_1 = \text{East}, receives reward r2=+1.0r_2 = +1.0, reaches doorway s2s_2. Termination check: β(s2)=1.0  ⟹  \beta(s_2) = 1.0 \implies Option terminates!
  • Next-State Value:
    • At doorway s2s_2, the agent can invoke options to enter Room 2. Suppose maximum next option value is: max⁡ω′∈Ω(s2)Q(s2,ω′)=6.00\max_{\omega' \in \Omega(s_2)} Q(s_2, \omega') = 6.00

Step 1: Compute the Multi-Step Discounted Reward R(s0,ωdoor)R(s_0, \omega_{\text{door}})

The accumulated discounted reward over the duration k=2k = 2 is:

R(s0,ωdoor)=r1+γr2=0.0+0.90×1.0=0.90R(s_0, \omega_{\text{door}}) = r_1 + \gamma r_2 = 0.0 + 0.90 \times 1.0 = 0.90

Step 2: Compute the Effective Temporal Discount Factor

Because the option executed for k=2k = 2 primitive timesteps, the future value at termination is discounted by γk\gamma^k:

γk=γ2=(0.90)2=0.81\gamma^k = \gamma^2 = (0.90)^2 = 0.81

Step 3: Compute the SMDP Bellman Target

The SMDP Bellman target for option value Q(s0,ωdoor)Q(s_0, \omega_{\text{door}}) is:

ySMDP=R(s0,ωdoor)+γkmax⁡ω′∈Ω(s2)Q(s2,ω′)=0.90+0.81×6.00=0.90+4.86=5.76y_{\text{SMDP}} = R(s_0, \omega_{\text{door}}) + \gamma^k \max_{\omega' \in \Omega(s_2)} Q(s_2, \omega') = 0.90 + 0.81 \times 6.00 = 0.90 + 4.86 = 5.76

Step 4: Evaluate Temporal Difference (TD) Error and Loss

Compared against the prior estimate Q(s0,ωdoor)=5.00Q(s_0, \omega_{\text{door}}) = 5.00:

δSMDP=ySMDP−Q(s0,ωdoor)=5.76−5.00=+0.76\delta_{\text{SMDP}} = y_{\text{SMDP}} - Q(s_0, \omega_{\text{door}}) = 5.76 - 5.00 = +0.76

The squared Bellman error loss is:

L=12δ2=12(0.76)2=12×0.5776=0.2888\mathcal{L} = \frac{1}{2} \delta^2 = \frac{1}{2} (0.76)^2 = \frac{1}{2} \times 0.5776 = 0.2888

Step 5: Contrast with Intra-Option Evaluation at Step 2

Under intra-option learning at step 2 (transition from s1→s2s_1 \to s_2 with r=1.0r = 1.0 and β(s2)=1.0\beta(s_2) = 1.0):

yintra=r2+γ[(1−β(s2))Q(s2,ω)+β(s2)max⁡ω′Q(s2,ω′)]y_{\text{intra}} = r_2 + \gamma \left[ (1 - \beta(s_2)) Q(s_2, \omega) + \beta(s_2) \max_{\omega'} Q(s_2, \omega') \right] yintra=1.0+0.90[(0.0)+(1.0×6.00)]=1.0+0.90×6.00=6.40y_{\text{intra}} = 1.0 + 0.90 \left[ (0.0) + (1.0 \times 6.00) \right] = 1.0 + 0.90 \times 6.00 = 6.40

Intra-option learning updates the value of reaching the doorway immediately on step 2 without waiting for retrospective SMDP trajectory stitching.

Code

import numpy as np

class OptionsFrameworkEvaluator:    """Evaluates multi-step temporal abstraction under the Options Framework:
    Option 3-tuple <I, pi, beta>, SMDP discounted return integration,    macro-Bellman target computation, and intra-option TD updates.    """
    def __init__(self, gamma: float = 0.90) -> None:        self.gamma = gamma
    def compute_smdp_return(        self, step_rewards: list[float]    ) -> tuple[float, float, int]:        """Computes multi-step discounted SMDP reward R(s, omega) and effective discount gamma^k:
        R(s, omega) = sum_{t=0}^{k-1} gamma^t * r_{t+1}        """        k = len(step_rewards)        discounted_r = 0.0        for t, r in enumerate(step_rewards):            discounted_r += (self.gamma**t) * r        effective_gamma = self.gamma**k        return float(discounted_r), float(effective_gamma), k
    def compute_smdp_target(        self,        smdp_return: float,        effective_gamma: float,        next_state_max_q: float,    ) -> float:        """Computes SMDP Bellman target: y = R(s, omega) + gamma^k * max_{omega'} Q(s', omega')."""        return float(smdp_return + effective_gamma * next_state_max_q)
    def compute_intra_option_target(        self,        reward: float,        beta_next: float,        q_same_option: float,        next_max_q: float,    ) -> float:        """Computes single-step intra-option target:
        y_intra = r + gamma * [ (1 - beta(s')) * Q(s', omega) + beta(s') * max_{omega'} Q(s', omega') ]        """        expected_continuation = (            1.0 - beta_next        ) * q_same_option + beta_next * next_max_q        return float(reward + self.gamma * expected_continuation)

if __name__ == "__main__":    np.set_printoptions(precision=4, suppress=True)
    evaluator = OptionsFrameworkEvaluator(gamma=0.90)
    # 4-room gridworld door navigation worked example    # Step 1: r=0.0, s1, beta(s1)=0.0    # Step 2: r=1.0, s2=s_door, beta(s2)=1.0    step_rewards = [0.0, 1.0]    next_max_q = 6.00    current_q_s0 = 5.00
    # 1. SMDP multi-step return and effective discount    r_smdp, eff_gamma, duration = evaluator.compute_smdp_return(step_rewards)
    # 2. SMDP Bellman target and temporal difference error    target_smdp = evaluator.compute_smdp_target(r_smdp, eff_gamma, next_max_q)    td_error_smdp = target_smdp - current_q_s0    loss_smdp = 0.5 * (td_error_smdp**2)
    # 3. Step-by-step intra-option targets    # Step 1: r=0.0, arrives at s1 where beta=0.0, suppose Q(s1, omega)=5.50    y_intra_step1 = evaluator.compute_intra_option_target(        reward=0.0, beta_next=0.0, q_same_option=5.50, next_max_q=5.50    )    # Step 2: r=1.0, arrives at s2 where beta=1.0, next_max_q=6.00    y_intra_step2 = evaluator.compute_intra_option_target(        reward=1.0, beta_next=1.0, q_same_option=4.00, next_max_q=6.00    )
    print(f"Option Duration k: {duration} steps")    # -> Option Duration k: 2 steps
    print(f"SMDP Multi-Step Reward R(s_0, omega): {r_smdp:.2f}")    # -> SMDP Multi-Step Reward R(s_0, omega): 0.90
    print(f"Effective Discount gamma^k: {eff_gamma:.4f}")    # -> Effective Discount gamma^k: 0.8100
    print(f"SMDP Bellman Target y: {target_smdp:.2f}")    # -> SMDP Bellman Target y: 5.76
    print(f"SMDP TD Error delta: +{td_error_smdp:.2f}")    # -> SMDP TD Error delta: +0.76
    print(f"Squared Bellman Loss: {loss_smdp:.4f}")    # -> Squared Bellman Loss: 0.2888
    print(f"Intra-Option Step 1 Target: {y_intra_step1:.2f}")    # -> Intra-Option Step 1 Target: 4.95
    print(f"Intra-Option Step 2 Target: {y_intra_step2:.2f}")    # -> Intra-Option Step 2 Target: 6.40
    # Assert correctness against worked example values    assert duration == 2    assert np.isclose(r_smdp, 0.90, atol=1e-2)    assert np.isclose(eff_gamma, 0.81, atol=1e-2)    assert np.isclose(target_smdp, 5.76, atol=1e-2)    assert np.isclose(td_error_smdp, 0.76, atol=1e-2)    assert np.isclose(loss_smdp, 0.2888, atol=1e-3)    assert np.isclose(y_intra_step1, 4.95, atol=1e-2)    assert np.isclose(y_intra_step2, 6.40, atol=1e-2)

Watch Out For

Option Degeneration, Chattering, and the Curse of Handcrafted Abstractions

When implementing hierarchical systems using the Options Framework, practitioners frequently encounter two catastrophic failure modes related to the termination condition βω\beta_\omega:

  1. Option Chattering (Premature Termination): If termination functions βω(s)\beta_\omega(s) are set too liberally (e.g., terminating whenever minor noise occurs), the high-level policy switches options at almost every timestep (k=1k = 1). This destroys the entire benefit of temporal abstraction, reverting the SMDP back into a flat, high-variance MDP while adding the computational overhead of hierarchical evaluation.
  2. Option Degeneration (Zombie Options): Conversely, if termination conditions are too strict or internal policies get stuck in loops, an option may never terminate (k→∞k \to \infty). The high-level policy is locked out of control, unable to adapt if environmental conditions shift.
  3. The Sub-Optimality Gap: Manually handcrafting options (e.g., hardcoding doorway waypoints) biases the agent's state-visitation trajectory. If the handcrafted subroutines fail to capture the true optimal path, the hierarchically optimal policy μ∗\mu^* will strictly underperform a flat, unconstrained policy.

The Fix: Modern hierarchical RL moves away from static, hand-designed options and uses end-to-end option discovery:

  • Adopt the Option-Critic Architecture, which parameterizes the termination function βω(s;ϑ)\beta_\omega(s; \vartheta) as a differentiable neural network trained directly via policy gradients to terminate only when the option's continuation value falls below the value of switching options.
  • Incorporate a deliberation cost (or switching penalty) η>0\eta > 0 into the termination gradient: penalize frequent option switching to naturally encourage longer, temporally meaningful options without manual tuning.

The Quick Version

  • Temporal Abstraction 3-Tuple: An option ω=⟨Iω,πω,βω⟩\omega = \langle \mathcal{I}_\omega, \pi_\omega, \beta_\omega \rangle formalizes macro-behaviors through an initiation set Iω\mathcal{I}_\omega, an internal primitive policy πω\pi_\omega, and a termination condition βω\beta_\omega.
  • Semi-Markov Decision Process (SMDP): When options execute over variable durations k≥1k \ge 1, the macro-level transition dynamics form an SMDP where rewards accumulate as R(s,ω)=∑t=0k−1γtrt+1R(s, \omega) = \sum_{t=0}^{k-1} \gamma^t r_{t+1} and future values discount by γk\gamma^k.
  • Intra-Option Efficiency: Intra-option learning avoids waiting for an option to terminate after kk steps by updating option action-values on every primitive transition, enabling simultaneous off-option updates.
  • Overcoming Flat RL Limits: Options dramatically accelerate exploration and credit assignment in long-horizon sparse-reward environments, serving as the foundational building block for modern hierarchical RL architectures like Option-Critic and Feudal Networks.