Course materials · Reinforcement Learning for Electrical Engineering

Value-Based Reinforcement Learning

English translation

Graduate course · Research application activities

Solving a small problem with a table provides a baseline for comparing complex function approximation models.

Before practice

01 What does one Q-table entry estimate?

Description

Q(s,a) ← Q(s,a)+α[r+γ max Q(s′,·)−Q(s,a)]. Exclude future value when the task itself terminates. Interpret time limits separately.

02 Are exploration return and evaluation return the same?

Description

Exploratory actions are needed during training, but evaluate policies separately under the same conditions. Also inspect Q-values for unvisited states.

Execution conditions

Run the baseline Queue example with NumPy. Compare policies on seed=100…104, which were not used for training.

Applications

Throughput and cost of equipment and communication resources

An average of 2 items arrive at the synthetic queue each time step. Increasing service capacity reduces queue length but increases energy cost.

Observation·State
Queue length q=0q=0…20. Observation q/20q/20.
Action
Choose a processing capacity of 0, 2, or 4.
Reward·Constraint
−(next queue length + 0.2×capacity² + 10×dropped items). Time limit at 100 steps.
Comparison baseline
Constant capacity of 2, and a threshold policy based on queue length.
Metrics to check
Evaluation return, mean queue length, mean capacity², and dropped-item count.

Mobile robot paths and safety

An application design case choosing either grid paths or continuous velocity control.

Observation·State
Position, target-relative position, and nearby obstacle observations.
Action
Grid direction selection or bounded linear and angular velocities.
Reward·Constraint
Separate arrival, collision, and movement costs. Distinguish collisions from timeouts.
Comparison baseline
Shortest path and rule-based avoidance.
Metrics to check
Success rate, collision rate, travel distance, and time. Evaluate on unseen maps.

Practice

Preview practice notebookDownload practice notebook

1. Q-learning in a small state space

Starting conditions

Learn Queue's q=0,…,20q=0,\ldots,20 and three actions using a Q-table. Use γ=0.95\gamma=0.95, α=0.1\alpha=0.1, and ϵ=0.2\epsilon=0.2, and run 50 episodes with at most 100 steps per episode.

Procedure

  1. Run the provided training loop and tabulate the Q-values and selected actions for q∈{0,5,10,20}q\in\{0,5,10,20\}.
  2. For evaluation, set ϵ=0\epsilon=0 and compare with the rule-based policy using the same seed.
  3. If low capacity is chosen for large queues, first check visit counts and the reward structure.

Results to retain

Items to record and points to check
q
Q(a=0a=0)
Q(a=1a=1)
Q(a=2a=2)
Selected action
Visit count

Points to check

  • Did you distinguish action selection from exploration during evaluation?
  • Did you retain bootstrapping at time limits and separate evaluation seeds from training seeds?

2. Discount factor and decision making

Starting conditions

Compare γ=.5\gamma=.5 and .95. Keep other training conditions and the total number of transitions fixed.

Procedure

  1. Wrap the Q-table training loop in a train_q(gamma) function, and replace constant .95 in the target formula with argument gamma. Run this function for both discount factors.
  2. Compare queue length, capacity², and dropped items on the same evaluation set.
  3. If the selected action changed at a particular q, explain it in terms of short-term cost and future queue length.

Results to retain

Items to record and points to check
γ
Evaluation return
Mean queue length
Capacity²
Dropped items
q values where the policy changed

Points to check

  • Did you keep the training budget unchanged?
  • Did you compare policies on a common evaluation set rather than one chance episode?

3. Apply this to your research problem

Starting conditions

Based on the preceding experiments, choose Queue, Motor, or one of your research problems and design an experiment for real application.

Procedure

  1. Define state, observation, action, reward, termination, and time limit in one table. Record each variable's units and the information you can actually obtain.
  2. Write 3 expected transitions numerically and check whether rewards for good and bad actions match your intent.
  3. Choose one rule-based comparison baseline, one evaluation condition, and one failure case of greatest concern. Also list the required measurements or simulator.

Results to retain

You may continue with the research problem and design table selected earlier. Revisit existing entries and transition examples using the concepts learned in this activity, and update changed entries or reasons for retaining them.

Items to record and points to check
Item
Concrete definition and units
Observability and verification method

Points to check

  • Did you exclude future information and evaluation labels from observations?
  • Did you define domain-specific metrics rather than judging the research contribution solely by training return?