mdpsolver 0.9.1__tar.gz → 0.9.2__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.1 → mdpsolver-0.9.2}/LICENSE +21 -21
- {mdpsolver-0.9.1/src/mdpsolver.egg-info → mdpsolver-0.9.2}/PKG-INFO +3 -3
- {mdpsolver-0.9.1 → mdpsolver-0.9.2}/README.md +130 -130
- {mdpsolver-0.9.1 → mdpsolver-0.9.2}/pyproject.toml +1 -1
- {mdpsolver-0.9.1 → mdpsolver-0.9.2}/src/mdpsolver/model.py +1 -1
- 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.1 → mdpsolver-0.9.2/src/mdpsolver.egg-info}/PKG-INFO +3 -3
- {mdpsolver-0.9.1 → mdpsolver-0.9.2}/src/mdpsolver.egg-info/SOURCES.txt +2 -0
- {mdpsolver-0.9.1 → mdpsolver-0.9.2}/MANIFEST.in +0 -0
- {mdpsolver-0.9.1 → mdpsolver-0.9.2}/setup.cfg +0 -0
- {mdpsolver-0.9.1 → mdpsolver-0.9.2}/src/mdpsolver/__init__.py +0 -0
- {mdpsolver-0.9.1 → mdpsolver-0.9.2}/src/mdpsolver/problems/cbmaux.py +0 -0
- {mdpsolver-0.9.1 → mdpsolver-0.9.2}/src/mdpsolver/problems/tbmaux.py +0 -0
- {mdpsolver-0.9.1 → mdpsolver-0.9.2}/src/mdpsolver/solvermodule.cp310-win_amd64.pyd +0 -0
- {mdpsolver-0.9.1 → mdpsolver-0.9.2}/src/mdpsolver/solvermodule.cpython-310-x86_64-linux-gnu.so +0 -0
- {mdpsolver-0.9.1 → mdpsolver-0.9.2}/src/mdpsolver.egg-info/dependency_links.txt +0 -0
- {mdpsolver-0.9.1 → mdpsolver-0.9.2}/src/mdpsolver.egg-info/top_level.txt +0 -0
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Anders Reenberg Andersen and Jesper Fink Andersen
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Anders Reenberg Andersen and Jesper Fink Andersen
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: mdpsolver
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.2
|
|
4
4
|
Summary: An efficient 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
|
|
@@ -22,7 +22,7 @@ License-File: LICENSE
|
|
|
22
22
|
* Available on PyPI.
|
|
23
23
|
* Solver-engine developed in C++.
|
|
24
24
|
* Available optimization algorithms: *Value iteration*, *Policy iteration*, and *Modified policy iteration*.
|
|
25
|
-
* Includes
|
|
25
|
+
* Includes support for sparse matrices.
|
|
26
26
|
|
|
27
27
|
# Quick start guide
|
|
28
28
|
|
|
@@ -82,7 +82,7 @@ print(mdl.getPolicy())
|
|
|
82
82
|
#[1, 1, 0]
|
|
83
83
|
```
|
|
84
84
|
|
|
85
|
-
##
|
|
85
|
+
## Sparse transition matrix?
|
|
86
86
|
|
|
87
87
|
`mdpsolver` has three alternative formats for large and highly sparse transition probability matrices.
|
|
88
88
|
|
|
@@ -1,131 +1,131 @@
|
|
|
1
|
-
# `mdpsolver`: An efficient solver for Markov Decision Processes
|
|
2
|
-
|
|
3
|
-
`mdpsolver` is the Python package for deriving the policies of Markov Decision Processes (MDPs) with infinite-horizon and the expected total discounted reward optimality criterion.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
* Available on PyPI.
|
|
8
|
-
* Solver-engine developed in C++.
|
|
9
|
-
* Available optimization algorithms: *Value iteration*, *Policy iteration*, and *Modified policy iteration*.
|
|
10
|
-
* Includes
|
|
11
|
-
|
|
12
|
-
# Quick start guide
|
|
13
|
-
|
|
14
|
-
The following shows how to get quickly started with `mdpsolver`.
|
|
15
|
-
|
|
16
|
-
## Installation
|
|
17
|
-
|
|
18
|
-
Download and install `mdpsolver` directly from PyPI.
|
|
19
|
-
|
|
20
|
-
```
|
|
21
|
-
pip install mdpsolver
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## Usage
|
|
25
|
-
|
|
26
|
-
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**.
|
|
27
|
-
|
|
28
|
-
```python
|
|
29
|
-
#Import packages
|
|
30
|
-
import mdpsolver
|
|
31
|
-
|
|
32
|
-
#Rewards (3 states x 2 actions)
|
|
33
|
-
#e.g. choosing second action in first state gives reward=-1
|
|
34
|
-
rewards = [[5,-1],
|
|
35
|
-
[1,-2],
|
|
36
|
-
[50,0]]
|
|
37
|
-
|
|
38
|
-
#Transition probabilities (3 from_states x 2 actions x 3 to_states)
|
|
39
|
-
#e.g. choosing first action in third state gives a probability of 0.6 of staying in third state
|
|
40
|
-
tranMatWithZeros = [[[0.9,0.1,0.0],[0.1,0.9,0.0]],
|
|
41
|
-
[[0.4,0.5,0.1],[0.3,0.5,0.2]],
|
|
42
|
-
[[0.2,0.2,0.6],[0.5,0.5,0.0]]]
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
Now, create the model object and insert the problem parameters.
|
|
46
|
-
|
|
47
|
-
```python
|
|
48
|
-
#Create model object
|
|
49
|
-
mdl = mdpsolver.model()
|
|
50
|
-
|
|
51
|
-
#Insert the problem parameters
|
|
52
|
-
mdl.mdp(discount=0.8,
|
|
53
|
-
rewards=rewards,
|
|
54
|
-
tranMatWithZeros=tranMatWithZeros)
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
We can now optimize the policy.
|
|
58
|
-
|
|
59
|
-
```python
|
|
60
|
-
mdl.solve()
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
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.
|
|
64
|
-
|
|
65
|
-
```python
|
|
66
|
-
print(mdl.getPolicy())
|
|
67
|
-
#[1, 1, 0]
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
##
|
|
71
|
-
|
|
72
|
-
`mdpsolver` has three alternative formats for large and highly sparse transition probability matrices.
|
|
73
|
-
|
|
74
|
-
**(1) Elementwise representation (excluding elements containing zeros):**
|
|
75
|
-
|
|
76
|
-
```python
|
|
77
|
-
#[from_state,action,to_state,probability]
|
|
78
|
-
tranMatElementwise = [[0,0,0,0.9],
|
|
79
|
-
[0,0,1,0.1],
|
|
80
|
-
[0,1,0,0.1],
|
|
81
|
-
[0,1,1,0.9],
|
|
82
|
-
[1,0,0,0.4],
|
|
83
|
-
[1,0,1,0.5],
|
|
84
|
-
[1,0,2,0.1],
|
|
85
|
-
[1,1,0,0.3],
|
|
86
|
-
[1,1,1,0.5],
|
|
87
|
-
[1,1,2,0.2],
|
|
88
|
-
[2,0,0,0.2],
|
|
89
|
-
[2,0,1,0.2],
|
|
90
|
-
[2,0,2,0.6],
|
|
91
|
-
[2,1,0,0.5],
|
|
92
|
-
[2,1,1,0.5]]
|
|
93
|
-
|
|
94
|
-
mdl.mdp(discount=0.8,
|
|
95
|
-
rewards=rewards,
|
|
96
|
-
tranMatElementwise=tranMatElementwise)
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
**(2) Probabilities and column (to_state) indices in separate lists:**
|
|
100
|
-
|
|
101
|
-
```python
|
|
102
|
-
tranMatProbs = [[[0.9,0.1],[0.1,0.9]],
|
|
103
|
-
[[0.4,0.5,0.1],[0.3,0.5,0.2]],
|
|
104
|
-
[[0.2,0.2,0.6],[0.5,0.5]]]
|
|
105
|
-
|
|
106
|
-
tranMatColumns = [[[0,1],[0,1]],
|
|
107
|
-
[[0,1,2],[0,1,2]],
|
|
108
|
-
[[0,1,2],[0,1]]]
|
|
109
|
-
|
|
110
|
-
mdl.mdp(discount=0.8,
|
|
111
|
-
rewards=rewards,
|
|
112
|
-
tranMatProbs=tranMatProbs,
|
|
113
|
-
tranMatColumns=tranMatColumns)
|
|
114
|
-
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
**(3) Load the elementwise representation from a file:**
|
|
118
|
-
|
|
119
|
-
```python
|
|
120
|
-
mdl.mdp(discount=0.8,
|
|
121
|
-
rewards=rewards,
|
|
122
|
-
tranMatFromFile="transitions.csv")
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
# User manual
|
|
126
|
-
|
|
127
|
-
Further information can be found in the wiki for `mdpsolver` on Github.
|
|
128
|
-
|
|
129
|
-
# How to cite
|
|
130
|
-
|
|
1
|
+
# `mdpsolver`: An efficient solver for Markov Decision Processes
|
|
2
|
+
|
|
3
|
+
`mdpsolver` is the Python package for deriving the policies of Markov Decision Processes (MDPs) with infinite-horizon and the expected total discounted reward optimality criterion.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
* Available on PyPI.
|
|
8
|
+
* Solver-engine developed in C++.
|
|
9
|
+
* Available optimization algorithms: *Value iteration*, *Policy iteration*, and *Modified policy iteration*.
|
|
10
|
+
* Includes support for sparse matrices.
|
|
11
|
+
|
|
12
|
+
# Quick start guide
|
|
13
|
+
|
|
14
|
+
The following shows how to get quickly started with `mdpsolver`.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
Download and install `mdpsolver` directly from PyPI.
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
pip install mdpsolver
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
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**.
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
#Import packages
|
|
30
|
+
import mdpsolver
|
|
31
|
+
|
|
32
|
+
#Rewards (3 states x 2 actions)
|
|
33
|
+
#e.g. choosing second action in first state gives reward=-1
|
|
34
|
+
rewards = [[5,-1],
|
|
35
|
+
[1,-2],
|
|
36
|
+
[50,0]]
|
|
37
|
+
|
|
38
|
+
#Transition probabilities (3 from_states x 2 actions x 3 to_states)
|
|
39
|
+
#e.g. choosing first action in third state gives a probability of 0.6 of staying in third state
|
|
40
|
+
tranMatWithZeros = [[[0.9,0.1,0.0],[0.1,0.9,0.0]],
|
|
41
|
+
[[0.4,0.5,0.1],[0.3,0.5,0.2]],
|
|
42
|
+
[[0.2,0.2,0.6],[0.5,0.5,0.0]]]
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Now, create the model object and insert the problem parameters.
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
#Create model object
|
|
49
|
+
mdl = mdpsolver.model()
|
|
50
|
+
|
|
51
|
+
#Insert the problem parameters
|
|
52
|
+
mdl.mdp(discount=0.8,
|
|
53
|
+
rewards=rewards,
|
|
54
|
+
tranMatWithZeros=tranMatWithZeros)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
We can now optimize the policy.
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
mdl.solve()
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
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.
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
print(mdl.getPolicy())
|
|
67
|
+
#[1, 1, 0]
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Sparse transition matrix?
|
|
71
|
+
|
|
72
|
+
`mdpsolver` has three alternative formats for large and highly sparse transition probability matrices.
|
|
73
|
+
|
|
74
|
+
**(1) Elementwise representation (excluding elements containing zeros):**
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
#[from_state,action,to_state,probability]
|
|
78
|
+
tranMatElementwise = [[0,0,0,0.9],
|
|
79
|
+
[0,0,1,0.1],
|
|
80
|
+
[0,1,0,0.1],
|
|
81
|
+
[0,1,1,0.9],
|
|
82
|
+
[1,0,0,0.4],
|
|
83
|
+
[1,0,1,0.5],
|
|
84
|
+
[1,0,2,0.1],
|
|
85
|
+
[1,1,0,0.3],
|
|
86
|
+
[1,1,1,0.5],
|
|
87
|
+
[1,1,2,0.2],
|
|
88
|
+
[2,0,0,0.2],
|
|
89
|
+
[2,0,1,0.2],
|
|
90
|
+
[2,0,2,0.6],
|
|
91
|
+
[2,1,0,0.5],
|
|
92
|
+
[2,1,1,0.5]]
|
|
93
|
+
|
|
94
|
+
mdl.mdp(discount=0.8,
|
|
95
|
+
rewards=rewards,
|
|
96
|
+
tranMatElementwise=tranMatElementwise)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**(2) Probabilities and column (to_state) indices in separate lists:**
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
tranMatProbs = [[[0.9,0.1],[0.1,0.9]],
|
|
103
|
+
[[0.4,0.5,0.1],[0.3,0.5,0.2]],
|
|
104
|
+
[[0.2,0.2,0.6],[0.5,0.5]]]
|
|
105
|
+
|
|
106
|
+
tranMatColumns = [[[0,1],[0,1]],
|
|
107
|
+
[[0,1,2],[0,1,2]],
|
|
108
|
+
[[0,1,2],[0,1]]]
|
|
109
|
+
|
|
110
|
+
mdl.mdp(discount=0.8,
|
|
111
|
+
rewards=rewards,
|
|
112
|
+
tranMatProbs=tranMatProbs,
|
|
113
|
+
tranMatColumns=tranMatColumns)
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**(3) Load the elementwise representation from a file:**
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
mdl.mdp(discount=0.8,
|
|
121
|
+
rewards=rewards,
|
|
122
|
+
tranMatFromFile="transitions.csv")
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
# User manual
|
|
126
|
+
|
|
127
|
+
Further information can be found in the wiki for `mdpsolver` on Github.
|
|
128
|
+
|
|
129
|
+
# How to cite
|
|
130
|
+
|
|
131
131
|
[](https://zenodo.org/badge/latestdoi/294063917)
|
|
Binary file
|
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: mdpsolver
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.2
|
|
4
4
|
Summary: An efficient 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
|
|
@@ -22,7 +22,7 @@ License-File: LICENSE
|
|
|
22
22
|
* Available on PyPI.
|
|
23
23
|
* Solver-engine developed in C++.
|
|
24
24
|
* Available optimization algorithms: *Value iteration*, *Policy iteration*, and *Modified policy iteration*.
|
|
25
|
-
* Includes
|
|
25
|
+
* Includes support for sparse matrices.
|
|
26
26
|
|
|
27
27
|
# Quick start guide
|
|
28
28
|
|
|
@@ -82,7 +82,7 @@ print(mdl.getPolicy())
|
|
|
82
82
|
#[1, 1, 0]
|
|
83
83
|
```
|
|
84
84
|
|
|
85
|
-
##
|
|
85
|
+
## Sparse transition matrix?
|
|
86
86
|
|
|
87
87
|
`mdpsolver` has three alternative formats for large and highly sparse transition probability matrices.
|
|
88
88
|
|
|
@@ -5,6 +5,8 @@ pyproject.toml
|
|
|
5
5
|
src/mdpsolver/__init__.py
|
|
6
6
|
src/mdpsolver/model.py
|
|
7
7
|
src/mdpsolver/solvermodule.cp310-win_amd64.pyd
|
|
8
|
+
src/mdpsolver/solvermodule.cp311-win_amd64.pyd
|
|
9
|
+
src/mdpsolver/solvermodule.cp312-win_amd64.pyd
|
|
8
10
|
src/mdpsolver/solvermodule.cpython-310-x86_64-linux-gnu.so
|
|
9
11
|
src/mdpsolver.egg-info/PKG-INFO
|
|
10
12
|
src/mdpsolver.egg-info/SOURCES.txt
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mdpsolver-0.9.1 → mdpsolver-0.9.2}/src/mdpsolver/solvermodule.cpython-310-x86_64-linux-gnu.so
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|