Lessons › Chapter 13: Reinforcement learning
Markov decision processes
A markov decision process writes a decision problem down precisely. First, the states. A smart thermostat’s room can be cold, comfy or hot.
Watch it move. This lesson is interactive on Gradient Lab: every step is an animated scene you can replay.
Start the interactive lessonStep by step
Write the problem down
Before training anything, Leo writes down the situations, the possible actions and the rewards precisely.
States
A markov decision process writes a decision problem down precisely. First, the states. A smart thermostat’s room can be cold, comfy or hot.
Actions and chances
In each state you can take an action: heat or wait. What happens next isn’t certain. Heating a cold room makes it comfy 80% of the time. Heating a comfy room often overshoots to hot.
Rewards
Each state gives a reward: +1 for comfy, −1 for too cold or too hot. (A real thermostat would also subtract a little for energy used.)
A policy
A policy says what to do in each state: heat when cold, wait when comfy or hot. Solving an MDP means finding the policy that earns the most reward over time.
In real life: a smart thermostat
Smart thermostats and building-energy systems face exactly this kind of problem: heat now or wait, trading comfort against energy cost, with uncertain results. Data-center cooling has been optimized with reinforcement learning in the same spirit.
Quick check: In an MDP, what does a policy tell you?
- Which action to take in each state (correct)
- The reward for each state
- Where the training data came from
A policy maps every state to an action (or to probabilities over actions).
Pseudocode
states = [cold, comfy, hot] actions = [heat, wait] P(next state | state, action) # e.g. heat when cold → comfy 80% R(state) # comfy = +1, cold or hot = −1 policy = which action to take in each state
Key terms
- markov decision process
- The standard frame for decision problems: states, actions, chances of what happens next, and rewards.