Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132939 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 Horizon $N \in \mathbb{N}_{\geq 1}$
26
\Statex Discounting factor $\alpha \in [0, 1]$
27
\Procedure{DynamicProgramming}{$\mathcal{X}$, $A$, $g$, $N$, $\alpha$}
28
\State $J_N(x) \gets g_N(x) \quad \forall x \in \mathcal{X}$
29
\For{$k = N - 1$ to $0$}
30
\For{$x \in \mathcal{X}$}
31
\For{$a \in A(x)$}
32
\State $Q(x, a) \gets g_k(x, a) + \alpha \sum_{j=1}^{n_x} f_{xj}(a) \cdot J_{k+1}(j)$
33
\EndFor
34
35
\State $J_k (x) \gets \min_a (Q_k(x,a))$
36
\State $\pi_k(x) \gets \arg \min_a (Q_k(x, a))$
37
\EndFor
38
\EndFor
39
\Return $\pi_{0:N-1}$
40
\EndProcedure
41
\end{algorithmic}
42
\caption{Dynamic Programming}
43
\label{alg:dynamic-programming: Learn a strategy}
44
\end{algorithm}
45
\end{preview}
46
\end{document}
47
48