mdpsolver 0.9.2__tar.gz → 0.9.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mdpsolver-0.9.2/src/mdpsolver.egg-info → mdpsolver-0.9.4}/PKG-INFO +9 -8
- {mdpsolver-0.9.2 → mdpsolver-0.9.4}/README.md +131 -130
- {mdpsolver-0.9.2 → mdpsolver-0.9.4}/pyproject.toml +2 -2
- {mdpsolver-0.9.2 → mdpsolver-0.9.4}/src/mdpsolver/model.py +6 -2
- mdpsolver-0.9.4/src/mdpsolver/solvermodule.cp310-win_amd64.pyd +0 -0
- mdpsolver-0.9.4/src/mdpsolver/solvermodule.cp311-win_amd64.pyd +0 -0
- mdpsolver-0.9.4/src/mdpsolver/solvermodule.cp312-win_amd64.pyd +0 -0
- mdpsolver-0.9.4/src/mdpsolver/solvermodule.cpython-310-x86_64-linux-gnu.so +0 -0
- {mdpsolver-0.9.2 → mdpsolver-0.9.4/src/mdpsolver.egg-info}/PKG-INFO +9 -8
- mdpsolver-0.9.2/src/mdpsolver/solvermodule.cp310-win_amd64.pyd +0 -0
- mdpsolver-0.9.2/src/mdpsolver/solvermodule.cp311-win_amd64.pyd +0 -0
- mdpsolver-0.9.2/src/mdpsolver/solvermodule.cp312-win_amd64.pyd +0 -0
- mdpsolver-0.9.2/src/mdpsolver/solvermodule.cpython-310-x86_64-linux-gnu.so +0 -0
- {mdpsolver-0.9.2 → mdpsolver-0.9.4}/LICENSE +0 -0
- {mdpsolver-0.9.2 → mdpsolver-0.9.4}/MANIFEST.in +0 -0
- {mdpsolver-0.9.2 → mdpsolver-0.9.4}/setup.cfg +0 -0
- {mdpsolver-0.9.2 → mdpsolver-0.9.4}/src/mdpsolver/__init__.py +0 -0
- {mdpsolver-0.9.2 → mdpsolver-0.9.4}/src/mdpsolver/problems/cbmaux.py +0 -0
- {mdpsolver-0.9.2 → mdpsolver-0.9.4}/src/mdpsolver/problems/tbmaux.py +0 -0
- {mdpsolver-0.9.2 → mdpsolver-0.9.4}/src/mdpsolver.egg-info/SOURCES.txt +0 -0
- {mdpsolver-0.9.2 → mdpsolver-0.9.4}/src/mdpsolver.egg-info/dependency_links.txt +0 -0
- {mdpsolver-0.9.2 → mdpsolver-0.9.4}/src/mdpsolver.egg-info/top_level.txt +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: mdpsolver
|
|
3
|
-
Version: 0.9.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 0.9.4
|
|
4
|
+
Summary: A fast solver for Markov Decision Processes
|
|
5
5
|
Author-email: Anders Reenberg Andersen <andersra@live.dk>, Jesper Fink Andersen <jfan@dtu.dk>
|
|
6
6
|
Project-URL: Homepage, https://github.com/areenberg/MDPSolver
|
|
7
7
|
Project-URL: Issues, https://github.com/areenberg/MDPSolver/issues
|
|
@@ -13,15 +13,16 @@ Requires-Python: >=3.10
|
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
14
14
|
License-File: LICENSE
|
|
15
15
|
|
|
16
|
-
# `mdpsolver`:
|
|
16
|
+
# `mdpsolver`: A fast solver for Markov Decision Processes
|
|
17
17
|
|
|
18
|
-
`mdpsolver` is the Python package for
|
|
18
|
+
`mdpsolver` is the Python package for Markov Decision Processes (MDPs) with discounted rewards and infinite-horizon.
|
|
19
19
|
|
|
20
20
|
## Features
|
|
21
21
|
|
|
22
|
+
* Fast solver-engine: Up-to **30x faster** than other Python-based solvers (see details in the documentation).
|
|
22
23
|
* Available on PyPI.
|
|
23
|
-
*
|
|
24
|
-
*
|
|
24
|
+
* Three optimization algorithms: *Value iteration*, *Policy iteration*, and *Modified policy iteration*.
|
|
25
|
+
* Three value-update methods: *Standard*, *Gauss–Seidel*, *Successive over-relaxation*.
|
|
25
26
|
* Includes support for sparse matrices.
|
|
26
27
|
|
|
27
28
|
# Quick start guide
|
|
@@ -137,9 +138,9 @@ mdl.mdp(discount=0.8,
|
|
|
137
138
|
tranMatFromFile="transitions.csv")
|
|
138
139
|
```
|
|
139
140
|
|
|
140
|
-
#
|
|
141
|
+
# Documentation
|
|
141
142
|
|
|
142
|
-
|
|
143
|
+
Documentation can be found in the wiki for `mdpsolver` on Github.
|
|
143
144
|
|
|
144
145
|
# How to cite
|
|
145
146
|
|
|
@@ -1,131 +1,132 @@
|
|
|
1
|
-
# `mdpsolver`:
|
|
2
|
-
|
|
3
|
-
`mdpsolver` is the Python package for
|
|
4
|
-
|
|
5
|
-
## Features
|
|
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
|
-
[[0.
|
|
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
|
-
[0,1,0
|
|
81
|
-
[0,1,
|
|
82
|
-
[1,
|
|
83
|
-
[1,0,
|
|
84
|
-
[1,0,
|
|
85
|
-
[1,
|
|
86
|
-
[1,1,
|
|
87
|
-
[1,1,
|
|
88
|
-
[
|
|
89
|
-
[2,0,
|
|
90
|
-
[2,0,
|
|
91
|
-
[2,
|
|
92
|
-
[2,1,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
[[0.
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
[[0,1,2],[0,1]]
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
1
|
+
# `mdpsolver`: A fast solver for Markov Decision Processes
|
|
2
|
+
|
|
3
|
+
`mdpsolver` is the Python package for Markov Decision Processes (MDPs) with discounted rewards and infinite-horizon.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
* Fast solver-engine: Up-to **30x faster** than other Python-based solvers (see details in the documentation).
|
|
8
|
+
* Available on PyPI.
|
|
9
|
+
* Three optimization algorithms: *Value iteration*, *Policy iteration*, and *Modified policy iteration*.
|
|
10
|
+
* Three value-update methods: *Standard*, *Gauss–Seidel*, *Successive over-relaxation*.
|
|
11
|
+
* Includes support for sparse matrices.
|
|
12
|
+
|
|
13
|
+
# Quick start guide
|
|
14
|
+
|
|
15
|
+
The following shows how to get quickly started with `mdpsolver`.
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
Download and install `mdpsolver` directly from PyPI.
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
pip install mdpsolver
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
Start by specifying the reward function and transition probabilities as lists. The following is an example of a simple MDP containing **three states** and **two actions in each state**.
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
#Import packages
|
|
31
|
+
import mdpsolver
|
|
32
|
+
|
|
33
|
+
#Rewards (3 states x 2 actions)
|
|
34
|
+
#e.g. choosing second action in first state gives reward=-1
|
|
35
|
+
rewards = [[5,-1],
|
|
36
|
+
[1,-2],
|
|
37
|
+
[50,0]]
|
|
38
|
+
|
|
39
|
+
#Transition probabilities (3 from_states x 2 actions x 3 to_states)
|
|
40
|
+
#e.g. choosing first action in third state gives a probability of 0.6 of staying in third state
|
|
41
|
+
tranMatWithZeros = [[[0.9,0.1,0.0],[0.1,0.9,0.0]],
|
|
42
|
+
[[0.4,0.5,0.1],[0.3,0.5,0.2]],
|
|
43
|
+
[[0.2,0.2,0.6],[0.5,0.5,0.0]]]
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Now, create the model object and insert the problem parameters.
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
#Create model object
|
|
50
|
+
mdl = mdpsolver.model()
|
|
51
|
+
|
|
52
|
+
#Insert the problem parameters
|
|
53
|
+
mdl.mdp(discount=0.8,
|
|
54
|
+
rewards=rewards,
|
|
55
|
+
tranMatWithZeros=tranMatWithZeros)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
We can now optimize the policy.
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
mdl.solve()
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The optimized policy can be returned in a variety of ways. Here, we return the policy as a list and print directly in the terminal.
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
print(mdl.getPolicy())
|
|
68
|
+
#[1, 1, 0]
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Sparse transition matrix?
|
|
72
|
+
|
|
73
|
+
`mdpsolver` has three alternative formats for large and highly sparse transition probability matrices.
|
|
74
|
+
|
|
75
|
+
**(1) Elementwise representation (excluding elements containing zeros):**
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
#[from_state,action,to_state,probability]
|
|
79
|
+
tranMatElementwise = [[0,0,0,0.9],
|
|
80
|
+
[0,0,1,0.1],
|
|
81
|
+
[0,1,0,0.1],
|
|
82
|
+
[0,1,1,0.9],
|
|
83
|
+
[1,0,0,0.4],
|
|
84
|
+
[1,0,1,0.5],
|
|
85
|
+
[1,0,2,0.1],
|
|
86
|
+
[1,1,0,0.3],
|
|
87
|
+
[1,1,1,0.5],
|
|
88
|
+
[1,1,2,0.2],
|
|
89
|
+
[2,0,0,0.2],
|
|
90
|
+
[2,0,1,0.2],
|
|
91
|
+
[2,0,2,0.6],
|
|
92
|
+
[2,1,0,0.5],
|
|
93
|
+
[2,1,1,0.5]]
|
|
94
|
+
|
|
95
|
+
mdl.mdp(discount=0.8,
|
|
96
|
+
rewards=rewards,
|
|
97
|
+
tranMatElementwise=tranMatElementwise)
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**(2) Probabilities and column (to_state) indices in separate lists:**
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
tranMatProbs = [[[0.9,0.1],[0.1,0.9]],
|
|
104
|
+
[[0.4,0.5,0.1],[0.3,0.5,0.2]],
|
|
105
|
+
[[0.2,0.2,0.6],[0.5,0.5]]]
|
|
106
|
+
|
|
107
|
+
tranMatColumns = [[[0,1],[0,1]],
|
|
108
|
+
[[0,1,2],[0,1,2]],
|
|
109
|
+
[[0,1,2],[0,1]]]
|
|
110
|
+
|
|
111
|
+
mdl.mdp(discount=0.8,
|
|
112
|
+
rewards=rewards,
|
|
113
|
+
tranMatProbs=tranMatProbs,
|
|
114
|
+
tranMatColumns=tranMatColumns)
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
**(3) Load the elementwise representation from a file:**
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
mdl.mdp(discount=0.8,
|
|
122
|
+
rewards=rewards,
|
|
123
|
+
tranMatFromFile="transitions.csv")
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
# Documentation
|
|
127
|
+
|
|
128
|
+
Documentation can be found in the wiki for `mdpsolver` on Github.
|
|
129
|
+
|
|
130
|
+
# How to cite
|
|
131
|
+
|
|
131
132
|
[](https://zenodo.org/badge/latestdoi/294063917)
|
|
@@ -10,12 +10,12 @@ where = ["src"]
|
|
|
10
10
|
|
|
11
11
|
[project]
|
|
12
12
|
name = "mdpsolver"
|
|
13
|
-
version = "0.9.
|
|
13
|
+
version = "0.9.4"
|
|
14
14
|
authors = [
|
|
15
15
|
{ name="Anders Reenberg Andersen", email="andersra@live.dk" },
|
|
16
16
|
{ name="Jesper Fink Andersen", email="jfan@dtu.dk" },
|
|
17
17
|
]
|
|
18
|
-
description = "
|
|
18
|
+
description = "A fast solver for Markov Decision Processes"
|
|
19
19
|
readme = "README.md"
|
|
20
20
|
requires-python = ">=3.10"
|
|
21
21
|
classifiers = [
|
|
@@ -21,7 +21,9 @@ class model:
|
|
|
21
21
|
SORrelaxation=1.0,
|
|
22
22
|
initPolicy=list(),
|
|
23
23
|
initValueVector=list(),
|
|
24
|
-
verbose=False
|
|
24
|
+
verbose=False,
|
|
25
|
+
postProcessing=True,
|
|
26
|
+
makeFinalCheck=True):
|
|
25
27
|
#solves the problem employing the specified algorithm
|
|
26
28
|
self.mdl.solve(algorithm=algorithm,
|
|
27
29
|
tolerance=tolerance,
|
|
@@ -30,7 +32,9 @@ class model:
|
|
|
30
32
|
SORrelaxation=SORrelaxation,
|
|
31
33
|
initPolicy=initPolicy,
|
|
32
34
|
initValueVector=initValueVector,
|
|
33
|
-
verbose=verbose
|
|
35
|
+
verbose=verbose,
|
|
36
|
+
postProcessing=postProcessing,
|
|
37
|
+
makeFinalCheck=makeFinalCheck)
|
|
34
38
|
|
|
35
39
|
def getRuntime(self):
|
|
36
40
|
#returns the runtime in milliseconds
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: mdpsolver
|
|
3
|
-
Version: 0.9.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 0.9.4
|
|
4
|
+
Summary: A fast solver for Markov Decision Processes
|
|
5
5
|
Author-email: Anders Reenberg Andersen <andersra@live.dk>, Jesper Fink Andersen <jfan@dtu.dk>
|
|
6
6
|
Project-URL: Homepage, https://github.com/areenberg/MDPSolver
|
|
7
7
|
Project-URL: Issues, https://github.com/areenberg/MDPSolver/issues
|
|
@@ -13,15 +13,16 @@ Requires-Python: >=3.10
|
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
14
14
|
License-File: LICENSE
|
|
15
15
|
|
|
16
|
-
# `mdpsolver`:
|
|
16
|
+
# `mdpsolver`: A fast solver for Markov Decision Processes
|
|
17
17
|
|
|
18
|
-
`mdpsolver` is the Python package for
|
|
18
|
+
`mdpsolver` is the Python package for Markov Decision Processes (MDPs) with discounted rewards and infinite-horizon.
|
|
19
19
|
|
|
20
20
|
## Features
|
|
21
21
|
|
|
22
|
+
* Fast solver-engine: Up-to **30x faster** than other Python-based solvers (see details in the documentation).
|
|
22
23
|
* Available on PyPI.
|
|
23
|
-
*
|
|
24
|
-
*
|
|
24
|
+
* Three optimization algorithms: *Value iteration*, *Policy iteration*, and *Modified policy iteration*.
|
|
25
|
+
* Three value-update methods: *Standard*, *Gauss–Seidel*, *Successive over-relaxation*.
|
|
25
26
|
* Includes support for sparse matrices.
|
|
26
27
|
|
|
27
28
|
# Quick start guide
|
|
@@ -137,9 +138,9 @@ mdl.mdp(discount=0.8,
|
|
|
137
138
|
tranMatFromFile="transitions.csv")
|
|
138
139
|
```
|
|
139
140
|
|
|
140
|
-
#
|
|
141
|
+
# Documentation
|
|
141
142
|
|
|
142
|
-
|
|
143
|
+
Documentation can be found in the wiki for `mdpsolver` on Github.
|
|
143
144
|
|
|
144
145
|
# How to cite
|
|
145
146
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|