Skip to main content

Markov Decision Process Python Library

Project description

![MDP Image](https://cdn-images-1.medium.com/max/1200/1*QuBOz2yQ5Fy6YnZyvSPXzw.png)

## Markov: Simple Python Library for Markov Decision Processes
#### Author: Stephen Offer

Markov is an easy to use collection of functions and objects to create MDP
functions.

Markov allows for synchronous and asynchronous execution to experiment with
the performance advantages of distributed systems.

#### States:

- Reward, Terminal State, Actions, Value, Previous States, Next States, State
Policy Probabilities.

#### Policies:

- Greedy Policy
- e-Greedy Policy
- More to come...

#### Algorithms:

- Dynamic Programming
- Linear coming soon

#### Optimizers:

- Value/Policy Iteration
- More to come...

#### Environments:

- Gridworld (ASCII, PyGame coming soon)
- Gym coming soon
- More to come...

### Example:
```python
import numpy as np
import argparse

from markov import GreedyPolicy
from markov.envs.gridworld import GridWorld


def value_iteration(K=1,discount_factor=1.):

env = GridWorld()

P = GreedyPolicy(env)

values = np.zeros(env.n_states)

for k in range(K):
for state in env.states:
v = 0
for i, action in enumerate(state.actions):
policy = state.policy[i]
next_state = action(env, state.action_args)
r = next_state.reward
v += policy * (r + discount_factor * next_state.value)

values[state.index] = v

for state in env.states:
state.value = values[state.index]

env.print()


def main():
parser = argparse.ArgumentParser()
parser.add_argument("--k", help="number of k-iterations",
type=int,default=1)
args = parser.parse_args()
k = args.k

value_iteration(k)


if __name__ == "__main__":
main()


```

#### Contributors Welcome



Project details


Release history Release notifications

This version

0.0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for markov-rlzoo, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size markov_rlzoo-0.0.1-py3-none-any.whl (6.0 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size markov_rlzoo-0.0.1.tar.gz (3.7 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page