CommonRLSpaces

A collection of structures to define observation or action spaces of Reinforcement Learning environments. [May be moved into CommonRLInterface once stable]

https://github.com/juliareinforcementlearning/commonrlspaces.jl

Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    1 of 4 committers (25.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.6%) to scientific vocabulary
Last synced: 7 months ago · JSON representation ·

Repository

A collection of structures to define observation or action spaces of Reinforcement Learning environments. [May be moved into CommonRLInterface once stable]

Basic Info
  • Host: GitHub
  • Owner: JuliaReinforcementLearning
  • License: mit
  • Language: Julia
  • Default Branch: main
  • Homepage:
  • Size: 60.5 KB
Statistics
  • Stars: 7
  • Watchers: 3
  • Forks: 3
  • Open Issues: 8
  • Releases: 4
Created almost 4 years ago · Last pushed over 1 year ago
Metadata Files
Readme License Citation

README.md

CommonRLSpaces

Build Status Coverage Code Style: Blue PkgEval

Introduction

A space is simply a set of objects. In a reinforcement learning context, spaces define the sets of possible states, actions, and observations.

In Julia, spaces can be represented by a variety of objects. For instance, a small discrete action set might be represented with ["up", "left", "down", "right"], or an interval of real numbers might be represented with an object from the IntervalSets package. In general, the space defined by any Julia object is the set of objects x for which x in space returns true.

In addition to establishing the definition above, this package provides three useful tools:

  1. Traits to communicate about the properties of spaces, e.g. whether they are continuous or discrete, how many subspaces they have, and how to interact with them.
  2. Functions such as product for constructing more complex spaces
  3. Constructors to for spaces whose elements are arrays, such as ArraySpace and Box.

Concepts and Interface

Interface for all spaces

Since a space is simply a set of objects, a wide variety of common Julia types including Vector, Set, Tuple, and Dict1can represent a space. Because of this inclusive definition, there is a very minimal interface that all spaces are expected to implement. Specifically, it consists of - in(x, space), which tests whether x is a member of the set space (this can also be called with the x in space syntax). - rand(space), which returns a valid member of the set2. - eltype(space), which returns the type of the elements in the space.

In addition, the SpaceStyle trait is always defined. Calling SpaceStyle(space) will return either a FiniteSpaceStyle, ContinuousSpaceStyle, HybridSpaceStyle, or an UnknownSpaceStyle object.

Finite discrete spaces

Spaces with a finite number of elements have FiniteSpaceStyle. These spaces are guaranteed to be iterable, implementing Julia's iteration interface. In particular collect(space) will return all elements in an array.

Continuous spaces

Continuous spaces represent sets that have an uncountable number of elements they have a SpaceStyle of type ContinuousSpaceStyle. CommonRLSpaces does not adopt a rigorous mathematical definition of a continuous set, but, roughly, elements in the interior of a continuous space have other elements very close to them.

Continuous spaces have some additional interface functions:

  • bounds(space) returns upper and lower bounds in a tuple. For example, if space is a unit circle, bounds(space) will return ([-1.0, -1.0], [1.0, 1.0]). This allows agents to choose policies that appropriately cover the space e.g. a normal distribution with a mean of mean(bounds(space)) and a standard deviation of half the distance between the bounds.
  • clamp(x, space) returns an element of space that is near x. i.e. if space is a unit circle, clamp([2.0, 0.0], space) might return [1.0, 0.0]. This allows for a convenient way for an agent to find a valid action if they sample actions from a distribution that doesn't match the space exactly (e.g. a normal distribution).
  • clamp!(x, space), similar to clamp, but clamps x in place.

Hybrid spaces

The interface for hybrid continuous-discrete spaces is currently planned, but not yet defined. If the space style is not FiniteSpaceStyle or ContinuousSpaceStyle, it is UnknownSpaceStyle.

Spaces of arrays

[need to figure this out, but I think elsize(space) should return the size of the arrays in the space]

Cartesian products of spaces

The Cartesian product of two spaces a and b can be constructed with c = product(a, b).

The exact form of the resulting space is unspecified and should be considered an implementation detail. The only guarantees are (1) that there will be one unique element of c for every combination of one object from a and one object from b and (2) that the resulting space conforms to the interface above.

The TupleSpaceProduct constructor provides a specialized Cartesian product where each element is a tuple, i.e. TupleSpaceProduct(a, b) has elements of type Tuple{eltype(a), eltype(b)}.


1Note: the elements of a space represented by a Dict are key-value Pairs. 2[TODO: should we make any guarantees about whether rand(space) is drawn from a uniform distribution?]

Usage

Construction

|Category|Style|Example| |:---|:----|:-----| |Enumerable discrete space| FiniteSpaceStyle{()}() | (:cat, :dog), 0:1, ["a","b","c"] | |One dimensional continuous space| ContinuousSpaceStyle{()}() | -1.2..3.3, Interval(1.0, 2.0) | |Multi-dimensional discrete space| FiniteSpaceStyle{(3,4)}() | ArraySpace((:cat, :dog), 3, 4), ArraySpace(0:1, 3, 4), ArraySpace(1:2, 3, 4), ArraySpace(Bool, 3, 4)| |Multi-dimensional variable discrete space| FiniteSpaceStyle{(2,)}() | product((:cat, :dog), (:litchi, :longan, :mango)), product(-1:1, (false, true))| |Multi-dimensional continuous space| ContinuousSpaceStyle{(2,)}() or ContinuousSpaceStyle{(3,4)}() | Box([-1.0, -2.0], [2.0, 4.0]), product(-1.2..3.3, -4.6..5.0), ArraySpace(-1.2..3.3, 3, 4), ArraySpace(Float32, 3, 4) | |Multi-dimensional hybrid space [planned for future]| HybridSpaceStyle{(2,),()}() | product(-1.2..3.3, -4.6..5.0, [:cat, :dog]), product(Box([-1.0, -2.0], [2.0, 4.0]), [1,2,3])|

API

```julia julia> using CommonRLSpaces

julia> s = (:litchi, :longan, :mango)

julia> rand(s) :litchi

julia> rand(s) in s true

julia> length(s) 3 ```

```julia julia> s = ArraySpace(1:5, 2,3) CommonRLSpaces.RepeatedSpace{UnitRange{Int64}, Tuple{Int64, Int64}}(1:5, (2, 3))

julia> rand(s) 23 Matrix{Int64}: 4 1 1 3 2 2

julia> rand(s) in s true

julia> SpaceStyle(s) FiniteSpaceStyle()

julia> elsize(s) (2, 3) ```

```julia julia> s = product(-1..1, 0..1) Box{StaticArraysCore.SVector{2, Float64}}([-1.0, 0.0], [1.0, 1.0])

julia> rand(s) 2-element StaticArraysCore.SVector{2, Float64} with indices SOneTo(2): 0.03049072910834738 0.6295234114874269

julia> rand(s) in s true

julia> SpaceStyle(s) ContinuousSpaceStyle()

julia> elsize(s) (2,)

julia> bounds(s) ([-1.0, 0.0], [1.0, 1.0])

julia> clamp([5, 5], s) 2-element StaticArraysCore.SizedVector{2, Float64, Vector{Float64}} with indices SOneTo(2): 1.0 1.0 ```

Owner

  • Name: JuliaReinforcementLearning
  • Login: JuliaReinforcementLearning
  • Kind: organization

A collection of tools for reinforcement learning research in Julia

Citation (CITATION.bib)

@misc{CommonRLSpaces.jl,
	author  = {Jun Tian <tianjun.cpp@gmail.com> and contributors},
	title   = {CommonRLSpaces.jl},
	url     = {https://github.com/Jun Tian/CommonRLSpaces.jl},
	version = {v0.1.0},
	year    = {2022},
	month   = {5}
}

GitHub Events

Total
  • Watch event: 1
Last Year
  • Watch event: 1

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 28
  • Total Committers: 4
  • Avg Commits per committer: 7.0
  • Development Distribution Score (DDS): 0.464
Past Year
  • Commits: 1
  • Committers: 1
  • Avg Commits per committer: 1.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Zachary Sunberg z****g@c****u 15
Jun Tian t****p@g****m 11
Jeremiah 4****s 1
Ludvig Killingberg l****k 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 8 months ago

All Time
  • Total issues: 9
  • Total pull requests: 9
  • Average time to close issues: 7 days
  • Average time to close pull requests: 3 days
  • Total issue authors: 4
  • Total pull request authors: 6
  • Average comments per issue: 2.33
  • Average comments per pull request: 1.22
  • Merged pull requests: 4
  • Bot issues: 0
  • Bot pull requests: 4
Past Year
  • Issues: 0
  • Pull requests: 1
  • Average time to close issues: N/A
  • Average time to close pull requests: 13 days
  • Issue authors: 0
  • Pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • zsunberg (6)
  • findmyway (1)
  • tym2021 (1)
  • JuliaTagBot (1)
Pull Request Authors
  • github-actions[bot] (4)
  • ludvigk (2)
  • zsunberg (1)
  • findmyway (1)
  • the-one-and-only-jackson (1)
  • jeremiahpslewis (1)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • julia 53 total
  • Total dependent packages: 1
  • Total dependent repositories: 0
  • Total versions: 4
juliahub.com: CommonRLSpaces

A collection of structures to define observation or action spaces of Reinforcement Learning environments. [May be moved into CommonRLInterface once stable]

  • Versions: 4
  • Dependent Packages: 1
  • Dependent Repositories: 0
  • Downloads: 53 Total
Rankings
Dependent repos count: 9.9%
Dependent packages count: 23.0%
Average: 29.6%
Forks count: 40.4%
Stargazers count: 45.1%
Last synced: 8 months ago

Dependencies

.github/workflows/CI.yml actions
  • actions/checkout v2 composite
  • codecov/codecov-action v2 composite
  • julia-actions/cache v1 composite
  • julia-actions/julia-buildpkg v1 composite
  • julia-actions/julia-docdeploy v1 composite
  • julia-actions/julia-processcoverage v1 composite
  • julia-actions/julia-runtest v1 composite
  • julia-actions/setup-julia v1 composite
.github/workflows/CompatHelper.yml actions
.github/workflows/TagBot.yml actions
  • JuliaRegistries/TagBot v1 composite
.github/workflows/register.yml actions
  • julia-actions/RegisterAction latest composite