Skip to main content

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 
from src.graph_envs import shortest_path
import numpy as np

env = gym.make('ShortestPath-v0', n_nodes=5, n_edges=7)

for _ in range(5):
    
    obs, info = env.reset()
    mask = info['mask']
    done = False
    
    while not done:
        valid_actions = mask.nonzero()[0]
        action = np.random.choice(valid_actions)
        obs, reward, done, _, info = env.step(action)
        print(obs, rewards, done)
        mask = info['mask']

Supported Environments

Environment Developed Action Space
Shortest Path $v \in \mathcal{V}$
Steiner Tree $e \in \mathcal{E}$
MST $e \in \mathcal{E}$
MultiCast Routing :heavy_multiplication_x: $(e, m) \in \mathcal{E} \times {1,2,..., M}$
Minimum Vertex Cover $v \in \mathcal{V}$
TSP $v \in \mathcal{V}$
Longest Path :heavy_multiplication_x: $v \in \mathcal{V}$
Largest Clique :heavy_multiplication_x: $v \in \mathcal{V}$
Hamilton Path $v \in \mathcal{V}$
Densest Subgraph :heavy_multiplication_x: $v \in \mathcal{V}$
Topological sorting :heavy_multiplication_x: $v \in \mathcal{V}$
  1. 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.
  2. Steiner Tree: The goal is to find the tree with the minimum weight that connects a source node to a number of destination nodes.

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

graph-envs-0.0.28.tar.gz (10.0 kB view hashes)

Uploaded Source

Built Distribution

graph_envs-0.0.28-py3-none-any.whl (13.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page