Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132930 views
License: OTHER
1
\documentclass{article}
2
\usepackage[pdftex,active,tightpage]{preview}
3
\setlength\PreviewBorder{2mm}
4
5
\usepackage[utf8]{inputenc} % this is needed for umlauts
6
\usepackage[ngerman]{babel} % this is needed for umlauts
7
\usepackage[T1]{fontenc} % this is needed for correct output of umlauts in pdf
8
\usepackage{amssymb,amsmath,amsfonts} % nice math rendering
9
\usepackage{braket} % needed for \Set
10
\usepackage{caption}
11
\usepackage{algorithm}
12
\usepackage[noend]{algpseudocode}
13
14
\DeclareCaptionFormat{myformat}{#3}
15
\captionsetup[algorithm]{format=myformat}
16
17
\begin{document}
18
\begin{preview}
19
\begin{algorithm}[H]
20
\begin{algorithmic}
21
\Require
22
\Statex Sates $\mathcal{X} = \{1, \dots, n_x\}$
23
\Statex Actions $\mathcal{A} = \{1, \dots, n_a\},\qquad A: \mathcal{X} \Rightarrow \mathcal{A}$
24
\Statex Cost function $g: \mathcal{X} \times \mathcal{A} \rightarrow \mathbb{R}$
25
\Statex Transition probabilities $f$, $F$
26
\Statex $\alpha \in (0, 1)$
27
\Procedure{PolicyIteration}{$\mathcal{X}$, $A$, $g$, $f$, $F$, $\alpha$}
28
\State Initialize $\pi$ arbitrarily
29
\While{$\pi$ is not converged}
30
\State $J \gets$ solve system of linear equations $(I - \alpha \cdot F(\pi)) \cdot J = g(\pi)$
31
32
\For{$x \in \mathcal{X}$}
33
\For{$a \in A(x)$}
34
\State $Q(x, a) \gets g(x, a) + \alpha \sum_{j=1}^{n_x} f_{xj}(a) \cdot J(j)$
35
\EndFor
36
\EndFor
37
\For{$x \in \mathcal{X}$}
38
\State $\pi(x) \gets \arg \min_a \{Q(x, a)\}$
39
\EndFor
40
\EndWhile
41
\Return $\pi$
42
\EndProcedure
43
\end{algorithmic}
44
\caption{Policy Iteration: Learning a policy $\pi: \mathcal{X} \rightarrow \mathcal{A}$}
45
\label{alg:policy-iteration}
46
\end{algorithm}
47
\end{preview}
48
\end{document}
49
50