MDPSolver

MDPSolver: An Efficient Solver for Markov Decision Processes - Published in JOSS (2025)

https://github.com/areenberg/mdpsolver

Science Score: 93.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 9 DOI reference(s) in README and JOSS metadata
  • Academic publication links
    Links to: joss.theoj.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software

Keywords

decision-process markov-decision-process optimization predictive-maintenance reinforcement-learning solver
Last synced: 4 months ago · JSON representation

Repository

A fast solver for Markov Decision Processes

Basic Info
  • Host: GitHub
  • Owner: areenberg
  • License: mit
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 23 MB
Statistics
  • Stars: 7
  • Watchers: 1
  • Forks: 1
  • Open Issues: 0
  • Releases: 8
Topics
decision-process markov-decision-process optimization predictive-maintenance reinforcement-learning solver
Created over 5 years ago · Last pushed 7 months ago
Metadata Files
Readme License

README.md

MDPSolver

Logo

DOI

MDPSolver is a Python package for large Markov Decision Processes (MDPs) with infinite-horizons.

Features

  • Fast solver: Our C++-based solver is substantially faster than other MDP packages available for Python. See details in the documentation.
  • Two optimality criteria: Discounted and Average reward.
  • Three optimization algorithms: Value iteration, Policy iteration, and Modified policy iteration.
  • Three value-update methods: Standard, Gauss–Seidel, and Successive over-relaxation.
  • Supports sparse matrices.
  • Employs parallel computing.

Installation

Linux

Install directly from PyPI with:

pip install mdpsolver

MDPSolver works out of the box on Ubuntu 22 and newer.

GLIBC not found

Some users will encounter the version 'GLIBC_2.32' not found error when attempting to import MDPSolver in Python. In this case, it might help to manually compile and replace the SO-file for the optimization module in the MDPSolver package. See the steps on how to solve the issue in the documentation.

Windows

Requires Visual Studio 2022 (17.9) with MSVC C++ compiler and libraries installed.

After installing Visual Studio (incl. MSVC C++ compiler and libraries), install directly from PyPI with:

pip install mdpsolver

Quick start guide

The following shows how to get quickly started with mdpsolver.

Usage

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.

```python

Import packages

import mdpsolver

Rewards (3 states x 2 actions)

e.g. choosing second action in first state gives reward=-1

rewards = [[5,-1], [1,-2], [50,0]]

Transition probabilities (3 fromstates x 2 actions x 3 tostates)

e.g. choosing first action in third state gives a probability of 0.6 of staying in third state

tranMatWithZeros = [[[0.9,0.1,0.0],[0.1,0.9,0.0]], [[0.4,0.5,0.1],[0.3,0.5,0.2]], [[0.2,0.2,0.6],[0.5,0.5,0.0]]] ```

Now, create the model object and insert the problem parameters.

```python

Create model object

mdl = mdpsolver.model()

Insert the problem parameters

mdl.mdp(discount=0.8, rewards=rewards, tranMatWithZeros=tranMatWithZeros) ```

We can now optimize the policy.

python mdl.solve()

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.

```python print(mdl.getPolicy())

[1, 1, 0]

```

Sparse transition matrix?

mdpsolver has three alternative formats for large and highly sparse transition probability matrices.

(1) Elementwise representation (excluding elements containing zeros):

```python

[fromstate,action,tostate,probability]

tranMatElementwise = [[0,0,0,0.9], [0,0,1,0.1], [0,1,0,0.1], [0,1,1,0.9], [1,0,0,0.4], [1,0,1,0.5], [1,0,2,0.1], [1,1,0,0.3], [1,1,1,0.5], [1,1,2,0.2], [2,0,0,0.2], [2,0,1,0.2], [2,0,2,0.6], [2,1,0,0.5], [2,1,1,0.5]]

mdl.mdp(discount=0.8, rewards=rewards, tranMatElementwise=tranMatElementwise) ```

(2) Probabilities and column (to_state) indices in separate lists:

```python tranMatProbs = [[[0.9,0.1],[0.1,0.9]], [[0.4,0.5,0.1],[0.3,0.5,0.2]], [[0.2,0.2,0.6],[0.5,0.5]]]

tranMatColumns = [[[0,1],[0,1]], [[0,1,2],[0,1,2]], [[0,1,2],[0,1]]]

mdl.mdp(discount=0.8, rewards=rewards, tranMatProbs=tranMatProbs, tranMatColumns=tranMatColumns)

```

(3) Load the elementwise representation from a file:

python mdl.mdp(discount=0.8, rewards=rewards, tranMatFromFile="transitions.csv")

Documentation

The documentation can be found in the wiki for MDPSolver.

How to cite

Andersen et al., (2025). MDPSolver: An Efficient Solver for Markov Decision Processes. Journal of Open Source Software, 10(109), 7544, https://doi.org/10.21105/joss.07544

BibTeX @article{Andersen2025, doi = {10.21105/joss.07544}, url = {https://doi.org/10.21105/joss.07544}, year = {2025}, publisher = {The Open Journal}, volume = {10}, number = {109}, pages = {7544}, author = {Anders Reenberg Andersen and Jesper Fink Andersen}, title = {MDPSolver: An Efficient Solver for Markov Decision Processes}, journal = {Journal of Open Source Software} }

Owner

  • Name: Anders Reenberg Andersen
  • Login: areenberg
  • Kind: user
  • Location: Copenhagen

Researcher in statistics with a focus on applied queueing theory.

JOSS Publication

MDPSolver: An Efficient Solver for Markov Decision Processes
Published
May 30, 2025
Volume 10, Issue 109, Page 7544
Authors
Anders Reenberg Andersen ORCID
Department of Applied Mathematics and Computer Science, Technical University of Denmark, Denmark
Jesper Fink Andersen ORCID
Department of Applied Mathematics and Computer Science, Technical University of Denmark, Denmark
Editor
Kelly Rowland ORCID
Tags
Markov Decision Process Optimization Stochasticity Dynamic Programming

GitHub Events

Total
  • Create event: 2
  • Release event: 2
  • Issues event: 8
  • Watch event: 4
  • Issue comment event: 16
  • Push event: 33
  • Gollum event: 36
  • Fork event: 1
Last Year
  • Create event: 2
  • Release event: 2
  • Issues event: 8
  • Watch event: 4
  • Issue comment event: 16
  • Push event: 33
  • Gollum event: 36
  • Fork event: 1

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 3
  • Total pull requests: 0
  • Average time to close issues: 29 days
  • Average time to close pull requests: N/A
  • Total issue authors: 3
  • Total pull request authors: 0
  • Average comments per issue: 5.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 3
  • Pull requests: 0
  • Average time to close issues: 29 days
  • Average time to close pull requests: N/A
  • Issue authors: 3
  • Pull request authors: 0
  • Average comments per issue: 5.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • gartavanis (1)
  • kach (1)
  • braniii (1)
  • mazqtpopx (1)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 20 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 9
  • Total maintainers: 1
pypi.org: mdpsolver

A fast solver for Markov Decision Processes

  • Versions: 9
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 20 Last month
Rankings
Dependent packages count: 9.5%
Average: 36.0%
Dependent repos count: 62.5%
Maintainers (1)
Last synced: 4 months ago