Paper - Pytorch
Project description
Opioid RL
OpioidRL is a cutting-edge reinforcement learning (RL) library that simulates drug addiction behaviors within RL agents. Inspired by the addictive properties of drugs like methamphetamine and crack cocaine, OpioidRL offers a unique environment where agents experience reward dependency, high-risk decision-making, and compulsive behaviors — pushing RL research into new and provocative territories.
Features
- Meth Simulation: Models the erratic and compulsive high-risk behaviors typically seen in methamphetamine addiction.
- Crack Simulation: Models the short-term, intense craving for rewards, leading to aggressive reward-seeking behaviors.
- Customizable Reward Loops: Easily adjust the reinforcement pathways to mimic varying levels of addiction, from mild dependency to extreme compulsion.
- Addiction Dynamics: Introduces tolerance, withdrawal, and relapse phenomena, simulating real-world addiction cycles.
- Compatible with Any RL Framework: Easily integrate OpioidRL with popular RL frameworks like PyTorch, TensorFlow, and Stable Baselines3.
Installation
You can install OpioidRL using pip
:
pip install opioidrl
Quick Start
Below is a simple example of how to integrate OpioidRL into your RL pipeline.
import opioidrl
from stable_baselines3 import PPO
# Create a Crack environment
env = opioidrl.make('Crack-v0')
# Train the agent using PPO
model = PPO('MlpPolicy', env, verbose=1)
model.learn(total_timesteps=100000)
# Test the agent
obs = env.reset()
for _ in range(1000):
action, _states = model.predict(obs)
obs, rewards, dones, info = env.step(action)
env.render()
Example: Meth Environment
import opioidrl
from stable_baselines3 import A2C
# Create a Meth environment
env = opioidrl.make('Meth-v0')
# Train the agent using A2C
model = A2C('MlpPolicy', env, verbose=1)
model.learn(total_timesteps=100000)
# Evaluate agent behavior
obs = env.reset()
for _ in range(1000):
action, _states = model.predict(obs)
obs, rewards, dones, info = env.step(action)
env.render()
Available Environments
OpioidRL currently offers two environments simulating different types of addiction:
- Crack-v0: Fast and intense, simulates the short-term, high-risk reward-seeking behaviors common in crack cocaine addiction.
- Meth-v0: More sustained compulsive behaviors, with agents showing an increasing tolerance and willingness to take extreme actions for delayed rewards.
Environment Customization
You can modify the parameters of each environment to simulate different levels of addiction severity:
env = opioidrl.make('Meth-v0', tolerance_increase_rate=0.01, withdrawal_penalty=5)
Configuration Options
tolerance_increase_rate
: How fast the agent builds tolerance to rewards.withdrawal_penalty
: The penalty imposed when the agent doesn't receive its expected reward.relapse_probability
: The probability that an agent will fall back into compulsive behaviors after overcoming addiction.
Roadmap
- Opioid-v0: A new environment simulating opioid addiction with prolonged reward dependency and extreme withdrawal effects.
- Alcohol-v0: An environment simulating long-term, mild addiction behaviors with subtle but persistent effects on decision-making.
- Nicotine-v0: Simulating the reward-seeking behavior tied to nicotine addiction, with frequent, small rewards.
Contributing
Contributions are welcome! If you have ideas for new environments or features, feel free to submit a pull request or open an issue.
Steps to Contribute:
- Fork this repository.
- Create a new branch:
git checkout -b feature-name
- Commit your changes:
git commit -m 'Add new feature'
- Push to the branch:
git push origin feature-name
- Submit a pull request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Disclaimer
OpioidRL is a research tool designed for educational and experimental purposes. The behaviors simulated within this library are based on abstract models of addiction and are not intended to trivialize or promote drug addiction in any form. Addiction is a serious issue, and if you or someone you know is struggling with addiction, please seek professional help.
Made with ❤️ by the OpioidRL team.
This `README.md` provides a comprehensive overview of **OpioidRL**, including its installation, features, examples of usage, and an important disclaimer. The meth and crack environments emphasize different aspects of addiction within RL simulations, making it clear what each environment simulates.
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
File details
Details for the file opioidrl-0.0.1.tar.gz
.
File metadata
- Download URL: opioidrl-0.0.1.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.3 Darwin/23.3.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c39de8a35e895a2937ba779efdc0c9ef3eab74de9034bfc1cbd0c3b6c77b0dd |
|
MD5 | 1d93cb16c72b6ff9a175764f3c0427c5 |
|
BLAKE2b-256 | fc8a0dfba129382f0365191cb647683e71de177ae93b4ac6a739d672163c2223 |
File details
Details for the file opioidrl-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: opioidrl-0.0.1-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.3 Darwin/23.3.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e40a0133a14ec34073dafb9ac04d476dba9f67d7ac65c777c6ee8cdd62fd47a |
|
MD5 | bd69e2f24959f6a4103ff318d63cbb3d |
|
BLAKE2b-256 | ab588be09bbe2bca67cd9b9c8c2e6e448b1edaf7bebbc0ab2a973a34118419ce |