{"id":23617044,"url":"https://github.com/reactivebayes/rxenvironments.jl","last_synced_at":"2026-03-09T04:02:30.150Z","repository":{"id":189768856,"uuid":"681270677","full_name":"ReactiveBayes/RxEnvironments.jl","owner":"ReactiveBayes","description":"Reactive environments for self-learning agents","archived":false,"fork":false,"pushed_at":"2025-11-04T10:24:58.000Z","size":1105,"stargazers_count":21,"open_issues_count":2,"forks_count":0,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-12-21T17:39:07.994Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ReactiveBayes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-08-21T16:38:10.000Z","updated_at":"2025-11-04T10:25:02.000Z","dependencies_parsed_at":"2023-08-21T18:07:52.331Z","dependency_job_id":"5e54c87f-7cfa-4d97-9258-078046e92eaa","html_url":"https://github.com/ReactiveBayes/RxEnvironments.jl","commit_stats":null,"previous_names":["biaslab/rxenvironments.jl","reactivebayes/rxenvironments.jl"],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/ReactiveBayes/RxEnvironments.jl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReactiveBayes%2FRxEnvironments.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReactiveBayes%2FRxEnvironments.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReactiveBayes%2FRxEnvironments.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReactiveBayes%2FRxEnvironments.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ReactiveBayes","download_url":"https://codeload.github.com/ReactiveBayes/RxEnvironments.jl/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReactiveBayes%2FRxEnvironments.jl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30282541,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T02:57:19.223Z","status":"ssl_error","status_checked_at":"2026-03-09T02:56:26.373Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-27T18:16:11.023Z","updated_at":"2026-03-09T04:02:30.103Z","avatar_url":"https://github.com/ReactiveBayes.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"| **Documentation**                                                         | **Build Status**                 | **Coverage**                       |\n|:-------------------------------------------------------------------------:|:--------------------------------:|:----------------------------------:|\n| [![][docs-stable-img]][docs-stable-url] [![][docs-dev-img]][docs-dev-url] | [![CI][ci-img]][ci-url]         | [![Codecov][codecov-img]][codecov-url] |\n\n\n[docs-dev-img]: https://img.shields.io/badge/docs-dev-blue.svg\n[docs-dev-url]: https://reactivebayes.github.io/RxEnvironments.jl/dev\n\n[docs-stable-img]: https://img.shields.io/badge/docs-stable-blue.svg\n[docs-stable-url]: https://reactivebayes.github.io/RxEnvironments.jl/stable\n\n[ci-img]: https://github.com/ReactiveBayes/RxEnvironments.jl/actions/workflows/CI.yml/badge.svg?branch=main\n[ci-url]: https://github.com/ReactiveBayes/RxEnvironments.jl/actions/workflows/CI.yml?query=branch%3Amain\n\n[codecov-img]: https://codecov.io/gh/ReactiveBayes/RxEnvironments.jl/graph/badge.svg?token=CxR2jysX7Z\n[codecov-url]: https://codecov.io/gh/ReactiveBayes/RxEnvironments.jl?branch=main\n\n# RxEnvironments\n\n`RxEnvironments` contains all boilerplate code to create reactive environments for self-learning agents, allowing for state transitions with variable time between state updates.`RxEnvironments` exports the `RxEnvironment` and `RxEntity` wrapper structs, that facilitate all plumbing to make an environment fully reactive. Under the hood, `RxEnvironments` uses [Rocket.jl](https://www.github.com/ReactiveBayes/Rocket.jl).\n\n# Installation\n`RxEnvironments.jl` can be installed through the Julia Registry:\n```bash\npkg\u003e add RxEnvironments\n```\n# Example\n\nWhen using RxEnvironments, you only have to specify the dynamics of your environment. Let's create the Bayesian Thermostat environment in `RxEnvironments`. For this example, you need `Distributions.jl` installed in your environment as well. \n\nLet's create the basics of our environment:\n\n```julia\nusing RxEnvironments\nusing Distributions\n\n# Empty agent, could contain states as well\nstruct ThermostatAgent end\n\nmutable struct BayesianThermostat{T\u003c:Real}\n    temperature::T\n    min_temp::T\n    max_temp::T\nend\n\n# Helper functions\ntemperature(env::BayesianThermostat) = env.temperature\nmin_temp(env::BayesianThermostat) = env.min_temp\nmax_temp(env::BayesianThermostat) = env.max_temp\nnoise(env::BayesianThermostat) = Normal(0.0, 0.1)\nset_temperature!(env::BayesianThermostat, temp::Real) = env.temperature = temp\nfunction add_temperature!(env::BayesianThermostat, diff::Real) \n    env.temperature += diff\n    if temperature(env) \u003c min_temp(env)\n        set_temperature!(env, min_temp(env))\n    elseif temperature(env) \u003e max_temp(env)\n        set_temperature!(env, max_temp(env))\n    end\nend\n```\n\nBy implementing `RxEnvironments.receive!`, `RxEnvironments.what_to_send` and `RxEnvironments.update!` for our environment, we can fully specify the behaviour of our environment, and `RxEnvironments` will take care of the rest. The `RxEnvironments.receive!` and `RxEnvironments.what_to_send` functions have a specific signature: `RxEnvironments.receive!(receiver, emitter, action)` takes as arguments the recipient of the action (in this example the environment), the emitter of the action (in this example the agent) and the action itself (in this example the change in temperature). The `receive!` function thus specifiec how an action from `emitter` to `recipient` affects the state of `recipient`. Always make sure to dispatch on the types of your environments, agents and actions, as `RxEnvironments` relies on Julia's multiple dispatch system to call the correct functions. Similarly for `what_to_send`, which takes the `recipient` and `emitter` (and potentially `observation`) as arguments, that computes the observation from `emitter` presented to `recipient` (when emitter has received `observation`). In our Bayesian Thermostat example, these functions look as follows:\n\n```julia\n# When the environment receives an action from the agent, we add the value of the action to the environment temperature.\nRxEnvironments.receive!(recipient::BayesianThermostat{T}, emitter::ThermostatAgent, action::T) where {T} = add_temperature!(recipient, action)\n\n# The environment sends a noisy observation of the temperature to the agent.\nRxEnvironments.what_to_send(recipient::ThermostatAgent, emitter::BayesianThermostat) = temperature(emitter) + rand(noise(emitter))\n\n# The environment cools down over time.\nRxEnvironments.update!(env::BayesianThermostat, elapsed_time)= add_temperature!(env, -0.1 * elapsed_time)\n```\n\nNow we've fully specified our environment, and we can interact with it. In order to create the environment, we use the `RxEnvironment` struct, and we add an agent to this environment using `add!`:\n\n```julia\nenvironment = RxEnvironment(BayesianThermostat(0.0, -10.0, 10.0); emit_every_ms = 900)\nagent = add!(environment, ThermostatAgent())\n```\n\nNow we can have the agent conduct actions in our environment. Let's have the agent conduct some actions, and inspect the observations that are being returned by the environment:\n\n```julia\n# Subscribe a logger actor to the observations of the agent\nRxEnvironments.subscribe_to_observations!(agent, RxEnvironments.logger())\n\n# Conduct 10 actions:\nfor i in 1:10\n    action = rand()\n    RxEnvironments.send!(environment, agent, action)\n    sleep(1)\nend\n```\n\n```\n[LogActor] Data: 0.006170718477015863\n[LogActor] Data: -0.09624863445330185\n[LogActor] Data: -0.3269267933074502\n[LogActor] Data: 0.001304207094952492\n[LogActor] Data: 0.03626599314271475\n[LogActor] Data: 0.010733164205412482\n[LogActor] Data: 0.12313893922057219\n[LogActor] Data: -0.013042652548091921\n[LogActor] Data: 0.03561033321842316\n[LogActor] Data: 0.6763921880509323\n[LogActor] Data: 0.8313618838112217\n[LogActor] Data: 1.7408316683602163\n[LogActor] Data: 1.7322639115928715\n[LogActor] Data: 1.458556241545732\n[LogActor] Data: 1.6689296645689367\n[LogActor] Data: 1.683300152848493\n[LogActor] Data: 2.087509970813057\n[LogActor] Data: 2.258940017058188\n[LogActor] Data: 2.6537100822978372\n[LogActor] Data: 2.6012179767058408\n[LogActor] Data: 3.0775745739101716\n[LogActor] Data: 2.7326464283572727\n```\n\nCongratulations! You've now implemented a basic environment in `RxEnvironments`.\n\n# Next steps\nYou can head to the [documentation](https://reactivebayes.github.io/RxEnvironments.jl/stable) for a more extensive reference on the contents of the package. \n\n# Missing anything?\n\nThis package is a WIP, feel free to open an issue with a feature request.\n\n# License\nThis package is open-source and available under the [MIT License](https://github.com/reactivebayes/RxEnvironments.jl/blob/main/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freactivebayes%2Frxenvironments.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freactivebayes%2Frxenvironments.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freactivebayes%2Frxenvironments.jl/lists"}