Skip to main content

Route-Gym

An openai gym that allows agent to solve shortest and longest route problems.

These simples are simple for humans, and can be computed easily by hand using Dijkstra's algorithm and its variants like A* (computation time permitting). As we work towards AGI, it is of my opinion that our complicated general-purpose algorithms should be asked to solve these simple problems. If convergence is slow, or if the supposedly "general" algorithm can't solve it easily, it is safe to say that that algorithm should be reworked.

Quickstart

env = ShortestRouteEnv(nx.frucht_graph(), 0, 5, random_weights=(1,10))
env.render()    # optionnal
done = False
# you might want to give the adjacency matrix to the policy
policy = ?
rew = 0
position = origin
while not done:
    action = policy.predict(position)
    position, reward, done, _ = env.step(action)
    end.render()    # optionnal
    rew += reward
print("Final reward:", rew)
print("Dijkstra's reward:", env.graph.dijkstra_rew)

What is provided in this gym?

The environment:

The two environments are based neton OpenAI's gym.

The environment can be called using routegym.env.ShortestRouteEnv or the equivalent for the longest route version.

The environments have a render function you can use to display the environment's state. In it, the blue path on the graph's arcs represents Dijkstra's path. This only works for ShortestRouteEnv.

The environments receive a networkx graph, an origin, a goal, and random weight boundaries (if need be) as part of their constructor.

You can also set the make_horizon flag to True to transform the graph into a finite-horizon problem. Be warned that this should only be used on smaller graphs: this generates a tree out of all the possible paths the agent can take from origin to goal and merges them into a single graph. Needless to say, the big O of this thing is enormous! This flag should only be used for toy examples.

The Graph class

The environments use a custom graph class as a backend. A typical user should not need to interact with this class.

But this class does calculate the Dijkstra solution for the problem. If you want to compare your algorithm's performance to Dijkstra's, you can use env.graph.dijkstra_path to get Dijkstra's path, or env.graph.dijkstra_rew to get Dijkstra's reward.

The validate script

This is an internal test, but it is provided as a courtesy to the users. You can get inspiration from that script, either as a tutorial on how to use this package, or as a way to generate many environments, etc.

You can view it in routegym.validate.py.

Metadata

Release files for route-gym 0.0.11

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

Source distribution (sdist)

Source distribution for route-gym 0.0.11
File Size Uploaded Provenance Actions
route-gym-0.0.11.tar.gz 10.2 kB Without provenance Details for route-gym-0.0.11.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for route-gym 0.0.11
File Interpreter ABI Platform Actions
route_gym-0.0.11-py3-none-any.whl Python 3 none any Details for route_gym-0.0.11-py3-none-any.whl

Total release size: 21.2 kB

Release files / route-gym-0.0.11.tar.gz

Download URL route-gym-0.0.11.tar.gz
Size 10.2 kB
Tags Source
SHA-256 checksum
How to use checksums
3fe41d7a5211c068181ac6eb5e99fb6bb2701d5f952e603190607f3b2479f8fc
BLAKE2b-256 checksum
How to use checksums
edd92c466078fcd89271c4f904b2a82daf52756b212fc4e83b5ab4a476835132
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.23.0 setuptools/49.3.1 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.8.6

Release files / route_gym-0.0.11-py3-none-any.whl

Download URL route_gym-0.0.11-py3-none-any.whl
Size 11.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a0576bdf42771e0827b05aee16edde406c0ef01bdc533a586181503752e4a8a4
BLAKE2b-256 checksum
How to use checksums
b122d1fc6e68b37722d4b5102f6f1c1c67bccba8ab24f536cb4d0f7182e813aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.23.0 setuptools/49.3.1 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.8.6

Security for route-gym 0.0.11

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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