Skip to main content

Multi Agent Reinforcement Learning on Trains

Project description

Test Running Test Coverage

https://i.imgur.com/0rnbSLY.gif

Flatland is a opensource toolkit for developing and comparing Multi Agent Reinforcement Learning algorithms in little (or ridiculously large !) gridworlds. The base environment is a two-dimensional grid in which many agents can be placed, and each agent must solve one or more navigational tasks in the grid world. More details about the environment and the problem statement can be found in the official docs.

This library was developed by SBB , AIcrowd and numerous contributors and AIcrowd research fellows from the AIcrowd community.

This library was developed specifically for the Flatland Challenge in which we strongly encourage you to take part in.

NOTE This document is best viewed in the official documentation site at Flatland-RL Docs

Contents

Quick Start

  • Install Anaconda by following the instructions here

  • Install the dependencies and the library

$ conda create python=3.6 --name flatland-rl
$ conda activate flatland-rl
$ conda install -c conda-forge cairosvg pycairo
$ conda install -c anaconda tk
$ pip install flatland-rl
  • Test that the installation works

$ flatland-demo

Basic Usage

Basic usage of the RailEnv environment used by the Flatland Challenge

import numpy as np
import time
from flatland.envs.rail_generators import complex_rail_generator
from flatland.envs.schedule_generators import complex_schedule_generator
from flatland.envs.rail_env import RailEnv
from flatland.utils.rendertools import RenderTool

NUMBER_OF_AGENTS = 10
env = RailEnv(
            width=20,
            height=20,
            rail_generator=complex_rail_generator(
                                    nr_start_goal=10,
                                    nr_extra=1,
                                    min_dist=8,
                                    max_dist=99999,
                                    seed=0),
            schedule_generator=complex_schedule_generator(),
            number_of_agents=NUMBER_OF_AGENTS)

env_renderer = RenderTool(env)

def my_controller():
    """
    You are supposed to write this controller
    """
    _action = {}
    for _idx in range(NUMBER_OF_AGENTS):
        _action[_idx] = np.random.randint(0, 5)
    return _action

for step in range(100):

    _action = my_controller()
    obs, all_rewards, done, _ = env.step(_action)
    print("Rewards: {}, [done={}]".format( all_rewards, done))
    env_renderer.render_env(show=True, frames=False, show_observations=False)
    time.sleep(0.3)

and ideally you should see something along the lines of

https://i.imgur.com/VrTQVeM.gif

Best of Luck !!

Contributions

Flatland is an opensource project, and we very much value all and any contributions you make towards the project. Please follow the Contribution Guidelines for more details on how you can successfully contribute to the project. We enthusiastically look forward to your contributions.

Partners

https://i.imgur.com/OSCXtde.png https://avatars1.githubusercontent.com/u/44522764?s=200&v=4

Authors

Acknowledgements

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

flatland-rl-2.0.0.tar.gz (2.7 MB view details)

Uploaded Source

File details

Details for the file flatland-rl-2.0.0.tar.gz.

File metadata

  • Download URL: flatland-rl-2.0.0.tar.gz
  • Upload date:
  • Size: 2.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for flatland-rl-2.0.0.tar.gz
Algorithm Hash digest
SHA256 24a34dbcb1c5c6aa25d5a3f8e213f3e5997b96e0ae6d6ac4c4321049641afdb8
MD5 2c1c6b9a2b12dc338fffc94a6b817434
BLAKE2b-256 61d0e4769ff43b9c525ee6e6d23054186b0ef536d8a75bacde454e50936399ab

See more details on using hashes here.

Supported by

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