Generate modern CLIs from OpenAPI specifications
Project description
MARKOV SOLVER
Solve Markov Chains in a glance.
Table of Contents
Features
- Solve Markov Chains: Compute steady-state probabilities for discrete-time Markov chains.
- Symbolic Transition Rates: Define transition rates using symbolic expressions with named parameters.
- YAML Chain Definitions: Define Markov chains in simple, human-readable YAML files.
- Graph Visualization: Automatically render Markov chain diagrams in SVG and PNG formats using Graphviz.
- CLI and Library: Use as a command-line tool or integrate directly into your Python projects.
- Export Results: Save solutions to TXT and CSV files for further analysis.
- High Precision: Calculations with 12 decimal places of floating-point precision.
Installation
pip install markov-solver
Usage
You can use markov-solver as a CLI or as a library in your project.
To use it as a CLI, check the recorded demo:
To use it as a library, you can check the examples.
In both cases you need to define the Markov Chain to solve. See the instructions below to know how to do it.
Chain with constant transition rates
Let us image that we want to solve the following Markov chain:
We should create a YAML file that defines the chain:
chain:
- from: "Sunny"
to: "Sunny"
value: "0.9"
- from: "Sunny"
to: "Rainy"
value: "0.1"
- from: "Rainy"
to: "Rainy"
value: "0.5"
- from: "Rainy"
to: "Sunny"
value: "0.5"
Then, running the following command:
markov-solver solve --definition [PATH_TO_DEFINITION_FILE]
We obtain the following result:
===============================================================
MARKOV CHAIN SOLUTION
===============================================================
states probability
Rainy.........................................0.166666666666667
Sunny.........................................0.833333333333333
Chain with symbolic transition rates
Let us image that we want to solve the following Markov chain:
We should create a YAML file that defines the chain:
symbols:
lambda: 1.5
mu: 2.0
chain:
- from: "0"
to: "1"
value: "lambda"
- from: "1"
to: "2"
value: "lambda"
- from: "2"
to: "3"
value: "lambda"
- from: "3"
to: "2"
value: "3*mu"
- from: "2"
to: "1"
value: "2*mu"
- from: "1"
to: "0"
value: "mu"
Then, running the following command:
markov-solver solve --definition [PATH_TO_DEFINITION_FILE]
We obtain the following result:
===============================================================
MARKOV CHAIN SOLUTION
===============================================================
states probability
0.............................................0.475836431226766
1.............................................0.356877323420074
2.............................................0.133828996282528
3............................................0.0334572490706320
References
- "Discrete-Event Simulation", 2006, L.M. Leemis, S.K. Park
- "Performance Modeling and Design of Computer Systems, 2013, M. Harchol-Balter
Issues
Please report any issues or feature requests on the GitHub Issues page.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file markov_solver-2.0.0.tar.gz.
File metadata
- Download URL: markov_solver-2.0.0.tar.gz
- Upload date:
- Size: 18.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78ca9c4b5206112e2bbc7d65d2d41955b821dd0e264a3c381c234bff46764fd2
|
|
| MD5 |
264904fd434c0e0580afdde8da04452a
|
|
| BLAKE2b-256 |
1b16f486a64129b2f71fb3ee60958a747441d6551a2c82dfffb458ccac82be83
|
File details
Details for the file markov_solver-2.0.0-py3-none-any.whl.
File metadata
- Download URL: markov_solver-2.0.0-py3-none-any.whl
- Upload date:
- Size: 22.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a07e97b1ce46875f73766d6b0f66b0249efcc2b38e161b9d93ef7b7755cf213
|
|
| MD5 |
b4eff5524f787b4a9c6b7b510dba043f
|
|
| BLAKE2b-256 |
be02a5d95b88d2b0d35230ec2f95b843a359b577eb7668b6a7848134778a64a2
|