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_{xy}(a) = \mathbb{P}(y | x, a)$
26
\Statex Discounting factor $\alpha \in (0, 1)$, typically $\alpha = 0.9$
27
\Procedure{ValueIteration}{$\mathcal{X}$, $A$, $g$, $f$, $\alpha$}
28
\State Initialize $J, J': \mathcal{X} \rightarrow \mathbb{R}_0^+$ arbitrarily
29
\While{$J$ is not converged}
30
\State $J' \gets J$
31
\For{$x \in \mathcal{X}$}
32
\For{$a \in A(x)$}
33
\State $Q(x, a) \gets g(x, a) + \alpha \sum_{j=1}^{n_x} f_{xj}(a) \cdot J'(j)$
34
\EndFor
35
\EndFor
36
\For{$x \in \mathcal{X}$}
37
\State $J(x) \gets \min_a \{Q(x, a)\}$
38
\EndFor
39
\EndWhile
40
\Return $J$
41
\EndProcedure
42
\end{algorithmic}
43
\caption{Value Iteration: Learn function $J: \mathcal{X} \rightarrow \mathbb{R}$}
44
\label{alg:value-iteration}
45
\end{algorithm}
46
\end{preview}
47
\end{document}
48
49