Skip to content

Commit

Permalink
re-ordered instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
zsunberg committed Jan 30, 2020
1 parent 2ba49f1 commit 1c5a69d
Showing 1 changed file with 24 additions and 19 deletions.
43 changes: 24 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![Coverage Status](https://coveralls.io/repos/github/JuliaPOMDP/DiscreteValueIteration.jl/badge.svg?branch=master)](https://coveralls.io/github/JuliaPOMDP/DiscreteValueIteration.jl?branch=master)

This package implements the discrete value iteration algorithm in Julia for solving Markov decision processes (MDPs).
The user should define the problem according to the API in [POMDPs.jl](https://github.com/JuliaPOMDP/POMDPs.jl). Examples of
The user should define the problem with [QuickPOMDPs.jl](https://github.com/JuliaPOMDP/QuickPOMDPs.jl) or according to the API in [POMDPs.jl](https://github.com/JuliaPOMDP/POMDPs.jl). Examples of
problem definitions can be found in [POMDPModels.jl](https://github.com/JuliaPOMDP/POMDPModels.jl). For an extensive tutorial, see [these](https://github.com/JuliaPOMDP/POMDPExamples.jl) notebooks.

There are two solvers in the package. The "vanilla" [`ValueIterationSolver`](src/vanilla.jl) calls functions from the POMDPs.jl interface in every iteration, while the [`SparseValueIterationSolver`](src/sparse.jl) first creates sparse transition and reward matrices and then performs value iteration with the new matrix representation. While both solvers take advantage of sparsity, the `SparseValueIterationSolver` is generally faster because of low-level optimizations, while the `ValueIterationSolver` has the advantage that it does not require allocation of transition matrices (which could potentially be too large to fit in memory).
Expand All @@ -26,7 +26,28 @@ using Pkg; Pkg.add("DiscreteValueIteration")

## Usage

Use
Given an MDP `mdp` defined with [QuickPOMDPs.jl](https://github.com/JuliaPOMDP/QuickPOMDPs.jl) or the POMDPs.jl interface, use

```julia
using DiscreteValueIteration

solver = ValueIterationSolver(max_iterations=100, belres=1e-6) # creates the solver
solve(solver, mdp) # runs value iterations
```
To extract the policy for a given state, simply call the action function:

```julia
a = action(policy, s) # returns the optimal action for state s
```

Or to extract the value, use
```julia
value(policy, s) # returns the optimal value at state s
```

### Requirements for problems defined using the POMDPs.jl interface

If you are using the POMDPs.jl interface instead of QuickPOMDPs.jl, you can see the requirements for using these solvers with

```julia
using POMDPs
Expand All @@ -35,7 +56,7 @@ using DiscreteValueIteration
@requirements_info SparseValueIterationSolver() YourMDP()
```

to get a list of POMDPs.jl functions necessary to use the solver. This should return a list of the following functions to be implemented for your MDP:
This should return a list of the following functions to be implemented for your MDP:

```julia
discount(::MDP)
Expand All @@ -51,19 +72,3 @@ pdf(::StateDistribution, ::State)
states(::MDP)
actions(::MDP)
```

Once the above functions are defined, the solver can be called with the following syntax:

```julia
using DiscreteValueIteration

mdp = MyMDP() # initializes the MDP
solver = ValueIterationSolver(max_iterations=100, belres=1e-6) # creates the solver
solve(solver, mdp) # runs value iterations
```

To extract the policy for a given state, simply call the action function:

```julia
a = action(policy, s) # returns the optimal action for state s
```

0 comments on commit 1c5a69d

Please sign in to comment.