Skip to content

How do we deal with metasampler ? #13

@HenriDeh

Description

@HenriDeh

Hi,

So I tried implementing the MetaSampler. Here's how I thought we could do it:

struct MetaSampler <: AbstractSampler
    samplers::Dict{Symbol, AbstractSampler}
end

"""
    MetaSampler(samplers::Pair{Symbol, <:AbstractSampler}...)

MetaSampler is a collection of Symbol => Sampler pairs. This is intended to be used by algorithm designers when they need different ways to sample a trajectory at various points in their implementation.
"""
MetaSampler(samplers::Pair{Symbol, <: AbstractSampler}...) = MetaSampler(Dict(samplers...))

Base.getindex(m::MetaSampler, idx) = m.samplers[idx]

The idea being that in the algorithm implementation one could use sample(trajectory.sampler[:policy], traces) to switch between samplers in the MetaSampler. However I have two questions:

  1. I don't see sample in the exported API in the readme. Does that mean that the design is to only use iterate ? sample is called by take! and take! is called by iterate. If we were to use sample directly, this would bypass the controler shenanigans, which is not desirable for ASync stuff. Perhaps we could implement take!(trajectory, :policy) (that is, the second argument is to specify a sampler. But it's weird to me to use take! as a sampling API.
  2. Anyways, how can we integrate MetaSampler to the iterate API ? I don't think iterate can accept a Symbol option.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions