Skip to main content

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

Supported Environments

GraphEnvs-Basic:

Environment Developed Action Space
Shortest Path $v \in \mathcal{V}$
Steiner Tree $e \in \mathcal{E}$
MST $e \in \mathcal{E}$
Minimum Vertex Cover $v \in \mathcal{V}$
TSP $v \in \mathcal{V}$
Longest Path $v \in \mathcal{V}$
Largest Clique ✅ (Min Vertex Cover) $v \in \mathcal{V}$
Densest Subgraph $v \in \mathcal{V}$
Node Coloring 🛠️ $(v, c) \in \mathcal{V} \times \mathbb{Z} $

GraphEnvs-Extended:

Environment Developed Action Space
MultiCast Routing $e \in \mathcal{E}$
Distribution Center Selection $v \in \mathcal{V}$
Persihable Product Delivery $v \in \mathcal{V}$
Public Transport Navigation 🛠️ -

Example

import gymnasium as gym 
import graph_envs
import numpy as np

env = gym.make('LongestPath-v0',
               n_nodes=10,
               n_edges=20,
               weighted=True,
               is_eval_env=True, 
               parenting=2
               )

for sd in range(0, 10):

    print(f'===== {sd} =====')
    obs, info = env.reset(seed=sd)
    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('Valid actions:', valid_actions, '  Action:', action, '  Reward:', reward, '  Done:', done)
        mask = info['mask']
        
    print(info['solution_cost'], info['solved'], info['heuristic_solution'])

Environment Details:

  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.

Release files for graph-envs 0.0.55

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for graph-envs 0.0.55
File Size Uploaded
graph-envs-0.0.55.tar.gz 15.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for graph-envs 0.0.55
File Interpreter ABI Platform
graph_envs-0.0.55-py3-none-any.whl Python 3 none any Details

Total release size: 41.9 kB

Release files / graph-envs-0.0.55.tar.gz

Download URL graph-envs-0.0.55.tar.gz
Size 15.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ba1e96525a132d5933fecd11981b85255125134f14d3d7980cb98eaccb7cdb82
BLAKE2b-256 checksum
How to use checksums
7d7da648ac194d1e5bb28ba15ec5caf943481f9b3265f4b5e18c6e6295abfb8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.11

Release files / graph_envs-0.0.55-py3-none-any.whl

Download URL graph_envs-0.0.55-py3-none-any.whl
Size 26.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6f1a0d9af066301aff7e0de0ed541f27c15fae183882cf4e09ab5ce37fa8bd70
BLAKE2b-256 checksum
How to use checksums
2ac02de4e3f7c3a89e488d7843113a3f1840ace448d65aa3957b67b3d5f0304a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.11

Release history Release notifications | RSS feed

This release

0.0.55 This release

2 release files

0.0.49

2 release files

0.0.48

2 release files

0.0.47

2 release files

0.0.46

2 release files

0.0.45

2 release files

0.0.44

2 release files

0.0.43

2 release files

0.0.42

2 release files

0.0.41

2 release files

0.0.40

2 release files

0.0.33

2 release files

0.0.32

2 release files

0.0.31

2 release files

0.0.29

2 release files

0.0.28

2 release files

0.0.27

2 release files

0.0.26

2 release files

0.0.24

2 release files

0.0.23

2 release files

0.0.22

2 release files

0.0.14

2 release files

0.0.13

2 release files

0.0.12

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page