From d941b2c9af6a877254526490e19392cda2ef417a Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Wed, 2 Oct 2024 18:45:11 +0200 Subject: [PATCH] Added RL to README --- README.md | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2612e3c..c4bc7f2 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ NuCon is a Python library designed to interface with and control parameters in Nucleares, a nuclear reactor simulation game. It provides a robust, type-safe foundation for reading and writing game parameters, allowing users to easily create their own automations and control systems. -In future versions, NuCon aims to implement built-in automation features. +NuCon further provides a work in progress implementation of a reinforcement learning environment for training control policies. ## Features @@ -83,6 +83,45 @@ Custom Enum Types: - `PumpOverloadStatus`: Enum for pump overload status (ACTIVE_AND_OVERLOAD, INACTIVE_OR_ACTIVE_NO_OVERLOAD) - `BreakerStatus`: Enum for breaker status (OPEN, CLOSED) +## Reinforcement Learning (Work in Progress) + +NuCon includes a preliminary Reinforcement Learning (RL) environment based on the OpenAI Gym interface. This feature is currently a work in progress and requires additional dependencies. + +### Additional Dependencies + +To use the RL features, you'll need to install the following packages: + +```bash +pip install gymnasium numpy +``` + +### RL Environment + +The `NuconEnv` class in `nucon/rl.py` provides a Gym-compatible environment for reinforcement learning tasks in the Nucleares simulation. Key features include: + +- Observation space: Includes all readable parameters from the Nucon system. +- Action space: Encompasses all writable parameters in the Nucon system. +- Step function: Applies actions to the Nucon system and returns new observations. +- Objective function: Allows for custom objective functions to be defined for training. + +### Usage + +Here's a basic example of how to use the RL environment: +```python +from nucon.rl import NuconEnv + +env = NuconEnv(objectives=['max_power'], seconds_per_step=5) + +obs, info = env.reset() +for _ in range(1000): + action = env.action_space.sample() # Your agent here (instead of random) + obs, reward, terminated, truncated, info = env.step(action) + + if terminated or truncated: + obs, info = env.reset() +env.close() +``` + ## Testing NuCon includes a test suite to verify its functionality and compatibility with the Nucleares game.