# Programowanie dynamiczne: iteracja wartości i polityki

EN: **Dynamic programming for MDPs (value and policy iteration)** · id `dynamicprogramming` · aliases: dynamic programming, value iteration, policy iteration, iteracja wartości, iteracja polityki

Path: [AI Atlas](https://aiatlasgraph.com/llms.txt) › [Uczenie ze wzmocnieniem i decyzje](https://aiatlasgraph.com/t/decisions.md) › [Podstawy RL](https://aiatlasgraph.com/t/rlbasics.md) › Programowanie dynamiczne: iteracja wartości i polityki

## Description

- PL: Obliczanie optymalnej polityki, gdy model przejść i nagród jest w pełni znany, przez wielokrotne stosowanie równań Bellmana. Punkt odniesienia dla metod uczących się z prób.
- EN: Computing an optimal policy when the transition and reward model is fully known, by repeatedly applying the Bellman equations. The reference point for methods that learn from trials.

## In one sentence

- PL: To liczenie najlepszego sposobu działania, gdy dokładnie znasz reguły świata i skutki każdego ruchu.
- EN: This computes the best way to act when you know the world's rules and the result of every move exactly.

## Problem it solves

- PL: Masz pełny opis zadania, ale sprawdzanie wszystkich możliwych planów po kolei trwałoby wieki.
- EN: You have a complete description of the task, but checking every possible plan one by one would take forever.

## What it does

- PL: Jak liczenie drogi od mety wstecz: każde pole dostaje ocenę z ocen sąsiadów, aż oceny przestaną się zmieniać.
- EN: Like working backwards from the finish line: each square gets a score from its neighbours' scores until the scores stop changing.

## Everyday example

- PL: Robot sprzątający zna plan mieszkania i dla każdego pokoju wylicza, którędy najszybciej dojedzie do stacji ładowania.
- EN: A cleaning robot knows the flat's floor plan and works out, for every room, the quickest way back to its charging dock.

## This concerns you if you…

- PL: znasz dokładne reguły i koszty swojego zadania
- PL: chcesz zrozumieć, skąd biorą się metody uczenia przez próby
- PL: potrzebujesz wzorcowego rozwiązania do porównań
- EN: know the exact rules and costs of your task
- EN: want to understand where trial-based learning methods come from
- EN: need a reference solution to compare against

## Keywords

value iteration · policy iteration · policy evaluation · generalized policy iteration · Bellman optimality equation · asynchronous dynamic programming · real-time dynamic programming

## How it works

- PL: Ocena polityki wielokrotnie stosuje równanie Bellmana dla ustalonej polityki, a poprawa polityki wybiera akcje zachłanne względem otrzymanych wartości. Iteracja wartości łączy oba kroki w jednej aktualizacji z maksimum po akcjach.
- EN: Policy evaluation repeatedly applies the Bellman equation for a fixed policy, and policy improvement picks actions greedily with respect to the resulting values. Value iteration merges both steps into one update with a maximum over actions.

## Limits

- PL: Wymaga pełnego modelu środowiska i przechodzi po wszystkich stanach, więc koszt rośnie z liczbą stanów (przekleństwo wymiarowości). W dużych problemach zastępuje się go próbkowaniem i aproksymacją.
- EN: It needs a full model of the environment and sweeps over every state, so cost grows with the number of states (the curse of dimensionality). Large problems replace it with sampling and approximation.

## Key terms

- PL: **iteracja wartości**: Powtarzanie aktualizacji Bellmana z maksimum po akcjach aż do zbieżności.
- PL: **iteracja polityki**: Naprzemienna pełna ocena polityki i jej zachłanna poprawa.
- PL: **uogólniona iteracja polityki**: Ogólny schemat wzajemnego poprawiania ocen i polityki, wspólny dla wielu metod RL.
- EN: **value iteration**: Repeating Bellman updates with a maximum over actions until convergence.
- EN: **policy iteration**: Alternating full policy evaluation and greedy policy improvement.
- EN: **generalised policy iteration**: The general pattern of values and policy improving each other, shared by many RL methods.

## Know first

- [Funkcje wartości i równanie Bellmana (Value functions and the Bellman equation)](https://aiatlasgraph.com/t/bellman.md)
- [Proces decyzyjny Markowa (MDP) (Markov decision processes (MDP))](https://aiatlasgraph.com/t/mdp.md)

## Examples

- PL: iteracja wartości · iteracja polityki · ocena polityki · uogólniona iteracja polityki
- EN: value iteration · policy iteration · policy evaluation · generalised policy iteration

## Sources

- [Reinforcement Learning: An Introduction (2nd edition)](<http://incompleteideas.net/book/the-book-2nd.html>) `sutton-barto-rl-2018` · by Richard S. Sutton, Andrew G. Barto
- [Planning and acting in partially observable stochastic domains](<https://doi.org/10.1016/S0004-3702(98)00023-X>) `kaelbling-pomdp-1998` · by Leslie Pack Kaelbling, Michael L. Littman, Anthony R. Cassandra
- [Stanford CS234 · Lecture 3: Model-Free Policy Evaluation (Winter 2026)](<https://web.stanford.edu/class/cs234/slides/lecture3pre.pdf>) `cs234-2026-lecture3` · by Emma Brunskill

---

AI Atlas revision 122 (2026-10-30) · HTML: https://aiatlasgraph.com/t/dynamicprogramming · index: https://aiatlasgraph.com/llms.txt · everything: https://aiatlasgraph.com/llms-full.txt · updated 2026-10-30
