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


Download files

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

Source Distribution

markov_rlzoo-0.0.1.tar.gz (3.7 kB view hashes)

Uploaded Source

Built Distribution

markov_rlzoo-0.0.1-py3-none-any.whl (6.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page