dynamic-programming.tex 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. \documentclass{article}
  2. \usepackage[pdftex,active,tightpage]{preview}
  3. \setlength\PreviewBorder{2mm}
  4. \usepackage[utf8]{inputenc} % this is needed for umlauts
  5. \usepackage[ngerman]{babel} % this is needed for umlauts
  6. \usepackage[T1]{fontenc} % this is needed for correct output of umlauts in pdf
  7. \usepackage{amssymb,amsmath,amsfonts} % nice math rendering
  8. \usepackage{braket} % needed for \Set
  9. \usepackage{caption}
  10. \usepackage{algorithm}
  11. \usepackage[noend]{algpseudocode}
  12. \DeclareCaptionFormat{myformat}{#3}
  13. \captionsetup[algorithm]{format=myformat}
  14. \begin{document}
  15. \begin{preview}
  16. \begin{algorithm}[H]
  17. \begin{algorithmic}
  18. \Require
  19. \Statex Sates $\mathcal{X} = \{1, \dots, n_x\}$
  20. \Statex Actions $\mathcal{A} = \{1, \dots, n_a\},\qquad A: \mathcal{X} \Rightarrow \mathcal{A}$
  21. \Statex Cost function $g: \mathcal{X} \times \mathcal{A} \rightarrow \mathbb{R}$
  22. \Statex Horizon $N \in \mathbb{N}_{\geq 1}$
  23. \Statex Discounting factor $\alpha \in [0, 1]$
  24. \Procedure{DynamicProgramming}{$\mathcal{X}$, $A$, $g$, $N$, $\alpha$}
  25. \State $J_N(x) \gets g_N(x) \quad \forall x \in \mathcal{X}$
  26. \For{$k = N - 1$ to $0$}
  27. \For{$x \in \mathcal{X}$}
  28. \For{$a \in A(x)$}
  29. \State $Q(x, a) \gets g_k(x, a) + \alpha \sum_{j=1}^{n_x} f_{xj}(a) \cdot J_{k+1}(j)$
  30. \EndFor
  31. \State $J_k (x) \gets \min_a (Q_k(x,a))$
  32. \State $\pi_k(x) \gets \arg \min_a (Q_k(x, a))$
  33. \EndFor
  34. \EndFor
  35. \Return $\pi_{0:N-1}$
  36. \EndProcedure
  37. \end{algorithmic}
  38. \caption{Dynamic Programming}
  39. \label{alg:dynamic-programming: Learn a strategy}
  40. \end{algorithm}
  41. \end{preview}
  42. \end{document}