-
Notifications
You must be signed in to change notification settings - Fork 3
/
README.Rmd
94 lines (68 loc) · 2.64 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
---
always_allow_html: true
bibliography: ./vignettes/litt.bib
output:
github_document
editor_options:
chunk_output_type: console
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include=FALSE}
library(knitr)
rgl::setupKnitr()
opts_chunk$set(
collapse = TRUE,
#comment = "#>",
fig.path = "man/figures/README-",
out.width = "99%", fig.width = 8, fig.align = "center", fig.asp = 0.62,
echo = TRUE, warning=FALSE, message=FALSE,
include = TRUE
)
library(MDP2)
## Use temp dir
wd <- setwd(tempdir())
```
<!-- badges: start -->
[![R-CMD-check](https://github.com/relund/mdp/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/relund/mdp/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/relund/mdp/branch/master/graph/badge.svg)](https://app.codecov.io/gh/relund/mdp?branch=master)
<!-- badges: end -->
# Markov Decision Processes (MDPs) in R
The `MDP2` package in R is a package for solving Markov decision processes (MDPs) with discrete
time-steps, states and actions. Both traditional MDPs [@Puterman94], semi-Markov decision processes
(semi-MDPs) [@Tijms03] and hierarchical-MDPs (HMDPs) [@Kristensen00] can be solved under a finite
and infinite time-horizon.
Building and solving an MDP is done in two steps. First, the MDP is built and saved in a set
of binary files. Next, you load the MDP into memory from the binary files and apply various
algorithms to the model.
The package implement well-known algorithms such as policy iteration and value iteration
under different criteria e.g. average reward per time unit and expected total discounted reward. The
model is stored using an underlying data structure based on the *state-expanded directed hypergraph*
of the MDP (@Relund06) implemented in `C++` for fast running times.
## Installation
Install the latest stable release from CRAN:
```{r, eval=FALSE}
install.packages("MDP2")
```
Alternatively, install the latest development version from GitHub (recommended):
```{r, eval=FALSE}
remotes::install_github("relund/mdp")
```
We load the package using
```{r Load package, echo=TRUE, warning=FALSE, results='hide', message=FALSE}
library(MDP2)
```
Help about the package can be seen by writing
```{r Package help, echo=TRUE, eval=FALSE}
?MDP2
```
To illustrate the package capabilities, we use a few examples, namely, an infinite and
finite-horizon semi-MDP and a HMDP. Before each example a short introduction to these models are
given.
## Learning more
To get started, first read `vignette("MDP2")`.
For more examples see `example("MDP2")`.
```{r, include=FALSE}
## reset working dir
setwd(wd)
```
## References