A lightweight reinforcement learning package
Project description
LightRL
Lightweight Reinforcement Learning python library for optimizing time dependent processes.
Read more about Multi-armed_bandit.
Installation
pip install lightrl
Example
Please see documentation docs.
Here is minimal example
import time
import random
from lightrl import EpsilonDecreasingBandit, two_state_time_dependent_process
def testing_simulation_function(num_tasks):
# Simulate the number of successful and failed tasks
# num_tasks = 0, p = 0.05
# num_tasks = 100, p = 0.05 + 100 / 200 = 0.55
# num_tasks = 200, p = 0.05 + 200 / 200 = 1.05
p = 0.05 + num_tasks / 200
noise = random.uniform(-0.04, 0.04)
p_with_noise = p + noise
p_with_noise = min(1.0, max(0.0, p_with_noise))
failed_tasks = num_tasks * p_with_noise
successful_tasks = num_tasks - failed_tasks
return successful_tasks, failed_tasks
if __name__ == "__main__":
request_nums = list(range(10, 210, 10))
bandit = EpsilonDecreasingBandit(
arms=request_nums, initial_epsilon=1.0, limit_epsilon=0.1, half_decay_steps=len(request_nums) * 5
)
print(bandit)
two_state_time_dependent_process(
bandit=bandit,
fun=testing_simulation_function,
failure_threshold=0.1, # Allowed failure is 10%
default_wait_time=0.1, # Wait 0.1 s between requests
extra_wait_time=0.1, # Wait extra 0.1 s when in blocked state
waiting_args=[
10
], # Working with only 10 requests in the waiting state to test if we are still blocked
max_steps=1000, # Run for maximum of 1000 steps
verbose=True,
reward_factor=1e-6, # In case you want to keep reward below 1 (for UCB1Bandit)
)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
lightrl-0.1.1.tar.gz
(6.3 kB
view details)
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 lightrl-0.1.1.tar.gz.
File metadata
- Download URL: lightrl-0.1.1.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e41679d40ae631253797e8c4468fd4b7e095199dac425f495c96e823f76ab934
|
|
| MD5 |
9792d12bdf9b96503d9c24706f3486e2
|
|
| BLAKE2b-256 |
f31436a28cbd504c3c74dd9dd12bbd4d205572ea11c6735e58fd61a6ee2f92e6
|
File details
Details for the file lightrl-0.1.1-py3-none-any.whl.
File metadata
- Download URL: lightrl-0.1.1-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8848ed7dc761a401578c19f74c3ff7b281a326dfcd0082ebecade4cff80e96e0
|
|
| MD5 |
f46f46b8d1d20e8630c7ec45e30d2653
|
|
| BLAKE2b-256 |
cc89286ff46be840b40c746fe65d52b60b1d79e10f13c20bc420ebb94a265540
|