A package implementing a Totally Asymmetric Simple Exclusion Process (TASEP) using reinforcement learning (RL) agents.
Project description
TASEP-Smarticles
Overview
The SmartTasep package implements a Totally Asymmetric Simple Exclusion Process (TASEP) using reinforcement learning (RL) agents. In this simulation, particles perceive their environment at each time step, and a neural network decides their next action (move forward, up, or down) to maximize the total current. The repository employs Double Deep Q Learning (DDQN) with a policy network and a target network that is updated using a soft update mechanism. Experience replay is used to sample from a buffer of past experiences, facilitating learning.
Features
- TASEP simulation with RL agents
- Double Deep Q Learning (dDQN)
- Policy network and target network with soft updates
- (Prioritized) Experience replay for improved learning
- Real-time training visualization with pygame and matplotlib
- Saving trained networks
- Loading and running pretrained simulations
- Testing learned policies interactively
- Customizable reward functions
Files
Classes in TASEP-Smarticles:
DQN.py: Neural network RL agent classGridEnvironment.py: Environment class that computes states, transitions, and rewardsTrainer.py: Wrapper class for training the network, saving, loading and running simulationsPlayground.py: Class for testing learned policies interactively
Setup
-
Install the package using pip:
pip install smarttasep
Using the package
-
Import the package:
from smarttasep import Trainer, EnvParams, Hyperparams, Playground
-
Run a training session:
envParams = EnvParams(render_mode="human", length=128, width=24, moves_per_timestep=200, window_height=200, observation_distance=3, distinguishable_particles=True, initial_state_template="checkerboard", social_reward=True, use_speeds=True, sigma=10, allow_wait=True, invert_speed_observation=True) hyperparams = Hyperparams(BATCH_SIZE=32, GAMMA=0.85, EPS_START=0.9, EPS_END=0.05, EPS_DECAY=100_000, TAU=0.005, LR=0.001, MEMORY_SIZE=500_000) trainer = Trainer(envParams, hyperparams, reset_interval=100_000, fl total_steps=500_000, plot_interval=4000, new_model=True) trainer.train_and_save()
-
Load a pretrained model and run a simulation:
trainer = trainer.load() # shows a list of available models and prompts the user to choose one trainer.run()
-
Test a learned policy interactively:
Playground() # shows a list of available models and prompts the user to choose one
Author
Jonas Märtens
GitHub: https://github.com/jonasmaertens
Version
Current Version: 0.1.0
License
This project is licensed under the MIT License - see the LICENSE.md file for details
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file smarttasep-0.1.4.tar.gz.
File metadata
- Download URL: smarttasep-0.1.4.tar.gz
- Upload date:
- Size: 27.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
700af83bc7018611e70f87a881261eab6ebebab4fbe75038816f506b2ac019a0
|
|
| MD5 |
279039e67d7f421e29fcce3937bfc2d7
|
|
| BLAKE2b-256 |
45369451ef248400e11663c25ec8f117539ca02935a10250b6c7fdd6e88bbf5c
|
File details
Details for the file smarttasep-0.1.4-py3-none-any.whl.
File metadata
- Download URL: smarttasep-0.1.4-py3-none-any.whl
- Upload date:
- Size: 28.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ba9a347b0daf9ee82f6bf8a6cdf1855b7dc9d3e1c2bc7633d1d361add839f99
|
|
| MD5 |
1a416e44d4aba01edbe60343386881de
|
|
| BLAKE2b-256 |
9ec075431c4ed8def582b0ebffaa1040c8ea7af3d97dca9dde53ec9b54e0e42b
|