Giter VIP home page Giter VIP logo

compressedbeliefmdps.jl's Introduction

CompressedBeliefMDPs

Build Status Dev-Docs codecov

Introduction

Welcome to CompressedBeliefMDPs.jl! This package is part of the POMDPs.jl ecosystem and takes inspiration from Exponential Family PCA for Belief Compression in POMDPs.

This package provides a general framework for applying belief compression in large POMDPs with generic compression, sampling, and planning algorithms.

Installation

You can install CompressedBeliefMDPs.jl using Julia's package manager. Open the Julia REPL (press ] to enter the package manager mode) and run the following command:

pkg> add CompressedBeliefMDPs

Quickstart

Using belief compression is easy. Simplify pick a Sampler, Compressor, and a base Policy and then use the standard POMDPs.jl interface.

using POMDPs, POMDPTools, POMDPModels
using CompressedBeliefMDPs

pomdp = BabyPOMDP()
compressor = PCACompressor(1)
updater = DiscreteUpdater(pomdp)
sampler = BeliefExpansionSampler(pomdp)
solver = CompressedBeliefSolver(
    pomdp;
    compressor=compressor,
    sampler=sampler,
    updater=updater,
    verbose=true, 
    max_iterations=100, 
    n_generative_samples=50, 
    k=2
)
policy = solve(solver, pomdp)

Continuous Example

This example demonstrates using CompressedBeliefMDP in a continuous setting with the LightDark1D POMDP. It combines particle filters for belief updating and Monte Carlo Tree Search (MCTS) as the solver. While compressing a 1D space is trivial toy problem, this architecture can be easily scaled to larger POMDPs with continuous state and action spaces.

using POMDPs, POMDPModels, POMDPTools
using ParticleFilters
using MCTS
using CompressedBeliefMDPs

pomdp = LightDark1D()
pomdp.movement_cost = 1
base_solver = MCTSSolver(n_iterations=10, depth=50, exploration_constant=5.0)
updater = BootstrapFilter(pomdp, 100)
solver = CompressedBeliefSolver(
    pomdp,
    base_solver;
    updater=updater,
    sampler=PolicySampler(pomdp; updater=updater)
)
policy = solve(solver, pomdp)
rs = RolloutSimulator(max_steps=50)
r = simulate(rs, pomdp, policy)

Large Example

In this example, we tackle a more realistic scenario with the TMaze POMDP, which has 123 states. To handle the larger state space efficiently, we employ a variational auto-encoder (VAE) to compress the belief simplex. By leveraging the VAE's ability to learn a compact representation of the belief state, we focus computational power on the relevant (compressed) belief states during each Bellman update.

using POMDPs, POMDPModels, POMDPTools
using CompressedBeliefMDPs

pomdp = TMaze(60, 0.9)
solver = CompressedBeliefSolver(
    pomdp;
    compressor=VAECompressor(123, 6; hidden_dim=10, verbose=true, epochs=2),
    sampler=PolicySampler(pomdp, n=500),
    verbose=true, 
    max_iterations=1000, 
    n_generative_samples=30,
    k=2
)
policy = solve(solver, pomdp)
rs = RolloutSimulator(max_steps=50)
r = simulate(rs, pomdp, policy)

compressedbeliefmdps.jl's People

Contributors

flyingworkshop avatar dependabot[bot] avatar mykelk avatar

Stargazers

Tyler Becker avatar Lasse Peters avatar  avatar Robert Moss avatar  avatar

Watchers

 avatar  avatar  avatar

compressedbeliefmdps.jl's Issues

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

Add code coverage

I think you will need to uncomment the relevant lines in CI.yml and add the badge to the readme.

ParticleFilters fails on discrete POMDPs

Steps to recreate:

using POMDPs, POMDPModels, POMDPTools
using ParticleFilters

using CompressedBeliefMDPs

using Random
Random.seed!(1)

pomdp = BabyPOMDP()
updater = SIRParticleFilter(pomdp, 1000)
solver = CompressedBeliefSolver(pomdp; updater=updater)
policy = solve(solver, pomdp)

Output:

julia> include("arena/filter_test.jl")
ERROR: LoadError: DimensionMismatch: dimensions must match: a has dims (Base.OneTo(1000),), b has dims (Base.OneTo(2),), mismatch at 1
Stacktrace:
  [1] promote_shape
    @ ./indices.jl:178 [inlined]
  [2] promote_shape
    @ ./indices.jl:169 [inlined]
  [3] -(A::Vector{Float64}, B::Vector{Float64})
    @ Base ./arraymath.jl:7
  [4] centralize(x::Vector{Float64}, m::Vector{Float64})
    @ MultivariateStats ~/.julia/packages/MultivariateStats/zLpz8/src/common.jl:15
  [5] predict(M::MultivariateStats.PCA{Float64}, x::Vector{Float64})
    @ MultivariateStats ~/.julia/packages/MultivariateStats/zLpz8/src/pca.jl:122
  [6] (::MVSCompressor{MultivariateStats.PCA})(beliefs::Vector{Float64})
    @ CompressedBeliefMDPs ~/VSCodeProjects/BeliefCompression/CompressedBeliefMDPs/src/compressors/mvs_compressors.jl:21
  [7] CompressedBeliefMDP(pomdp::BabyPOMDP, updater::BasicParticleFilter{…}, compressor::MVSCompressor{…})
    @ CompressedBeliefMDPs ~/VSCodeProjects/BeliefCompression/CompressedBeliefMDPs/src/cbmdp.jl:45
  [8] _make_compressed_belief_MDP(pomdp::BabyPOMDP, sampler::BeliefExpansionSampler, updater::BasicParticleFilter{…}, compressor::MVSCompressor{…})
    @ CompressedBeliefMDPs ~/VSCodeProjects/BeliefCompression/CompressedBeliefMDPs/src/solver.jl:96
  [9] CompressedBeliefSolver(pomdp::BabyPOMDP; updater::BasicParticleFilter{…}, sampler::BeliefExpansionSampler, compressor::MVSCompressor{…}, interp::Nothing, k::Int64, verbose::Bool, max_iterations::Int64, n_generative_samples::Int64, belres::Float64)
    @ CompressedBeliefMDPs ~/VSCodeProjects/BeliefCompression/CompressedBeliefMDPs/src/solver.jl:127
 [10] top-level scope
    @ ~/VSCodeProjects/BeliefCompression/arena/filter_test.jl:12
 [11] include(fname::String)
    @ Base.MainInclude ./client.jl:489
 [12] top-level scope
    @ REPL[1]:1
 [13] top-level scope
    @ ~/.julia/packages/Infiltrator/TNlCu/src/Infiltrator.jl:798
in expression starting at /Users/logan/VSCodeProjects/BeliefCompression/arena/filter_test.jl:12
Some type information was truncated. Use `show(err)` to see complete types.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.