Skip to main content

dfa-gym

This repo implements (Multi-Agent) Reinforcement Learning environments in JAX for solving objectives given as Deteministic Finite Automata (DFAs). There are three environments:

  1. TokenEnv is a fully observable grid environment with tokens in cells. The grid can be created randomly or from a specific layout. It can be instantiated in both single- and multi-agent settings.
  2. DFAWrapper is an environment wrapper assigning tasks represented as Deterministic Finite Automata (DFAs) to the agents in the wrapped environment. DFAs are repsented as DFAx objects.
  3. DFABisimEnv is an environment for solving DFA bisimulation games to learn RAD Embeddings, provably correct latent DFA representation, as described in this paper.

Installation

Install using pip.

pip install dfa-gym

TokenEnv

Create a grid world with token and agent positions assigned randomly.

from dfa_gym import TokenEnv

env = TokenEnv(
        n_agents=1, # Single agent
        n_tokens=10, # 10 different token types
        n_token_repeat=2, # Each token repeated twice
        grid_shape=(7, 7), # Shape of the grid
        fixed_map_seed=None, # If not None, then samples the same map using the given seed
        max_steps_in_episode=100, # Episode length is 100
    )

Create a grid world from a given layout.

layout = """
    [ 0 ][   ][   ][   ][ # ][ # ][ # ][ # ][ # ]
    [   ][   ][ a ][   ][#,a][ 0 ][   ][ 2 ][ # ]
    [ A ][   ][ a ][   ][#,a][   ][ 8 ][   ][ # ]
    [   ][   ][ a ][   ][#,a][ 6 ][   ][ 4 ][ # ]
    [ 1 ][   ][   ][ 3 ][ # ][ # ][ # ][ # ][ # ]
    [   ][   ][ b ][   ][#,b][ 1 ][   ][ 3 ][ # ]
    [ B ][   ][ b ][   ][#,b][   ][ 9 ][   ][ # ]
    [   ][   ][ b ][   ][#,b][ 7 ][   ][ 5 ][ # ]
    [ 2 ][   ][   ][   ][ # ][ # ][ # ][ # ][ # ]
    """
    env = TokenEnv(
        layout=layout, # Set layout, where each [] indicates a cell, uppercase letters are
                       # agents, # are walls, and lower case letters are buttons when alone
                       # and doors when paired with a wall. For example, [#,a] is a door
                       # that is open if an agent is on a [ a ] cell and closed otherwise.
    )

DFAWrapper

Wrap a TokenEnv instance using DFAWrapper .

from dfa_gym import DFAWrapper
from dfax.samplers import ReachSampler

env = DFAWrapper(
    env=TokenEnv(layout=layout),
    sampler=ReachSampler()
)

DFABisimEnv

Create DFA bisimulation game.

from dfa_gym import DFABisimEnv
from dfax.samplers import RADSampler

env = DFABisimEnv(sampler=RADSampler())

Metadata

Release files for dfa-gym 0.2.18

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dfa-gym 0.2.18
File Size Uploaded Provenance Actions
dfa_gym-0.2.18.tar.gz 208.4 kB Without provenance Details for dfa_gym-0.2.18.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dfa-gym 0.2.18
File Interpreter ABI Platform Actions
dfa_gym-0.2.18-py3-none-any.whl Python 3 none any Details for dfa_gym-0.2.18-py3-none-any.whl

Total release size: 322.7 kB

Release files / dfa_gym-0.2.18.tar.gz

Download URL dfa_gym-0.2.18.tar.gz
Size 208.4 kB
Tags Source
SHA-256 checksum
How to use checksums
be53e43812e8fd5323e78e55f495cdd983cd4ce8793d3488b6e2f1dd845ee407
BLAKE2b-256 checksum
How to use checksums
4381684e4f3620734757dd645422ff5d16dda47c7f441db87350d6a7a054a9d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.18

Release files / dfa_gym-0.2.18-py3-none-any.whl

Download URL dfa_gym-0.2.18-py3-none-any.whl
Size 114.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dade51a97a52b0f04d3cb2fc50f0bc4ea39f675a874c1560c5975cd4dd886de4
BLAKE2b-256 checksum
How to use checksums
69e0425dec3f8362f6c7417599d0f83bba56f104aa322700587b70878955e8ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.18

Security for dfa-gym 0.2.18

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page