Graph Reinforcement Learning Environments
Project description
GraphEnvs
Graph Reinforcement Learning (RL) Environments
Installation
First install torch and pytorch geometric. The simply use pip to install graph_envs:
pip install graph-envs
Example
import gymnasium as gym
import graph_envs
import numpy as np
env = gym.make('ShortestPath-v0', n_nodes=10, n_edges=20)
for _ in range(5):
obs, info = env.reset()
mask = info['mask']
done = False
while not done:
valid_actions = mask.nonzero()
action = np.random.choice(len(valid_actions[0]))
action = (valid_actions[0][action], valid_actions[1][action])
obs, reward, done, _, info = env.step(action)
print(obs, reward, done)
mask = info['mask']
Supported Environments
- Shortest Path: The goal is to find the shortest path from the source node to the target node. At each step, an edge is added to the path. The episode is over when we reach the target node.
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
graph-envs-0.0.8.tar.gz
(5.3 kB
view hashes)
Built Distribution
Close
Hashes for graph_envs-0.0.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bda2a215f35888d426d1c970f39004d1fd3ef1323ed52247541b5ffe259e427f |
|
MD5 | 9c946838bb64594a371c7050d8a9f574 |
|
BLAKE2b-256 | 53521c5c171762b5c2cf38035889591d115e50ab9289fa9ad46c5fdfb60a8fc0 |